]> granicus.if.org Git - libatomic_ops/commitdiff
Eliminate redundant lwsync 2nd call in CAS_full on fail (gcc/PowerPC)
authorIvan Maidanski <ivmai@mail.ru>
Tue, 5 Apr 2016 21:10:56 +0000 (00:10 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 5 Apr 2016 21:10:56 +0000 (00:10 +0300)
* src/atomic_ops/sysdeps/gcc/powerpc.h (AO_compare_and_swap_full,
AO_fetch_compare_and_swap_full): Do not call AO_lwsync 2nd time if
CAS is not successful.

src/atomic_ops/sysdeps/gcc/powerpc.h

index 94e83e7a19a2bbec1a97a1e5f7e98adc734b1c8d..5bee4755d8e705b896043d36ad8bcee49a529831 100644 (file)
@@ -227,7 +227,8 @@ AO_test_and_set_full(volatile AO_TS_t *addr) {
     int result;
     AO_lwsync();
     result = AO_compare_and_swap(addr, old, new_val);
-    AO_lwsync();
+    if (result)
+      AO_lwsync();
     return result;
   }
 # define AO_HAVE_compare_and_swap_full
@@ -291,7 +292,8 @@ AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
   AO_t result;
   AO_lwsync();
   result = AO_fetch_compare_and_swap(addr, old_val, new_val);
-  AO_lwsync();
+  if (result == old_val)
+    AO_lwsync();
   return result;
 }
 #define AO_HAVE_fetch_compare_and_swap_full