summaryrefslogtreecommitdiff
path: root/boost/atomic
diff options
context:
space:
mode:
Diffstat (limited to 'boost/atomic')
-rw-r--r--boost/atomic/detail/bitwise_cast.hpp15
-rw-r--r--boost/atomic/detail/interlocked.hpp9
-rw-r--r--boost/atomic/detail/ops_gcc_x86_dcas.hpp14
-rw-r--r--boost/atomic/detail/platform.hpp2
4 files changed, 30 insertions, 10 deletions
diff --git a/boost/atomic/detail/bitwise_cast.hpp b/boost/atomic/detail/bitwise_cast.hpp
index 8654d10b95..1405a25d6a 100644
--- a/boost/atomic/detail/bitwise_cast.hpp
+++ b/boost/atomic/detail/bitwise_cast.hpp
@@ -29,6 +29,17 @@ namespace boost {
namespace atomics {
namespace detail {
+template< typename T >
+BOOST_FORCEINLINE T* addressof(T& value) BOOST_NOEXCEPT
+{
+ // Note: The point of using a local struct as the intermediate type instead of char is to avoid gcc warnings
+ // if T is a const volatile char*:
+ // warning: casting ‘const volatile char* const’ to ‘const volatile char&’ does not dereference pointer
+ // The local struct makes sure T is not related to the cast target type.
+ struct opaque_type;
+ return reinterpret_cast< T* >(&const_cast< opaque_type& >(reinterpret_cast< const volatile opaque_type& >(value)));
+}
+
template< typename To, typename From >
BOOST_FORCEINLINE To bitwise_cast(From const& from) BOOST_NOEXCEPT
{
@@ -39,8 +50,8 @@ BOOST_FORCEINLINE To bitwise_cast(From const& from) BOOST_NOEXCEPT
value = {};
BOOST_ATOMIC_DETAIL_MEMCPY
(
- &reinterpret_cast< char& >(value.to),
- &reinterpret_cast< const char& >(from),
+ atomics::detail::addressof(value.to),
+ atomics::detail::addressof(from),
(sizeof(From) < sizeof(To) ? sizeof(From) : sizeof(To))
);
return value.to;
diff --git a/boost/atomic/detail/interlocked.hpp b/boost/atomic/detail/interlocked.hpp
index 1c62396bf5..82b6d3a0dc 100644
--- a/boost/atomic/detail/interlocked.hpp
+++ b/boost/atomic/detail/interlocked.hpp
@@ -169,7 +169,7 @@ extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
#endif
-#if _MSC_VER >= 1700 && defined(_M_ARM)
+#if _MSC_VER >= 1700 && (defined(_M_ARM) || defined(_M_ARM64))
#if defined(BOOST_MSVC)
#pragma intrinsic(_InterlockedExchangeAdd64)
@@ -251,10 +251,17 @@ extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_ACQUIRE(dest, addend) _InterlockedExchangeAdd64_acq((__int64*)(dest), (__int64)(addend))
#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELEASE(dest, addend) _InterlockedExchangeAdd64_rel((__int64*)(dest), (__int64)(addend))
+#if defined(_M_ARM64)
+#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64((__int64*)(dest), byte_offset))
+#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_RELAXED(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELAXED((__int64*)(dest), byte_offset))
+#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_ACQUIRE(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_ACQUIRE((__int64*)(dest), byte_offset))
+#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_RELEASE(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD64_RELEASE((__int64*)(dest), byte_offset))
+#else
#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD((long*)(dest), byte_offset))
#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_RELAXED(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELAXED((long*)(dest), byte_offset))
#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_ACQUIRE(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_ACQUIRE((long*)(dest), byte_offset))
#define BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_POINTER_RELEASE(dest, byte_offset) ((void*)BOOST_ATOMIC_INTERLOCKED_EXCHANGE_ADD_RELEASE((long*)(dest), byte_offset))
+#endif
#if defined(BOOST_MSVC)
#pragma intrinsic(_InterlockedExchange8_nf)
diff --git a/boost/atomic/detail/ops_gcc_x86_dcas.hpp b/boost/atomic/detail/ops_gcc_x86_dcas.hpp
index 2f51182e5a..e356e8cfbd 100644
--- a/boost/atomic/detail/ops_gcc_x86_dcas.hpp
+++ b/boost/atomic/detail/ops_gcc_x86_dcas.hpp
@@ -73,6 +73,7 @@ struct gcc_dcas_x86
{
#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS)
#if defined(__PIC__)
+ uint32_t v_lo = (uint32_t)v;
uint32_t scratch;
__asm__ __volatile__
(
@@ -84,8 +85,8 @@ struct gcc_dcas_x86
"1: lock; cmpxchg8b %[dest]\n\t"
"jne 1b\n\t"
"movl %[scratch], %%ebx\n\t"
- : [scratch] "=m" (scratch), [dest] "=o" (storage)
- : [value_lo] "a" ((uint32_t)v), "c" ((uint32_t)(v >> 32))
+ : [scratch] "=m" (scratch), [dest] "=o" (storage), [value_lo] "+a" (v_lo)
+ : "c" ((uint32_t)(v >> 32))
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "edx", "memory"
);
#else // defined(__PIC__)
@@ -103,6 +104,7 @@ struct gcc_dcas_x86
#endif // defined(__PIC__)
#else // !defined(BOOST_ATOMIC_DETAIL_NO_ASM_IMPLIED_ZERO_DISPLACEMENTS)
#if defined(__PIC__)
+ uint32_t v_lo = (uint32_t)v;
uint32_t scratch;
__asm__ __volatile__
(
@@ -115,11 +117,11 @@ struct gcc_dcas_x86
"jne 1b\n\t"
"movl %[scratch], %%ebx\n\t"
#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES)
- : [scratch] "=m,m" (scratch)
- : [value_lo] "a,a" ((uint32_t)v), "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage)
+ : [scratch] "=m,m" (scratch), [value_lo] "+a,a" (v_lo)
+ : "c,c" ((uint32_t)(v >> 32)), [dest] "D,S" (&storage)
#else
- : [scratch] "=m" (scratch)
- : [value_lo] "a" ((uint32_t)v), "c" ((uint32_t)(v >> 32)), [dest] "D" (&storage)
+ : [scratch] "=m" (scratch), [value_lo] "+a" (v_lo)
+ : "c" ((uint32_t)(v >> 32)), [dest] "D" (&storage)
#endif
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "edx", "memory"
);
diff --git a/boost/atomic/detail/platform.hpp b/boost/atomic/detail/platform.hpp
index 34be8e6a0a..cc3cf1b67a 100644
--- a/boost/atomic/detail/platform.hpp
+++ b/boost/atomic/detail/platform.hpp
@@ -88,7 +88,7 @@
#define BOOST_ATOMIC_DETAIL_PLATFORM msvc_x86
-#elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_M_ARM)
+#elif defined(_MSC_VER) && _MSC_VER >= 1700 && (defined(_M_ARM) || defined(_M_ARM64))
#define BOOST_ATOMIC_DETAIL_PLATFORM msvc_arm