2 * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 #ifndef _COMPAT_ENDIAN_H
19 #define _COMPAT_ENDIAN_H
25 * htobe/betoh are not defined for glibc <2.9, so add them
26 * explicitly if they are missing.
29 /* Conversion interfaces. */
30 # include <byteswap.h>
32 # if __BYTE_ORDER == __LITTLE_ENDIAN
34 # define htobe16(x) __bswap_16(x)
37 # define htole16(x) (x)
40 # define be16toh(x) __bswap_16(x)
43 # define le16toh(x) (x)
47 # define htobe32(x) __bswap_32(x)
50 # define htole32(x) (x)
53 # define be32toh(x) __bswap_32(x)
56 # define le32toh(x) (x)
60 # define htobe64(x) __bswap_64(x)
63 # define htole64(x) (x)
66 # define be64toh(x) __bswap_64(x)
69 # define le64toh(x) (x)
72 # else /* __BYTE_ORDER == __LITTLE_ENDIAN */
74 # define htobe16(x) (x)
77 # define htole16(x) __bswap_16(x)
80 # define be16toh(x) (x)
83 # define le16toh(x) __bswap_16(x)
87 # define htobe32(x) (x)
90 # define htole32(x) __bswap_32(x)
93 # define be32toh(x) (x)
96 # define le32toh(x) __bswap_32(x)
100 # define htobe64(x) (x)
103 # define htole64(x) __bswap_64(x)
106 # define be64toh(x) (x)
109 # define le64toh(x) __bswap_64(x)
112 # endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
113 #endif /* __USE_BSD */
115 #elif defined(__FreeBSD__)
116 #include <machine/endian.h>
118 #error "Please add support for your OS."
121 #endif /* _COMPAT_ENDIAN_H */
This page took 0.031557 seconds and 4 git commands to generate.