blob: 436c320be88cecf6c8493ec03ab3121854890d55 (
plain)
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
49
|
#if sun
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
#define PDP_ENDIAN 3412
#include <sys/isa_defs.h>
#if defined(_LITTLE_ENDIAN)
#define BYTE_ORDER LITTLE_ENDIAN
#elif defined(_BIG_ENDIAN)
#define BYTE_ORDER BIG_ENDIAN
#endif
#else
/* linux */
#include <endian.h>
#endif
/* ---------------------------------------------------------------------- */
#if BYTE_ORDER == LITTLE_ENDIAN
# define cpu_to_le32(x) (x)
# define cpu_to_le16(x) (x)
# define le32_to_cpu(x) (x)
# define le16_to_cpu(x) (x)
#elif BYTE_ORDER == BIG_ENDIAN
# define cpu_to_le32(x) (\
((x & 0x000000FF) << 24) | \
((x & 0x0000FF00) << 8) | \
((x & 0x00FF0000) >> 8) | \
((x & 0xFF000000) >> 24))
# define le32_to_cpu(x) cpu_to_le32(x)
# define cpu_to_le16(x) (((x & 0x00FF) << 8) | (x >> 8))
# define le16_to_cpu(x) cpu_to_le16(x)
#else
# error Unknow byte order type
#endif
|