annotate DEPENDENCIES/generic/include/boost/predef/other/endian.h @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 /*
Chris@16 2 Copyright Redshift Software, Inc. 2013
Chris@16 3 Distributed under the Boost Software License, Version 1.0.
Chris@16 4 (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7
Chris@16 8 #ifndef BOOST_PREDEF_ENDIAN_H
Chris@16 9 #define BOOST_PREDEF_ENDIAN_H
Chris@16 10
Chris@16 11 #include <boost/predef/version_number.h>
Chris@16 12 #include <boost/predef/make.h>
Chris@16 13 #include <boost/predef/library/c/gnu.h>
Chris@16 14 #include <boost/predef/os/macos.h>
Chris@16 15 #include <boost/predef/os/bsd.h>
Chris@16 16
Chris@16 17 /*`
Chris@16 18 [heading `BOOST_ENDIAN_*`]
Chris@16 19
Chris@16 20 Detection of endian memory ordering. There are four defined macros
Chris@16 21 in this header that define the various generally possible endian
Chris@16 22 memory orderings:
Chris@16 23
Chris@16 24 * `BOOST_ENDIAN_BIG_BYTE`, byte-swapped big-endian.
Chris@16 25 * `BOOST_ENDIAN_BIG_WORD`, word-swapped big-endian.
Chris@16 26 * `BOOST_ENDIAN_LITTLE_BYTE`, byte-swapped little-endian.
Chris@16 27 * `BOOST_ENDIAN_LITTLE_WORD`, word-swapped little-endian.
Chris@16 28
Chris@16 29 The detection is conservative in that it only identifies endianness
Chris@16 30 that it knows for certain. In particular bi-endianness is not
Chris@16 31 indicated as is it not practically possible to determine the
Chris@16 32 endianness from anything but an operating system provided
Chris@16 33 header. And the currently known headers do not define that
Chris@16 34 programatic bi-endianness is available.
Chris@16 35
Chris@16 36 This implementation is a compilation of various publicly available
Chris@16 37 information and acquired knowledge:
Chris@16 38
Chris@16 39 # The indispensable documentation of "Pre-defined Compiler Macros"
Chris@16 40 [@http://sourceforge.net/p/predef/wiki/Endianness Endianness].
Chris@16 41 # The various endian specifications available in the
Chris@16 42 [@http://wikipedia.org/ Wikipedia] computer architecture pages.
Chris@16 43 # Generally available searches for headers that define endianness.
Chris@16 44 */
Chris@16 45
Chris@16 46 #define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_NOT_AVAILABLE
Chris@16 47 #define BOOST_ENDIAN_BIG_WORD BOOST_VERSION_NUMBER_NOT_AVAILABLE
Chris@16 48 #define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_NOT_AVAILABLE
Chris@16 49 #define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_NOT_AVAILABLE
Chris@16 50
Chris@16 51 /* GNU libc provides a header defining __BYTE_ORDER, or _BYTE_ORDER.
Chris@16 52 * And some OSs provide some for of endian header also.
Chris@16 53 */
Chris@16 54 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
Chris@16 55 !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
Chris@16 56 # if BOOST_LIB_C_GNU
Chris@16 57 # include <endian.h>
Chris@16 58 # else
Chris@16 59 # if BOOST_OS_MACOS
Chris@16 60 # include <machine/endian.h>
Chris@16 61 # else
Chris@16 62 # if BOOST_OS_BSD
Chris@16 63 # if BOOST_OS_BSD_OPEN
Chris@16 64 # include <machine/endian.h>
Chris@16 65 # else
Chris@16 66 # include <sys/endian.h>
Chris@16 67 # endif
Chris@16 68 # endif
Chris@16 69 # endif
Chris@16 70 # endif
Chris@16 71 # if defined(__BYTE_ORDER)
Chris@16 72 # if (__BYTE_ORDER == __BIG_ENDIAN)
Chris@16 73 # undef BOOST_ENDIAN_BIG_BYTE
Chris@16 74 # define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 75 # endif
Chris@16 76 # if (__BYTE_ORDER == __LITTLE_ENDIAN)
Chris@16 77 # undef BOOST_ENDIAN_LITTLE_BYTE
Chris@16 78 # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 79 # endif
Chris@16 80 # if (__BYTE_ORDER == __PDP_ENDIAN)
Chris@16 81 # undef BOOST_ENDIAN_LITTLE_WORD
Chris@16 82 # define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 83 # endif
Chris@16 84 # endif
Chris@16 85 # if !defined(__BYTE_ORDER) && defined(_BYTE_ORDER)
Chris@16 86 # if (_BYTE_ORDER == _BIG_ENDIAN)
Chris@16 87 # undef BOOST_ENDIAN_BIG_BYTE
Chris@16 88 # define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 89 # endif
Chris@16 90 # if (_BYTE_ORDER == _LITTLE_ENDIAN)
Chris@16 91 # undef BOOST_ENDIAN_LITTLE_BYTE
Chris@16 92 # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 93 # endif
Chris@16 94 # if (_BYTE_ORDER == _PDP_ENDIAN)
Chris@16 95 # undef BOOST_ENDIAN_LITTLE_WORD
Chris@16 96 # define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 97 # endif
Chris@16 98 # endif
Chris@16 99 #endif
Chris@16 100
Chris@16 101 /* Built-in byte-swpped big-endian macros.
Chris@16 102 */
Chris@16 103 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
Chris@16 104 !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
Chris@16 105 # if !BOOST_ENDIAN_BIG_BYTE
Chris@16 106 # if (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) || \
Chris@16 107 defined(__ARMEB__) || \
Chris@16 108 defined(__THUMBEB__) || \
Chris@16 109 defined(__AARCH64EB__) || \
Chris@16 110 defined(_MIPSEB) || \
Chris@16 111 defined(__MIPSEB) || \
Chris@16 112 defined(__MIPSEB__)
Chris@16 113 # undef BOOST_ENDIAN_BIG_BYTE
Chris@16 114 # define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 115 # endif
Chris@16 116 # endif
Chris@16 117 #endif
Chris@16 118
Chris@16 119 /* Built-in byte-swpped little-endian macros.
Chris@16 120 */
Chris@16 121 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
Chris@16 122 !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
Chris@16 123 # if !BOOST_ENDIAN_LITTLE_BYTE
Chris@16 124 # if (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
Chris@16 125 defined(__ARMEL__) || \
Chris@16 126 defined(__THUMBEL__) || \
Chris@16 127 defined(__AARCH64EL__) || \
Chris@16 128 defined(_MIPSEL) || \
Chris@16 129 defined(__MIPSEL) || \
Chris@16 130 defined(__MIPSEL__)
Chris@16 131 # undef BOOST_ENDIAN_LITTLE_BYTE
Chris@16 132 # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 133 # endif
Chris@16 134 # endif
Chris@16 135 #endif
Chris@16 136
Chris@16 137 /* Some architectures are strictly one endianess (as opposed
Chris@16 138 * the current common bi-endianess).
Chris@16 139 */
Chris@16 140 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
Chris@16 141 !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
Chris@16 142 # include <boost/predef/architecture.h>
Chris@16 143 # if BOOST_ARCH_M68K || \
Chris@16 144 BOOST_ARCH_PARISK || \
Chris@16 145 BOOST_ARCH_SYS370 || \
Chris@16 146 BOOST_ARCH_SYS390 || \
Chris@16 147 BOOST_ARCH_Z
Chris@16 148 # undef BOOST_ENDIAN_BIG_BYTE
Chris@16 149 # define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 150 # endif
Chris@16 151 # if BOOST_ARCH_AMD64 || \
Chris@16 152 BOOST_ARCH_IA64 || \
Chris@16 153 BOOST_ARCH_X86 || \
Chris@16 154 BOOST_ARCH_BLACKFIN
Chris@16 155 # undef BOOST_ENDIAN_LITTLE_BYTE
Chris@16 156 # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 157 # endif
Chris@16 158 #endif
Chris@16 159
Chris@16 160 /* Windows on ARM, if not otherwise detected/specified, is always
Chris@16 161 * byte-swaped little-endian.
Chris@16 162 */
Chris@16 163 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
Chris@16 164 !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
Chris@16 165 # if BOOST_ARCH_ARM
Chris@16 166 # include <boost/predef/os/windows.h>
Chris@16 167 # if BOOST_OS_WINDOWS
Chris@16 168 # undef BOOST_ENDIAN_LITTLE_BYTE
Chris@16 169 # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
Chris@16 170 # endif
Chris@16 171 # endif
Chris@16 172 #endif
Chris@16 173
Chris@16 174 #if BOOST_ENDIAN_BIG_BYTE
Chris@16 175 # define BOOST_ENDIAN_BIG_BYTE_AVAILABLE
Chris@16 176 #endif
Chris@16 177 #if BOOST_ENDIAN_BIG_WORD
Chris@16 178 # define BOOST_ENDIAN_BIG_WORD_BYTE_AVAILABLE
Chris@16 179 #endif
Chris@16 180 #if BOOST_ENDIAN_LITTLE_BYTE
Chris@16 181 # define BOOST_ENDIAN_LITTLE_BYTE_AVAILABLE
Chris@16 182 #endif
Chris@16 183 #if BOOST_ENDIAN_LITTLE_WORD
Chris@16 184 # define BOOST_ENDIAN_LITTLE_WORD_BYTE_AVAILABLE
Chris@16 185 #endif
Chris@16 186
Chris@16 187 #define BOOST_ENDIAN_BIG_BYTE_NAME "Byte-Swapped Big-Endian"
Chris@16 188 #define BOOST_ENDIAN_BIG_WORD_NAME "Word-Swapped Big-Endian"
Chris@16 189 #define BOOST_ENDIAN_LITTLE_BYTE_NAME "Byte-Swapped Little-Endian"
Chris@16 190 #define BOOST_ENDIAN_LITTLE_WORD_NAME "Word-Swapped Little-Endian"
Chris@16 191
Chris@16 192 #include <boost/predef/detail/test.h>
Chris@16 193 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_BIG_BYTE,BOOST_ENDIAN_BIG_BYTE_NAME)
Chris@16 194
Chris@16 195 #include <boost/predef/detail/test.h>
Chris@16 196 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_BIG_WORD,BOOST_ENDIAN_BIG_WORD_NAME)
Chris@16 197
Chris@16 198 #include <boost/predef/detail/test.h>
Chris@16 199 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_LITTLE_BYTE,BOOST_ENDIAN_LITTLE_BYTE_NAME)
Chris@16 200
Chris@16 201 #include <boost/predef/detail/test.h>
Chris@16 202 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_LITTLE_WORD,BOOST_ENDIAN_LITTLE_WORD_NAME)
Chris@16 203
Chris@16 204
Chris@16 205 #endif