-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalignment.h
48 lines (34 loc) · 912 Bytes
/
alignment.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef __alignment_h__
#define __alignment_h__
// Windows
#if 1
#define SWAPSHORT(x) x
#define SWAPLONG(x) x
#define SWAPLONGLONG(x) x
#else
// Solaris
#define SWAPSHORT(x) \
(\
((((x) & 0x00ff) << 8) | \
(((x) & 0xff00) >> 8)) \
)
#define SWAPLONG(x) \
(\
((((x) & 0x000000ff) << 24) | \
(((x) & 0x0000ff00) << 8) | \
(((x) & 0x00ff0000) >> 8) | \
(((x) & 0xff000000) >> 24)) \
)
#define SWAPLONGLONG(x) \
(\
((((x) & 0x00000000000000FFull) << 56) | \
(((x) & 0x000000000000FF00ull) << 40) | \
(((x) & 0x0000000000FF0000ull) << 24) | \
(((x) & 0x00000000FF000000ull) << 8) | \
(((x) & 0x000000FF00000000ull) >> 8) | \
(((x) & 0x0000FF0000000000ull) >> 24) | \
(((x) & 0x00FF000000000000ull) >> 40) | \
(((x) & 0xFF00000000000000ull) >> 56)) \
)
#endif
#endif // __alignment_h__