Mercurial > hg > toybox
diff lib/portability.h @ 100:c3d1d74d5d8f
MacOS X has a defective sed with no -r.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 13 Feb 2007 16:41:51 -0500 |
parents | 884c03c29f21 |
children | 5f1d3ad8a888 |
line wrap: on
line diff
--- a/lib/portability.h Mon Feb 12 20:03:01 2007 -0500 +++ b/lib/portability.h Tue Feb 13 16:41:51 2007 -0500 @@ -1,13 +1,30 @@ - // Humor glibc to get dprintf, then #define it to something more portable. #define _GNU_SOURCE #include <stdio.h> #define fdprintf(...) dprintf(__VA_ARGS__) + +#ifndef __APPLE__ +#include <byteswap.h> #include <endian.h> #if __BYTE_ORDER == __BIG_ENDIAN #define IS_BIG_ENDIAN 1 +#else +#define IS_BIG_ENDIAN 0 +#endif + +#else + +#ifdef __BIG_ENDIAN__ +#define IS_BIG_ENDIAN 1 +#else +#define IS_BIG_ENDIAN 0 +#endif + +#endif + +#if IS_BIG_ENDIAN #define IS_LITTLE_ENDIAN 0 #define SWAP_BE16(x) (x) #define SWAP_BE32(x) (x) @@ -17,7 +34,6 @@ #define SWAP_LE64(x) bswap_64(x) #else #define IS_LITTLE_ENDIAN 1 -#define IS_BIG_ENDIAN 0 #define SWAP_BE16(x) bswap_16(x) #define SWAP_BE32(x) bswap_32(x) #define SWAP_BE64(x) bswap_64(x)