aboutsummaryrefslogtreecommitdiffstats
path: root/testing/ocfs2-tools/musl-libocfs2-__bswap_constant_32.patch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/ocfs2-tools/musl-libocfs2-__bswap_constant_32.patch')
-rw-r--r--testing/ocfs2-tools/musl-libocfs2-__bswap_constant_32.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/ocfs2-tools/musl-libocfs2-__bswap_constant_32.patch b/testing/ocfs2-tools/musl-libocfs2-__bswap_constant_32.patch
new file mode 100644
index 0000000000..e813db4743
--- /dev/null
+++ b/testing/ocfs2-tools/musl-libocfs2-__bswap_constant_32.patch
@@ -0,0 +1,29 @@
+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