summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2017-01-20 03:03:54 +0300
committerIvan Maidanski <ivmai@mail.ru>2017-01-20 03:03:54 +0300
commite213ec3b782fe18babff4044a36d9a1c0a894f52 (patch)
treef99b5f782e357b72cafc5a67ee0a06d3ccdeab24
parent45896dc8681951f6ef3e0fcb7dd38e7e2a435411 (diff)
downloadlibatomic_ops-e213ec3b782fe18babff4044a36d9a1c0a894f52.tar.gz
Add assertion that double-wide CAS target is aligned (msftc/x86[_64])
* src/atomic_ops/sysdeps/msftc/x86.h [AO_ASSUME_VISTA] (AO_double_compare_and_swap_full): Add assert() that addr pointer is aligned according to the size of AO_double_t. * src/atomic_ops/sysdeps/msftc/x86_64.h [AO_CMPXCHG16B_AVAILABLE && _MSC_VER>=1500] (AO_compare_double_and_swap_double_full): Likewise.
-rw-r--r--src/atomic_ops/sysdeps/msftc/x86.h1
-rw-r--r--src/atomic_ops/sysdeps/msftc/x86_64.h2
2 files changed, 3 insertions, 0 deletions
diff --git a/src/atomic_ops/sysdeps/msftc/x86.h b/src/atomic_ops/sysdeps/msftc/x86.h
index 0e26aaa..aa6ca1b 100644
--- a/src/atomic_ops/sysdeps/msftc/x86.h
+++ b/src/atomic_ops/sysdeps/msftc/x86.h
@@ -124,6 +124,7 @@ AO_test_and_set_full(volatile AO_TS_t *addr)
AO_double_compare_and_swap_full(volatile AO_double_t *addr,
AO_double_t old_val, AO_double_t new_val)
{
+ assert(((size_t)addr & (sizeof(AO_double_t) - 1)) == 0);
return (double_ptr_storage)_InterlockedCompareExchange64(
(__int64 volatile *)addr,
new_val.AO_whole /* exchange */,
diff --git a/src/atomic_ops/sysdeps/msftc/x86_64.h b/src/atomic_ops/sysdeps/msftc/x86_64.h
index 41df6e2..c06d0e9 100644
--- a/src/atomic_ops/sysdeps/msftc/x86_64.h
+++ b/src/atomic_ops/sysdeps/msftc/x86_64.h
@@ -186,6 +186,8 @@ AO_compare_double_and_swap_double_full(volatile AO_double_t *addr,
AO_t new_val1, AO_t new_val2)
{
__int64 comparandResult[2];
+
+ assert(((size_t)addr & (sizeof(AO_double_t) - 1)) == 0);
comparandResult[0] = old_val1; /* low */
comparandResult[1] = old_val2; /* high */
return _InterlockedCompareExchange128((volatile __int64 *)addr,