gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH] Detect endianness on OS X.


From: Greg Troxel
Subject: [gpsd-dev] [PATCH] Detect endianness on OS X.
Date: Mon, 11 Nov 2013 21:57:00 -0500

This commit adds recognizing Darwin-specific endianness defines, and
mapping them to the values used on Linux.  Tested on OS X 10.7.

Signed-off-by: Greg Troxel <address@hidden>
---
 SConstruct     |  7 +++++++
 driver_rtcm2.c | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/SConstruct b/SConstruct
index 8443e90..7115542 100644
--- a/SConstruct
+++ b/SConstruct
@@ -602,12 +602,19 @@ else:
     if config.CheckHeader("endian.h"):
         confdefs.append("#define HAVE_ENDIAN_H 1\n")
         confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n")
+        confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n")
     elif config.CheckHeader("sys/endian.h"):
         confdefs.append("/* #undef HAVE_ENDIAN_H */\n")
         confdefs.append("#define HAVE_SYS_ENDIAN_H 1\n")
+        confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n")
+    elif config.CheckHeader("machine/endian.h"):
+        confdefs.append("/* #undef HAVE_ENDIAN_H */\n")
+        confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n")
+        confdefs.append("#define HAVE_MACHINE_ENDIAN_H 1\n")
     else:
         confdefs.append("/* #undef HAVE_ENDIAN_H */\n")
         confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n")
+        confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n")
         announce("You do not have the endian.h header file. RTCM V2 support 
disabled.")
         env["rtcm104v2"] = False
 
diff --git a/driver_rtcm2.c b/driver_rtcm2.c
index f86ef64..90d9a5a 100644
--- a/driver_rtcm2.c
+++ b/driver_rtcm2.c
@@ -83,6 +83,8 @@ BSD terms apply: see the file COPYING in the distribution 
root for details.
 #include <endian.h>
 #elif defined(HAVE_SYS_ENDIAN_H)
 #include <sys/endian.h>
+#elif defined(HAVE_MACHINE_ENDIAN_H)
+#include <machine/endian.h>
 #endif
 
 /*
@@ -98,6 +100,19 @@ BSD terms apply: see the file COPYING in the distribution 
root for details.
 #define __LITTLE_ENDIAN _LITTLE_ENDIAN
 #endif
 
+/*
+ * Darwin (Mac OS X) uses special defines.
+ */
+#if !defined( __BYTE_ORDER) && defined(__DARWIN_BYTE_ORDER)
+#define __BYTE_ORDER __DARWIN_BYTE_ORDER
+#endif
+#if !defined( __BIG_ENDIAN) && defined(__DARWIN_BIG_ENDIAN)
+#define __BIG_ENDIAN __DARWIN_BIG_ENDIAN
+#endif
+#if !defined( __LITTLE_ENDIAN) && defined(__DARWIN_LITTLE_ENDIAN)
+#define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
+#endif
+
 #if !defined(__BYTE_ORDER) || !defined(__BIG_ENDIAN) || 
!defined(__LITTLE_ENDIAN)
 #error endianness macros are not defined
 #endif
-- 
1.8.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]