summaryrefslogtreecommitdiff
path: root/boost/atomic/detail/ops_msvc_x86.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/atomic/detail/ops_msvc_x86.hpp')
-rw-r--r--boost/atomic/detail/ops_msvc_x86.hpp127
1 files changed, 46 insertions, 81 deletions
diff --git a/boost/atomic/detail/ops_msvc_x86.hpp b/boost/atomic/detail/ops_msvc_x86.hpp
index 85bed28ad1..70b0ea994b 100644
--- a/boost/atomic/detail/ops_msvc_x86.hpp
+++ b/boost/atomic/detail/ops_msvc_x86.hpp
@@ -73,6 +73,7 @@ namespace detail {
struct msvc_x86_operations_base
{
+ static BOOST_CONSTEXPR_OR_CONST bool full_cas_based = false;
static BOOST_CONSTEXPR_OR_CONST bool is_always_lock_free = true;
static BOOST_FORCEINLINE void hardware_full_fence() BOOST_NOEXCEPT
@@ -107,11 +108,15 @@ struct msvc_x86_operations_base
}
};
-template< typename T, typename Derived >
+template< std::size_t Size, bool Signed, typename Derived >
struct msvc_x86_operations :
public msvc_x86_operations_base
{
- typedef T storage_type;
+ typedef typename make_storage_type< Size >::type storage_type;
+ typedef typename make_storage_type< Size >::aligned aligned_storage_type;
+
+ static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = Size;
+ static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed;
static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
@@ -159,14 +164,10 @@ struct msvc_x86_operations :
template< bool Signed >
struct operations< 4u, Signed > :
- public msvc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > >
+ public msvc_x86_operations< 4u, Signed, operations< 4u, Signed > >
{
- typedef msvc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type;
+ typedef msvc_x86_operations< 4u, Signed, operations< 4u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
- typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type;
-
- static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 4u;
- static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
@@ -234,14 +235,10 @@ struct operations< 4u, Signed > :
template< bool Signed >
struct operations< 1u, Signed > :
- public msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > >
+ public msvc_x86_operations< 1u, Signed, operations< 1u, Signed > >
{
- typedef msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type;
+ typedef msvc_x86_operations< 1u, Signed, operations< 1u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
- typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type;
-
- static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 1u;
- static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
@@ -282,14 +279,10 @@ struct operations< 1u, Signed > :
template< bool Signed >
struct operations< 1u, Signed > :
- public msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > >
+ public msvc_x86_operations< 1u, Signed, operations< 1u, Signed > >
{
- typedef msvc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type;
+ typedef msvc_x86_operations< 1u, Signed, operations< 1u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
- typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type;
-
- static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 1u;
- static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
@@ -342,22 +335,19 @@ struct operations< 1u, Signed > :
static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
- int backup;
__asm
{
- mov backup, ebx
- xor edx, edx
mov edi, storage
- movzx ebx, v
+ movzx ecx, v
+ xor edx, edx
movzx eax, byte ptr [edi]
align 16
again:
mov dl, al
- and dl, bl
+ and dl, cl
lock cmpxchg byte ptr [edi], dl
jne again
mov v, al
- mov ebx, backup
};
base_type::fence_after(order);
return v;
@@ -366,22 +356,19 @@ struct operations< 1u, Signed > :
static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
- int backup;
__asm
{
- mov backup, ebx
- xor edx, edx
mov edi, storage
- movzx ebx, v
+ movzx ecx, v
+ xor edx, edx
movzx eax, byte ptr [edi]
align 16
again:
mov dl, al
- or dl, bl
+ or dl, cl
lock cmpxchg byte ptr [edi], dl
jne again
mov v, al
- mov ebx, backup
};
base_type::fence_after(order);
return v;
@@ -390,22 +377,19 @@ struct operations< 1u, Signed > :
static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
- int backup;
__asm
{
- mov backup, ebx
- xor edx, edx
mov edi, storage
- movzx ebx, v
+ movzx ecx, v
+ xor edx, edx
movzx eax, byte ptr [edi]
align 16
again:
mov dl, al
- xor dl, bl
+ xor dl, cl
lock cmpxchg byte ptr [edi], dl
jne again
mov v, al
- mov ebx, backup
};
base_type::fence_after(order);
return v;
@@ -426,14 +410,10 @@ struct operations< 1u, Signed > :
template< bool Signed >
struct operations< 2u, Signed > :
- public msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > >
+ public msvc_x86_operations< 2u, Signed, operations< 2u, Signed > >
{
- typedef msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type;
+ typedef msvc_x86_operations< 2u, Signed, operations< 2u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
- typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type;
-
- static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 2u;
- static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
@@ -474,14 +454,10 @@ struct operations< 2u, Signed > :
template< bool Signed >
struct operations< 2u, Signed > :
- public msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > >
+ public msvc_x86_operations< 2u, Signed, operations< 2u, Signed > >
{
- typedef msvc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type;
+ typedef msvc_x86_operations< 2u, Signed, operations< 2u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
- typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type;
-
- static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 2u;
- static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
@@ -534,22 +510,19 @@ struct operations< 2u, Signed > :
static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
- int backup;
__asm
{
- mov backup, ebx
- xor edx, edx
mov edi, storage
- movzx ebx, v
+ movzx ecx, v
+ xor edx, edx
movzx eax, word ptr [edi]
align 16
again:
mov dx, ax
- and dx, bx
+ and dx, cx
lock cmpxchg word ptr [edi], dx
jne again
mov v, ax
- mov ebx, backup
};
base_type::fence_after(order);
return v;
@@ -558,22 +531,19 @@ struct operations< 2u, Signed > :
static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
- int backup;
__asm
{
- mov backup, ebx
- xor edx, edx
mov edi, storage
- movzx ebx, v
+ movzx ecx, v
+ xor edx, edx
movzx eax, word ptr [edi]
align 16
again:
mov dx, ax
- or dx, bx
+ or dx, cx
lock cmpxchg word ptr [edi], dx
jne again
mov v, ax
- mov ebx, backup
};
base_type::fence_after(order);
return v;
@@ -582,22 +552,19 @@ struct operations< 2u, Signed > :
static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
- int backup;
__asm
{
- mov backup, ebx
- xor edx, edx
mov edi, storage
- movzx ebx, v
+ movzx ecx, v
+ xor edx, edx
movzx eax, word ptr [edi]
align 16
again:
mov dx, ax
- xor dx, bx
+ xor dx, cx
lock cmpxchg word ptr [edi], dx
jne again
mov v, ax
- mov ebx, backup
};
base_type::fence_after(order);
return v;
@@ -620,9 +587,10 @@ struct operations< 2u, Signed > :
template< bool Signed >
struct msvc_dcas_x86
{
- typedef typename make_storage_type< 8u, Signed >::type storage_type;
- typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type;
+ typedef typename make_storage_type< 8u >::type storage_type;
+ typedef typename make_storage_type< 8u >::aligned aligned_storage_type;
+ static BOOST_CONSTEXPR_OR_CONST bool full_cas_based = true;
static BOOST_CONSTEXPR_OR_CONST bool is_always_lock_free = true;
static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 8u;
@@ -670,7 +638,7 @@ struct msvc_dcas_x86
}
else
{
- int backup;
+ uint32_t backup;
__asm
{
mov backup, ebx
@@ -758,7 +726,7 @@ struct msvc_dcas_x86
expected = old_val;
#else
bool result;
- int backup;
+ uint32_t backup;
__asm
{
mov backup, ebx
@@ -791,7 +759,7 @@ struct msvc_dcas_x86
BOOST_ATOMIC_DETAIL_COMPILER_BARRIER();
storage_type volatile* p = &storage;
- int backup;
+ uint32_t backup;
__asm
{
mov backup, ebx
@@ -825,14 +793,10 @@ struct operations< 8u, Signed > :
template< bool Signed >
struct operations< 8u, Signed > :
- public msvc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > >
+ public msvc_x86_operations< 8u, Signed, operations< 8u, Signed > >
{
- typedef msvc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type;
+ typedef msvc_x86_operations< 8u, Signed, operations< 8u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
- typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type;
-
- static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 8u;
- static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
@@ -876,9 +840,10 @@ struct operations< 8u, Signed > :
template< bool Signed >
struct msvc_dcas_x86_64
{
- typedef typename make_storage_type< 16u, Signed >::type storage_type;
- typedef typename make_storage_type< 16u, Signed >::aligned aligned_storage_type;
+ typedef typename make_storage_type< 16u >::type storage_type;
+ typedef typename make_storage_type< 16u >::aligned aligned_storage_type;
+ static BOOST_CONSTEXPR_OR_CONST bool full_cas_based = true;
static BOOST_CONSTEXPR_OR_CONST bool is_always_lock_free = true;
static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 16u;