From f45b357740612b91d8e6105e76c23d5947947906 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 24 Jun 2018 00:01:06 +0200 Subject: [PATCH] Remove the dependency on the glibc-only byteswap.h. --- plat/linuxppc/emu/emu.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plat/linuxppc/emu/emu.c b/plat/linuxppc/emu/emu.c index 90c9fd518..91ae87a8b 100644 --- a/plat/linuxppc/emu/emu.c +++ b/plat/linuxppc/emu/emu.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include "emu.h" @@ -24,8 +23,23 @@ static inline bool carry(void) fatal("carry() not supported yet"); } -#define swb16(x) bswap_16(x) -#define swb32(x) bswap_32(x) +/* Byte-swaps a 16-bit value. */ +static inline uint16_t swb16(uint16_t n) +{ + return + (((n >> 8) & 0xff) | + ((n & 0xff) << 8)); +} + +/* Byte-swaps a 32-bit value. */ +static inline uint32_t swb32(uint32_t n) +{ + return + (((n & 0xff000000) >> 24) | + ((n & 0x00ff0000) >> 8) | + ((n & 0x0000ff00) << 8) | + ((n & 0x000000ff) << 24)); +} /* Returns the state of a carry flag after a three-way add. */ static inline bool carry_3(uint32_t a, uint32_t b, uint32_t c) -- 2.34.1