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]

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


> 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.

That says you only defined and only used in under [__WORDSIZE == 64],
which is not so.

	* sysdeps/x86/bits/byteswap.h
	[__GNUC_PREREQ (4, 2)] (__bswap_uint64_t): New macro,
	different definitions for [__WORDSIZE == 64] and not.
	[__GNUC_PREREQ (4, 2)] (__bswap_64): Use it for return and arg types.

> +#  if __WORDSIZE == 64
> +#   define __bswap_uint64_t unsigned long int
> +#  else
> +#   define __bswap_uint64_t unsigned long long int
> +#  endif

Add a comment saying this must match the type used for uint64_t.

Hmm.  Actually, I think you can #include <bits/types.h> and use __uint64_t
without any name space issues.  So that's clearly the right thing to do,
and is sufficiently inherently obvious that it doesn't require any special
comments.  And then it's clearly right to use __uint64_t uniformly
throughout this file, even in the places where there is no variation in
possible definitions.


Thanks,
Roland


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