Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [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 | /** |
| 3 | * Copyright (c) 2013-2014, Regents of the University of California. |
| 4 | * All rights reserved. |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 5 | * |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 7 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 8 | * |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 9 | * This file licensed under New BSD License. See COPYING for detailed information about |
| 10 | * ndn-cxx library copyright, permissions, and redistribution restrictions. |
| 11 | * |
| 12 | * @author Junxiao Shi <http://www.cs.arizona.edu/people/shijunxiao/> |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 13 | */ |
| 14 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 15 | #ifndef NDN_ENCODING_ENDIAN_HPP |
| 16 | #define NDN_ENCODING_ENDIAN_HPP |
| 17 | |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 18 | #ifdef __linux__ |
| 19 | |
| 20 | #include <endian.h> |
| 21 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 22 | #endif // __linux__ |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 23 | |
| 24 | #ifdef __FreeBSD__ |
| 25 | |
| 26 | #include <sys/endian.h> |
| 27 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 28 | #endif // __FreeBSD__ |
Alexander Afanasyev | 13bb51a | 2014-01-02 19:13:26 -0800 | [diff] [blame] | 29 | |
| 30 | #ifdef __APPLE__ |
| 31 | |
| 32 | #include <libkern/OSByteOrder.h> |
| 33 | #define htobe16(x) OSSwapHostToBigInt16(x) |
| 34 | #define htole16(x) OSSwapHostToLittleInt16(x) |
| 35 | #define be16toh(x) OSSwapBigToHostInt16(x) |
| 36 | #define le16toh(x) OSSwapLittleToHostInt16(x) |
| 37 | #define htobe32(x) OSSwapHostToBigInt32(x) |
| 38 | #define htole32(x) OSSwapHostToLittleInt32(x) |
| 39 | #define be32toh(x) OSSwapBigToHostInt32(x) |
| 40 | #define le32toh(x) OSSwapLittleToHostInt32(x) |
| 41 | #define htobe64(x) OSSwapHostToBigInt64(x) |
| 42 | #define htole64(x) OSSwapHostToLittleInt64(x) |
| 43 | #define be64toh(x) OSSwapBigToHostInt64(x) |
| 44 | #define le64toh(x) OSSwapLittleToHostInt64(x) |
| 45 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 46 | #endif // __APPLE__ |
| 47 | |
| 48 | #endif // NDN_ENCODING_ENDIAN_HPP |