summaryrefslogtreecommitdiff
path: root/sys/arch/sh
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2018-10-05 15:13:56 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2018-10-05 15:13:56 +0000
commit3f27463693ec790748080c9b2f43aef7318e224e (patch)
tree89713d05a9ac46ce68801ee23076aa943e322793 /sys/arch/sh
parent99141fb4d805166f19fa2bebf85d9a1d6d87163b (diff)
Provide an MD 64-bit byteswapping function build on 32-bit swaps
as we do on arm and i386. Copied from arm. If there are no MD byteswapping functions, MI macros are used. These are wrapped by static inline functions to prevent multiple evaluation of their argument. If there are MD functions, they are used directly and therefore we must implicitly guarantee that they are safe from multiple evaluation. Defining an MD function to an MI macro breaks this promise. ok deraadt@
Diffstat (limited to 'sys/arch/sh')
-rw-r--r--sys/arch/sh/include/endian.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/arch/sh/include/endian.h b/sys/arch/sh/include/endian.h
index ef0050be1ad..b80fbe6a1f2 100644
--- a/sys/arch/sh/include/endian.h
+++ b/sys/arch/sh/include/endian.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: endian.h,v 1.6 2018/10/02 21:30:44 naddy Exp $ */
+/* $OpenBSD: endian.h,v 1.7 2018/10/05 15:13:55 naddy Exp $ */
/* $NetBSD: endian.h,v 1.4 2000/03/17 00:09:25 mycroft Exp $ */
/* Written by Manuel Bouyer. Public domain */
@@ -31,7 +31,16 @@ __swap32md(__uint32_t _x)
return (_rv);
}
-#define __swap64md __swap64gen
+static __inline __uint64_t
+__swap64md(__uint64_t _x)
+{
+ __uint64_t _rv;
+
+ _rv = (__uint64_t)__swap32md(_x >> 32) |
+ (__uint64_t)__swap32md(_x) << 32;
+
+ return (_rv);
+}
/* Tell sys/endian.h we have MD variants of the swap macros. */
#define __HAVE_MD_SWAP