Remove unsafe emulation-based implementation of double CAS (SunCC/x86)
authorIvan Maidanski <ivmai@mail.ru>
Sat, 29 Sep 2012 18:28:45 +0000 (22:28 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 29 Sep 2012 18:28:45 +0000 (22:28 +0400)
* src/atomic_ops/sysdeps/sunc/x86.h
(AO_compare_double_and_swap_double_full): Do not test
AO_WEAK_DOUBLE_CAS_EMULATION and remove emulation-based implementation
since it is unsafe (not atomic with respect to other kinds of updates)
leading to test_stack failure.
* configure.ac (AO_WEAK_DOUBLE_CAS_EMULATION): Update and refine
documentation.
* src/atomic_ops/sysdeps/sunc/x86.h
(AO_compare_double_and_swap_double_full): Likewise.

configure.ac
src/atomic_ops/sysdeps/sunc/x86.h

index fbb4df7..347c881 100644 (file)
@@ -136,7 +136,7 @@ AH_TEMPLATE([AO_USE_SYNC_CAS_BUILTIN],
          (only gcc/x86, gcc/x86_64)])
 AH_TEMPLATE([AO_WEAK_DOUBLE_CAS_EMULATION],
         [Emulate double-width CAS via pthread locking in case of no hardware \
-         support (only gcc/x86_64, sunc/x86_64)])
+         support (only gcc/x86_64, the emulation is unsafe)])
 
 THREADDLLIBS=
 have_pthreads=true
index bc4274b..7d2e8d2 100644 (file)
@@ -205,14 +205,8 @@ AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
 # define AO_HAVE_int_fetch_and_add_full
 
 # ifdef AO_CMPXCHG16B_AVAILABLE
-    /* NEC LE-IT: older AMD Opterons are missing this instruction.      */
-    /* On these machines SIGILL will be thrown.                         */
-    /* Define AO_WEAK_DOUBLE_CAS_EMULATION to have an emulated (lock    */
-    /* based) version available.                                        */
-    /* HB: Changed this to not define either by default.  There are     */
-    /* enough machines and tool chains around on which cmpxchg16b       */
-    /* doesn't work.  And the emulation is unsafe by our usual rules.   */
-    /* However both are clearly useful in certain cases.                */
+    /* Older AMD Opterons are missing this instruction (SIGILL should   */
+    /* be thrown in this case).                                         */
     AO_INLINE int
     AO_compare_double_and_swap_double_full (volatile AO_double_t *addr,
                                             AO_t old_val1, AO_t old_val2,
@@ -227,26 +221,6 @@ AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
       return (int) result;
     }
 #   define AO_HAVE_compare_double_and_swap_double_full
-
-# elif defined(AO_WEAK_DOUBLE_CAS_EMULATION)
-    /* This one provides spinlock based emulation of CAS implemented in */
-    /* atomic_ops.c.  We probably do not want to do this here, since it */
-    /* is not atomic with respect to other kinds of updates of *addr.   */
-    /* On the other hand, this may be a useful facility on occasion.    */
-    int AO_compare_double_and_swap_double_emulation(
-                                                volatile AO_double_t *addr,
-                                                AO_t old_val1, AO_t old_val2,
-                                                AO_t new_val1, AO_t new_val2);
-
-    AO_INLINE int
-    AO_compare_double_and_swap_double_full(volatile AO_double_t *addr,
-                                           AO_t old_val1, AO_t old_val2,
-                                           AO_t new_val1, AO_t new_val2)
-    {
-      return AO_compare_double_and_swap_double_emulation(addr,
-                                old_val1, old_val2, new_val1, new_val2);
-    }
-#   define AO_HAVE_compare_double_and_swap_double_full
-# endif /* AO_WEAK_DOUBLE_CAS_EMULATION && !AO_CMPXCHG16B_AVAILABLE */
+# endif /* !AO_CMPXCHG16B_AVAILABLE */
 
 #endif /* x64 */