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