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?

Index: arch/sh/include/endian.h
===================================================================
RCS file: /cvs/src/sys/arch/sh/include/endian.h,v
retrieving revision 1.6
diff -u -p -r1.6 endian.h
--- arch/sh/include/endian.h    2 Oct 2018 21:30:44 -0000       1.6
+++ arch/sh/include/endian.h    5 Oct 2018 13:17:00 -0000
@@ -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
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to