[llvm-commits] [llvm] r149980 - /llvm/trunk/include/llvm/Bitcode/BitstreamReader.h

NAKAMURA Takumi geek4civic at gmail.com
Tue Feb 7 02:53:20 PST 2012


Author: chapuni
Date: Tue Feb  7 04:53:19 2012
New Revision: 149980

URL: http://llvm.org/viewvc/llvm-project?rev=149980&view=rev
Log:
Bitcode/BitstreamReader.h: Tweak for big endian hosts.

Modified:
    llvm/trunk/include/llvm/Bitcode/BitstreamReader.h

Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=149980&r1=149979&r2=149980&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original)
+++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Tue Feb  7 04:53:19 2012
@@ -17,6 +17,7 @@
 
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Support/Endian.h"
 #include "llvm/Support/StreamableMemoryObject.h"
 #include <climits>
 #include <string>
@@ -242,12 +243,13 @@
   }
 
   uint32_t getWord(size_t pos) {
-    uint32_t word = -1;
+    uint8_t buf[sizeof(uint32_t)];
+    memset(buf, 0xFF, sizeof(buf));
     BitStream->getBitcodeBytes().readBytes(pos,
-                                           sizeof(word),
-                                           reinterpret_cast<uint8_t *>(&word),
+                                           sizeof(buf),
+                                           buf,
                                            NULL);
-    return word;
+    return *reinterpret_cast<support::ulittle32_t *>(buf);
   }
 
   bool AtEndOfStream() {





More information about the llvm-commits mailing list