This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Use unsigned long int in __bswap_64 for __WORDSIZE == 64


Hi,

My __bswap_64 return type changes in 2.16 caused

warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat]

when PRIx64 is used on return value of bswap_64 without casting to
uint64_t.  This patches restores unsigned long int in __bswap_64 for
__WORDSIZE == 64 and GCC >= 4.2.  Tested on x32 and x86-64.  OK for
trunk and 2.16?

Thanks.

H.J.
---
2012-10-09  H.J. Lu  <hongjiu.lu@intel.com>

	* sysdeps/x86/bits/byteswap.h [__WORDSIZE == 64](__bswap_64): 
	Use unsigned long int for GCC >= 4.2.

diff --git a/sysdeps/x86/bits/byteswap.h b/sysdeps/x86/bits/byteswap.h
index 4178439..ed29cec 100644
--- a/sysdeps/x86/bits/byteswap.h
+++ b/sysdeps/x86/bits/byteswap.h
@@ -104,11 +104,19 @@ __bswap_32 (unsigned int __bsx)
 		     | (((x) & 0x00000000000000ffull) << 56)))
 
 # if __GNUC_PREREQ (4, 2)
+#  if __WORDSIZE == 64
+static __inline unsigned long int
+__bswap_64 (unsigned long int __bsx)
+{
+  return __builtin_bswap64 (__bsx);
+}
+#  else
 static __inline unsigned long long int
 __bswap_64 (unsigned long long int __bsx)
 {
   return __builtin_bswap64 (__bsx);
 }
+#  endif
 # elif __WORDSIZE == 64
 #  define __bswap_64(x) \
      (__extension__							      \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]