1 /* Useful byte conversion macros, not available on all platforms.
2 * Copyright (C) 2009-2010 Red Hat Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation;
7 * version 2.1 of the License.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
15 #ifndef hivex_byteorder_h
16 #define hivex_byteorder_h
23 #if __BYTE_ORDER == __LITTLE_ENDIAN
25 #define be32toh(x) bswap_32 (x)
28 #define htobe32(x) bswap_32 (x)
31 #define be64toh(x) bswap_64 (x)
34 #define htobe64(x) bswap_64 (x)
37 #define le16toh(x) (x)
40 #define htole16(x) (x)
43 #define le32toh(x) (x)
46 #define htole32(x) (x)
49 #define le64toh(x) (x)
52 #define htole64(x) (x)
54 #else /* __BYTE_ORDER == __BIG_ENDIAN */
56 #define be32toh(x) (x)
59 #define htobe32(x) (x)
62 #define be64toh(x) (x)
65 #define htobe64(x) (x)
68 #define le16toh(x) bswap_16 (x)
71 #define htole16(x) bswap_16 (x)
74 #define le32toh(x) bswap_32 (x)
77 #define htole32(x) bswap_32 (x)
80 #define le64toh(x) bswap_64 (x)
83 #define htole64(x) bswap_64 (x)
85 #endif /* __BYTE_ORDER == __BIG_ENDIAN */
87 #endif /* hivex_byteorder_h */