]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add __bswap_64 definition for non GCC compilers.
authorAndreas Jaeger <aj@suse.de>
Wed, 28 Mar 2012 14:39:25 +0000 (16:39 +0200)
committerAndreas Jaeger <aj@suse.de>
Tue, 3 Apr 2012 07:13:59 +0000 (09:13 +0200)
[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.

ChangeLog
NEWS
bits/byteswap.h
string/byteswap.h
string/endian.h
sysdeps/i386/bits/byteswap.h
sysdeps/s390/bits/byteswap.h
sysdeps/x86_64/bits/byteswap.h

index 09f040e63229f89632f3259205796a7013567a73..70e2633b82775680b2a30ffe039970379c08860c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2012-04-03  Andreas Jaeger  <aj@suse.de>
+
+       [BZ #13926]
+       * sysdeps/i386/bits/byteswap.h [!__GNUC__](__bswap_constant_64):
+       New macro for this case.
+       [!__GNUC__] (__bswap_64): New inline function for this case.
+       * sysdeps/x86_64/bits/byteswap.h: Likewise.
+       * bits/byteswap.h: Likewise.
+       * sysdeps/s390/bits/byteswap.h: [!__GNUC__] (__bswap_64): Use
+       ull, guard with __GLIBC_HAVE_LONG_LONG.
+
+       * string/endian.h (htobe64,htole64,be64toh,le64toh): Guard with
+       __GLIBC_HAVE_LONG_LONG.
+
+       * string/byteswap.h (bswap_64): Guard with __GLIBC_HAVE_LONG_LONG.
+       Include <features.h> for __GLIBC_HAVE_LONG_LONG.
+
 2012-04-02 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
 
        [BZ #13691]
diff --git a/NEWS b/NEWS
index 5489c9725d3bd08e25b2a4698a7e1a3cc49106c1..93485c96fe5f3cb863d182c4a6cec60b0988d225 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,7 +18,8 @@ Version 2.16
   13618, 13637, 13656, 13658, 13673, 13691, 13695, 13704, 13706, 13726,
   13738, 13760, 13761, 13786, 13792, 13806, 13824, 13840, 13841, 13844,
   13846, 13851, 13852, 13854, 13871, 13879, 13883, 13892, 13910, 13911,
-  13912, 13913, 13915, 13916, 13917, 13918, 13919, 13920, 13921, 13928
+  13912, 13913, 13915, 13916, 13917, 13918, 13919, 13920, 13921, 13926,
+  13928
 
 * ISO C11 support:
 
index 9d658e44727eae79461fdbd6925645f8401423c4..31e9a16716aebee4a9a3ea89269c2f91cb965f3b 100644 (file)
@@ -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 */
index 18ca95d37359f425752995ff034a960c999ac8f7..7d769573ad367d2a0da98febd5bb4c0b8a9e5900 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 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
@@ -18,6 +18,8 @@
 #ifndef _BYTESWAP_H
 #define _BYTESWAP_H    1
 
+#include <features.h>
+
 /* Get the machine specific, optimized definitions.  */
 #include <bits/byteswap.h>
 
@@ -31,7 +33,7 @@
 /* Return a value with all bytes in the 32 bit argument swapped.  */
 #define bswap_32(x) __bswap_32 (x)
 
-#if defined __GNUC__ && __GNUC__ >= 2
+#if __GLIBC_HAVE_LONG_LONG
 /* Return a value with all bytes in the 64 bit argument swapped.  */
 # define bswap_64(x) __bswap_64 (x)
 #endif
index 13e8c75c9fc1b8093e34a6f66806ab9c5e193471..0c293f6379bc960c7ff92f67cf808be500aabad6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1992-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
 #  define be32toh(x) __bswap_32 (x)
 #  define le32toh(x) (x)
 
-#  define htobe64(x) __bswap_64 (x)
-#  define htole64(x) (x)
-#  define be64toh(x) __bswap_64 (x)
-#  define le64toh(x) (x)
+#  if __GLIBC_HAVE_LONG_LONG
+#   define htobe64(x) __bswap_64 (x)
+#   define htole64(x) (x)
+#   define be64toh(x) __bswap_64 (x)
+#   define le64toh(x) (x)
+#  endif
+
 # else
 #  define htobe16(x) (x)
 #  define htole16(x) __bswap_16 (x)
 #  define be32toh(x) (x)
 #  define le32toh(x) __bswap_32 (x)
 
-#  define htobe64(x) (x)
-#  define htole64(x) __bswap_64 (x)
-#  define be64toh(x) (x)
-#  define le64toh(x) __bswap_64 (x)
+#  if __GLIBC_HAVE_LONG_LONG
+#   define htobe64(x) (x)
+#   define htole64(x) __bswap_64 (x)
+#   define be64toh(x) (x)
+#   define le64toh(x) __bswap_64 (x)
+#  endif
 # endif
 #endif
 
index 4a159d19c92986f66b3b88b4405dc5fb9358dc27..fb0a827c8d2ecd8a91dc09b8643390cca513c5ae 100644 (file)
@@ -1,6 +1,5 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997, 1998, 2000, 2002, 2003, 2006, 2007, 2008, 2010, 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
@@ -131,6 +130,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 */
index ac325b0e49c6f7a9f5c2076370bb91c9aab08ee4..fd7c279509b44bd5a4c8e2978f889abc2fdbde7c 100644 (file)
@@ -1,5 +1,5 @@
 /* Macros to swap the order of bytes in integer values.  s390 version.
-   Copyright (C) 2000-2003, 2008, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2008, 2011, 2012 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -150,16 +150,16 @@ __bswap_32 (unsigned int __bsx)
          __r.__l[1] = __bswap_32 (__w.__l[0]);         \
          __r.__ll; })
 # endif
-#else
+#elif __GLIBC_HAVE_LONG_LONG
 # define __bswap_constant_64(x) \
-     ((((x) & 0xff00000000000000ul) >> 56)                                   \
-      | (((x) & 0x00ff000000000000ul) >>  40)                                \
-      | (((x) & 0x0000ff0000000000ul) >> 24)                                 \
-      | (((x) & 0x000000ff00000000ul) >> 8)                                  \
-      | (((x) & 0x00000000ff000000ul) << 8)                                  \
-      | (((x) & 0x0000000000ff0000ul) << 24)                                 \
-      | (((x) & 0x000000000000ff00ul) << 40)                                 \
-      | (((x) & 0x00000000000000fful) << 56))
+     ((((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)
index 5094a0540d0491fcb0015f3a83fffc0047e04dbe..472281fc8209d976e11b17987bf53048c3b130b0 100644 (file)
@@ -1,6 +1,5 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007, 2008, 2010, 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
           }                                                                  \
         __r.__ll; }))
 # endif
+#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 */