aboutsummaryrefslogblamecommitdiffstats
path: root/testing/ocfs2-tools/musl-libocfs2-__bswap_constant_32.patch
blob: e813db47437fc93b97c05b5ff93b19496207d43f (plain) (tree)




























                                                                   
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Wed, 23 May 2018 19:56:00 +0200
Subject: [PATCH] Ensure compatibility with other libcs

The musl libc does not provide __bswap_constant_32.

--- a/libocfs2/crc32table.h
+++ b/libocfs2/crc32table.h
@@ -6,11 +6,18 @@
  */
 #include <inttypes.h>
 #include <byteswap.h>
+
+#ifndef __bswap_constant_32
+#define __bswap_constant_32(x) \
+	((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) \
+	| (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
+#endif
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 # define tole(x) ((uint32_t)(x))
-# define tobe(x) ((uint32_t)__bswap_constant_32(x))
+# define tobe(x) ((uint32_t)__builtin_bswap32(x))
 #elif __BYTE_ORDER == __BIG_ENDIAN
-# define tole(x) ((uint32_t)__bswap_constant_32(x))
+# define tole(x) ((uint32_t)__builtin_bswap32(x))
 # define tobe(x) ((uint32_t)(x))
 #else
 # error Invalid byte order __BYTE_ORDER