Use macro bswap
This commit is contained in:
@@ -6,7 +6,24 @@
|
||||
#include <unicorn/unicorn.h>
|
||||
#include "acutest.h"
|
||||
#include "endian.h"
|
||||
#include "bswap.h"
|
||||
|
||||
// Copied from glibc-2.29
|
||||
|
||||
/* Swap bytes in 32 bit value. */
|
||||
#define bswap_32(x) \
|
||||
((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
|
||||
(((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
|
||||
|
||||
/* Swap bytes in 64 bit value. */
|
||||
#define bswap_64(x) \
|
||||
((((x) & 0xff00000000000000ull) >> 56) \
|
||||
| (((x) & 0x00ff000000000000ull) >> 40) \
|
||||
| (((x) & 0x0000ff0000000000ull) >> 24) \
|
||||
| (((x) & 0x000000ff00000000ull) >> 8) \
|
||||
| (((x) & 0x00000000ff000000ull) << 8) \
|
||||
| (((x) & 0x0000000000ff0000ull) << 24) \
|
||||
| (((x) & 0x000000000000ff00ull) << 40) \
|
||||
| (((x) & 0x00000000000000ffull) << 56))
|
||||
|
||||
/**
|
||||
* Assert that err matches expect
|
||||
|
||||
Reference in New Issue
Block a user