This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: checking changes for warning regressions
On Wed, Oct 10, 2012 at 5:26 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Oct 10, 2012 at 4:26 PM, Roland McGrath <roland@hack.frob.com> wrote:
>>> If it is true, why can't we use uint64_t for bswap_64?
>>
>> We can if we think it's OK for all the headers using <bits/byteswap.h>
>> to include <stdint.h> and put all those symbols into the name space.
>> That may well be fine, but it needs careful consideration.
>>
>> The conservative change is to conditionalize the use of long vs long long
>> in bits/byteswap.h--that just fixes the regression, without changing the
>> API of any public header.
>
> Glibc 2.16 has
>
> # if __GNUC_PREREQ (4, 2)
> static __inline unsigned long long int
> __bswap_64 (unsigned long long int __bsx)
> {
> return __builtin_bswap64 (__bsx);
> }
>
> It works for x32, i686 and x86-64. We can use long if
> __WORDSIZE == 64.
>
Like this.
--
H.J.
---
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__