Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:48:06

0001 /*
0002 Copyright Rene Rivera 2013-2015
0003 Distributed under the Boost Software License, Version 1.0.
0004 (See accompanying file LICENSE_1_0.txt or copy at
0005 http://www.boost.org/LICENSE_1_0.txt)
0006 */
0007 
0008 #ifndef BOOST_PREDEF_ENDIAN_H
0009 #define BOOST_PREDEF_ENDIAN_H
0010 
0011 #include <boost/predef/version_number.h>
0012 #include <boost/predef/make.h>
0013 #include <boost/predef/library/c/gnu.h>
0014 #include <boost/predef/os/macos.h>
0015 #include <boost/predef/os/bsd.h>
0016 #include <boost/predef/platform/android.h>
0017 
0018 /* tag::reference[]
0019 = `BOOST_ENDIAN_*`
0020 
0021 Detection of endian memory ordering. There are four defined macros
0022 in this header that define the various generally possible endian
0023 memory orderings:
0024 
0025 * `BOOST_ENDIAN_BIG_BYTE`, byte-swapped big-endian.
0026 * `BOOST_ENDIAN_BIG_WORD`, word-swapped big-endian.
0027 * `BOOST_ENDIAN_LITTLE_BYTE`, byte-swapped little-endian.
0028 * `BOOST_ENDIAN_LITTLE_WORD`, word-swapped little-endian.
0029 
0030 The detection is conservative in that it only identifies endianness
0031 that it knows for certain. In particular bi-endianness is not
0032 indicated as is it not practically possible to determine the
0033 endianness from anything but an operating system provided
0034 header. And the currently known headers do not define that
0035 programatic bi-endianness is available.
0036 
0037 This implementation is a compilation of various publicly available
0038 information and acquired knowledge:
0039 
0040 . The indispensable documentation of "Pre-defined Compiler Macros"
0041   http://sourceforge.net/p/predef/wiki/Endianness[Endianness].
0042 . The various endian specifications available in the
0043   http://wikipedia.org/[Wikipedia] computer architecture pages.
0044 . Generally available searches for headers that define endianness.
0045 */ // end::reference[]
0046 
0047 #define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_NOT_AVAILABLE
0048 #define BOOST_ENDIAN_BIG_WORD BOOST_VERSION_NUMBER_NOT_AVAILABLE
0049 #define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_NOT_AVAILABLE
0050 #define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_NOT_AVAILABLE
0051 
0052 /* GNU libc provides a header defining __BYTE_ORDER, or _BYTE_ORDER.
0053  * And some OSs provide some for of endian header also.
0054  */
0055 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
0056     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
0057 #   if BOOST_LIB_C_GNU || BOOST_PLAT_ANDROID || BOOST_OS_BSD_OPEN
0058 #       include <endian.h>
0059 #   else
0060 #       if BOOST_OS_MACOS
0061 #           include <machine/endian.h>
0062 #       else
0063 #           if BOOST_OS_BSD
0064 #               include <sys/endian.h>
0065 #           endif
0066 #       endif
0067 #   endif
0068 #   if defined(__BYTE_ORDER)
0069 #       if defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN)
0070 #           undef BOOST_ENDIAN_BIG_BYTE
0071 #           define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0072 #       endif
0073 #       if defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN)
0074 #           undef BOOST_ENDIAN_LITTLE_BYTE
0075 #           define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0076 #       endif
0077 #       if defined(__PDP_ENDIAN) && (__BYTE_ORDER == __PDP_ENDIAN)
0078 #           undef BOOST_ENDIAN_LITTLE_WORD
0079 #           define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE
0080 #       endif
0081 #   endif
0082 #   if !defined(__BYTE_ORDER) && defined(_BYTE_ORDER)
0083 #       if defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN)
0084 #           undef BOOST_ENDIAN_BIG_BYTE
0085 #           define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0086 #       endif
0087 #       if defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN)
0088 #           undef BOOST_ENDIAN_LITTLE_BYTE
0089 #           define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0090 #       endif
0091 #       if defined(_PDP_ENDIAN) && (_BYTE_ORDER == _PDP_ENDIAN)
0092 #           undef BOOST_ENDIAN_LITTLE_WORD
0093 #           define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE
0094 #       endif
0095 #   endif
0096 #endif
0097 
0098 /* Built-in byte-swapped big-endian macros.
0099  */
0100 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
0101     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
0102 #   if (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) || \
0103        (defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)) || \
0104         defined(__ARMEB__) || \
0105         defined(__THUMBEB__) || \
0106         defined(__AARCH64EB__) || \
0107         defined(_MIPSEB) || \
0108         defined(__MIPSEB) || \
0109         defined(__MIPSEB__)
0110 #       undef BOOST_ENDIAN_BIG_BYTE
0111 #       define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0112 #   endif
0113 #endif
0114 
0115 /* Built-in byte-swapped little-endian macros.
0116  */
0117 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
0118     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
0119 #   if (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
0120        (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)) || \
0121         defined(__ARMEL__) || \
0122         defined(__THUMBEL__) || \
0123         defined(__AARCH64EL__) || \
0124         defined(__loongarch__) || \
0125         defined(_MIPSEL) || \
0126         defined(__MIPSEL) || \
0127         defined(__MIPSEL__) || \
0128         defined(__riscv) || \
0129         defined(__e2k__)
0130 #       undef BOOST_ENDIAN_LITTLE_BYTE
0131 #       define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0132 #   endif
0133 #endif
0134 
0135 /* Some architectures are strictly one endianess (as opposed
0136  * the current common bi-endianess).
0137  */
0138 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
0139     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
0140 #   include <boost/predef/architecture.h>
0141 #   if BOOST_ARCH_M68K || \
0142         BOOST_ARCH_PARISC || \
0143         BOOST_ARCH_SPARC || \
0144         BOOST_ARCH_SYS370 || \
0145         BOOST_ARCH_SYS390 || \
0146         BOOST_ARCH_Z
0147 #       undef BOOST_ENDIAN_BIG_BYTE
0148 #       define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0149 #   endif
0150 #   if BOOST_ARCH_IA64 || \
0151         BOOST_ARCH_X86 || \
0152         BOOST_ARCH_BLACKFIN
0153 #       undef BOOST_ENDIAN_LITTLE_BYTE
0154 #       define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0155 #   endif
0156 #endif
0157 
0158 /* Windows on ARM, if not otherwise detected/specified, is always
0159  * byte-swapped little-endian.
0160  */
0161 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
0162     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
0163 #   if BOOST_ARCH_ARM
0164 #       include <boost/predef/os/windows.h>
0165 #       if BOOST_OS_WINDOWS
0166 #           undef BOOST_ENDIAN_LITTLE_BYTE
0167 #           define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
0168 #       endif
0169 #   endif
0170 #endif
0171 
0172 #if BOOST_ENDIAN_BIG_BYTE
0173 #   define BOOST_ENDIAN_BIG_BYTE_AVAILABLE
0174 #endif
0175 #if BOOST_ENDIAN_BIG_WORD
0176 #   define BOOST_ENDIAN_BIG_WORD_BYTE_AVAILABLE
0177 #endif
0178 #if BOOST_ENDIAN_LITTLE_BYTE
0179 #   define BOOST_ENDIAN_LITTLE_BYTE_AVAILABLE
0180 #endif
0181 #if BOOST_ENDIAN_LITTLE_WORD
0182 #   define BOOST_ENDIAN_LITTLE_WORD_BYTE_AVAILABLE
0183 #endif
0184 
0185 #define BOOST_ENDIAN_BIG_BYTE_NAME "Byte-Swapped Big-Endian"
0186 #define BOOST_ENDIAN_BIG_WORD_NAME "Word-Swapped Big-Endian"
0187 #define BOOST_ENDIAN_LITTLE_BYTE_NAME "Byte-Swapped Little-Endian"
0188 #define BOOST_ENDIAN_LITTLE_WORD_NAME "Word-Swapped Little-Endian"
0189 
0190 #endif
0191 
0192 #include <boost/predef/detail/test.h>
0193 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_BIG_BYTE,BOOST_ENDIAN_BIG_BYTE_NAME)
0194 
0195 #include <boost/predef/detail/test.h>
0196 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_BIG_WORD,BOOST_ENDIAN_BIG_WORD_NAME)
0197 
0198 #include <boost/predef/detail/test.h>
0199 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_LITTLE_BYTE,BOOST_ENDIAN_LITTLE_BYTE_NAME)
0200 
0201 #include <boost/predef/detail/test.h>
0202 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_LITTLE_WORD,BOOST_ENDIAN_LITTLE_WORD_NAME)