mirror of
https://github.com/openssl/openssl.git
synced 2024-12-15 04:53:52 +08:00
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>
This commit is contained in:
parent
cb4b54c23b
commit
11fc6c7611
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user