Fix bswap16 issue on Debian 6.

Versions of GCC prior to 4.8 didn't provide an implementation
of __builtin_bswap16 on x86_64. Detect those versions and
supply a fallback implementation. A cleaner fix would be
to detect bswap16 independently of bswap32 in configure
and handle them separately.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
This commit is contained in:
Ralph Giles 2014-07-02 14:12:38 -07:00 committed by Erik de Castro Lopo
parent 7422e084f4
commit 22d4893d28
1 changed files with 8 additions and 0 deletions

View File

@ -33,6 +33,14 @@
#if HAVE_BSWAP32 /* GCC and Clang */
/* GCC prior to 4.8 didn't provide bswap16 on x86_64 */
#if __GNUC__ <= 4 && __GNUC_MINOR__ < 8
static inline unsigned short __builtin_bswap16(unsigned short a)
{
return (a<<8)|(a>>8);
}
#endif
#define ENDSWAP_16(x) (__builtin_bswap16 (x))
#define ENDSWAP_32(x) (__builtin_bswap32 (x))