diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2014-03-07 11:43:06 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2014-03-07 11:43:06 +0400 |
commit | 9836fd5d131e405106508a5f706268e371418e05 (patch) | |
tree | 4a43934baccbb60e79ad3271eb0fb15e68c8bac3 /include/atomic/gcc_builtins.h | |
parent | 6dda6428d22021043ca7e3ea4ae9bce15def6947 (diff) | |
download | mariadb-git-9836fd5d131e405106508a5f706268e371418e05.tar.gz |
MDEV-5766 - my_atomic_load does memory writes
my_atomic_load() is implemented as __sync_fetch_and_or(var, 0) which
writes or-ed value back to var. Memory writes as such have worse
performance and scalability than reads.
gcc 4.7 and up offers better facility for atomic loads/stores. Use it
whenever it is available.
Diffstat (limited to 'include/atomic/gcc_builtins.h')
-rw-r--r-- | include/atomic/gcc_builtins.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h index fb6a537d204..6e807b3c51c 100644 --- a/include/atomic/gcc_builtins.h +++ b/include/atomic/gcc_builtins.h @@ -31,6 +31,12 @@ #define make_atomic_store_body(S) *a= v #define MY_ATOMIC_MODE "gcc-builtins-up" +#elif defined(__ATOMIC_SEQ_CST) +#define MY_ATOMIC_MODE "gcc-builtins-smp" +#define make_atomic_load_body(S) \ + ret= __atomic_load_n(a, __ATOMIC_SEQ_CST) +#define make_atomic_store_body(S) \ + __atomic_store_n(a, v, __ATOMIC_SEQ_CST) #else #define MY_ATOMIC_MODE "gcc-builtins-smp" #define make_atomic_load_body(S) \ |