17 #include <pia/common/common_definitions.h> 36 static inline u16 Swap16(u16 v)
38 return (v << 8) | (v >> 8);
41 static inline u32 Swap32(u32 v)
43 u32 w = ((v & 0xff00ff00) >> 8) | ((v & 0x00ff00ff) << 8);
44 return (w >> 16) | (w << 16);
47 static inline u64 Swap64(u64 v)
49 u64 w = ((v & 0xff00ff00ff00ff00) >> 8) | ((v & 0x00ff00ff00ff00ff) << 8);
50 u64 x = ((w & 0xffff0000ffff0000) >> 16) | ((w & 0x0000ffff0000ffff) << 16);
51 return (x >> 32) | (x << 32);
114 #if NN_PIA_ENDIAN_BIG 131 #if NN_PIA_ENDIAN_BIG 148 #if NN_PIA_ENDIAN_BIG 163 template <
size_t Size>
164 static inline void Swap(
void* pTo,
const void* cpFrom);
171 inline void ByteOrder::Swap<1>(
void* pTo,
const void* cpFrom)
173 *
reinterpret_cast<u8*
>(pTo) = *reinterpret_cast<const u8*>(cpFrom);
177 inline void ByteOrder::Swap<2>(
void* pTo,
const void* cpFrom)
179 *
reinterpret_cast<u16*
>(pTo) = Swap16(*reinterpret_cast<const u16*>(cpFrom));
183 inline void ByteOrder::Swap<4>(
void* pTo,
const void* cpFrom)
185 *
reinterpret_cast<u32*
>(pTo) = Swap32(*reinterpret_cast<const u32*>(cpFrom));
189 inline void ByteOrder::Swap<8>(
void* pTo,
const void* cpFrom)
191 reinterpret_cast<u32*
>(pTo)[0] = Swap32(reinterpret_cast<const u32*>(cpFrom)[1]);
192 reinterpret_cast<u32*
>(pTo)[1] = Swap32(reinterpret_cast<const u32*>(cpFrom)[0]);
static u16 HostToNetwork16(u16 host)
Converts a u16 value from host byte order to network byte order.
Definition: common_ByteOrder.h:112
static u64 HostToNetwork64(u64 host)
Converts a u64 value from host byte order to network byte order.
Definition: common_ByteOrder.h:146
Converts the byte order.
Definition: common_ByteOrder.h:33
static u32 NetworkToHost32(u32 net)
Converts a u32 value from network byte order to host byte order.
Definition: common_ByteOrder.h:78
static u64 NetworkToHost64(u64 net)
Converts a u64 value from network byte order to host byte order.
Definition: common_ByteOrder.h:95
static u32 HostToNetwork32(u32 host)
Converts a u32 value from host byte order to network byte order.
Definition: common_ByteOrder.h:129
static u16 NetworkToHost16(u16 net)
Converts a u16 value from network byte order to host byte order.
Definition: common_ByteOrder.h:61