Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Apr 2003 18:42:16 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 28135 for review
Message-ID:  <200304050242.h352gGjh095355@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=28135

Change 28135 by peter@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304050242.h352gGjh095355>