This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PATCH: Use unsigned long int in __bswap_64 for __WORDSIZE == 64
On Thu, Oct 11, 2012 at 1:16 PM, Roland McGrath <roland@hack.frob.com> wrote:
>> I don't think it is worth the complexity since there is a check
>> for __WORDSIZE already.
>
> I consider it less complexity than repeating a function definition.
> It also will make for a simple and obvious change if we later conclude
> that just using uint64_t directly is an OK thing to do.
>
How about this?
2012-10-11 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/x86/bits/byteswap.h [__GNUC_PREREQ (4, 2)]
[__WORDSIZE == 64] (__bswap_uint64_t): New macro.
[__GNUC_PREREQ (4, 2)] [__WORDSIZE == 64] (__bswap_64): Use
it.
diff --git a/sysdeps/x86/bits/byteswap.h b/sysdeps/x86/bits/byteswap.h
index 4178439..34c67bb 100644
--- a/sysdeps/x86/bits/byteswap.h
+++ b/sysdeps/x86/bits/byteswap.h
@@ -104,8 +104,13 @@ __bswap_32 (unsigned int __bsx)
| (((x) & 0x00000000000000ffull) << 56)))
# if __GNUC_PREREQ (4, 2)
-static __inline unsigned long long int
-__bswap_64 (unsigned long long int __bsx)
+# if __WORDSIZE == 64
+# define __bswap_uint64_t unsigned long int
+# else
+# define __bswap_uint64_t unsigned long long int
+# endif
+static __inline __bswap_uint64_t
+__bswap_64 (__bswap_uint64_t __bsx)
{
return __builtin_bswap64 (__bsx);
}
--
H.J.