diff options
author | Yonggang Luo <luoyonggang@gmail.com> | 2022-09-20 16:43:05 +0800 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2022-10-17 10:35:21 +0200 |
commit | 0e18267a05247b5bda60115270203b4ad3af8e55 (patch) | |
tree | 4b14d75d4d88d13b30327772cfe74126dce4d6ea /libcpu | |
parent | 96263dfee3591a9c732b00a33a4a221b8f01bf46 (diff) | |
download | elfutils-0e18267a05247b5bda60115270203b4ad3af8e55.tar.gz |
Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIAN
__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>
Diffstat (limited to 'libcpu')
-rw-r--r-- | libcpu/ChangeLog | 5 | ||||
-rw-r--r-- | libcpu/i386_disasm.c | 2 | ||||
-rw-r--r-- | libcpu/memory-access.h | 26 | ||||
-rw-r--r-- | libcpu/riscv_disasm.c | 2 |
4 files changed, 20 insertions, 15 deletions
diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog index 48fbba19..93c4b72f 100644 --- a/libcpu/ChangeLog +++ b/libcpu/ChangeLog @@ -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 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" |