From b1aa60f32d34030b28bca04aeee084cd3bedecfa Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Wed, 28 Mar 2012 16:39:25 +0200 Subject: Add __bswap_64 definition for non GCC compilers. [BZ#13926] Currently __bswap_64 is not defined at all for non-GCC compilers. Define it but guard it with __GLIBC_HAVE_LONG_LONG. endian.h uses __bswap_64, make the functions only available if __GLIBC_HAVE_LONG_LONG is defined. --- bits/byteswap.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'bits') diff --git a/bits/byteswap.h b/bits/byteswap.h index 9d658e4472..31e9a16716 100644 --- a/bits/byteswap.h +++ b/bits/byteswap.h @@ -1,6 +1,5 @@ /* Macros to swap the order of bytes in integer values. - Copyright (C) 1997,1998,2000-2002,2005,2008,2011 - Free Software Foundation, Inc. + Copyright (C) 1997-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -82,6 +81,22 @@ __bswap_32 (unsigned int __bsx) __r.__l[1] = __bswap_32 (__w.__l[0]); \ } \ __r.__ll; })) +#elif __GLIBC_HAVE_LONG_LONG +# define __bswap_constant_64(x) \ + ((((x) & 0xff00000000000000ull) >> 56) \ + | (((x) & 0x00ff000000000000ull) >> 40) \ + | (((x) & 0x0000ff0000000000ull) >> 24) \ + | (((x) & 0x000000ff00000000ull) >> 8) \ + | (((x) & 0x00000000ff000000ull) << 8) \ + | (((x) & 0x0000000000ff0000ull) << 24) \ + | (((x) & 0x000000000000ff00ull) << 40) \ + | (((x) & 0x00000000000000ffull) << 56)) + +static __inline unsigned long long int +__bswap_64 (unsigned long long int __bsx) +{ + return __bswap_constant_64 (__bsx); +} #endif #endif /* _BITS_BYTESWAP_H */ -- cgit 1.4.1