]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
authorYonggang Luo <luoyonggang@gmail.com>
Tue, 20 Sep 2022 08:43:05 +0000 (16:43 +0800)
committerMark Wielaard <mark@klomp.org>
Mon, 17 Oct 2022 08:35:21 +0000 (10:35 +0200)
__BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined by the
gcc/clang preprocessor. BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN are
defined in <endian.h>.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
17 files changed:
lib/ChangeLog
lib/system.h
libcpu/ChangeLog
libcpu/i386_disasm.c
libcpu/memory-access.h
libcpu/riscv_disasm.c
libdw/ChangeLog
libdw/memory-access.h
libdwfl/ChangeLog
libdwfl/dwfl_segment_report_module.c
libelf/ChangeLog
libelf/common.h
libelf/elf32_checksum.c
libelf/elf32_xlatetof.c
libelf/elf_getarsym.c
src/ChangeLog
src/arlib.h

index e4f00a8f4968000082c1f35fd774b4a153b6075e..ab555c17efcf0f87c3570621d2af9059e28e4cfb 100644 (file)
@@ -1,3 +1,7 @@
+2022-09-20  Yonggang Luo  <luoyonggang@gmail.com>
+
+       * system.h: Use BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN.
+
 2022-10-16  Yonggang Luo  <luoyonggang@gmail.com>
 
        * system.h: Add sys/mman.h as system dependend header.
index 48004df19e99877d97c8076ea14b998ef8dc3235..bbbe06c443072432b6dc9bda5811376441b0ae5e 100644 (file)
@@ -64,12 +64,12 @@ void error(int status, int errnum, const char *format, ...);
     exit (EXIT_FAILURE); \
   } while (0)
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 # define LE32(n)       (n)
 # define LE64(n)       (n)
 # define BE32(n)       bswap_32 (n)
 # define BE64(n)       bswap_64 (n)
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif BYTE_ORDER == BIG_ENDIAN
 # define BE32(n)       (n)
 # define BE64(n)       (n)
 # define LE32(n)       bswap_32 (n)
index 48fbba19f14865d90fdaa776ca2194aa83ea1554..93c4b72f2edda5d5f1ff8ef12e7780ad2ebb1b6b 100644 (file)
@@ -1,3 +1,8 @@
+2022-09-20  Yonggang Luo  <luoyonggang@gmail.com>
+
+       * memory-access.h: Use BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN.
+       * riscv_disasm.c: Likewise.
+
 2021-12-04  Mark Wielaard  <mark@klomp.org>
 
        * Makefile.am (GENDIS_ENV): New variable, depends on
index fd7340ccfa1bba7912f2e853b129fd0b84908c61..40475b81d7c049ecae8c3e926cc6f8fb2e7478f0 100644 (file)
@@ -44,7 +44,7 @@
 
 #include "../libebl/libeblP.h"
 
-#define MACHINE_ENCODING __LITTLE_ENDIAN
+#define MACHINE_ENCODING LITTLE_ENDIAN
 #include "memory-access.h"
 
 
index 779825fa8e0d17711573a30c2f484ef1f72cecf3..3b6ca19baaf6528537556920e44312a29b296732 100644 (file)
@@ -41,7 +41,7 @@
 #ifndef MACHINE_ENCODING
 # error "MACHINE_ENCODING needs to be defined"
 #endif
-#if MACHINE_ENCODING != __BIG_ENDIAN && MACHINE_ENCODING != __LITTLE_ENDIAN
+#if MACHINE_ENCODING != BIG_ENDIAN && MACHINE_ENCODING != LITTLE_ENDIAN
 # error "MACHINE_ENCODING must signal either big or little endian"
 #endif
 
 #if ALLOW_UNALIGNED
 
 # define read_2ubyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)                               \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)                                 \
    ? bswap_16 (*((const uint16_t *) (Addr)))                                 \
    : *((const uint16_t *) (Addr)))
 # define read_2sbyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)                               \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)                                 \
    ? (int16_t) bswap_16 (*((const int16_t *) (Addr)))                        \
    : *((const int16_t *) (Addr)))
 
 # define read_4ubyte_unaligned_noncvt(Addr) \
    *((const uint32_t *) (Addr))
 # define read_4ubyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)                               \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)                                 \
    ? bswap_32 (*((const uint32_t *) (Addr)))                                 \
    : *((const uint32_t *) (Addr)))
 # define read_4sbyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)                               \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)                                 \
    ? (int32_t) bswap_32 (*((const int32_t *) (Addr)))                        \
    : *((const int32_t *) (Addr)))
 
 # define read_8ubyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)                               \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)                                 \
    ? bswap_64 (*((const uint64_t *) (Addr)))                                 \
    : *((const uint64_t *) (Addr)))
 # define read_8sbyte_unaligned(Addr) \
-  (unlikely (MACHINE_ENCODING != __BYTE_ORDER)                               \
+  (unlikely (MACHINE_ENCODING != BYTE_ORDER)                                 \
    ? (int64_t) bswap_64 (*((const int64_t *) (Addr)))                        \
    : *((const int64_t *) (Addr)))
 
@@ -96,7 +96,7 @@ static inline uint16_t
 read_2ubyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return bswap_16 (up->u2);
   return up->u2;
 }
@@ -104,7 +104,7 @@ static inline int16_t
 read_2sbyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return (int16_t) bswap_16 (up->u2);
   return up->s2;
 }
@@ -119,7 +119,7 @@ static inline uint32_t
 read_4ubyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return bswap_32 (up->u4);
   return up->u4;
 }
@@ -127,7 +127,7 @@ static inline int32_t
 read_4sbyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return (int32_t) bswap_32 (up->u4);
   return up->s4;
 }
@@ -136,7 +136,7 @@ static inline uint64_t
 read_8ubyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return bswap_64 (up->u8);
   return up->u8;
 }
@@ -144,7 +144,7 @@ static inline int64_t
 read_8sbyte_unaligned (const void *p)
 {
   const union unaligned *up = p;
-  if (MACHINE_ENCODING != __BYTE_ORDER)
+  if (MACHINE_ENCODING != BYTE_ORDER)
     return (int64_t) bswap_64 (up->u8);
   return up->s8;
 }
index bc0d8f371b5a6e3c503fcb6835dc1e36c55fc2d5..7175c077062d4a3ef3efa78684e37a7b2523b8c7 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "../libebl/libeblP.h"
 
-#define MACHINE_ENCODING __LITTLE_ENDIAN
+#define MACHINE_ENCODING LITTLE_ENDIAN
 #include "memory-access.h"
 
 
index 9a798ff986b9b3832e98ab7a7bd7538ce189ef25..b14b53833b96c0754510b5c5e16d734777731daf 100644 (file)
@@ -1,3 +1,7 @@
+2022-09-20  Yonggang Luo  <luoyonggang@gmail.com>
+
+       * memory-access.h: Use BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN.
+
 2022-09-13  Aleksei Vetrov  <vvvvvv@google.com>
 
        * libdw.map (ELFUTILS_0.188): Add dwfl_report_offline_memory.
index 8b2386ee67deb50c796bd75e39954c0d2225fa54..800b517c7cbd6738cde1bfcbbed420352f2ed7f6 100644 (file)
@@ -355,10 +355,10 @@ read_8sbyte_unaligned_1 (bool other_byte_order, const void *p)
 static inline int
 file_byte_order (bool other_byte_order)
 {
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-  return other_byte_order ? __BIG_ENDIAN : __LITTLE_ENDIAN;
+#if BYTE_ORDER == LITTLE_ENDIAN
+  return other_byte_order ? BIG_ENDIAN : LITTLE_ENDIAN;
 #else
-  return other_byte_order ? __LITTLE_ENDIAN : __BIG_ENDIAN;
+  return other_byte_order ? LITTLE_ENDIAN : BIG_ENDIAN;
 #endif
 }
 
@@ -372,7 +372,7 @@ read_3ubyte_unaligned (Dwarf *dbg, const unsigned char *p)
   } d;
   bool other_byte_order = dbg->other_byte_order;
 
-  if (file_byte_order (other_byte_order) == __BIG_ENDIAN)
+  if (file_byte_order (other_byte_order) == BIG_ENDIAN)
     {
       d.c[0] = 0x00;
       d.c[1] = p[0];
index 942f05d53d7f4eb13ad59be16852df3143e259d1..faa97fca6e62236b241e7e613a58cdb07bda31eb 100644 (file)
@@ -1,3 +1,8 @@
+2022-09-20  Yonggang Luo  <luoyonggang@gmail.com>
+
+       * dwfl_segment_report_module.c: Use BYTE_ORDER, LITTLE_ENDIAN and
+       BIG_ENDIAN.
+
 2022-09-13  Aleksei Vetrov  <vvvvvv@google.com>
 
        * libdwfl.h (dwfl_report_offline_memory): New function.
index 1461ae26aee3a5cce3c56cabb680fdf2e248c793..28f87f10dd3962082ec4b995f43069ffc4b5e3d4 100644 (file)
@@ -49,7 +49,7 @@
 
 #define INITIAL_READ   1024
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 # define MY_ELFDATA    ELFDATA2LSB
 #else
 # define MY_ELFDATA    ELFDATA2MSB
index 1c6c492111397c9b95c0a1b0e0b2090c916cc4ed..86b12e815b40a246d0bdd2b440a522936bad9d12 100644 (file)
@@ -1,3 +1,9 @@
+2022-09-20  Yonggang Luo  <luoyonggang@gmail.com>
+
+       * elf32_checksum.c: Use BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN.
+       * elf32_xlatetof.c: Likewise.
+       * elf_getarsym.c: Likewise.
+
 2022-10-16  Yonggang Luo  <luoyonggang@gmail.com>
 
        * common.h: Remove ar.h, byteswap.h and endian.h.
index 4561854fb3f7bb451b3d38b88af8258d0f02d3e1..9b2a856d118a55c0977bbc8d9978d8f6b42f18b3 100644 (file)
@@ -151,7 +151,7 @@ libelf_release_all (Elf *elf)
                 : bswap_64 (Var))))
 
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 # define MY_ELFDATA    ELFDATA2LSB
 #else
 # define MY_ELFDATA    ELFDATA2MSB
index 521668a7485c4311e2c0e026d336ad7b49ac2e00..a47b307d51b84113e5a90ec8fd5d8b921d845059 100644 (file)
@@ -73,9 +73,9 @@ elfw2(LIBELFBITS,checksum) (Elf *elf)
      is the same.  */
   ident = elf->state.ELFW(elf,LIBELFBITS).ehdr->e_ident;
   same_byte_order = ((ident[EI_DATA] == ELFDATA2LSB
-                     && __BYTE_ORDER == __LITTLE_ENDIAN)
+                     && BYTE_ORDER == LITTLE_ENDIAN)
                     || (ident[EI_DATA] == ELFDATA2MSB
-                        && __BYTE_ORDER == __BIG_ENDIAN));
+                        && BYTE_ORDER == BIG_ENDIAN));
 
   /* If we don't have native byte order, we will likely need to
      convert the data with xlate functions.  We do it upfront instead
index 377659c8955594c2411768a071c65bc3e47f79c4..ab857409329a3524141165a6e96a30c58bef8b2e 100644 (file)
@@ -82,8 +82,8 @@ elfw2(LIBELFBITS, xlatetof) (Elf_Data *dest, const Elf_Data *src,
        and vice versa since the function only has to copy and/or
        change the byte order.
   */
-  if ((__BYTE_ORDER == __LITTLE_ENDIAN && encode == ELFDATA2LSB)
-      || (__BYTE_ORDER == __BIG_ENDIAN && encode == ELFDATA2MSB))
+  if ((BYTE_ORDER == LITTLE_ENDIAN && encode == ELFDATA2LSB)
+      || (BYTE_ORDER == BIG_ENDIAN && encode == ELFDATA2MSB))
     {
       /* We simply have to copy since the byte order is the same.  */
       if (src->d_buf != dest->d_buf)
index 2203521fa50c63b86a11b2ee2aba8f9776476b2f..281f0c1c56022bef6d8adc17b96be9707b971156 100644 (file)
@@ -61,7 +61,7 @@ read_number_entries (uint64_t *nump, Elf *elf, size_t *offp, bool index64_p)
 
   *offp += w;
 
-  if (__BYTE_ORDER == __LITTLE_ENDIAN)
+  if (BYTE_ORDER == LITTLE_ENDIAN)
     *nump = index64_p ? bswap_64 (u.ret64) : bswap_32 (u.ret32);
   else
     *nump = index64_p ? u.ret64 : u.ret32;
@@ -266,7 +266,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
              if (index64_p)
                {
                  uint64_t tmp = (*u64)[cnt];
-                 if (__BYTE_ORDER == __LITTLE_ENDIAN)
+                 if (BYTE_ORDER == LITTLE_ENDIAN)
                    tmp = bswap_64 (tmp);
 
                  arsym[cnt].as_off = tmp;
@@ -286,7 +286,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
                      goto out;
                    }
                }
-             else if (__BYTE_ORDER == __LITTLE_ENDIAN)
+             else if (BYTE_ORDER == LITTLE_ENDIAN)
                arsym[cnt].as_off = bswap_32 ((*u32)[cnt]);
              else
                arsym[cnt].as_off = (*u32)[cnt];
index 9348c562245da6b4bb862fea6e149af58e982b80..23c971d18b8a50e0b041d1c92a2fd822d3815c1b 100644 (file)
@@ -1,3 +1,7 @@
+2022-09-20  Yonggang Luo  <luoyonggang@gmail.com>
+
+       * arlib.h: Use BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN.
+
 2022-08-28  Mark Wielaard  <mark@klomp.org>
 
        * ar.c (do_oper_extract): Predecrement instance before compare
index e117166e47aa2a8c0f13ad819ea199f4bf665b58..d4a4221072d83de73fcd4c883a083cf65beb0a67 100644 (file)
@@ -46,7 +46,7 @@ extern const struct argp_child arlib_argp_children[];
 #define AR_HDR_WORDS (sizeof (struct ar_hdr) / sizeof (uint32_t))
 
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 # define le_bswap_32(val) bswap_32 (val)
 #else
 # define le_bswap_32(val) (val)