diff options
Diffstat (limited to 'src/xine-engine/bswap.h')
-rw-r--r-- | src/xine-engine/bswap.h | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/src/xine-engine/bswap.h b/src/xine-engine/bswap.h index 72a6badbc..1532ff758 100644 --- a/src/xine-engine/bswap.h +++ b/src/xine-engine/bswap.h @@ -92,52 +92,43 @@ inline static unsigned long long int ByteSwap64(unsigned long long int x) #define le2me_64(x) (x) #endif -#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) -#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \ - (((uint8_t*)(x))[1] << 16) | \ - (((uint8_t*)(x))[2] << 8) | \ - ((uint8_t*)(x))[3]) -#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) -#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \ - (((uint8_t*)(x))[2] << 16) | \ - (((uint8_t*)(x))[1] << 8) | \ - ((uint8_t*)(x))[0]) -#ifdef DEBUG - -inline static void* check_ptr_alignment(void* ptr, int align) -{ - XINE_ASSERT((int)ptr % align == 0, "Improper pointer alignment."); - return ptr; -} - -#define ABE_16(x) (be2me_16(*(uint16_t*)check_ptr_alignment((x), 2))) -#define ABE_32(x) (be2me_32(*(uint32_t*)check_ptr_alignment((x), 4))) -#define ALE_16(x) (le2me_16(*(uint16_t*)check_ptr_alignment((x), 2))) -#define ALE_32(x) (le2me_32(*(uint32_t*)check_ptr_alignment((x), 4))) - -#else - #define ABE_16(x) (be2me_16(*(uint16_t*)(x))) #define ABE_32(x) (be2me_32(*(uint32_t*)(x))) #define ALE_16(x) (le2me_16(*(uint16_t*)(x))) #define ALE_32(x) (le2me_32(*(uint32_t*)(x))) -#endif +#ifdef ARCH_X86 -#ifdef WORDS_BIGENDIAN +#define BE_16(x) ABE_16(x) +#define BE_32(x) ABE_32(x) +#define LE_16(x) ALE_16(x) +#define LE_32(x) ALE_32(x) +#else + +#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) +#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \ + (((uint8_t*)(x))[1] << 16) | \ + (((uint8_t*)(x))[2] << 8) | \ + ((uint8_t*)(x))[3]) +#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) +#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \ + (((uint8_t*)(x))[2] << 16) | \ + (((uint8_t*)(x))[1] << 8) | \ + ((uint8_t*)(x))[0]) + +#endif /* !ARCH_X86 */ + +#ifdef WORDS_BIGENDIAN #define ME_16(x) BE_16(x) #define ME_32(x) BE_32(x) #define AME_16(x) ABE_16(x) #define AME_32(x) ABE_32(x) - #else - #define ME_16(x) LE_16(x) #define ME_32(x) LE_32(x) #define AME_16(x) ALE_16(x) #define AME_32(x) ALE_32(x) - #endif #endif |