diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-01-22 23:50:07 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-01-22 23:50:07 +0000 | 
| commit | 34eab390b97ca0ac10eeffb0134eced897d1a9a6 (patch) | |
| tree | ccec0208aa6ff72112671fafb31f51291e19f2a1 | |
| parent | fe0f1788cacfd71a9325f578329b8c0734465020 (diff) | |
| download | bcm5719-llvm-34eab390b97ca0ac10eeffb0134eced897d1a9a6.tar.gz bcm5719-llvm-34eab390b97ca0ac10eeffb0134eced897d1a9a6.zip | |
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.
llvm-svn: 62815
| -rw-r--r-- | clang/lib/Lex/PTHLexer.cpp | 19 | 
1 files changed, 8 insertions, 11 deletions
| diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index 497e225b470..51d49cf6e2c 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/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;  } | 

