Add XIPH_BSWAP32 configure macro to detect __builtin_bswap32() intrinsic.

This commit is contained in:
Erik de Castro Lopo
2012-02-06 07:15:48 +11:00
parent 3abb6c98e9
commit d7bfc779c8
3 changed files with 65 additions and 4 deletions

View File

@@ -31,16 +31,20 @@
/* It is assumed that this header will be included after "config.h". */
#if HAVE_BYTESWAP_H
#if HAVE_BSWAP32 /* GCC and Clang */
#include <byteswap.h> /* Linux */
#define ENDSWAP_INT(x) ((int) bswap_32 (x))
#define ENDSWAP_INT(x) (__builtin_bswap32 (x))
#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
#define ENDSWAP_INT(x) ((int) _byteswap_ulong (x))
#elif HAVE_BYTESWAP_H /* Linux */
#include <byteswap.h>
#define ENDSWAP_INT(x) ((int) bswap_32 (x))
#else
#define ENDSWAP_INT(x) ((((x) >> 24) & 0xFF) + (((x) >> 8) & 0xFF00) + (((x) & 0xFF00) << 8) + (((x) & 0xFF) << 24))