提交 1beca676 编写于 作者: R Richard Levitte 提交者: Matt Caswell

CRYPTO_atomic_add(): check that the object is lock free

If not, fall back to our own code, using the given mutex
Reviewed-by: NAndy Polyakov <appro@openssl.org>
上级 11fc6c76
......@@ -110,8 +110,11 @@ 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_ACQ_REL)
*ret = __atomic_add_fetch(val, amount, __ATOMIC_ACQ_REL);
# else
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册