blob: e37fa98f733dc3aefaa06050bcca0b91c92ce5bd [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07002/**
Alexander Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 Regents of the University of California.
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -08004 *
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07005 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -08006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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 Afanasyevdfa52c42014-04-24 21:10:11 -070020 *
21 * @author Junxiao Shi <http://www.cs.arizona.edu/people/shijunxiao/>
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -080022 */
23
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070024#ifndef NDN_ENCODING_ENDIAN_HPP
25#define NDN_ENCODING_ENDIAN_HPP
26
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -080027#ifdef __linux__
28
29#include <endian.h>
30
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070031#endif // __linux__
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -080032
33#ifdef __FreeBSD__
34
35#include <sys/endian.h>
36
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070037#endif // __FreeBSD__
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -080038
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 Afanasyev258ec2b2014-05-14 16:15:37 -070055#endif // __APPLE__
56
57#endif // NDN_ENCODING_ENDIAN_HPP