public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Yonggang Luo <luoyonggang@gmail.com>
To: elfutils-devel@sourceware.org
Cc: Yonggang Luo <luoyonggang@gmail.com>
Subject: [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
Date: Tue, 20 Sep 2022 16:43:05 +0800	[thread overview]
Message-ID: <20220920084307.1696-6-luoyonggang@gmail.com> (raw)
In-Reply-To: <20220920084307.1696-1-luoyonggang@gmail.com>

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 lib/system.h                         |  4 ++--
 libcpu/i386_disasm.c                 |  2 +-
 libcpu/memory-access.h               | 26 +++++++++++++-------------
 libcpu/riscv_disasm.c                |  2 +-
 libdw/memory-access.h                |  8 ++++----
 libdwfl/dwfl_segment_report_module.c |  2 +-
 libelf/common.h                      |  2 +-
 libelf/elf32_checksum.c              |  4 ++--
 libelf/elf32_xlatetof.c              |  4 ++--
 libelf/elf_getarsym.c                |  6 +++---
 src/arlib.h                          |  2 +-
 11 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/lib/system.h b/lib/system.h
index 48004df1..bbbe06c4 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -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)
diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c
index fd7340cc..40475b81 100644
--- a/libcpu/i386_disasm.c
+++ b/libcpu/i386_disasm.c
@@ -44,7 +44,7 @@
 
 #include "../libebl/libeblP.h"
 
-#define MACHINE_ENCODING __LITTLE_ENDIAN
+#define MACHINE_ENCODING LITTLE_ENDIAN
 #include "memory-access.h"
 
 
diff --git a/libcpu/memory-access.h b/libcpu/memory-access.h
index 779825fa..3b6ca19b 100644
--- a/libcpu/memory-access.h
+++ b/libcpu/memory-access.h
@@ -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
 
@@ -51,31 +51,31 @@
 #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;
 }
diff --git a/libcpu/riscv_disasm.c b/libcpu/riscv_disasm.c
index bc0d8f37..7175c077 100644
--- a/libcpu/riscv_disasm.c
+++ b/libcpu/riscv_disasm.c
@@ -41,7 +41,7 @@
 
 #include "../libebl/libeblP.h"
 
-#define MACHINE_ENCODING __LITTLE_ENDIAN
+#define MACHINE_ENCODING LITTLE_ENDIAN
 #include "memory-access.h"
 
 
diff --git a/libdw/memory-access.h b/libdw/memory-access.h
index 8b2386ee..800b517c 100644
--- a/libdw/memory-access.h
+++ b/libdw/memory-access.h
@@ -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];
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 1461ae26..28f87f10 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -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
diff --git a/libelf/common.h b/libelf/common.h
index 4561854f..9b2a856d 100644
--- a/libelf/common.h
+++ b/libelf/common.h
@@ -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
diff --git a/libelf/elf32_checksum.c b/libelf/elf32_checksum.c
index 521668a7..a47b307d 100644
--- a/libelf/elf32_checksum.c
+++ b/libelf/elf32_checksum.c
@@ -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
diff --git a/libelf/elf32_xlatetof.c b/libelf/elf32_xlatetof.c
index 377659c8..ab857409 100644
--- a/libelf/elf32_xlatetof.c
+++ b/libelf/elf32_xlatetof.c
@@ -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)
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index 2203521f..281f0c1c 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -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];
diff --git a/src/arlib.h b/src/arlib.h
index e117166e..d4a42210 100644
--- a/src/arlib.h
+++ b/src/arlib.h
@@ -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)
-- 
2.36.1.windows.1


  parent reply	other threads:[~2022-09-20  8:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20  8:43 [PATCH 0/7] Enable building libelf of elfutils on win32 Yonggang Luo
2022-09-20  8:43 ` [PATCH 1/7] Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec' Yonggang Luo
2022-10-14 20:35   ` Mark Wielaard
2022-10-19 18:45     ` 罗勇刚(Yonggang Luo)
2022-10-19 19:49       ` Frank Ch. Eigler
2022-10-19 21:23         ` 罗勇刚(Yonggang Luo)
2022-10-19 21:27         ` 罗勇刚(Yonggang Luo)
2022-10-21 15:45           ` Frank Ch. Eigler
2022-10-20 16:07         ` Mark Wielaard
2022-10-31 13:29           ` Mark Wielaard
2022-11-24  8:27             ` 罗勇刚(Yonggang Luo)
2022-09-20  8:43 ` [PATCH 2/7] move platform depended include into system.h Yonggang Luo
2022-10-14 21:16   ` Mark Wielaard
2022-10-15 17:01     ` 罗勇刚(Yonggang Luo)
2022-09-20  8:43 ` [PATCH 3/7] lib: Use NOT_HAVE_LIBINTL to guard if need #include <libintl.h> Yonggang Luo
2022-09-20  8:43 ` [PATCH 4/7] Remove duplicated " Yonggang Luo
2022-09-20  8:43 ` Yonggang Luo [this message]
2022-10-16 21:11   ` [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN Mark Wielaard
2022-10-17  3:40     ` 罗勇刚(Yonggang Luo)
2022-10-17  8:42       ` Mark Wielaard
2022-09-20  8:43 ` [PATCH 6/7] Fixes building with msvc/clang mingw/gcc Yonggang Luo
2022-10-16 21:21   ` Mark Wielaard
2022-12-16 21:12     ` 罗勇刚(Yonggang Luo)
2022-09-20  8:43 ` [PATCH 7/7] Add CMake build files Yonggang Luo
2022-10-16 21:23   ` Mark Wielaard
2022-12-16 21:12     ` 罗勇刚(Yonggang Luo)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220920084307.1696-6-luoyonggang@gmail.com \
    --to=luoyonggang@gmail.com \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).