Back to home page

EIC code displayed by LXR

 
 

    


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

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) 2009 Phil Endecott
0008  * Copyright (c) 2013 Tim Blechmann
0009  * ARM Code by Phil Endecott, based on other architectures.
0010  * Copyright (c) 2014, 2020, 2022 Andrey Semashev
0011  */
0012 /*!
0013  * \file   atomic/detail/caps_arch_gcc_arm.hpp
0014  *
0015  * This header defines feature capabilities macros
0016  */
0017 
0018 #ifndef BOOST_ATOMIC_DETAIL_CAPS_ARCH_GCC_ARM_HPP_INCLUDED_
0019 #define BOOST_ATOMIC_DETAIL_CAPS_ARCH_GCC_ARM_HPP_INCLUDED_
0020 
0021 #include <boost/atomic/detail/config.hpp>
0022 #include <boost/atomic/detail/platform.hpp>
0023 
0024 #ifdef BOOST_HAS_PRAGMA_ONCE
0025 #pragma once
0026 #endif
0027 
0028 #if defined(__ARMEL__) || \
0029     (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
0030     (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
0031     defined(BOOST_WINDOWS)
0032 #define BOOST_ATOMIC_DETAIL_ARM_LITTLE_ENDIAN
0033 #elif defined(__ARMEB__) || \
0034     defined(__ARM_BIG_ENDIAN) || \
0035     (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
0036     (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__))
0037 #define BOOST_ATOMIC_DETAIL_ARM_BIG_ENDIAN
0038 #else
0039 #include <boost/predef/other/endian.h>
0040 #if BOOST_ENDIAN_LITTLE_BYTE
0041 #define BOOST_ATOMIC_DETAIL_ARM_LITTLE_ENDIAN
0042 #elif BOOST_ENDIAN_BIG_BYTE
0043 #define BOOST_ATOMIC_DETAIL_ARM_BIG_ENDIAN
0044 #else
0045 #error "Boost.Atomic: Failed to determine ARM endianness, the target platform is not supported. Please, report to the developers (patches are welcome)."
0046 #endif
0047 #endif
0048 
0049 #if defined(__GNUC__) && defined(__arm__) && (BOOST_ATOMIC_DETAIL_ARM_ARCH >= 6)
0050 
0051 #if BOOST_ATOMIC_DETAIL_ARM_ARCH > 6
0052 // ARMv7 and later have dmb instruction
0053 #define BOOST_ATOMIC_DETAIL_ARM_HAS_DMB 1
0054 #endif
0055 
0056 #if defined(__ARM_FEATURE_LDREX)
0057 
0058 #if (__ARM_FEATURE_LDREX & 1)
0059 #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXB_STREXB 1
0060 #endif
0061 #if (__ARM_FEATURE_LDREX & 2)
0062 #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXH_STREXH 1
0063 #endif
0064 #if (__ARM_FEATURE_LDREX & 8)
0065 #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD 1
0066 #endif
0067 
0068 #else // defined(__ARM_FEATURE_LDREX)
0069 
0070 #if !(defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6Z__))
0071 
0072 // ARMv6k and ARMv7 have 8 and 16-bit ldrex/strex variants, but at least GCC 4.7 fails to compile them. GCC 4.9 is known to work.
0073 #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409
0074 #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXB_STREXB 1
0075 #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXH_STREXH 1
0076 #endif
0077 
0078 #if !(((defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__)) && defined(__thumb__)) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7M__))
0079 // ARMv6k and ARMv7 except ARMv7-M have 64-bit ldrex/strex variants.
0080 // Unfortunately, GCC (at least 4.7.3 on Ubuntu) does not allocate register pairs properly when targeting ARMv6k Thumb,
0081 // which is required for ldrexd/strexd instructions, so we disable 64-bit support. When targeting ARMv6k ARM
0082 // or ARMv7 (both ARM and Thumb 2) it works as expected.
0083 #define BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD 1
0084 #endif
0085 
0086 #endif // !(defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6Z__))
0087 
0088 #endif // defined(__ARM_FEATURE_LDREX)
0089 
0090 #endif // defined(__GNUC__) && defined(__arm__) && (BOOST_ATOMIC_DETAIL_ARM_ARCH >= 6)
0091 
0092 #define BOOST_ATOMIC_INT8_LOCK_FREE 2
0093 #define BOOST_ATOMIC_INT16_LOCK_FREE 2
0094 #define BOOST_ATOMIC_INT32_LOCK_FREE 2
0095 #if defined(BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD)
0096 #define BOOST_ATOMIC_INT64_LOCK_FREE 2
0097 #endif
0098 #define BOOST_ATOMIC_POINTER_LOCK_FREE 2
0099 
0100 #define BOOST_ATOMIC_THREAD_FENCE 2
0101 #define BOOST_ATOMIC_SIGNAL_FENCE 2
0102 
0103 #endif // BOOST_ATOMIC_DETAIL_CAPS_ARCH_GCC_ARM_HPP_INCLUDED_