update master-with-bazel from master branch
This commit is contained in:
+1
-1
@@ -415,7 +415,7 @@ crypto_sources = [
|
||||
"src/crypto/rand_extra/windows.c",
|
||||
"src/crypto/rc4/rc4.c",
|
||||
"src/crypto/refcount_c11.c",
|
||||
"src/crypto/refcount_lock.c",
|
||||
"src/crypto/refcount_no_threads.c",
|
||||
"src/crypto/refcount_win.c",
|
||||
"src/crypto/rsa_extra/rsa_asn1.c",
|
||||
"src/crypto/rsa_extra/rsa_crypt.c",
|
||||
|
||||
+1
-1
@@ -408,7 +408,7 @@ add_library(
|
||||
src/crypto/rand_extra/windows.c
|
||||
src/crypto/rc4/rc4.c
|
||||
src/crypto/refcount_c11.c
|
||||
src/crypto/refcount_lock.c
|
||||
src/crypto/refcount_no_threads.c
|
||||
src/crypto/refcount_win.c
|
||||
src/crypto/rsa_extra/rsa_asn1.c
|
||||
src/crypto/rsa_extra/rsa_crypt.c
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@
|
||||
"src/crypto/rand_extra/windows.c",
|
||||
"src/crypto/rc4/rc4.c",
|
||||
"src/crypto/refcount_c11.c",
|
||||
"src/crypto/refcount_lock.c",
|
||||
"src/crypto/refcount_no_threads.c",
|
||||
"src/crypto/refcount_win.c",
|
||||
"src/crypto/rsa_extra/rsa_asn1.c",
|
||||
"src/crypto/rsa_extra/rsa_crypt.c",
|
||||
|
||||
@@ -203,7 +203,7 @@ add_library(
|
||||
rand_extra/windows.c
|
||||
rc4/rc4.c
|
||||
refcount_c11.c
|
||||
refcount_lock.c
|
||||
refcount_no_threads.c
|
||||
refcount_win.c
|
||||
rsa_extra/rsa_asn1.c
|
||||
rsa_extra/rsa_crypt.c
|
||||
|
||||
@@ -556,6 +556,16 @@ OPENSSL_EXPORT void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void));
|
||||
#define OPENSSL_WINDOWS_ATOMIC
|
||||
#endif
|
||||
|
||||
// Require some atomics implementation. Contact BoringSSL maintainers if you
|
||||
// have a platform with fails this check.
|
||||
//
|
||||
// Note this check can only be done in C. From C++, we don't know whether the
|
||||
// corresponding C mode would support C11 atomics.
|
||||
#if !defined(__cplusplus) && defined(OPENSSL_THREADS) && \
|
||||
!defined(OPENSSL_C11_ATOMIC) && !defined(OPENSSL_WINDOWS_ATOMIC)
|
||||
#error "Thread-compatible configurations require atomics"
|
||||
#endif
|
||||
|
||||
// CRYPTO_REFCOUNT_MAX is the value at which the reference count saturates.
|
||||
#define CRYPTO_REFCOUNT_MAX 0xffffffff
|
||||
|
||||
|
||||
@@ -18,35 +18,25 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#if !defined(OPENSSL_C11_ATOMIC) && !defined(OPENSSL_WINDOWS_ATOMIC)
|
||||
#if !defined(OPENSSL_THREADS)
|
||||
|
||||
static_assert((CRYPTO_refcount_t)-1 == CRYPTO_REFCOUNT_MAX,
|
||||
"CRYPTO_REFCOUNT_MAX is incorrect");
|
||||
|
||||
static struct CRYPTO_STATIC_MUTEX g_refcount_lock = CRYPTO_STATIC_MUTEX_INIT;
|
||||
|
||||
void CRYPTO_refcount_inc(CRYPTO_refcount_t *count) {
|
||||
CRYPTO_STATIC_MUTEX_lock_write(&g_refcount_lock);
|
||||
if (*count < CRYPTO_REFCOUNT_MAX) {
|
||||
(*count)++;
|
||||
}
|
||||
CRYPTO_STATIC_MUTEX_unlock_write(&g_refcount_lock);
|
||||
}
|
||||
|
||||
int CRYPTO_refcount_dec_and_test_zero(CRYPTO_refcount_t *count) {
|
||||
int ret;
|
||||
|
||||
CRYPTO_STATIC_MUTEX_lock_write(&g_refcount_lock);
|
||||
if (*count == 0) {
|
||||
abort();
|
||||
}
|
||||
if (*count < CRYPTO_REFCOUNT_MAX) {
|
||||
(*count)--;
|
||||
}
|
||||
ret = (*count == 0);
|
||||
CRYPTO_STATIC_MUTEX_unlock_write(&g_refcount_lock);
|
||||
|
||||
return ret;
|
||||
return *count == 0;
|
||||
}
|
||||
|
||||
#endif // !OPENSSL_C11_ATOMIC && !OPENSSL_WINDOWS_ATOMICS
|
||||
#endif // !OPENSSL_THREADS
|
||||
Reference in New Issue
Block a user