aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PTHLexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-22 23:50:07 +0000
committerChris Lattner <sabre@nondot.org>2009-01-22 23:50:07 +0000
commit6f78c3b8b9343e7e9fbf2d457cccf00df6da5d47 (patch)
tree27281ee7aea0b5a9fb31cbe6471379e85672d36d /lib/Lex/PTHLexer.cpp
parent6fd8f914d399035e1417d9e548d3a8d598195370 (diff)
remove my gross #ifdef's, using portable abstractions now that the 32-bit
load is always aligned. I verified that the bswap doesn't occur in the assembly code on x86. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62815 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r--lib/Lex/PTHLexer.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index 497e225b47..51d49cf6e2 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -19,10 +19,12 @@
#include "clang/Lex/PTHManager.h"
#include "clang/Lex/Token.h"
#include "clang/Lex/Preprocessor.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/MemoryBuffer.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/OwningPtr.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/System/Host.h"
using namespace clang;
#define DISK_TOKEN_SIZE (1+1+2+4+4)
@@ -39,16 +41,11 @@ static inline uint16_t ReadUnalignedLE16(const unsigned char *&Data) {
}
static inline uint32_t ReadLE32(const unsigned char *&Data) {
-// Targets that directly support unaligned little-endian 32-bit loads can just
-// use them.
-#if defined(__i386__) || defined(__x86_64__)
+ // Hosts that directly support unaligned little-endian 32-bit loads can just
+ // use them.
uint32_t V = *((uint32_t*)Data);
-#else
- uint32_t V = ((uint32_t)Data[0] << 0) |
- ((uint32_t)Data[1] << 8) |
- ((uint32_t)Data[2] << 16) |
- ((uint32_t)Data[3] << 24);
-#endif
+ if (llvm::sys::isBigEndianHost())
+ V = llvm::ByteSwap_32(V);
Data += 4;
return V;
}