diff --git a/src/xenia/byte_order.h b/src/xenia/byte_order.h index b9a73e3ae..cfd08a135 100644 --- a/src/xenia/byte_order.h +++ b/src/xenia/byte_order.h @@ -47,6 +47,31 @@ #endif +#if XE_CPU(BIGENDIAN) +#define XESWAPF32BE(p) (p) +#define XESWAPF64BE(p) (p) +XEFORCEINLINE float XESWAPF32LE(float value) { + uint32_t dummy = XESWAP32LE(*reinterpret_cast(&value)); + return *reinterpret_cast(&dummy); +} +XEFORCEINLINE double XESWAPF64LE(double value) { + uint64_t dummy = XESWAP64LE(*reinterpret_cast(&value)); + return *reinterpret_cast(&dummy); +} +#else +XEFORCEINLINE float XESWAPF32BE(float value) { + uint32_t dummy = XESWAP32BE(*reinterpret_cast(&value)); + return *reinterpret_cast(&dummy); +} +XEFORCEINLINE double XESWAPF64BE(double value) { + uint64_t dummy = XESWAP64BE(*reinterpret_cast(&value)); + return *reinterpret_cast(&dummy); +} +#define XESWAPF32LE(p) (p) +#define XESWAPF64LE(p) (p) +#endif + + #define XEGETINT8BE(p) ( (int8_t)(*(p))) #define XEGETUINT8BE(p) ( (uint8_t)(*(p))) #define XEGETINT16BE(p) ( (int16_t)XESWAP16BE(*(uint16_t*)(p)))