From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id A74EB3858295 for ; Tue, 20 Sep 2022 08:43:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A74EB3858295 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x62e.google.com with SMTP id p18so1671101plr.8 for ; Tue, 20 Sep 2022 01:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XJH8B5jDSHMHlMB23vE6Yt+3LA4cEe8gIizwyTIsdUQ=; b=A43PcPNfuIUh+7TZFJOFGm8fWPULHUFkfPtC7qIBDCHXjdnNjFXmuyBxJ7yUJVcHFl SxtJ44F+BwPiKuE7OVe2o6uZgUXVhDTUEr6ZBSXRXDpY0dk0xKJotlzrz3YLvA1c87QY n+9HlgZeMSBLtKkbLQ7WF5nsdpC13gj4PvJz+0lJwVk6XwGxXTQFISxkubytrrn48WK8 VVV36d8mIQbC4M/b2XZ9CGEDmc+MIhW/kDUAU0DCydoE07TBdkdTuNX1j2ydCSfvL2Zg uZvfgTJZ1hxWa2RKmrgEwJm9JsyzMmw8LZTgJZ4FMT6HJOiqrZf339vWse/nbj7TOaGh VqhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XJH8B5jDSHMHlMB23vE6Yt+3LA4cEe8gIizwyTIsdUQ=; b=CmJNisRXSIW5AHLu0UTumOoPWDk04u8YoAONctZVcLPxglSX+eP+wqmawDLehPXkbS DM2tMXb004J6ayhsvPV2DPX1ySqXQ3h9HwQU/2CZqCTIXqu8YmuKayN6KWjdfxWSrU/Z KKXGiS6O4hFtjN44Qzx3ycYoRYQ2nNHUBWGWD5sahr143/37jX1/6/pi3EpqC8E32How MnibT30Z39Bpp3zqLh4ik5C4bBIbDCdxRwHji0iWOZoxd74nqqJIL8EW1D1K87yRvNrX iGfPdxaaZdrcWo/sjxLxtI37x6sO5d8aAsvXcTj6P+/AIEcDE+WgeYahJp3CjbmiMTG7 LxOg== X-Gm-Message-State: ACrzQf30xYSQSrmGrUpCRuByvtO2UxjDClxpHA2WL+ugbeFiTVQ75IIB Sfx+D3hP7/XTgt+oTPwmDvAYYxGO8xY= X-Google-Smtp-Source: AMsMyM6x9YcaqqHYilOXUuZEOhOAKgm20J1vXshzdC3Pn+7WbnOWViQvb8J25oZ4G46nKBamWeQw1g== X-Received: by 2002:a17:90b:3b90:b0:202:8a60:c852 with SMTP id pc16-20020a17090b3b9000b002028a60c852mr2748522pjb.169.1663663410293; Tue, 20 Sep 2022 01:43:30 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id so16-20020a17090b1f9000b002009db534d1sm873372pjb.24.2022.09.20.01.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 01:43:29 -0700 (PDT) From: Yonggang Luo To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH 5/7] Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN Date: Tue, 20 Sep 2022 16:43:05 +0800 Message-Id: <20220920084307.1696-6-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20220920084307.1696-1-luoyonggang@gmail.com> References: <20220920084307.1696-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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: 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