Commit 5d5cc0d0 authored by Johann's avatar Johann

Check for bswap* builtins before using

Canonical builtin checks for clang are to use
__has_builtin. Much less fragile than version checks.

https://code.google.com/p/webm/issues/detail?id=1082

Change-Id: I8151fb75899acdf1a935c23aad9441da99a9abcd
parent ec623a0b
...@@ -25,14 +25,10 @@ ...@@ -25,14 +25,10 @@
# define LOCAL_GCC_PREREQ(maj, min) 0 # define LOCAL_GCC_PREREQ(maj, min) 0
#endif #endif
#ifdef __clang__ // handle clang compatibility
# define LOCAL_CLANG_VERSION ((__clang_major__ << 8) | __clang_minor__) #ifndef __has_builtin
# define LOCAL_CLANG_PREREQ(maj, min) \ # define __has_builtin(x) 0
(LOCAL_CLANG_VERSION >= (((maj) << 8) | (min))) #endif
#else
# define LOCAL_CLANG_VERSION 0
# define LOCAL_CLANG_PREREQ(maj, min) 0
#endif // __clang__
// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__) // some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__)
#if !defined(WORDS_BIGENDIAN) && \ #if !defined(WORDS_BIGENDIAN) && \
...@@ -53,14 +49,16 @@ ...@@ -53,14 +49,16 @@
#define HToBE32(X) BSwap32(X) #define HToBE32(X) BSwap32(X)
#endif #endif
// clang-3.3 and gcc-4.3 have builtin functions for swap32/swap64 #if LOCAL_GCC_PREREQ(4, 8) || __has_builtin(__builtin_bswap16)
#if LOCAL_GCC_PREREQ(4, 3) || LOCAL_CLANG_PREREQ(3, 3) #define HAVE_BUILTIN_BSWAP16
#endif
#if LOCAL_GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap32)
#define HAVE_BUILTIN_BSWAP32 #define HAVE_BUILTIN_BSWAP32
#define HAVE_BUILTIN_BSWAP64
#endif #endif
// clang-3.3 and gcc-4.8 have a builtin function for swap16
#if LOCAL_GCC_PREREQ(4, 8) || LOCAL_CLANG_PREREQ(3, 3) #if LOCAL_GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap64)
#define HAVE_BUILTIN_BSWAP16 #define HAVE_BUILTIN_BSWAP64
#endif #endif
#if HAVE_MIPS32 && defined(__mips__) && !defined(__mips64) && \ #if HAVE_MIPS32 && defined(__mips__) && !defined(__mips64) && \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment