endian.h
Go to the documentation of this file.
00001 /*
00002 Copyright Rene Rivera 2013-2015
00003 Distributed under the Boost Software License, Version 1.0.
00004 (See accompanying file LICENSE_1_0.txt or copy at
00005 http://www.boost.org/LICENSE_1_0.txt)
00006 */
00007 
00008 #ifndef BOOST_PREDEF_ENDIAN_H
00009 #define BOOST_PREDEF_ENDIAN_H
00010 
00011 #include <boost/predef/version_number.h>
00012 #include <boost/predef/make.h>
00013 #include <boost/predef/library/c/gnu.h>
00014 #include <boost/predef/os/macos.h>
00015 #include <boost/predef/os/bsd.h>
00016 #include <boost/predef/os/android.h>
00017 
00018 /*`
00019 [heading `BOOST_ENDIAN_*`]
00020 
00021 Detection of endian memory ordering. There are four defined macros
00022 in this header that define the various generally possible endian
00023 memory orderings:
00024 
00025 * `BOOST_ENDIAN_BIG_BYTE`, byte-swapped big-endian.
00026 * `BOOST_ENDIAN_BIG_WORD`, word-swapped big-endian.
00027 * `BOOST_ENDIAN_LITTLE_BYTE`, byte-swapped little-endian.
00028 * `BOOST_ENDIAN_LITTLE_WORD`, word-swapped little-endian.
00029 
00030 The detection is conservative in that it only identifies endianness
00031 that it knows for certain. In particular bi-endianness is not
00032 indicated as is it not practically possible to determine the
00033 endianness from anything but an operating system provided
00034 header. And the currently known headers do not define that
00035 programatic bi-endianness is available.
00036 
00037 This implementation is a compilation of various publicly available
00038 information and acquired knowledge:
00039 
00040 # The indispensable documentation of "Pre-defined Compiler Macros"
00041   [@http://sourceforge.net/p/predef/wiki/Endianness Endianness].
00042 # The various endian specifications available in the
00043   [@http://wikipedia.org/ Wikipedia] computer architecture pages.
00044 # Generally available searches for headers that define endianness.
00045  */
00046 
00047 #define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_NOT_AVAILABLE
00048 #define BOOST_ENDIAN_BIG_WORD BOOST_VERSION_NUMBER_NOT_AVAILABLE
00049 #define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_NOT_AVAILABLE
00050 #define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_NOT_AVAILABLE
00051 
00052 /* GNU libc provides a header defining __BYTE_ORDER, or _BYTE_ORDER.
00053  * And some OSs provide some for of endian header also.
00054  */
00055 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
00056     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
00057 #   if BOOST_LIB_C_GNU || BOOST_OS_ANDROID
00058 #       include <endian.h>
00059 #   else
00060 #       if BOOST_OS_MACOS
00061 #           include <machine/endian.h>
00062 #       else
00063 #           if BOOST_OS_BSD
00064 #               if BOOST_OS_BSD_OPEN
00065 #                   include <machine/endian.h>
00066 #               else
00067 #                   include <sys/endian.h>
00068 #               endif
00069 #           endif
00070 #       endif
00071 #   endif
00072 #   if defined(__BYTE_ORDER)
00073 #       if defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN)
00074 #           undef BOOST_ENDIAN_BIG_BYTE
00075 #           define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00076 #       endif
00077 #       if defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN)
00078 #           undef BOOST_ENDIAN_LITTLE_BYTE
00079 #           define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00080 #       endif
00081 #       if defined(__PDP_ENDIAN) && (__BYTE_ORDER == __PDP_ENDIAN)
00082 #           undef BOOST_ENDIAN_LITTLE_WORD
00083 #           define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE
00084 #       endif
00085 #   endif
00086 #   if !defined(__BYTE_ORDER) && defined(_BYTE_ORDER)
00087 #       if defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN)
00088 #           undef BOOST_ENDIAN_BIG_BYTE
00089 #           define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00090 #       endif
00091 #       if defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN)
00092 #           undef BOOST_ENDIAN_LITTLE_BYTE
00093 #           define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00094 #       endif
00095 #       if defined(_PDP_ENDIAN) && (_BYTE_ORDER == _PDP_ENDIAN)
00096 #           undef BOOST_ENDIAN_LITTLE_WORD
00097 #           define BOOST_ENDIAN_LITTLE_WORD BOOST_VERSION_NUMBER_AVAILABLE
00098 #       endif
00099 #   endif
00100 #endif
00101 
00102 /* Built-in byte-swpped big-endian macros.
00103  */
00104 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
00105     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
00106 #   if (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) || \
00107        (defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)) || \
00108         defined(__ARMEB__) || \
00109         defined(__THUMBEB__) || \
00110         defined(__AARCH64EB__) || \
00111         defined(_MIPSEB) || \
00112         defined(__MIPSEB) || \
00113         defined(__MIPSEB__)
00114 #       undef BOOST_ENDIAN_BIG_BYTE
00115 #       define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00116 #   endif
00117 #endif
00118 
00119 /* Built-in byte-swpped little-endian macros.
00120  */
00121 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
00122     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
00123 #   if (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
00124        (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)) || \
00125         defined(__ARMEL__) || \
00126         defined(__THUMBEL__) || \
00127         defined(__AARCH64EL__) || \
00128         defined(_MIPSEL) || \
00129         defined(__MIPSEL) || \
00130         defined(__MIPSEL__)
00131 #       undef BOOST_ENDIAN_LITTLE_BYTE
00132 #       define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00133 #   endif
00134 #endif
00135 
00136 /* Some architectures are strictly one endianess (as opposed
00137  * the current common bi-endianess).
00138  */
00139 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
00140     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
00141 #   include <boost/predef/architecture.h>
00142 #   if BOOST_ARCH_M68K || \
00143         BOOST_ARCH_PARISC || \
00144         BOOST_ARCH_SPARC || \
00145         BOOST_ARCH_SYS370 || \
00146         BOOST_ARCH_SYS390 || \
00147         BOOST_ARCH_Z
00148 #       undef BOOST_ENDIAN_BIG_BYTE
00149 #       define BOOST_ENDIAN_BIG_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00150 #   endif
00151 #   if BOOST_ARCH_AMD64 || \
00152         BOOST_ARCH_IA64 || \
00153         BOOST_ARCH_X86 || \
00154         BOOST_ARCH_BLACKFIN
00155 #       undef BOOST_ENDIAN_LITTLE_BYTE
00156 #       define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00157 #   endif
00158 #endif
00159 
00160 /* Windows on ARM, if not otherwise detected/specified, is always
00161  * byte-swaped little-endian.
00162  */
00163 #if !BOOST_ENDIAN_BIG_BYTE && !BOOST_ENDIAN_BIG_WORD && \
00164     !BOOST_ENDIAN_LITTLE_BYTE && !BOOST_ENDIAN_LITTLE_WORD
00165 #   if BOOST_ARCH_ARM
00166 #       include <boost/predef/os/windows.h>
00167 #       if BOOST_OS_WINDOWS
00168 #           undef BOOST_ENDIAN_LITTLE_BYTE
00169 #           define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
00170 #       endif
00171 #   endif
00172 #endif
00173 
00174 #if BOOST_ENDIAN_BIG_BYTE
00175 #   define BOOST_ENDIAN_BIG_BYTE_AVAILABLE
00176 #endif
00177 #if BOOST_ENDIAN_BIG_WORD
00178 #   define BOOST_ENDIAN_BIG_WORD_BYTE_AVAILABLE
00179 #endif
00180 #if BOOST_ENDIAN_LITTLE_BYTE
00181 #   define BOOST_ENDIAN_LITTLE_BYTE_AVAILABLE
00182 #endif
00183 #if BOOST_ENDIAN_LITTLE_WORD
00184 #   define BOOST_ENDIAN_LITTLE_WORD_BYTE_AVAILABLE
00185 #endif
00186 
00187 #define BOOST_ENDIAN_BIG_BYTE_NAME "Byte-Swapped Big-Endian"
00188 #define BOOST_ENDIAN_BIG_WORD_NAME "Word-Swapped Big-Endian"
00189 #define BOOST_ENDIAN_LITTLE_BYTE_NAME "Byte-Swapped Little-Endian"
00190 #define BOOST_ENDIAN_LITTLE_WORD_NAME "Word-Swapped Little-Endian"
00191 
00192 #endif
00193 
00194 #include <boost/predef/detail/test.h>
00195 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_BIG_BYTE,BOOST_ENDIAN_BIG_BYTE_NAME)
00196 
00197 #include <boost/predef/detail/test.h>
00198 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_BIG_WORD,BOOST_ENDIAN_BIG_WORD_NAME)
00199 
00200 #include <boost/predef/detail/test.h>
00201 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_LITTLE_BYTE,BOOST_ENDIAN_LITTLE_BYTE_NAME)
00202 
00203 #include <boost/predef/detail/test.h>
00204 BOOST_PREDEF_DECLARE_TEST(BOOST_ENDIAN_LITTLE_WORD,BOOST_ENDIAN_LITTLE_WORD_NAME)


cv_bridge
Author(s): Patrick Mihelich, James Bowman
autogenerated on Wed Aug 9 2017 02:51:41