From bba7f08d2788bc9bc30a7a60fdfd873a73fead9a Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 29 May 2006 05:51:12 +0000 Subject: Add SWAP_LE?? and SWAP_BE?? macros, and make things use them. Converts values to/from little endian or big endian, which is a NOP if that's what the current platform already is. --- include/platform.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/platform.h b/include/platform.h index d684c2dda..10c1d7d86 100644 --- a/include/platform.h +++ b/include/platform.h @@ -48,11 +48,6 @@ # define __const const #endif -#ifndef __THROW -# define __THROW -#endif - - #ifndef ATTRIBUTE_UNUSED # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #endif /* ATTRIBUTE_UNUSED */ @@ -118,6 +113,22 @@ # define BB_LITTLE_ENDIAN 1 #endif +#if BB_BIG_ENDIAN +#define SWAP_BE16(x) x +#define SWAP_BE32(x) x +#define SWAP_BE64(x) x +#define SWAP_LE16(x) bswap_16(x) +#define SWAP_LE32(x) bswap_32(x) +#define SWAP_LE64(x) bswap_64(x) +#else +#define SWAP_BE16(x) bswap_16(x) +#define SWAP_BE32(x) bswap_32(x) +#define SWAP_BE64(x) bswap_64(x) +#define SWAP_LE16(x) x +#define SWAP_LE32(x) x +#define SWAP_LE64(x) x +#endif + /* ---- Networking ------------------------------------------ */ #ifndef __APPLE__ # include -- cgit v1.2.3