summaryrefslogtreecommitdiffstats
path: root/crypto/threads_pthread.c
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-05-17 13:15:01 +0100
committerHugo Landau <hlandau@openssl.org>2023-05-24 10:34:54 +0100
commit629b408c12c56b2c9e3279de8658718e8dd658a2 (patch)
tree13916b230422a8d1b27fcf9467ce8bbdcb45646f /crypto/threads_pthread.c
parent1a0de4c1eea1f32a3e1113add26625d49b3854d8 (diff)
QUIC: Fix bugs where threading is disabled
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20856)
Diffstat (limited to 'crypto/threads_pthread.c')
-rw-r--r--crypto/threads_pthread.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c
index 4aeba50479..a511271c53 100644
--- a/crypto/threads_pthread.c
+++ b/crypto/threads_pthread.c
@@ -270,6 +270,30 @@ int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock)
return 1;
}
+
+int CRYPTO_atomic_load_int(int *val, int *ret, CRYPTO_RWLOCK *lock)
+{
+# if defined(__GNUC__) && defined(__ATOMIC_ACQUIRE) && !defined(BROKEN_CLANG_ATOMICS)
+ if (__atomic_is_lock_free(sizeof(*val), val)) {
+ __atomic_load(val, ret, __ATOMIC_ACQUIRE);
+ return 1;
+ }
+# elif defined(__sun) && (defined(__SunOS_5_10) || defined(__SunOS_5_11))
+ /* This will work for all future Solaris versions. */
+ if (ret != NULL) {
+ *ret = (int *)atomic_or_uint_nv((unsigned int *)val, 0);
+ return 1;
+ }
+# endif
+ if (lock == NULL || !CRYPTO_THREAD_read_lock(lock))
+ return 0;
+ *ret = *val;
+ if (!CRYPTO_THREAD_unlock(lock))
+ return 0;
+
+ return 1;
+}
+
# ifndef FIPS_MODULE
int openssl_init_fork_handlers(void)
{