diff options
author | Richard Levitte <levitte@openssl.org> | 2016-08-24 12:01:39 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-08-24 14:37:40 +0100 |
commit | 11fc6c761165283f5aed9aed5edd65c1bb963e79 (patch) | |
tree | e90ca43f2990f3e9110127e0db2050664fda1135 | |
parent | cb4b54c23b95e4638d643eb349d8d8dfa1cc2fd3 (diff) |
CRYPTO_atomic_add(): use acquire release memory order rather than relaxed
For increments, the relaxed model is fine. For decrements, it's
recommended to use the acquire release model. We therefore go for the
latter.
Reviewed-by: Andy Polyakov <appro@openssl.org>
-rw-r--r-- | crypto/threads_pthread.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 72ea83892b..9f4ae76bf8 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -109,8 +109,8 @@ int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b) int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock) { -# if defined(__GNUC__) && defined(__ATOMIC_RELAXED) - *ret = __atomic_add_fetch(val, amount, __ATOMIC_RELAXED); +# if defined(__GNUC__) && defined(__ATOMIC_ACQ_REL) + *ret = __atomic_add_fetch(val, amount, __ATOMIC_ACQ_REL); # else if (!CRYPTO_THREAD_write_lock(lock)) return 0; |