blob: 8b330b9f9a5ba23a8d942e3d812522d3c25cd1aa [file] [log] [blame]
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07002/**
3 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -08005 *
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 * 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 Afanasyev13bb51a2014-01-02 19:13:26 -08008 *
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07009 * 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 Afanasyev13bb51a2014-01-02 19:13:26 -080013 */
14
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070015#ifndef NDN_ENCODING_ENDIAN_HPP
16#define NDN_ENCODING_ENDIAN_HPP
17
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -080018#ifdef __linux__
19
20#include <endian.h>
21
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070022#endif // __linux__
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -080023
24#ifdef __FreeBSD__
25
26#include <sys/endian.h>
27
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070028#endif // __FreeBSD__
Alexander Afanasyev13bb51a2014-01-02 19:13:26 -080029
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 Afanasyev258ec2b2014-05-14 16:15:37 -070046#endif // __APPLE__
47
48#endif // NDN_ENCODING_ENDIAN_HPP