The branch master has been updated via 1beca67688189f6542c7d08233c28e8fab73dba7 (commit) via 11fc6c761165283f5aed9aed5edd65c1bb963e79 (commit) via cb4b54c23b95e4638d643eb349d8d8dfa1cc2fd3 (commit) from 63db6b772fa264a62927f6a3584733192dc5a352 (commit)
- Log ----------------------------------------------------------------- commit 1beca67688189f6542c7d08233c28e8fab73dba7 Author: Richard Levitte <levi...@openssl.org> Date: Wed Aug 24 09:14:44 2016 +0200 CRYPTO_atomic_add(): check that the object is lock free If not, fall back to our own code, using the given mutex Reviewed-by: Andy Polyakov <ap...@openssl.org> commit 11fc6c761165283f5aed9aed5edd65c1bb963e79 Author: Richard Levitte <levi...@openssl.org> Date: Wed Aug 24 12:01:39 2016 +0200 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 <ap...@openssl.org> commit cb4b54c23b95e4638d643eb349d8d8dfa1cc2fd3 Author: Richard Levitte <levi...@openssl.org> Date: Wed Aug 24 13:03:20 2016 +0200 Check for __GNUC__ to use GNU C atomic buildins Note: we trust any other compiler that fully implements GNU extension to define __GNUC__ RT#4642 Reviewed-by: Andy Polyakov <ap...@openssl.org> ----------------------------------------------------------------------- Summary of changes: crypto/threads_pthread.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 6f5e812..5cc48af 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -109,9 +109,12 @@ 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) { -#ifdef __ATOMIC_RELAXED - *ret = __atomic_add_fetch(val, amount, __ATOMIC_RELAXED); -#else +# if defined(__GNUC__) && defined(__ATOMIC_ACQ_REL) + if (__atomic_is_lock_free(sizeof(*val), val)) { + *ret = __atomic_add_fetch(val, amount, __ATOMIC_ACQ_REL); + return 1; + } +# endif if (!CRYPTO_THREAD_write_lock(lock)) return 0; @@ -120,7 +123,6 @@ int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock) if (!CRYPTO_THREAD_unlock(lock)) return 0; -#endif return 1; } _____ openssl-commits mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-commits