summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-03-12 22:27:49 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-03-12 22:27:49 +0000
commit452ec94604f8f21327e793c9a22c9580b4fc234f (patch)
tree589836a89a596a5ce56b0e6e6d0f8690fa2c79c0 /sys/arch/amd64
parentc94a68a54fd313a38a535cbd46a26187809c3ce0 (diff)
Implement swap64 with the bswapq instruction. (Commit stolen from mikeb@)
Add missing __statement modifiers and correct %1 to %0 in the asm. ok mikeb@, pirofti@, drahn@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/include/endian.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/arch/amd64/include/endian.h b/sys/arch/amd64/include/endian.h
index fcfc49cd013..7889a374f47 100644
--- a/sys/arch/amd64/include/endian.h
+++ b/sys/arch/amd64/include/endian.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: endian.h,v 1.4 2011/03/11 15:17:08 pirofti Exp $ */
+/* $OpenBSD: endian.h,v 1.5 2011/03/12 22:27:48 guenther Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@@ -29,25 +29,24 @@
#ifdef __GNUC__
-#define __swap32md(x) ({ \
+#define __swap32md(x) __statement({ \
u_int32_t __swap32md_x = (x); \
\
- __asm ("bswap %1" : "+r" (__swap32md_x)); \
+ __asm ("bswap %0" : "+r" (__swap32md_x)); \
__swap32md_x; \
})
-/* XXX - I'm sure there is a better way on this cpu. */
-#define __swap64md(x) ({ \
+#define __swap64md(x) __statement({ \
u_int64_t __swap64md_x = (x); \
\
- (u_int64_t)__swap32md(__swap64md_x >> 32) | \
- (u_int64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \
+ __asm ("bswapq %0" : "+r" (__swap64md_x)); \
+ __swap64md_x; \
})
-#define __swap16md(x) ({ \
+#define __swap16md(x) __statement({ \
u_int16_t __swap16md_x = (x); \
\
- __asm ("rorw $8, %w1" : "+r" (__swap16md_x)); \
+ __asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \
__swap16md_x; \
})