diff options
author | Greg Troxel <gdt@ir.bbn.com> | 2013-11-10 09:24:03 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-11-10 11:12:40 -0500 |
commit | 7edf502c0fa7eb9615061fc7b916737dd4aaa58a (patch) | |
tree | 82866cc1a95ad8e9e7502f55d32a797e9df7e784 /driver_rtcm2.c | |
parent | 1104b60be9d442c5223bd0af6b88c5ad4e85bf3a (diff) | |
download | gpsd-7edf502c0fa7eb9615061fc7b916737dd4aaa58a.tar.gz |
Fix endian detection on BSD.
On BSD, the macro is _BYTE_ORDER, not __BYTE_ORDER. Adapt to the
presence of either macro. Error out if the macro is not defined.
Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
Diffstat (limited to 'driver_rtcm2.c')
-rw-r--r-- | driver_rtcm2.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/driver_rtcm2.c b/driver_rtcm2.c index c3ab6a73..f86ef64b 100644 --- a/driver_rtcm2.c +++ b/driver_rtcm2.c @@ -85,6 +85,23 @@ BSD terms apply: see the file COPYING in the distribution root for details. #include <sys/endian.h> #endif +/* + * BSD uses _BYTE_ORDER, and Linux uses __BYTE_ORDER. + */ +#if !defined( __BYTE_ORDER) && defined(_BYTE_ORDER) +#define __BYTE_ORDER _BYTE_ORDER +#endif +#if !defined( __BIG_ENDIAN) && defined(_BIG_ENDIAN) +#define __BIG_ENDIAN _BIG_ENDIAN +#endif +#if !defined( __LITTLE_ENDIAN) && defined(_LITTLE_ENDIAN) +#define __LITTLE_ENDIAN _LITTLE_ENDIAN +#endif + +#if !defined(__BYTE_ORDER) || !defined(__BIG_ENDIAN) || !defined(__LITTLE_ENDIAN) +#error endianness macros are not defined +#endif + #if __BYTE_ORDER == __BIG_ENDIAN #define WORDS_BIGENDIAN 1 #elif __BYTE_ORDER == __LITTLE_ENDIAN |