1 |
#define rotl32(x,n) (((x) << ((word32)(n))) | ((x) >> (32 - (word32)(n)))) |
2 |
#define rotr32(x,n) (((x) >> ((word32)(n))) | ((x) << (32 - (word32)(n)))) |
3 |
#define rotl16(x,n) (((x) << ((word16)(n))) | ((x) >> (16 - (word16)(n)))) |
4 |
#define rotr16(x,n) (((x) >> ((word16)(n))) | ((x) << (16 - (word16)(n)))) |
5 |
|
6 |
/* Use hardware rotations.. when available */ |
7 |
#ifdef swap32 |
8 |
# define byteswap32(x) swap32(x) |
9 |
#else |
10 |
# ifdef swap_32 |
11 |
# define byteswap32(x) swap_32(x) |
12 |
# else |
13 |
# ifdef bswap_32 |
14 |
# define byteswap32(x) bswap_32(x) |
15 |
# else |
16 |
# define byteswap32(x) ((rotl32(x, 8) & 0x00ff00ff) | (rotr32(x, 8) & 0xff00ff00)) |
17 |
# endif |
18 |
# endif |
19 |
#endif |
20 |
|
21 |
#ifdef swap16 |
22 |
# define byteswap16(x) swap16(x) |
23 |
#else |
24 |
# ifdef swap_16 |
25 |
# define byteswap16(x) swap_16(x) |
26 |
# else |
27 |
# ifdef bswap_16 |
28 |
# define byteswap16(x) bswap_16(x) |
29 |
# else |
30 |
# define byteswap16(x) ((rotl16(x, 8) & 0x00ff) | (rotr16(x, 8) & 0xff00)) |
31 |
# endif |
32 |
# endif |
33 |
#endif |
34 |
|
35 |
|
36 |
#define Bzero(x, y) memset(x, 0, y) |