[Lldb-commits] [lldb] r105799 - /lldb/trunk/source/Core/DataExtractor.cpp

Eli Friedman eli.friedman at gmail.com
Thu Jun 10 16:56:16 PDT 2010


Author: efriedma
Date: Thu Jun 10 18:56:16 2010
New Revision: 105799

URL: http://llvm.org/viewvc/llvm-project?rev=105799&view=rev
Log:
Remove dependency on Mac-specific libkern/OSByteOrder.h.


Modified:
    lldb/trunk/source/Core/DataExtractor.cpp

Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=105799&r1=105798&r2=105799&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Thu Jun 10 18:56:16 2010
@@ -8,12 +8,13 @@
 //===----------------------------------------------------------------------===//
 
 #include <assert.h>
-#include <libkern/OSByteOrder.h>
 #include <stddef.h>
 
 #include <bitset>
 #include <string>
 
+#include "llvm/Support/MathExtras.h"
+
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/DataBuffer.h"
 #include "lldb/Core/Log.h"
@@ -25,6 +26,37 @@
 using namespace lldb;
 using namespace lldb_private;
 
+static uint16_t LLDB_ReadInt16(const unsigned char* ptr, unsigned offset) {
+  uint16_t val;
+  memcpy(&val, ptr + offset, sizeof(val));
+  return val;
+}
+static uint32_t LLDB_ReadInt32(const unsigned char* ptr, unsigned offset) {
+  uint32_t val;
+  memcpy(&val, ptr + offset, sizeof(val));
+  return val;
+}
+static uint64_t LLDB_ReadInt64(const unsigned char* ptr, unsigned offset) {
+  uint64_t val;
+  memcpy(&val, ptr + offset, sizeof(val));
+  return val;
+}
+static uint16_t LLDB_ReadSwapInt16(const unsigned char* ptr, unsigned offset) {
+  uint16_t val;
+  memcpy(&val, ptr + offset, sizeof(val));
+  return llvm::ByteSwap_16(val);
+}
+static uint32_t LLDB_ReadSwapInt32(const unsigned char* ptr, unsigned offset) {
+  uint32_t val;
+  memcpy(&val, ptr + offset, sizeof(val));
+  return llvm::ByteSwap_32(val);
+}
+static uint64_t LLDB_ReadSwapInt64(const unsigned char* ptr, unsigned offset) {
+  uint64_t val;
+  memcpy(&val, ptr + offset, sizeof(val));
+  return llvm::ByteSwap_64(val);
+}
+
 #define NON_PRINTABLE_CHAR '.'
 //----------------------------------------------------------------------
 // Default constructor.
@@ -426,9 +458,9 @@
     if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
     {
         if (m_byte_order != eByteOrderHost)
-            val = OSReadSwapInt16(m_start, offset);
+            val = LLDB_ReadSwapInt16(m_start, offset);
         else
-            val = _OSReadInt16 (m_start, offset);
+            val = LLDB_ReadInt16 (m_start, offset);
 
         // Advance the offset
         *offset_ptr += sizeof(val);
@@ -459,12 +491,12 @@
         if (m_byte_order != eByteOrderHost)
         {
             for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = OSReadSwapInt16 (m_start, offset);
+                *value_ptr = LLDB_ReadSwapInt16 (m_start, offset);
         }
         else
         {
             for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = _OSReadInt16 (m_start, offset);
+                *value_ptr = LLDB_ReadInt16 (m_start, offset);
         }
 
         // Advance the offset
@@ -490,9 +522,9 @@
     if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
     {
         if (m_byte_order != eByteOrderHost)
-            val = OSReadSwapInt32 (m_start, offset);
+            val = LLDB_ReadSwapInt32 (m_start, offset);
         else
-            val = _OSReadInt32 (m_start, offset);
+            val = LLDB_ReadInt32 (m_start, offset);
 
         // Advance the offset
         *offset_ptr += sizeof(val);
@@ -523,13 +555,13 @@
         if (m_byte_order != eByteOrderHost)
         {
             for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = OSReadSwapInt32 (m_start, offset);
+                *value_ptr = LLDB_ReadSwapInt32 (m_start, offset);
 
         }
         else
         {
             for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = _OSReadInt32 (m_start, offset);
+                *value_ptr = LLDB_ReadInt32 (m_start, offset);
         }
 
         // Advance the offset
@@ -554,9 +586,9 @@
     if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
     {
         if (m_byte_order != eByteOrderHost)
-            val = OSReadSwapInt64 (m_start, offset);
+            val = LLDB_ReadSwapInt64 (m_start, offset);
         else
-            val = _OSReadInt64 (m_start, offset);
+            val = LLDB_ReadInt64 (m_start, offset);
 
         // Advance the offset
         *offset_ptr += sizeof(val);
@@ -585,13 +617,13 @@
         if (m_byte_order != eByteOrderHost)
         {
             for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = OSReadSwapInt64 (m_start, offset);
+                *value_ptr = LLDB_ReadSwapInt64 (m_start, offset);
 
         }
         else
         {
             for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = _OSReadInt64 (m_start, offset);
+                *value_ptr = LLDB_ReadInt64 (m_start, offset);
         }
 
         // Advance the offset
@@ -710,9 +742,9 @@
     if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
     {
         if (m_byte_order != eByteOrderHost)
-            val = OSReadSwapInt32 (m_start, offset);
+            val = LLDB_ReadSwapInt32 (m_start, offset);
         else
-            val = _OSReadInt32 (m_start, offset);
+            val = LLDB_ReadInt32 (m_start, offset);
 
         // Advance the offset
         *offset_ptr += sizeof(val);
@@ -728,9 +760,9 @@
     if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
     {
         if (m_byte_order != eByteOrderHost)
-            val = OSReadSwapInt64 (m_start, offset);
+            val = LLDB_ReadSwapInt64 (m_start, offset);
         else
-            val = _OSReadInt64 (m_start, offset);
+            val = LLDB_ReadInt64 (m_start, offset);
 
         // Advance the offset
         *offset_ptr += sizeof(val);
@@ -750,9 +782,9 @@
         if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
         {
             if (m_byte_order != eByteOrderHost)
-                val = OSReadSwapInt64 (m_start, offset);
+                val = LLDB_ReadSwapInt64 (m_start, offset);
             else
-                val = _OSReadInt64 (m_start, offset);
+                val = LLDB_ReadInt64 (m_start, offset);
 
             // Advance the offset
             *offset_ptr += sizeof(val);





More information about the lldb-commits mailing list