]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
autotools: stop using AC_C_BIGENDIAN / WORDS_BIGENDIAN
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 14 Oct 2022 19:54:47 +0000 (21:54 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Fri, 14 Oct 2022 20:00:48 +0000 (22:00 +0200)
This define is specific to autotools. Not defining the macro will lead
to silently miscompiled code as has happened with the meson build.

Instead use macros provided by the compiler itself. It does not need any
support from the buildsystem and is supported by both gcc and clang.

If a compiler does not support this feature we will get a loud error
instead of silent miscompilation.

Furthermore it probably better supports universal binaries on macOS
which compiles multiple architectures in a single build.

configure.ac
disk-utils/cramfs.h
include/bitops.h
lib/md5.c
lib/sha1.c
libblkid/src/superblocks/minix.c
sys-utils/lscpu.c
tests/helpers/test_sysinfo.c

index e760889ccf682d011f632ee059eba47ebb1eb446..6c0720c143ae55112063b879db89d6f04c4af9ba 100644 (file)
@@ -127,7 +127,6 @@ AC_PROG_YACC
 AC_CANONICAL_HOST
 AC_C_CONST
 AC_C_VOLATILE
-AC_C_BIGENDIAN
 
 dnl Compiler warnings
 UL_WARN_ADD([-fno-common])
index e0ddbda1c8a025cf80e006fd721c2605be9eba3b..43bbf526491cbc3e0f6494b188a17f78f82f6bc4 100644 (file)
 #define CRAMFS_OFFSET_WIDTH 26
 
 #ifndef HOST_IS_BIG_ENDIAN
-#ifdef WORDS_BIGENDIAN
-#define HOST_IS_BIG_ENDIAN 1
-#else
-#define HOST_IS_BIG_ENDIAN 0
-#endif
+#define HOST_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
 #endif
 
 /*
index 72274de0b539c4c1055e5c873c2ebcdda6833055..16ba2abd613c6980fb3c88b66369491e11d94542 100644 (file)
@@ -87,7 +87,7 @@
 #endif
 
 #ifndef htobe16
-# if !defined(WORDS_BIGENDIAN)
+# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #  define htobe16(x) bswap_16 (x)
 #  define htole16(x) (x)
 #  define be16toh(x) bswap_16 (x)
index 3765ab93edd6f5c313c2fa881b7dc4c7612fc08d..eedc71b075d19e3263898503552581f7288001cd 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -18,7 +18,7 @@
 
 #include "md5.h"
 
-#if !defined(WORDS_BIGENDIAN)
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 # define byteReverse(buf, len) /* Nothing */
 #else
 static void byteReverse(unsigned char *buf, unsigned longs);
@@ -38,7 +38,7 @@ static void byteReverse(unsigned char *buf, unsigned longs)
     } while (--longs);
 }
 #endif /* !ASM_MD5 */
-#endif /* !WORDS_BIGENDIAN */
+#endif /* __ORDER_LITTLE_ENDIAN__ */
 
 /*
  * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
index 22d33b3151216bad1beb7269f86338c6171d11d6..eedeaa84aea89a86d0bfd2a5fe51914be965ad69 100644 (file)
@@ -19,7 +19,7 @@
 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
 
 /* blk0() and blk() perform the initial expand. */
-#ifdef WORDS_BIGENDIAN
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 # define blk0(i) block->l[i]
 #else
 # define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
index 6011842f7f4b1706b716b3ddad6131fa03f97bb4..8447814f45963faba826f1c8dcf60c0b8a27c366 100644 (file)
@@ -61,7 +61,7 @@ static int get_minix_version(const unsigned char *data, int *other_endian)
        if (!version)
                return -1;
 
-#if defined(WORDS_BIGENDIAN)
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
        endian = *other_endian ? "LE" : "BE";
 #else
        endian = *other_endian ? "BE" : "LE";
index 7c9e4505eb57768b7193f07c65dd27e930f984a0..f6135158737dc658455ad8122751c4d1be914f40 100644 (file)
@@ -999,7 +999,7 @@ static void print_summary(struct lscpu_cxt *cxt)
        }
        if (ct && ct->addrsz)
                add_summary_s(tb, sec, _("Address sizes:"), ct->addrsz);
-#if !defined(WORDS_BIGENDIAN)
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
        add_summary_s(tb, sec, _("Byte Order:"), "Little Endian");
 #else
        add_summary_s(tb, sec, _("Byte Order:"), "Big Endian");
index e13931d04b1b2ead228a4a32a6e3fe649e33076c..aea019276b7312b1d42e1a2636e7a9fe55af7542 100644 (file)
@@ -35,7 +35,7 @@ static int hlp_wordsize(void)
 
 static int hlp_endianness(void)
 {
-#if !defined(WORDS_BIGENDIAN)
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
        printf("LE\n");
 #else
        printf("BE\n");