1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-25 12:15:32 +03:00
aports/testing/ocfs2-tools/musl-libocfs2-__bswap_constant_32.patch
Jakub Jirutka 4f24ccb86c testing/ocfs2-tools: rewrite aport and upgrade to 1.8.5
Note: We use the same ("unofficial"?) upstream as Fedora.
2018-05-23 22:18:39 +02:00

29 lines
907 B
Diff

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