27 #ifndef RL_HAL_ENDIAN_H
28 #define RL_HAL_ENDIAN_H
39 static ::std::uint32_t
bigDoubleWord(const ::std::uint16_t& highWord, const ::std::uint16_t& lowWord);
41 static ::std::uint8_t
bigHighByte(const ::std::uint16_t& word);
45 static ::std::uint16_t
bigHighWord(const ::std::uint32_t& doubleWord);
47 static ::std::uint8_t
bigLowByte(const ::std::uint16_t& word);
51 static ::std::uint16_t
bigLowWord(const ::std::uint32_t& doubleWord);
53 static ::std::uint64_t
bigQuadWord(const ::std::uint32_t& highDoubleWord, const ::std::uint32_t& lowDoubleWord);
63 static void bigToHost(::std::int16_t& word);
65 static void bigToHost(::std::uint16_t& word);
67 static void bigToHost(::std::int32_t& doubleWord);
69 static void bigToHost(::std::uint32_t& doubleWord);
73 static void bigToHost(::std::int64_t& quadWord);
75 static void bigToHost(::std::uint64_t& quadWord);
79 static ::std::uint16_t
bigWord(const ::std::uint8_t& highByte, const ::std::uint8_t& lowByte);
81 static ::std::uint32_t
hostDoubleWord(const ::std::uint16_t& highWord, const ::std::uint16_t& lowWord)
83 return (highWord << 16) | lowWord;
91 static ::std::uint16_t
hostHighWord(const ::std::uint32_t& doubleWord)
93 return (doubleWord >> 16);
98 return (quadWord >> 32);
103 return (word & 0xFF);
106 static ::std::uint16_t
hostLowWord(const ::std::uint32_t& doubleWord)
108 return (doubleWord & 0xFFFF);
113 return (quadWord & 0xFFFFFFFF);
116 static ::std::uint64_t
hostQuadWord(const ::std::uint32_t& highDoubleWord, const ::std::uint32_t& lowDoubleWord)
118 return (
static_cast< ::std::uint64_t
>(highDoubleWord) << 32) | lowDoubleWord;
129 static void hostToBig(::std::int16_t& word);
131 static void hostToBig(::std::uint16_t& word);
133 static void hostToBig(::std::int32_t& doubleWord);
135 static void hostToBig(::std::uint32_t& doubleWord);
139 static void hostToBig(::std::int64_t& quadWord);
141 static void hostToBig(::std::uint64_t& quadWord);
169 static ::std::uint16_t
hostWord(const ::std::uint8_t& highByte, const ::std::uint8_t& lowByte)
171 return (highByte << 8) | lowByte;
174 static ::std::uint32_t
littleDoubleWord(const ::std::uint16_t& highWord, const ::std::uint16_t& lowWord);
176 static ::std::uint8_t
littleHighByte(const ::std::uint16_t& word);
180 static ::std::uint16_t
littleHighWord(const ::std::uint32_t& doubleWord);
182 static ::std::uint8_t
littleLowByte(const ::std::uint16_t& word);
186 static ::std::uint16_t
littleLowWord(const ::std::uint32_t& doubleWord);
188 static ::std::uint64_t
littleQuadWord(const ::std::uint32_t& highDoubleWord, const ::std::uint32_t& lowDoubleWord);
214 static ::std::uint16_t
littleWord(const ::std::uint8_t& highByte, const ::std::uint8_t& lowByte);
220 static void reverse(::std::uint8_t& character)
226 word = (word >> 8) | (word << 8);
231 word = (word >> 8) | (word << 8);
234 static void reverse(::std::int32_t& doubleWord)
236 doubleWord = ((doubleWord & 0x000000FF) << 24) | ((doubleWord & 0x0000FF00) << 8) |
237 ((doubleWord & 0xFF000000) >> 24) | ((doubleWord & 0x00FF0000) >> 8);
240 static void reverse(::std::uint32_t& doubleWord)
242 doubleWord = ((doubleWord & 0x000000FF) << 24) | ((doubleWord & 0x0000FF00) << 8) |
243 ((doubleWord & 0xFF000000) >> 24) | ((doubleWord & 0x00FF0000) >> 8);
248 reverse(*
reinterpret_cast< ::std::uint32_t*
>(&real32));
253 quadWord = ((quadWord & 0x00000000000000FF) << 56) | ((quadWord & 0x000000000000FF00) << 40) | ((quadWord & 0x0000000000FF0000) << 24) | ((quadWord & 0x00000000FF000000) << 8) |
254 ((quadWord & 0xFF00000000000000) >> 56) | ((quadWord & 0x00FF000000000000) >> 40) | ((quadWord & 0x0000FF0000000000) >> 24) | ((quadWord & 0x000000FF00000000) >> 8);
257 static void reverse(::std::uint64_t& quadWord)
259 quadWord = ((quadWord & 0x00000000000000FF) << 56) | ((quadWord & 0x000000000000FF00) << 40) | ((quadWord & 0x0000000000FF0000) << 24) | ((quadWord & 0x00000000FF000000) << 8) |
260 ((quadWord & 0xFF00000000000000) >> 56) | ((quadWord & 0x00FF000000000000) >> 40) | ((quadWord & 0x0000FF0000000000) >> 24) | ((quadWord & 0x000000FF00000000) >> 8);
265 reverse(*
reinterpret_cast< ::std::uint64_t*
>(&real64));
282 #endif // RL_HAL_ENDIAN_H