summaryrefslogtreecommitdiff
path: root/driver_rtcm2.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-11-05 20:44:58 -0500
committerEric S. Raymond <esr@thyrsus.com>2013-11-05 21:26:40 -0500
commit9a2ee06ee166dec94a78541c646c8d2a9f0a06be (patch)
tree28e55ab69d22888789b418188d4a5a9a1c873e39 /driver_rtcm2.c
parentedc4eb375078fe61662c12e3909b1002cc1f13eb (diff)
downloadgpsd-9a2ee06ee166dec94a78541c646c8d2a9f0a06be.tar.gz
Use a clever test for big-endianness.
Diffstat (limited to 'driver_rtcm2.c')
-rw-r--r--driver_rtcm2.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/driver_rtcm2.c b/driver_rtcm2.c
index 5c8532e1..3e249aa2 100644
--- a/driver_rtcm2.c
+++ b/driver_rtcm2.c
@@ -61,32 +61,7 @@ BSD terms apply: see the file COPYING in the distribution root for details.
#include "gpsd.h"
-/*
- __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__ */
+#define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100)
/*
* Structures for interpreting words in an RTCM-104 2.x message (after
@@ -135,7 +110,7 @@ BSD terms apply: see the file COPYING in the distribution root for details.
* Reminder: Emacs reverse-region is useful...
*/
-#ifndef WORDS_BIGENDIAN /* little-endian, like x86 */
+#ifndef IS_BIGENDIAN /* little-endian, like x86 */
struct rtcm2_msg_t {
struct rtcm2_msghw1 { /* header word 1 */