[Lldb-commits] [lldb] r105892 - /lldb/trunk/include/lldb/lldb-enumerations.h

Greg Clayton gclayton at apple.com
Sat Jun 12 09:46:01 PDT 2010


Author: gclayton
Date: Sat Jun 12 11:46:01 2010
New Revision: 105892

URL: http://llvm.org/viewvc/llvm-project?rev=105892&view=rev
Log:
Reverted changes for eByteOrderHost detection, but added linux support for using <endian.h>. No files in "API" can include any LLVM header files. We must keep LLVM behind our API.

Modified:
    lldb/trunk/include/lldb/lldb-enumerations.h

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=105892&r1=105891&r2=105892&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Sat Jun 12 11:46:01 2010
@@ -10,7 +10,11 @@
 #ifndef LLDB_enumerations_h_
 #define LLDB_enumerations_h_
 
-#include "llvm/System/Host.h"
+#if !defined (__APPLE__)
+
+#include <endian.h>
+
+#endif
 
 namespace lldb {
 
@@ -73,17 +77,40 @@
     eByteOrderInvalid   = 0,
     eByteOrderLittle    = 1234,
     eByteOrderBig       = 4321,
-    eByteOrderPDP       = 3412
-} ByteOrder;
+    eByteOrderPDP       = 3412,
+
+#if defined (__APPLE__)
 
-inline ByteOrder getHostByteOrder() {
-  if (llvm::sys::isLittleEndianHost())
-    return eByteOrderLittle;
-  return eByteOrderBig;
-}
+// On Mac OS X there are preprocessor defines automatically defined
+// for the byte order that we can rely on.
 
-// FIXME: Replace uses of eByteOrderHost with getHostByteOrder()!
-#define eByteOrderHost getHostByteOrder()
+#if   defined (__LITTLE_ENDIAN__)
+    eByteOrderHost      = eByteOrderLittle
+#elif defined (__BIG_ENDIAN__)
+    eByteOrderHost      = eByteOrderBig
+#elif defined (__PDP_ENDIAN__)
+    eByteOrderHost      = eByteOrderPDP
+#else
+#error unable to detect endianness
+#endif
+
+#else
+
+// On linux we rely upon the defines in <endian.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+    eByteOrderHost      = eByteOrderLittle
+#elif __BYTE_ORDER == __BIG_ENDIAN
+    eByteOrderHost      = eByteOrderBig
+#elif __BYTE_ORDER == __PDP_ENDIAN
+    eByteOrderHost      = eByteOrderPDP
+#else
+#error unable to detect endianness
+#endif
+
+#endif
+
+} ByteOrder;
 
 //----------------------------------------------------------------------
 // Register encoding definitions





More information about the lldb-commits mailing list