1 // Copyright 2005 Caleb Epstein 2 // Copyright 2006 John Maddock 3 // Copyright 2010 Rene Rivera 4 // Distributed under the Boost Software License, Version 1.0. (See accompany- 5 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 7 /* 8 * Copyright (c) 1997 9 * Silicon Graphics Computer Systems, Inc. 10 * 11 * Permission to use, copy, modify, distribute and sell this software 12 * and its documentation for any purpose is hereby granted without fee, 13 * provided that the above copyright notice appear in all copies and 14 * that both that copyright notice and this permission notice appear 15 * in supporting documentation. Silicon Graphics makes no 16 * representations about the suitability of this software for any 17 * purpose. It is provided "as is" without express or implied warranty. 18 */ 19 20 /* 21 * Copyright notice reproduced from <boost/detail/limits.hpp>, from 22 * which this code was originally taken. 23 * 24 * Modified by Caleb Epstein to use <endian.h> with GNU libc and to 25 * defined the BOOST_ENDIAN macro. 26 */ 27 28 #ifndef BOOST_DETAIL_ENDIAN_HPP 29 #define BOOST_DETAIL_ENDIAN_HPP 30 31 // GNU libc offers the helpful header <endian.h> which defines 32 // __BYTE_ORDER 33 34 #if defined (__GLIBC__) || defined(__ANDROID__) 35 # include <endian.h> 36 # if (__BYTE_ORDER == __LITTLE_ENDIAN) 37 # define BOOST_LITTLE_ENDIAN 38 # elif (__BYTE_ORDER == __BIG_ENDIAN) 39 # define BOOST_BIG_ENDIAN 40 # elif (__BYTE_ORDER == __PDP_ENDIAN) 41 # define BOOST_PDP_ENDIAN 42 # else 43 # error Unknown machine endianness detected. 44 # endif 45 # define BOOST_BYTE_ORDER __BYTE_ORDER 46 #elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) || \ 47 defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) || \ 48 defined(_STLP_BIG_ENDIAN) && !defined(_STLP_LITTLE_ENDIAN) 49 # define BOOST_BIG_ENDIAN 50 # define BOOST_BYTE_ORDER 4321 51 #elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) || \ 52 defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) || \ 53 defined(_STLP_LITTLE_ENDIAN) && !defined(_STLP_BIG_ENDIAN) 54 # define BOOST_LITTLE_ENDIAN 55 # define BOOST_BYTE_ORDER 1234 56 #elif defined(__sparc) || defined(__sparc__) \ 57 || defined(_POWER) || defined(__powerpc__) \ 58 || defined(__ppc__) || defined(__hpux) || defined(__hppa) \ 59 || defined(_MIPSEB) || defined(_POWER) \ 60 || defined(__s390__) 61 # define BOOST_BIG_ENDIAN 62 # define BOOST_BYTE_ORDER 4321 63 #elif defined(__i386__) || defined(__alpha__) \ 64 || defined(__ia64) || defined(__ia64__) \ 65 || defined(_M_IX86) || defined(_M_IA64) \ 66 || defined(_M_ALPHA) || defined(__amd64) \ 67 || defined(__amd64__) || defined(_M_AMD64) \ 68 || defined(__x86_64) || defined(__x86_64__) \ 69 || defined(_M_X64) || defined(__bfin__) 70 71 # define BOOST_LITTLE_ENDIAN 72 # define BOOST_BYTE_ORDER 1234 73 #else 74 # error The file boost/detail/endian.hpp needs to be set up for your CPU type. 75 #endif 76 77 78 #endif 79