diff options
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Support/Endian.h | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/include/llvm/Support/Endian.h b/include/llvm/Support/Endian.h index 1058bef..dc88a12 100644 --- a/include/llvm/Support/Endian.h +++ b/include/llvm/Support/Endian.h @@ -48,43 +48,43 @@ struct alignment_access_helper<value_type, unaligned> } // end namespace detail -namespace endian {
- template<typename value_type, alignment align>
- static value_type read_le(const void *memory) {
- value_type t =
- reinterpret_cast<const detail::alignment_access_helper
- <value_type, align> *>(memory)->val;
- if (sys::isBigEndianHost())
- return sys::SwapByteOrder(t);
- return t;
- }
-
- template<typename value_type, alignment align>
- static void write_le(void *memory, value_type value) {
- if (sys::isBigEndianHost())
- value = sys::SwapByteOrder(value);
- reinterpret_cast<detail::alignment_access_helper<value_type, align> *>
- (memory)->val = value;
- }
-
- template<typename value_type, alignment align>
- static value_type read_be(const void *memory) {
- value_type t =
- reinterpret_cast<const detail::alignment_access_helper
- <value_type, align> *>(memory)->val;
- if (sys::isLittleEndianHost())
- return sys::SwapByteOrder(t);
- return t;
- }
-
- template<typename value_type, alignment align>
- static void write_be(void *memory, value_type value) {
- if (sys::isLittleEndianHost())
- value = sys::SwapByteOrder(value);
- reinterpret_cast<detail::alignment_access_helper<value_type, align> *>
- (memory)->val = value;
+namespace endian { + template<typename value_type, alignment align> + static value_type read_le(const void *memory) { + value_type t = + reinterpret_cast<const detail::alignment_access_helper + <value_type, align> *>(memory)->val; + if (sys::isBigEndianHost()) + return sys::SwapByteOrder(t); + return t; } -}; + + template<typename value_type, alignment align> + static void write_le(void *memory, value_type value) { + if (sys::isBigEndianHost()) + value = sys::SwapByteOrder(value); + reinterpret_cast<detail::alignment_access_helper<value_type, align> *> + (memory)->val = value; + } + + template<typename value_type, alignment align> + static value_type read_be(const void *memory) { + value_type t = + reinterpret_cast<const detail::alignment_access_helper + <value_type, align> *>(memory)->val; + if (sys::isLittleEndianHost()) + return sys::SwapByteOrder(t); + return t; + } + + template<typename value_type, alignment align> + static void write_be(void *memory, value_type value) { + if (sys::isLittleEndianHost()) + value = sys::SwapByteOrder(value); + reinterpret_cast<detail::alignment_access_helper<value_type, align> *> + (memory)->val = value; + } +} namespace detail { |