summaryrefslogtreecommitdiff
path: root/boost/atomic/detail/extra_ops_msvc_x86.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/atomic/detail/extra_ops_msvc_x86.hpp')
-rw-r--r--boost/atomic/detail/extra_ops_msvc_x86.hpp473
1 files changed, 454 insertions, 19 deletions
diff --git a/boost/atomic/detail/extra_ops_msvc_x86.hpp b/boost/atomic/detail/extra_ops_msvc_x86.hpp
index 6d95dbed74..17451a83d6 100644
--- a/boost/atomic/detail/extra_ops_msvc_x86.hpp
+++ b/boost/atomic/detail/extra_ops_msvc_x86.hpp
@@ -109,7 +109,7 @@ struct msvc_x86_extra_operations_common :
};
template< typename Base, bool Signed >
-struct extra_operations< Base, 1u, Signed > :
+struct extra_operations< Base, 1u, Signed, true > :
public msvc_x86_extra_operations_common< Base, 1u, Signed >
{
typedef msvc_x86_extra_operations_common< Base, 1u, Signed > base_type;
@@ -136,6 +136,47 @@ struct extra_operations< Base, 1u, Signed > :
return old_val;
}
+ static BOOST_FORCEINLINE storage_type negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ storage_type new_val;
+ __asm
+ {
+ mov ecx, storage
+ movzx eax, byte ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ neg dl
+ lock cmpxchg byte ptr [ecx], dl
+ jne again
+ mov new_val, dl
+ };
+ base_type::fence_after(order);
+ return new_val;
+ }
+
+ static BOOST_FORCEINLINE bool negate_and_test(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ bool result;
+ __asm
+ {
+ mov ecx, storage
+ movzx eax, byte ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ neg dl
+ lock cmpxchg byte ptr [ecx], dl
+ jne again
+ test dl, dl
+ setnz result
+ };
+ base_type::fence_after(order);
+ return result;
+ }
+
static BOOST_FORCEINLINE void opaque_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -153,6 +194,69 @@ struct extra_operations< Base, 1u, Signed > :
base_type::fence_after(order);
}
+ static BOOST_FORCEINLINE storage_type bitwise_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ movzx ecx, v
+ xor edx, edx
+ movzx eax, byte ptr [edi]
+ align 16
+ again:
+ mov dl, al
+ and dl, cl
+ lock cmpxchg byte ptr [edi], dl
+ jne again
+ mov v, dl
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
+ static BOOST_FORCEINLINE storage_type bitwise_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ movzx ecx, v
+ xor edx, edx
+ movzx eax, byte ptr [edi]
+ align 16
+ again:
+ mov dl, al
+ or dl, cl
+ lock cmpxchg byte ptr [edi], dl
+ jne again
+ mov v, dl
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
+ static BOOST_FORCEINLINE storage_type bitwise_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ movzx ecx, v
+ xor edx, edx
+ movzx eax, byte ptr [edi]
+ align 16
+ again:
+ mov dl, al
+ xor dl, cl
+ lock cmpxchg byte ptr [edi], dl
+ jne again
+ mov v, dl
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
static BOOST_FORCEINLINE storage_type fetch_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -173,6 +277,47 @@ struct extra_operations< Base, 1u, Signed > :
return old_val;
}
+ static BOOST_FORCEINLINE storage_type bitwise_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ storage_type new_val;
+ __asm
+ {
+ mov ecx, storage
+ movzx eax, byte ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ not dl
+ lock cmpxchg byte ptr [ecx], dl
+ jne again
+ mov new_val, dl
+ };
+ base_type::fence_after(order);
+ return new_val;
+ }
+
+ static BOOST_FORCEINLINE bool complement_and_test(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ bool result;
+ __asm
+ {
+ mov ecx, storage
+ movzx eax, byte ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ not dl
+ lock cmpxchg byte ptr [ecx], dl
+ jne again
+ test dl, dl
+ setnz result
+ };
+ base_type::fence_after(order);
+ return result;
+ }
+
static BOOST_FORCEINLINE void opaque_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -281,7 +426,7 @@ struct extra_operations< Base, 1u, Signed > :
mov edx, storage
movzx eax, v
lock add byte ptr [edx], al
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -296,7 +441,7 @@ struct extra_operations< Base, 1u, Signed > :
mov edx, storage
movzx eax, v
lock sub byte ptr [edx], al
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -311,7 +456,7 @@ struct extra_operations< Base, 1u, Signed > :
mov edx, storage
movzx eax, v
lock and byte ptr [edx], al
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -326,7 +471,7 @@ struct extra_operations< Base, 1u, Signed > :
mov edx, storage
movzx eax, v
lock or byte ptr [edx], al
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -341,7 +486,7 @@ struct extra_operations< Base, 1u, Signed > :
mov edx, storage
movzx eax, v
lock xor byte ptr [edx], al
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -350,7 +495,7 @@ struct extra_operations< Base, 1u, Signed > :
};
template< typename Base, bool Signed >
-struct extra_operations< Base, 2u, Signed > :
+struct extra_operations< Base, 2u, Signed, true > :
public msvc_x86_extra_operations_common< Base, 2u, Signed >
{
typedef msvc_x86_extra_operations_common< Base, 2u, Signed > base_type;
@@ -377,6 +522,47 @@ struct extra_operations< Base, 2u, Signed > :
return old_val;
}
+ static BOOST_FORCEINLINE storage_type negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ storage_type new_val;
+ __asm
+ {
+ mov ecx, storage
+ movzx eax, word ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ neg dx
+ lock cmpxchg word ptr [ecx], dx
+ jne again
+ mov new_val, dx
+ };
+ base_type::fence_after(order);
+ return new_val;
+ }
+
+ static BOOST_FORCEINLINE bool negate_and_test(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ bool result;
+ __asm
+ {
+ mov ecx, storage
+ movzx eax, word ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ neg dx
+ lock cmpxchg word ptr [ecx], dx
+ jne again
+ test dx, dx
+ setnz result
+ };
+ base_type::fence_after(order);
+ return result;
+ }
+
static BOOST_FORCEINLINE void opaque_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -394,6 +580,69 @@ struct extra_operations< Base, 2u, Signed > :
base_type::fence_after(order);
}
+ static BOOST_FORCEINLINE storage_type bitwise_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ movzx ecx, v
+ xor edx, edx
+ movzx eax, word ptr [edi]
+ align 16
+ again:
+ mov dx, ax
+ and dx, cx
+ lock cmpxchg word ptr [edi], dx
+ jne again
+ mov v, dx
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
+ static BOOST_FORCEINLINE storage_type bitwise_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ movzx ecx, v
+ xor edx, edx
+ movzx eax, word ptr [edi]
+ align 16
+ again:
+ mov dx, ax
+ or dx, cx
+ lock cmpxchg word ptr [edi], dx
+ jne again
+ mov v, dx
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
+ static BOOST_FORCEINLINE storage_type bitwise_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ movzx ecx, v
+ xor edx, edx
+ movzx eax, word ptr [edi]
+ align 16
+ again:
+ mov dx, ax
+ xor dx, cx
+ lock cmpxchg word ptr [edi], dx
+ jne again
+ mov v, dx
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
static BOOST_FORCEINLINE storage_type fetch_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -414,6 +663,47 @@ struct extra_operations< Base, 2u, Signed > :
return old_val;
}
+ static BOOST_FORCEINLINE storage_type bitwise_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ storage_type new_val;
+ __asm
+ {
+ mov ecx, storage
+ movzx eax, word ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ not dx
+ lock cmpxchg word ptr [ecx], dx
+ jne again
+ mov new_val, dx
+ };
+ base_type::fence_after(order);
+ return new_val;
+ }
+
+ static BOOST_FORCEINLINE bool complement_and_test(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ bool result;
+ __asm
+ {
+ mov ecx, storage
+ movzx eax, word ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ not dx
+ lock cmpxchg word ptr [ecx], dx
+ jne again
+ test dx, dx
+ setnz result
+ };
+ base_type::fence_after(order);
+ return result;
+ }
+
static BOOST_FORCEINLINE void opaque_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -522,7 +812,7 @@ struct extra_operations< Base, 2u, Signed > :
mov edx, storage
movzx eax, v
lock add word ptr [edx], ax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -537,7 +827,7 @@ struct extra_operations< Base, 2u, Signed > :
mov edx, storage
movzx eax, v
lock sub word ptr [edx], ax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -552,7 +842,7 @@ struct extra_operations< Base, 2u, Signed > :
mov edx, storage
movzx eax, v
lock and word ptr [edx], ax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -567,7 +857,7 @@ struct extra_operations< Base, 2u, Signed > :
mov edx, storage
movzx eax, v
lock or word ptr [edx], ax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -582,7 +872,7 @@ struct extra_operations< Base, 2u, Signed > :
mov edx, storage
movzx eax, v
lock xor word ptr [edx], ax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -591,7 +881,7 @@ struct extra_operations< Base, 2u, Signed > :
};
template< typename Base, bool Signed >
-struct extra_operations< Base, 4u, Signed > :
+struct extra_operations< Base, 4u, Signed, true > :
public msvc_x86_extra_operations_common< Base, 4u, Signed >
{
typedef msvc_x86_extra_operations_common< Base, 4u, Signed > base_type;
@@ -618,6 +908,47 @@ struct extra_operations< Base, 4u, Signed > :
return old_val;
}
+ static BOOST_FORCEINLINE storage_type negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ storage_type new_val;
+ __asm
+ {
+ mov ecx, storage
+ mov eax, dword ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ neg edx
+ lock cmpxchg dword ptr [ecx], edx
+ jne again
+ mov new_val, edx
+ };
+ base_type::fence_after(order);
+ return new_val;
+ }
+
+ static BOOST_FORCEINLINE bool negate_and_test(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ bool result;
+ __asm
+ {
+ mov ecx, storage
+ mov eax, dword ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ neg edx
+ lock cmpxchg dword ptr [ecx], edx
+ jne again
+ test edx, edx
+ setnz result
+ };
+ base_type::fence_after(order);
+ return result;
+ }
+
static BOOST_FORCEINLINE void opaque_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -635,6 +966,69 @@ struct extra_operations< Base, 4u, Signed > :
base_type::fence_after(order);
}
+ static BOOST_FORCEINLINE storage_type bitwise_and(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ mov ecx, v
+ xor edx, edx
+ mov eax, dword ptr [edi]
+ align 16
+ again:
+ mov edx, eax
+ and edx, ecx
+ lock cmpxchg dword ptr [edi], edx
+ jne again
+ mov v, edx
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
+ static BOOST_FORCEINLINE storage_type bitwise_or(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ mov ecx, v
+ xor edx, edx
+ mov eax, dword ptr [edi]
+ align 16
+ again:
+ mov edx, eax
+ or edx, ecx
+ lock cmpxchg dword ptr [edi], edx
+ jne again
+ mov v, edx
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
+ static BOOST_FORCEINLINE storage_type bitwise_xor(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ __asm
+ {
+ mov edi, storage
+ mov ecx, v
+ xor edx, edx
+ mov eax, dword ptr [edi]
+ align 16
+ again:
+ mov edx, eax
+ xor edx, ecx
+ lock cmpxchg dword ptr [edi], edx
+ jne again
+ mov v, edx
+ };
+ base_type::fence_after(order);
+ return v;
+ }
+
static BOOST_FORCEINLINE storage_type fetch_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -655,6 +1049,47 @@ struct extra_operations< Base, 4u, Signed > :
return old_val;
}
+ static BOOST_FORCEINLINE storage_type bitwise_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ storage_type new_val;
+ __asm
+ {
+ mov ecx, storage
+ mov eax, dword ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ not edx
+ lock cmpxchg dword ptr [ecx], edx
+ jne again
+ mov new_val, edx
+ };
+ base_type::fence_after(order);
+ return new_val;
+ }
+
+ static BOOST_FORCEINLINE bool complement_and_test(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
+ {
+ base_type::fence_before(order);
+ bool result;
+ __asm
+ {
+ mov ecx, storage
+ mov eax, dword ptr [ecx]
+ align 16
+ again:
+ mov edx, eax
+ not edx
+ lock cmpxchg dword ptr [ecx], edx
+ jne again
+ test edx, edx
+ setnz result
+ };
+ base_type::fence_after(order);
+ return result;
+ }
+
static BOOST_FORCEINLINE void opaque_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
base_type::fence_before(order);
@@ -763,7 +1198,7 @@ struct extra_operations< Base, 4u, Signed > :
mov edx, storage
mov eax, v
lock add dword ptr [edx], eax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -778,7 +1213,7 @@ struct extra_operations< Base, 4u, Signed > :
mov edx, storage
mov eax, v
lock sub dword ptr [edx], eax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -793,7 +1228,7 @@ struct extra_operations< Base, 4u, Signed > :
mov edx, storage
mov eax, v
lock and dword ptr [edx], eax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -808,7 +1243,7 @@ struct extra_operations< Base, 4u, Signed > :
mov edx, storage
mov eax, v
lock or dword ptr [edx], eax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -823,7 +1258,7 @@ struct extra_operations< Base, 4u, Signed > :
mov edx, storage
mov eax, v
lock xor dword ptr [edx], eax
- setz result
+ setnz result
};
base_type::fence_after(order);
return result;
@@ -836,7 +1271,7 @@ struct extra_operations< Base, 4u, Signed > :
#if defined(BOOST_ATOMIC_INTERLOCKED_BTS64) && defined(BOOST_ATOMIC_INTERLOCKED_BTR64)
template< typename Base, bool Signed >
-struct extra_operations< Base, 8u, Signed > :
+struct extra_operations< Base, 8u, Signed, true > :
public generic_extra_operations< Base, 8u, Signed >
{
typedef generic_extra_operations< Base, 8u, Signed > base_type;