moved bx_bswap definition into osdep.h so bximage tool can also include them
This commit is contained in:
parent
5da69a6fb4
commit
c62426145a
@ -491,32 +491,6 @@ void bx_center_print(FILE *file, const char *line, unsigned maxwidth);
|
|||||||
|
|
||||||
#include "instrument.h"
|
#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
|
// These are some convenience macros which abstract out accesses between
|
||||||
// a variable in native byte ordering to/from guest (x86) memory, which is
|
// 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
|
// always in little endian format. You must deal with alignment (if your
|
||||||
|
@ -38,6 +38,32 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#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.
|
// Hacks for win32, but exclude MINGW32 because it doesn't need them.
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user