aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2012-03-28 16:39:25 +0200
committerAndreas Jaeger <aj@suse.de>2012-04-03 09:13:59 +0200
commitb1aa60f32d34030b28bca04aeee084cd3bedecfa (patch)
tree430b4c30f7a613b4b219528ec861de1b2c5b1172
parent39c59c35723120c32dc42dde4115bba92305179f (diff)
downloadglibc-b1aa60f32d34030b28bca04aeee084cd3bedecfa.zip
glibc-b1aa60f32d34030b28bca04aeee084cd3bedecfa.tar.gz
glibc-b1aa60f32d34030b28bca04aeee084cd3bedecfa.tar.bz2
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.
-rw-r--r--ChangeLog17
-rw-r--r--NEWS3
-rw-r--r--bits/byteswap.h19
-rw-r--r--string/byteswap.h6
-rw-r--r--string/endian.h23
-rw-r--r--sysdeps/i386/bits/byteswap.h19
-rw-r--r--sysdeps/s390/bits/byteswap.h20
-rw-r--r--sysdeps/x86_64/bits/byteswap.h19
8 files changed, 98 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 09f040e..70e2633 100644
--- 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 5489c97..93485c9 100644
--- 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:
diff --git a/bits/byteswap.h b/bits/byteswap.h
index 9d658e4..31e9a16 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 */
diff --git a/string/byteswap.h b/string/byteswap.h
index 18ca95d..7d76957 100644
--- a/string/byteswap.h
+++ b/string/byteswap.h
@@ -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
diff --git a/string/endian.h b/string/endian.h
index 13e8c75..0c293f6 100644
--- a/string/endian.h
+++ b/string/endian.h
@@ -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
@@ -70,10 +70,13 @@
# 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)
@@ -85,10 +88,12 @@
# 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
diff --git a/sysdeps/i386/bits/byteswap.h b/sysdeps/i386/bits/byteswap.h
index 4a159d1..fb0a827 100644
--- a/sysdeps/i386/bits/byteswap.h
+++ b/sysdeps/i386/bits/byteswap.h
@@ -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 */
diff --git a/sysdeps/s390/bits/byteswap.h b/sysdeps/s390/bits/byteswap.h
index ac325b0..fd7c279 100644
--- a/sysdeps/s390/bits/byteswap.h
+++ b/sysdeps/s390/bits/byteswap.h
@@ -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)
diff --git a/sysdeps/x86_64/bits/byteswap.h b/sysdeps/x86_64/bits/byteswap.h
index 5094a05..472281f 100644
--- a/sysdeps/x86_64/bits/byteswap.h
+++ b/sysdeps/x86_64/bits/byteswap.h
@@ -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
@@ -131,6 +130,22 @@
} \
__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 */