# HG changeset patch # User Matti Hamalainen # Date 1318189078 -10800 # Node ID 1607c0691deeee7520780bc12e47e8617ebe8ec1 # Parent 1fa969d0f5515e7e92cfab7e4ac574d88df9f56c Change byteorder support. Now TH_BYTEORDER must be defined to either TH_BIG_ENDIAN or TH_LITTLE_ENDIAN. diff -r 1fa969d0f551 -r 1607c0691dee th_endian.h --- a/th_endian.h Mon Oct 03 18:39:31 2011 +0300 +++ b/th_endian.h Sun Oct 09 22:37:58 2011 +0300 @@ -46,7 +46,11 @@ /* Macros that swap only when needed ... */ -#ifdef TH_BIGENDIAN +#ifndef TH_BYTEORDER +# error Undefined byteorder (TH_BYTEORDER not set.) +#endif + +#if (TH_BYTEORDER == TH_BIG_ENDIAN) #define TH_LE16_TO_NATIVE(value) TH_SWAP_16_LE_BE(value) #define TH_LE32_TO_NATIVE(value) TH_SWAP_32_LE_BE(value) @@ -65,7 +69,8 @@ #define TH_NATIVE_TO_BE64(value) ((uint64_t) (value)) #endif -#else /* !TH_BIGENDIAN */ +/* !TH_BIG_ENDIAN */ +#elif (TH_BYTEORDER == TH_LITTLE_ENDIAN) #define TH_LE16_TO_NATIVE(value) ((uint16_t) (value)) #define TH_LE32_TO_NATIVE(value) ((uint32_t) (value)) @@ -84,6 +89,8 @@ #define TH_NATIVE_TO_BE64(value) TH_SWAP_64_LE_BE(value) #endif +#else +# error Unsupported byte order! #endif