From c62426145a1228a2dee935b7b2a84c93ef6890eb Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Wed, 28 Dec 2011 22:17:12 +0000 Subject: [PATCH] moved bx_bswap definition into osdep.h so bximage tool can also include them --- bochs/bochs.h | 26 -------------------------- bochs/osdep.h | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/bochs/bochs.h b/bochs/bochs.h index e65c3bd9c..ce6a423ff 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -491,32 +491,6 @@ void bx_center_print(FILE *file, const char *line, unsigned maxwidth); #include "instrument.h" -BX_CPP_INLINE Bit16u bx_bswap16(Bit16u val16) -{ - return (val16<<8) | (val16>>8); -} - -#if BX_HAVE___BUILTIN_BSWAP32 -#define bx_bswap32 __builtin_bswap32 -#else -BX_CPP_INLINE Bit32u bx_bswap32(Bit32u val32) -{ - val32 = ((val32<<8) & 0xFF00FF00) | ((val32>>8) & 0x00FF00FF); - return (val32<<16) | (val32>>16); -} -#endif - -#if BX_HAVE___BUILTIN_BSWAP64 -#define bx_bswap64 __builtin_bswap64 -#else -BX_CPP_INLINE Bit64u bx_bswap64(Bit64u val64) -{ - Bit32u lo = bx_bswap32((Bit32u)(val64 >> 32)); - Bit32u hi = bx_bswap32((Bit32u)(val64 & 0xFFFFFFFF)); - return ((Bit64u)hi << 32) | (Bit64u)lo; -} -#endif - // These are some convenience macros which abstract out accesses between // a variable in native byte ordering to/from guest (x86) memory, which is // always in little endian format. You must deal with alignment (if your diff --git a/bochs/osdep.h b/bochs/osdep.h index e0d87efac..ee364fd8b 100644 --- a/bochs/osdep.h +++ b/bochs/osdep.h @@ -38,6 +38,32 @@ extern "C" { #endif /* __cplusplus */ +BX_CPP_INLINE Bit16u bx_bswap16(Bit16u val16) +{ + return (val16<<8) | (val16>>8); +} + +#if BX_HAVE___BUILTIN_BSWAP32 +#define bx_bswap32 __builtin_bswap32 +#else +BX_CPP_INLINE Bit32u bx_bswap32(Bit32u val32) +{ + val32 = ((val32<<8) & 0xFF00FF00) | ((val32>>8) & 0x00FF00FF); + return (val32<<16) | (val32>>16); +} +#endif + +#if BX_HAVE___BUILTIN_BSWAP64 +#define bx_bswap64 __builtin_bswap64 +#else +BX_CPP_INLINE Bit64u bx_bswap64(Bit64u val64) +{ + Bit32u lo = bx_bswap32((Bit32u)(val64 >> 32)); + Bit32u hi = bx_bswap32((Bit32u)(val64 & 0xFFFFFFFF)); + return ((Bit64u)hi << 32) | (Bit64u)lo; +} +#endif + ////////////////////////////////////////////////////////////////////// // Hacks for win32, but exclude MINGW32 because it doesn't need them. //////////////////////////////////////////////////////////////////////