diff options
author | Davide Italiano <davide@freebsd.org> | 2017-12-11 05:09:35 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2017-12-11 05:09:35 +0000 |
commit | 226aab7cdb09a341b7e8a091ea3354c39456e90d (patch) | |
tree | e3ffbe31d0866c80dee0694afe64e1e479f54fd3 | |
parent | 1e83485613f2d3ae46cd816312ea499f858b501c (diff) | |
download | bcm5719-llvm-226aab7cdb09a341b7e8a091ea3354c39456e90d.tar.gz bcm5719-llvm-226aab7cdb09a341b7e8a091ea3354c39456e90d.zip |
Revert "[DataEncoder] Replace buggy versions of write functions."
The commit exposes a bunch of failures in the LLDB testsuite that
I need to analyze more carefully. Reverting for now.
llvm-svn: 320341
-rw-r--r-- | lldb/source/Utility/DataEncoder.cpp | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/lldb/source/Utility/DataEncoder.cpp b/lldb/source/Utility/DataEncoder.cpp index 94cc19769ab..f7ce46889d2 100644 --- a/lldb/source/Utility/DataEncoder.cpp +++ b/lldb/source/Utility/DataEncoder.cpp @@ -12,7 +12,6 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/Endian.h" -#include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" // for llvm_unreachable #include "llvm/Support/MathExtras.h" @@ -23,7 +22,36 @@ using namespace lldb; using namespace lldb_private; -using namespace llvm::support::endian; + +static inline void WriteInt16(unsigned char *ptr, unsigned offset, + uint16_t value) { + *(uint16_t *)(ptr + offset) = value; +} + +static inline void WriteInt32(unsigned char *ptr, unsigned offset, + uint32_t value) { + *(uint32_t *)(ptr + offset) = value; +} + +static inline void WriteInt64(unsigned char *ptr, unsigned offset, + uint64_t value) { + *(uint64_t *)(ptr + offset) = value; +} + +static inline void WriteSwappedInt16(unsigned char *ptr, unsigned offset, + uint16_t value) { + *(uint16_t *)(ptr + offset) = llvm::ByteSwap_16(value); +} + +static inline void WriteSwappedInt32(unsigned char *ptr, unsigned offset, + uint32_t value) { + *(uint32_t *)(ptr + offset) = llvm::ByteSwap_32(value); +} + +static inline void WriteSwappedInt64(unsigned char *ptr, unsigned offset, + uint64_t value) { + *(uint64_t *)(ptr + offset) = llvm::ByteSwap_64(value); +} //---------------------------------------------------------------------- // Default constructor. @@ -174,9 +202,9 @@ uint32_t DataEncoder::PutU8(uint32_t offset, uint8_t value) { uint32_t DataEncoder::PutU16(uint32_t offset, uint16_t value) { if (ValidOffsetForDataOfSize(offset, sizeof(value))) { if (m_byte_order != endian::InlHostByteOrder()) - write16be(m_start, offset + value); + WriteSwappedInt16(m_start, offset, value); else - write16le(m_start, offset + value); + WriteInt16(m_start, offset, value); return offset + sizeof(value); } @@ -186,9 +214,9 @@ uint32_t DataEncoder::PutU16(uint32_t offset, uint16_t value) { uint32_t DataEncoder::PutU32(uint32_t offset, uint32_t value) { if (ValidOffsetForDataOfSize(offset, sizeof(value))) { if (m_byte_order != endian::InlHostByteOrder()) - write32be(m_start, offset + value); + WriteSwappedInt32(m_start, offset, value); else - write32le(m_start, offset + value); + WriteInt32(m_start, offset, value); return offset + sizeof(value); } @@ -198,9 +226,9 @@ uint32_t DataEncoder::PutU32(uint32_t offset, uint32_t value) { uint32_t DataEncoder::PutU64(uint32_t offset, uint64_t value) { if (ValidOffsetForDataOfSize(offset, sizeof(value))) { if (m_byte_order != endian::InlHostByteOrder()) - write64be(m_start, offset + value); + WriteSwappedInt64(m_start, offset, value); else - write64le(m_start, offset + value); + WriteInt64(m_start, offset, value); return offset + sizeof(value); } |