From: Tomas Mraz Date: Wed, 16 Nov 2022 13:51:48 +0000 (+0100) Subject: Add functions supporting thread pool only when it is enabled X-Git-Tag: openssl-3.2.0-alpha1~1691 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5a3669c8bc9cd1ea00f2bb7d058a752e6d2f152;p=thirdparty%2Fopenssl.git Add functions supporting thread pool only when it is enabled Fixes #19691 Reviewed-by: Hugo Landau Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/19695) --- diff --git a/crypto/context.c b/crypto/context.c index 173256bcfb1..dcd9a1396b6 100644 --- a/crypto/context.c +++ b/crypto/context.c @@ -174,7 +174,7 @@ static int context_init(OSSL_LIB_CTX *ctx) goto err; #endif -#if defined(OPENSSL_THREADS) +#ifndef OPENSSL_NO_THREAD_POOL ctx->threads = ossl_threads_ctx_new(ctx); if (ctx->threads == NULL) goto err; @@ -308,7 +308,7 @@ static void context_deinit_objs(OSSL_LIB_CTX *ctx) } #endif -#if defined(OPENSSL_THREADS) +#ifndef OPENSSL_NO_THREAD_POOL if (ctx->threads != NULL) { ossl_threads_ctx_free(ctx->threads); ctx->threads = NULL; @@ -551,7 +551,7 @@ void *ossl_lib_ctx_get_data(OSSL_LIB_CTX *ctx, int index) case OSSL_LIB_CTX_SELF_TEST_CB_INDEX: return ctx->self_test_cb; #endif -#if defined(OPENSSL_THREADS) +#ifndef OPENSSL_NO_THREAD_POOL case OSSL_LIB_CTX_THREAD_INDEX: return ctx->threads; #endif diff --git a/crypto/thread/arch.c b/crypto/thread/arch.c index 3dddcb10a83..8d6f4777066 100644 --- a/crypto/thread/arch.c +++ b/crypto/thread/arch.c @@ -10,8 +10,6 @@ #include #include -#if defined(OPENSSL_THREADS) - CRYPTO_THREAD *ossl_crypto_thread_native_start(CRYPTO_THREAD_ROUTINE routine, void *data, int joinable) { @@ -133,18 +131,3 @@ int ossl_crypto_thread_native_clean(CRYPTO_THREAD *handle) return 1; } - -#else - -CRYPTO_THREAD *ossl_crypto_thread_native_start(CRYPTO_THREAD_ROUTINE routine, - void *data, int joinable) -{ - return NULL; -} - -int ossl_crypto_thread_native_clean(CRYPTO_THREAD *handle) -{ - return 0; -} - -#endif diff --git a/crypto/thread/build.info b/crypto/thread/build.info index 3ab689d4a4f..1e9b97d48a5 100644 --- a/crypto/thread/build.info +++ b/crypto/thread/build.info @@ -1,8 +1,12 @@ LIBS=../../libcrypto -$THREADS=\ +IF[{- !$disabled{'thread-pool'} -}] + $THREADS=\ api.c internal.c arch.c \ arch/thread_win.c arch/thread_posix.c arch/thread_none.c +ELSE + $THREADS=api.c +ENDIF SOURCE[../../libcrypto]=$THREADS SOURCE[../../providers/libfips.a]=$THREADS diff --git a/crypto/thread/internal.c b/crypto/thread/internal.c index 22af876cd7e..4d966f3e53b 100644 --- a/crypto/thread/internal.c +++ b/crypto/thread/internal.c @@ -124,8 +124,6 @@ int ossl_crypto_thread_clean(void *vhandle) #endif -#if defined(OPENSSL_THREADS) - void *ossl_threads_ctx_new(OSSL_LIB_CTX *ctx) { struct openssl_threads_st *t = OPENSSL_zalloc(sizeof(*t)); @@ -157,5 +155,3 @@ void ossl_threads_ctx_free(void *vdata) ossl_crypto_condvar_free(&t->cond_finished); OPENSSL_free(t); } - -#endif