]> granicus.if.org Git - libatomic_ops/commitdiff
Add assertion that double-wide CAS target is aligned (msftc/x86[_64])
authorIvan Maidanski <ivmai@mail.ru>
Fri, 20 Jan 2017 00:03:54 +0000 (03:03 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 6 Feb 2017 06:28:04 +0000 (09:28 +0300)
* 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.

src/atomic_ops/sysdeps/msftc/x86.h
src/atomic_ops/sysdeps/msftc/x86_64.h

index 7c2995a4e38e55bc8753d91f8a997b0e998e8a4f..1f87a12afb0240c4950fdc58bf0701d7b9740b21 100644 (file)
@@ -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 */,
index b4b0a3c1acc7a0af13058d0f11a34b5b12b06129..2bbc3fdeff9d3d0d689641a5f64ec59f357fac4c 100644 (file)
@@ -159,6 +159,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,