summaryrefslogtreecommitdiff
path: root/include/share
diff options
context:
space:
mode:
authorRalph Giles <giles@thaumas.net>2014-07-02 14:12:38 -0700
committerErik de Castro Lopo <erikd@mega-nerd.com>2014-07-03 18:59:49 +1000
commit22d4893d28a6fbcb2a2375378c487eb739f8d14c (patch)
treeffd6b58ad7738ca98f4b2e7d09648976b9ee6853 /include/share
parent7422e084f43cc160598dc8a5f1a2bbd2063b8bbb (diff)
downloadflac-22d4893d28a6fbcb2a2375378c487eb739f8d14c.tar.gz
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>
Diffstat (limited to 'include/share')
-rw-r--r--include/share/endswap.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/share/endswap.h b/include/share/endswap.h
index 058fe0b7..9a5d86fa 100644
--- a/include/share/endswap.h
+++ b/include/share/endswap.h
@@ -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))