All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
endian.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2013, Regents of the University of California
4  *
5  * BSD license, See the LICENSE file for more information
6  *
7  * Author: Junxiao Shi <[email protected]>
8  */
9 
10 #ifdef __linux__
11 
12 #include <endian.h>
13 
14 #endif
15 
16 #ifdef __FreeBSD__
17 
18 #include <sys/endian.h>
19 
20 #endif
21 
22 #ifdef __APPLE__
23 
24 #include <libkern/OSByteOrder.h>
25 #define htobe16(x) OSSwapHostToBigInt16(x)
26 #define htole16(x) OSSwapHostToLittleInt16(x)
27 #define be16toh(x) OSSwapBigToHostInt16(x)
28 #define le16toh(x) OSSwapLittleToHostInt16(x)
29 #define htobe32(x) OSSwapHostToBigInt32(x)
30 #define htole32(x) OSSwapHostToLittleInt32(x)
31 #define be32toh(x) OSSwapBigToHostInt32(x)
32 #define le32toh(x) OSSwapLittleToHostInt32(x)
33 #define htobe64(x) OSSwapHostToBigInt64(x)
34 #define htole64(x) OSSwapHostToLittleInt64(x)
35 #define be64toh(x) OSSwapBigToHostInt64(x)
36 #define le64toh(x) OSSwapLittleToHostInt64(x)
37 
38 #endif
39