Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2014 Regents of the University of California. |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 20 | * |
| 21 | * @author Junxiao Shi <http://www.cs.arizona.edu/people/shijunxiao/> |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 22 | */ |
| 23 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 24 | #ifndef NDN_ENCODING_ENDIAN_HPP |
| 25 | #define NDN_ENCODING_ENDIAN_HPP |
| 26 | |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 27 | #ifdef __linux__ |
| 28 | |
| 29 | #include <endian.h> |
| 30 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 31 | #endif // __linux__ |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 32 | |
| 33 | #ifdef __FreeBSD__ |
| 34 | |
| 35 | #include <sys/endian.h> |
| 36 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 37 | #endif // __FreeBSD__ |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 38 | |
| 39 | #ifdef __APPLE__ |
| 40 | |
| 41 | #include <libkern/OSByteOrder.h> |
| 42 | #define htobe16(x) OSSwapHostToBigInt16(x) |
| 43 | #define htole16(x) OSSwapHostToLittleInt16(x) |
| 44 | #define be16toh(x) OSSwapBigToHostInt16(x) |
| 45 | #define le16toh(x) OSSwapLittleToHostInt16(x) |
| 46 | #define htobe32(x) OSSwapHostToBigInt32(x) |
| 47 | #define htole32(x) OSSwapHostToLittleInt32(x) |
| 48 | #define be32toh(x) OSSwapBigToHostInt32(x) |
| 49 | #define le32toh(x) OSSwapLittleToHostInt32(x) |
| 50 | #define htobe64(x) OSSwapHostToBigInt64(x) |
| 51 | #define htole64(x) OSSwapHostToLittleInt64(x) |
| 52 | #define be64toh(x) OSSwapBigToHostInt64(x) |
| 53 | #define le64toh(x) OSSwapLittleToHostInt64(x) |
| 54 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 55 | #endif // __APPLE__ |
| 56 | |
| 57 | #endif // NDN_ENCODING_ENDIAN_HPP |