Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:33:57

0001 /*
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * Copyright (c) 2009 Helge Bahmann
0007  * Copyright (c) 2014-2018, 2020 Andrey Semashev
0008  */
0009 /*!
0010  * \file   atomic/detail/platform.hpp
0011  *
0012  * This header defines macros for the target platform detection
0013  */
0014 
0015 #ifndef BOOST_ATOMIC_DETAIL_PLATFORM_HPP_INCLUDED_
0016 #define BOOST_ATOMIC_DETAIL_PLATFORM_HPP_INCLUDED_
0017 
0018 #include <boost/atomic/detail/config.hpp>
0019 
0020 #ifdef BOOST_HAS_PRAGMA_ONCE
0021 #pragma once
0022 #endif
0023 
0024 #if defined(__GNUC__) && defined(__arm__)
0025 
0026 // Newer gcc versions define __ARM_ARCH. Older ones don't, so we have to deduce ARM arch version from a bunch of version-specific macros.
0027 #if defined(__ARM_ARCH)
0028 #define BOOST_ATOMIC_DETAIL_ARM_ARCH __ARM_ARCH
0029 #elif defined(__ARM_ARCH_8A__)
0030 #define BOOST_ATOMIC_DETAIL_ARM_ARCH 8
0031 #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) ||\
0032     defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) ||\
0033     defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7S__)
0034 #define BOOST_ATOMIC_DETAIL_ARM_ARCH 7
0035 #elif defined(__ARM_ARCH_6__)  || defined(__ARM_ARCH_6J__) ||\
0036     defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) ||\
0037     defined(__ARM_ARCH_6ZK__)
0038 #define BOOST_ATOMIC_DETAIL_ARM_ARCH 6
0039 #else
0040 // We are not interested in older versions - they don't support atomic ops
0041 #define BOOST_ATOMIC_DETAIL_ARM_ARCH 0
0042 #endif
0043 
0044 #endif // defined(__GNUC__) && defined(__arm__)
0045 
0046 #if !defined(BOOST_ATOMIC_FORCE_FALLBACK)
0047 
0048 // Determine the target platform.
0049 // The target platform describes the compiler and target architecture. It can be used by more generic backends, such as the ones
0050 // based on compiler intrinsics, to implement specialized operations in a non-generic way.
0051 
0052 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
0053 
0054 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND gcc_x86
0055 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND gcc_x86
0056 
0057 #elif defined(__GNUC__) && defined(__aarch64__)
0058 
0059 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND gcc_aarch64
0060 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND gcc_aarch64
0061 
0062 #elif defined(__GNUC__) && defined(__arm__) && (BOOST_ATOMIC_DETAIL_ARM_ARCH >= 6)
0063 
0064 #if (BOOST_ATOMIC_DETAIL_ARM_ARCH >= 8)
0065 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND gcc_aarch32
0066 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND gcc_aarch32
0067 #else
0068 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND gcc_arm
0069 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND gcc_arm
0070 #endif
0071 
0072 #elif defined(__GNUC__) && (defined(__POWERPC__) || defined(__PPC__))
0073 
0074 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND gcc_ppc
0075 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND gcc_ppc
0076 
0077 #elif (defined(__GNUC__) || defined(__SUNPRO_CC)) && (defined(__sparcv8plus) || defined(__sparc_v9__))
0078 
0079 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND gcc_sparc
0080 
0081 #elif defined(__GNUC__) && defined(__alpha__)
0082 
0083 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND gcc_alpha
0084 
0085 #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
0086 
0087 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND msvc_x86
0088 
0089 #elif defined(_MSC_VER) && _MSC_VER >= 1700 && (defined(_M_ARM) || defined(_M_ARM64))
0090 
0091 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND msvc_arm
0092 
0093 #endif
0094 
0095 // Compiler-based backends
0096 
0097 // IBM XL C++ Compiler has to be checked before GCC/Clang as it pretends to be one but does not support __atomic* intrinsics.
0098 // It does support GCC inline assembler though.
0099 #if !(defined(__ibmxl__) || defined(__IBMCPP__)) &&\
0100     ((defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407)) ||\
0101         (defined(BOOST_CLANG) && ((__clang_major__ * 100 + __clang_minor__) >= 302))) &&\
0102     (\
0103         (__GCC_ATOMIC_BOOL_LOCK_FREE == 2) ||\
0104         (__GCC_ATOMIC_CHAR_LOCK_FREE == 2) ||\
0105         (__GCC_ATOMIC_SHORT_LOCK_FREE == 2) ||\
0106         (__GCC_ATOMIC_INT_LOCK_FREE == 2) ||\
0107         (__GCC_ATOMIC_LONG_LOCK_FREE == 2) ||\
0108         (__GCC_ATOMIC_LLONG_LOCK_FREE == 2)\
0109     )
0110 
0111 #define BOOST_ATOMIC_DETAIL_CORE_BACKEND gcc_atomic
0112 
0113 // GCC __sync* instrinsics backend is less efficient than asm-based backends, so use it only when nothing better is available.
0114 #elif !defined(BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND) &&\
0115     defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 401) &&\
0116     (\
0117         defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1) ||\
0118         defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) ||\
0119         defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) ||\
0120         defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) ||\
0121         defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)\
0122     )
0123 
0124 #define BOOST_ATOMIC_DETAIL_CORE_BACKEND gcc_sync
0125 
0126 #endif
0127 
0128 // OS-based backends
0129 
0130 #if !defined(BOOST_ATOMIC_DETAIL_CORE_BACKEND) && !defined(BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND)
0131 
0132 #if defined(__linux__) && defined(__arm__)
0133 
0134 #define BOOST_ATOMIC_DETAIL_CORE_BACKEND linux_arm
0135 
0136 #elif defined(BOOST_WINDOWS) || defined(_WIN32_CE)
0137 
0138 #define BOOST_ATOMIC_DETAIL_CORE_BACKEND windows
0139 
0140 #endif
0141 
0142 #endif // !defined(BOOST_ATOMIC_DETAIL_CORE_BACKEND)
0143 
0144 // Waiting and notifying operations backends
0145 #if defined(BOOST_WINDOWS)
0146 
0147 #define BOOST_ATOMIC_DETAIL_WAIT_BACKEND windows
0148 
0149 #else // defined(BOOST_WINDOWS)
0150 
0151 #include <boost/atomic/detail/futex.hpp>
0152 
0153 #if defined(BOOST_ATOMIC_DETAIL_HAS_FUTEX)
0154 #define BOOST_ATOMIC_DETAIL_WAIT_BACKEND futex
0155 #elif defined(__APPLE__)
0156 #if !defined(BOOST_ATOMIC_NO_DARWIN_ULOCK) && (\
0157     (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200) || \
0158     (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100000) || \
0159     (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 100000) || \
0160     (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 30000))
0161 // Darwin 16+ supports ulock API
0162 #define BOOST_ATOMIC_DETAIL_WAIT_BACKEND darwin_ulock
0163 #endif // __ENVIRONMENT_*_VERSION_MIN_REQUIRED__
0164 #elif defined(__FreeBSD__)
0165 #include <sys/param.h>
0166 // FreeBSD prior to 7.0 had _umtx_op with a different signature
0167 #if defined(__FreeBSD_version) && __FreeBSD_version >= 700000
0168 #define BOOST_ATOMIC_DETAIL_WAIT_BACKEND freebsd_umtx
0169 #endif // defined(__FreeBSD_version) && __FreeBSD_version >= 700000
0170 #elif defined(__DragonFly__)
0171 #define BOOST_ATOMIC_DETAIL_WAIT_BACKEND dragonfly_umtx
0172 #endif
0173 
0174 #endif // defined(BOOST_WINDOWS)
0175 
0176 #endif // !defined(BOOST_ATOMIC_FORCE_FALLBACK)
0177 
0178 #if !defined(BOOST_ATOMIC_DETAIL_FP_BACKEND)
0179 #define BOOST_ATOMIC_DETAIL_FP_BACKEND generic
0180 #define BOOST_ATOMIC_DETAIL_FP_BACKEND_GENERIC
0181 #endif
0182 
0183 #if !defined(BOOST_ATOMIC_DETAIL_EXTRA_BACKEND)
0184 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND generic
0185 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND_GENERIC
0186 #endif
0187 
0188 #if !defined(BOOST_ATOMIC_DETAIL_EXTRA_FP_BACKEND)
0189 #define BOOST_ATOMIC_DETAIL_EXTRA_FP_BACKEND generic
0190 #define BOOST_ATOMIC_DETAIL_EXTRA_FP_BACKEND_GENERIC
0191 #endif
0192 
0193 #if !defined(BOOST_ATOMIC_DETAIL_WAIT_BACKEND)
0194 #define BOOST_ATOMIC_DETAIL_WAIT_BACKEND generic
0195 #define BOOST_ATOMIC_DETAIL_WAIT_BACKEND_GENERIC
0196 #endif
0197 
0198 #if defined(BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND)
0199 #define BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND).hpp>
0200 #endif
0201 #if defined(BOOST_ATOMIC_DETAIL_CORE_BACKEND)
0202 #define BOOST_ATOMIC_DETAIL_CORE_BACKEND_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_CORE_BACKEND).hpp>
0203 #endif
0204 #define BOOST_ATOMIC_DETAIL_FP_BACKEND_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_FP_BACKEND).hpp>
0205 #define BOOST_ATOMIC_DETAIL_EXTRA_BACKEND_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_EXTRA_BACKEND).hpp>
0206 #define BOOST_ATOMIC_DETAIL_EXTRA_FP_BACKEND_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_EXTRA_FP_BACKEND).hpp>
0207 #define BOOST_ATOMIC_DETAIL_WAIT_BACKEND_HEADER(prefix) <BOOST_JOIN(prefix, BOOST_ATOMIC_DETAIL_WAIT_BACKEND).hpp>
0208 
0209 #endif // BOOST_ATOMIC_DETAIL_PLATFORM_HPP_INCLUDED_