Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
endian_conversion.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef _ENDIAN_CONVERSION_H
6 #define _ENDIAN_CONVERSION_H 1
7 
8 #include <endian.h>
9 
10 #ifdef __USE_BSD
11 /* Conversion interfaces. */
12 # include <byteswap.h>
13 
14 # if __BYTE_ORDER == __LITTLE_ENDIAN
15 # define htobe16(x) __bswap_16 (x)
16 # define htole16(x) (x)
17 # define be16toh(x) __bswap_16 (x)
18 # define le16toh(x) (x)
19 
20 # define htobe32(x) __bswap_32 (x)
21 # define htole32(x) (x)
22 # define be32toh(x) __bswap_32 (x)
23 # define le32toh(x) (x)
24 
25 # define htobe64(x) __bswap_64 (x)
26 # define htole64(x) (x)
27 # define be64toh(x) __bswap_64 (x)
28 # define le64toh(x) (x)
29 # else
30 # define htobe16(x) (x)
31 # define htole16(x) __bswap_16 (x)
32 # define be16toh(x) (x)
33 # define le16toh(x) __bswap_16 (x)
34 
35 # define htobe32(x) (x)
36 # define htole32(x) __bswap_32 (x)
37 # define be32toh(x) (x)
38 # define le32toh(x) __bswap_32 (x)
39 
40 # define htobe64(x) (x)
41 # define htole64(x) __bswap_64 (x)
42 # define be64toh(x) (x)
43 # define le64toh(x) __bswap_64 (x)
44 # endif
45 #endif
46 
47 #endif /* _ENDIAN_CONVERSION_H */