From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 16BE43858C83 for ; Sun, 16 Oct 2022 21:11:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 16BE43858C83 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x0e.wildebeest.org [172.31.17.144]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id A64003000913; Sun, 16 Oct 2022 23:11:07 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id 4F47E2E812E3; Sun, 16 Oct 2022 23:11:07 +0200 (CEST) Date: Sun, 16 Oct 2022 23:11:07 +0200 From: Mark Wielaard To: Yonggang Luo Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN Message-ID: References: <20220920084307.1696-1-luoyonggang@gmail.com> <20220920084307.1696-6-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220920084307.1696-6-luoyonggang@gmail.com> X-Spam-Status: No, score=-3039.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, This seems to work and is probably OK. But do you know when/what the __ prefix versions are defined and when/what defines the non-prefixed versions? Thanks, Mark On Tue, Sep 20, 2022 at 04:43:05PM +0800, Yonggang Luo via Elfutils-devel wrote: > Signed-off-by: Yonggang Luo > --- > 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 >