summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-04-06 00:10:56 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-04-06 00:10:56 +0300
commit157e8ad79a1bcc3d0ab331ab2217a9b81f35864c (patch)
tree726421123a504cc63547e83dc01bfd592e5f3733
parent3315a037247cd7f468d5bd863c52230d05548dcd (diff)
downloadlibatomic_ops-157e8ad79a1bcc3d0ab331ab2217a9b81f35864c.tar.gz
Eliminate redundant lwsync 2nd call in CAS_full on fail (gcc/PowerPC)
* 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.
-rw-r--r--src/atomic_ops/sysdeps/gcc/powerpc.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/atomic_ops/sysdeps/gcc/powerpc.h b/src/atomic_ops/sysdeps/gcc/powerpc.h
index 94e83e7..5bee475 100644
--- a/src/atomic_ops/sysdeps/gcc/powerpc.h
+++ b/src/atomic_ops/sysdeps/gcc/powerpc.h
@@ -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