diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-11-06 21:30:26 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-11-06 21:30:26 -0500 |
commit | 3f9b209d3ca917f76f32db1ec4c8a1c0b2db0274 (patch) | |
tree | 2255d321c7d07f80fd3a859fb6bd3d50c92fa67f /driver_rtcm2.c | |
parent | 56e719970de0fcbbc6c086159f31f82b5eb35128 (diff) | |
download | gpsd-3f9b209d3ca917f76f32db1ec4c8a1c0b2db0274.tar.gz |
Revert "Use a clever test for big-endianness."
Until I can repair it.
Diffstat (limited to 'driver_rtcm2.c')
-rw-r--r-- | driver_rtcm2.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/driver_rtcm2.c b/driver_rtcm2.c index 3e249aa2..5c8532e1 100644 --- a/driver_rtcm2.c +++ b/driver_rtcm2.c @@ -61,7 +61,32 @@ BSD terms apply: see the file COPYING in the distribution root for details. #include "gpsd.h" -#define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100) +/* + __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are define in some gcc versions + only, probably depending on the architecture. Try to use endian.h if + the gcc way fails - endian.h also doesn not seem to be available on all + platforms. +*/ +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#else /* __BIG_ENDIAN__ */ +#ifdef __LITTLE_ENDIAN__ +#undef WORDS_BIGENDIAN +#else +#ifdef BSD +#include <sys/endian.h> +#else +#include <endian.h> +#endif +#if __BYTE_ORDER == __BIG_ENDIAN +#define WORDS_BIGENDIAN 1 +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#undef WORDS_BIGENDIAN +#else +#error "unable to determine endianess!" +#endif /* __BYTE_ORDER */ +#endif /* __LITTLE_ENDIAN__ */ +#endif /* __BIG_ENDIAN__ */ /* * Structures for interpreting words in an RTCM-104 2.x message (after @@ -110,7 +135,7 @@ BSD terms apply: see the file COPYING in the distribution root for details. * Reminder: Emacs reverse-region is useful... */ -#ifndef IS_BIGENDIAN /* little-endian, like x86 */ +#ifndef WORDS_BIGENDIAN /* little-endian, like x86 */ struct rtcm2_msg_t { struct rtcm2_msghw1 { /* header word 1 */ |