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