forked from pool/erofs-utils
db479c5e0d
OBS-URL: https://build.opensuse.org/request/show/650306 OBS-URL: https://build.opensuse.org/package/show/filesystems/erofs-utils?expand=0&rev=1
43 lines
1.4 KiB
Diff
43 lines
1.4 KiB
Diff
From: Jan Engelhardt <jengelh@inai.de>
|
|
Date: 2018-11-19 22:07:39.047450605 +0100
|
|
---
|
|
erofs_types.h | 25 ++++++++++++++++++-------
|
|
1 file changed, 18 insertions(+), 7 deletions(-)
|
|
|
|
Index: erofs-utils-0.0.1~4/erofs_types.h
|
|
===================================================================
|
|
--- erofs-utils-0.0.1~4.orig/erofs_types.h
|
|
+++ erofs-utils-0.0.1~4/erofs_types.h
|
|
@@ -26,13 +26,24 @@
|
|
#define s32 int32_t
|
|
#define s64 int64_t
|
|
|
|
-#define cpu_to_le16(X) htole16(X)
|
|
-#define cpu_to_le32(X) htole32(X)
|
|
-#define cpu_to_le64(X) htole64(X)
|
|
-
|
|
-#define le16_to_cpu(X) le16toh(X)
|
|
-#define le32_to_cpu(X) le32toh(X)
|
|
-#define le64_to_cpu(X) le64toh(X)
|
|
+#if (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) || \
|
|
+ (defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN)
|
|
+ /* We need to use constexpr functions, and htole16 unfortunately is not. */
|
|
+# define cpu_to_le16(x) __builtin_bswap16(x)
|
|
+# define cpu_to_le32(x) __builtin_bswap32(x)
|
|
+# define cpu_to_be64(x) (x)
|
|
+# define le16_to_cpu(x) __builtin_bswap16(x)
|
|
+# define le32_to_cpu(x) __builtin_bswap32(x)
|
|
+# define be64_to_cpu(x) (x)
|
|
+#else
|
|
+# define cpu_to_le16(x) (x)
|
|
+# define cpu_to_le32(x) (x)
|
|
+# define cpu_to_le64(x) (x)
|
|
+# define cpu_to_be64(x) __builtin_bswap64(x)
|
|
+# define le16_to_cpu(x) (x)
|
|
+# define le32_to_cpu(x) (x)
|
|
+# define be64_to_cpu(x) __builtin_bswap64(x)
|
|
+#endif
|
|
|
|
#ifndef __OPTIMIZE__
|
|
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
|