23#define SWAP16 _byteswap_ushort
24#define SWAP32 _byteswap_ulong
25#define SWAP64 _byteswap_uint64
27#define SWAP16 __builtin_bswap16
28#define SWAP32 __builtin_bswap32
29#define SWAP64 __builtin_bswap64
37template<
typename T> T bigEndian(T x);
40inline u16 bigEndian(u16 x)
42 if constexpr (std::endian::native == std::endian::big) {
50inline u32 bigEndian(u32 x)
52 if constexpr (std::endian::native == std::endian::big) {
60inline u64 bigEndian(u64 x)
62 if constexpr (std::endian::native == std::endian::big) {
74#define R8BE(a) (*(u8 *)(a))
75#define R16BE(a) HI_LO(*(u8 *)(a), *(u8 *)((a)+1))
76#define R32BE(a) HI_HI_LO_LO(*(u8 *)(a), *(u8 *)((a)+1), *(u8 *)((a)+2), *(u8 *)((a)+3))
85#define W8BE(a,v) { *(u8 *)(a) = (v); }
86#define W16BE(a,v) { *(u8 *)(a) = HI_BYTE(v); *(u8 *)((a)+1) = LO_BYTE(v); }
87#define W32BE(a,v) { W16BE(a,HI_WORD(v)); W16BE((a)+2,LO_WORD(v)); }
96bool isZero(
const u8 *ptr, isize size);
99void replace(u8 *p, isize size,
const u8 *sequence,
const u8 *substitute);
100void replace(
char *p, isize size,
const char *sequence,
const char *substitute);
103void readAscii(
const u8 *buf, isize len,
char *result,
char fill =
'.');
106void hexdump(u8 *p, isize size, isize cols, isize pad);
107void hexdump(u8 *p, isize size, isize cols = 32);
108void hexdumpWords(u8 *p, isize size, isize cols = 32);
109void hexdumpLongwords(u8 *p, isize size, isize cols = 32);