chromium/third_party/libvpx/source/libvpx/vpx_util/endian_inl.h

// Copyright 2014 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Endian related functions.

#ifndef VPX_VPX_UTIL_ENDIAN_INL_H_
#define VPX_VPX_UTIL_ENDIAN_INL_H_

#include <stdlib.h>
#include "./vpx_config.h"
#include "vpx/vpx_integer.h"

#if defined(__GNUC__)
#define LOCAL_GCC_VERSION
#define LOCAL_GCC_PREREQ(maj, min)
#else
#define LOCAL_GCC_VERSION
#define LOCAL_GCC_PREREQ
#endif

// handle clang compatibility
#ifndef __has_builtin
#define __has_builtin
#endif

// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__)
#if !defined(WORDS_BIGENDIAN) &&                   \
    (defined(__BIG_ENDIAN__) || defined(_M_PPC) || \
     (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)))
#define WORDS_BIGENDIAN
#endif

#if defined(WORDS_BIGENDIAN)
#define HToLE32
#define HToLE16
#define HToBE64
#define HToBE32
#else
#define HToLE32(x)
#define HToLE16(x)
#define HToBE64(X)
#define HToBE32(X)
#endif

#if LOCAL_GCC_PREREQ(4, 8) || __has_builtin(__builtin_bswap16)
#define HAVE_BUILTIN_BSWAP16
#endif

#if LOCAL_GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap32)
#define HAVE_BUILTIN_BSWAP32
#endif

#if LOCAL_GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap64)
#define HAVE_BUILTIN_BSWAP64
#endif

#if HAVE_MIPS32 && defined(__mips__) && !defined(__mips64) && \
    defined(__mips_isa_rev) && (__mips_isa_rev >= 2) && (__mips_isa_rev < 6)
#define VPX_USE_MIPS32_R2
#endif

static INLINE uint16_t BSwap16(uint16_t x) {}

static INLINE uint32_t BSwap32(uint32_t x) {}

static INLINE uint64_t BSwap64(uint64_t x) {}

#endif  // VPX_VPX_UTIL_ENDIAN_INL_H_