From 8d90fb3e4a5d02df75584016563ef84901967b9f Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 7 Jan 2022 20:24:34 +0200 Subject: Merged bits.h and bytes.h --- common/bits.c | 32 ++++++++++++++++++++++++++++++++ common/bytes.c | 32 -------------------------------- common/elf.c | 2 +- 3 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 common/bits.c delete mode 100644 common/bytes.c (limited to 'common') diff --git a/common/bits.c b/common/bits.c new file mode 100644 index 0000000..ca99ed2 --- /dev/null +++ b/common/bits.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +#undef __bswap16 +__weak uint16_t __bswap16(uint16_t u) +{ + return (u & 0xff00) >> 8 | (u & 0x00ff) << 8; +} + +#undef __bswap32 +__weak uint32_t __bswap32(uint32_t u) +{ + return (u & 0xff000000) >> 24 | + (u & 0x00ff0000) >> 8 | + (u & 0x0000ff00) << 8 | + (u & 0x000000ff) << 24; +} + +#undef __bswap64 +__weak uint64_t __bswap64(uint64_t u) +{ + return (u & 0xff00000000000000ULL) >> 56 | + (u & 0x00ff000000000000ULL) >> 40 | + (u & 0x0000ff0000000000ULL) >> 24 | + (u & 0x000000ff00000000ULL) >> 8 | + (u & 0x00000000ff000000ULL) << 8 | + (u & 0x0000000000ff0000ULL) << 24 | + (u & 0x000000000000ff00ULL) << 40 | + (u & 0x00000000000000ffULL) << 56; +} diff --git a/common/bytes.c b/common/bytes.c deleted file mode 100644 index a5b3c4a..0000000 --- a/common/bytes.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include - -#undef __bswap16 -__weak uint16_t __bswap16(uint16_t u) -{ - return (u & 0xff00) >> 8 | (u & 0x00ff) << 8; -} - -#undef __bswap32 -__weak uint32_t __bswap32(uint32_t u) -{ - return (u & 0xff000000) >> 24 | - (u & 0x00ff0000) >> 8 | - (u & 0x0000ff00) << 8 | - (u & 0x000000ff) << 24; -} - -#undef __bswap64 -__weak uint64_t __bswap64(uint64_t u) -{ - return (u & 0xff00000000000000ULL) >> 56 | - (u & 0x00ff000000000000ULL) >> 40 | - (u & 0x0000ff0000000000ULL) >> 24 | - (u & 0x000000ff00000000ULL) >> 8 | - (u & 0x00000000ff000000ULL) << 8 | - (u & 0x0000000000ff0000ULL) << 24 | - (u & 0x000000000000ff00ULL) << 40 | - (u & 0x00000000000000ffULL) << 56; -} diff --git a/common/elf.c b/common/elf.c index 6b7b6dd..9ce357d 100644 --- a/common/elf.c +++ b/common/elf.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include static uint8_t __elf_to_uvflags(uint8_t elf_flags) -- cgit v1.3