summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-02-27 04:21:40 +0000
committerRui Ueyama <ruiu@google.com>2015-02-27 04:21:40 +0000
commite088a0f9899e0c51a138b7a1a8d70ebd1fdbe9d4 (patch)
tree303722d9bf86b3870252a97faf41ce8ae79f9465
parent4a7e390c12157bd8e48295eae47291e05d292afa (diff)
downloadbcm5719-llvm-e088a0f9899e0c51a138b7a1a8d70ebd1fdbe9d4.tar.gz
bcm5719-llvm-e088a0f9899e0c51a138b7a1a8d70ebd1fdbe9d4.zip
Use read{le,be}{16,32}. NFC.
llvm-svn: 230728
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h34
1 files changed, 10 insertions, 24 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
index 90ad33f00a4..ae47329034b 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
@@ -9,11 +9,11 @@
#include "MachONormalizedFile.h"
+#include "lld/Core/Endian.h"
#include "lld/Core/Error.h"
#include "lld/Core/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
-#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MachO.h"
@@ -28,60 +28,46 @@ namespace normalized {
using llvm::sys::getSwappedBytes;
- using llvm::support::ubig16_t;
- using llvm::support::ubig32_t;
- using llvm::support::ubig64_t;
-
- using llvm::support::ulittle16_t;
- using llvm::support::ulittle32_t;
- using llvm::support::ulittle64_t;
-
template<typename T>
static inline uint16_t read16(const T *loc, bool isBig) {
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
- if (isBig)
- return *(const ubig16_t *)loc;
- return *(const ulittle16_t *)loc;
+ return isBig ? read16be(loc) : read16le(loc);
}
template<typename T>
static inline uint32_t read32(const T *loc, bool isBig) {
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
- if (isBig)
- return *(const ubig32_t *)loc;
- return *(const ulittle32_t *)loc;
+ return isBig ? read32be(loc) : read32le(loc);
}
template<typename T>
static inline uint64_t read64(const T *loc, bool isBig) {
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
- if (isBig)
- return *(const ubig64_t *)loc;
- return *(const ulittle64_t *)loc;
+ return isBig ? read64be(loc) : read64le(loc);
}
inline void write16(uint8_t *loc, uint16_t value, bool isBig) {
if (isBig)
- *(ubig16_t *)loc = value;
+ write16be(loc, value);
else
- *(ulittle16_t *)loc = value;
+ write16le(loc, value);
}
inline void write32(uint8_t *loc, uint32_t value, bool isBig) {
if (isBig)
- *(ubig32_t *)loc = value;
+ write32be(loc, value);
else
- *(ulittle32_t *)loc = value;
+ write32le(loc, value);
}
inline void write64(uint8_t *loc, uint64_t value, bool isBig) {
if (isBig)
- *(ubig64_t *)loc = value;
+ write64be(loc, value);
else
- *(ulittle64_t *)loc = value;
+ write64le(loc, value);
}
inline uint32_t
OpenPOWER on IntegriCloud