Mercurial > hg > th-libs
changeset 51:1607c0691dee
Change byteorder support. Now TH_BYTEORDER must be defined to either
TH_BIG_ENDIAN or TH_LITTLE_ENDIAN.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 09 Oct 2011 22:37:58 +0300 |
parents | 1fa969d0f551 |
children | 2a452b142301 |
files | th_endian.h |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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