llvm.org GIT mirror llvm / 2e6048f
I hate line endings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117132 91177308-0d34-0410-b5e6-96231b3b80d8 Michael J. Spencer 9 years ago
1 changed file(s) with 37 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
4747
4848 } // end namespace detail
4949
50 namespace endian {
51 template
52 static value_type read_le(const void *memory) {
53 value_type t =
54 reinterpret_cast
55 *>(memory)->val;
56 if (sys::isBigEndianHost())
57 return sys::SwapByteOrder(t);
58 return t;
59 }
60
61 template
62 static void write_le(void *memory, value_type value) {
63 if (sys::isBigEndianHost())
64 value = sys::SwapByteOrder(value);
65 reinterpret_cast *>
66 (memory)->val = value;
67 }
68
69 template
70 static value_type read_be(const void *memory) {
71 value_type t =
72 reinterpret_cast
73 *>(memory)->val;
74 if (sys::isLittleEndianHost())
75 return sys::SwapByteOrder(t);
76 return t;
77 }
78
79 template
80 static void write_be(void *memory, value_type value) {
81 if (sys::isLittleEndianHost())
82 value = sys::SwapByteOrder(value);
83 reinterpret_cast *>
84 (memory)->val = value;
85 }
86 };
50 namespace endian {
51 template
52 static value_type read_le(const void *memory) {
53 value_type t =
54 reinterpret_cast
55 *>(memory)->val;
56 if (sys::isBigEndianHost())
57 return sys::SwapByteOrder(t);
58 return t;
59 }
60
61 template
62 static void write_le(void *memory, value_type value) {
63 if (sys::isBigEndianHost())
64 value = sys::SwapByteOrder(value);
65 reinterpret_cast *>
66 (memory)->val = value;
67 }
68
69 template
70 static value_type read_be(const void *memory) {
71 value_type t =
72 reinterpret_cast
73 *>(memory)->val;
74 if (sys::isLittleEndianHost())
75 return sys::SwapByteOrder(t);
76 return t;
77 }
78
79 template
80 static void write_be(void *memory, value_type value) {
81 if (sys::isLittleEndianHost())
82 value = sys::SwapByteOrder(value);
83 reinterpret_cast *>
84 (memory)->val = value;
85 }
86 }
8787
8888 namespace detail {
8989