PERFORCE change 28135 for review
Peter Wemm
peter at FreeBSD.org
Fri Apr 4 18:42:19 PST 2003
http://perforce.freebsd.org/chv.cgi?CH=28135
Change 28135 by peter at peter_overcee on 2003/04/04 18:41:49
use 64 bit bswap. XXX check constraints.
Affected files ...
.. //depot/projects/hammer/sys/x86_64/include/endian.h#5 edit
Differences ...
==== //depot/projects/hammer/sys/x86_64/include/endian.h#5 (text+ko) ====
@@ -74,12 +74,15 @@
__asm ("rorl $16, %0" : "+r" (__X)); \
__X; })
-#if defined(_KERNEL)
#define __byte_swap_int(x) \
__extension__ ({ register __uint32_t __X = (x); \
__asm ("bswap %0" : "+r" (__X)); \
__X; })
-#endif
+
+#define __byte_swap_long(x) \
+__extension__ ({ register __uint64_t __X = (x); \
+ __asm ("bswap %0" : "+r" (__X)); \
+ __X; })
#define __byte_swap_word(x) \
__extension__ ({ register __uint16_t __X = (x); \
@@ -89,11 +92,8 @@
static __inline __uint64_t
__bswap64(__uint64_t _x)
{
- /* XXX we have a 64 bit variation of the bswap instruction now */
- return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
- ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
- ((_x << 24) & ((__uint64_t)0xff << 40)) |
- ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
+
+ return (__byte_swap_long(_x));
}
static __inline __uint32_t
More information about the p4-projects
mailing list