multipathd: fix reservation_key check
[multipath-tools/.git] / libmultipath / byteorder.h
1 #ifndef BYTEORDER_H_INCLUDED
2 #define BYTEORDER_H_INCLUDED
3
4 #ifdef __linux__
5 #  include <endian.h>
6 #  include <byteswap.h>
7 #else
8 #  error unsupported
9 #endif
10
11 #if BYTE_ORDER == LITTLE_ENDIAN
12 #  define le16_to_cpu(x) (x)
13 #  define be16_to_cpu(x) bswap_16(x)
14 #  define le32_to_cpu(x) (x)
15 #  define le64_to_cpu(x) (x)
16 #  define be32_to_cpu(x) bswap_32(x)
17 #  define be64_to_cpu(x) bswap_64(x)
18 #elif BYTE_ORDER == BIG_ENDIAN
19 #  define le16_to_cpu(x) bswap_16(x)
20 #  define be16_to_cpu(x) (x)
21 #  define le32_to_cpu(x) bswap_32(x)
22 #  define le64_to_cpu(x) bswap_64(x)
23 #  define be32_to_cpu(x) (x)
24 #  define be64_to_cpu(x) (x)
25 #else
26 #  error unsupported
27 #endif
28
29 #define cpu_to_le16(x) le16_to_cpu(x)
30 #define cpu_to_be16(x) be16_to_cpu(x)
31 #define cpu_to_le32(x) le32_to_cpu(x)
32 #define cpu_to_be32(x) be32_to_cpu(x)
33 #define cpu_to_le64(x) le64_to_cpu(x)
34 #define cpu_to_be64(x) be64_to_cpu(x)
35
36 struct be64 {
37         uint64_t _v;
38 };
39
40 #define get_be64(x) be64_to_cpu((x)._v)
41 #define put_be64(x, y) do { (x)._v = cpu_to_be64(y); } while (0)
42
43
44 #endif                          /* BYTEORDER_H_INCLUDED */