[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-dev] [PATCH] Fix endian detection on BSD.
From: |
Greg Troxel |
Subject: |
[gpsd-dev] [PATCH] Fix endian detection on BSD. |
Date: |
Sun, 10 Nov 2013 09:24:03 -0500 |
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.
---
driver_rtcm2.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/driver_rtcm2.c b/driver_rtcm2.c
index c3ab6a7..f86ef64 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
--
1.8.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gpsd-dev] [PATCH] Fix endian detection on BSD.,
Greg Troxel <=