From 4574a7fd8dda070b129d76defca07703cab53842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Cestm=C3=ADr=20Kalina?= Date: Mon, 27 Sep 2021 22:42:11 +0200 Subject: crypto: add preemptive threading support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some primitives are designed to be used in a multi-threaded environment, if supported, e.g., Argon2. This patch adds support for preemptive threading and basic synchronization primitives for platforms compliant with POSIX threads or Windows CRT. Native functions are wrapped to provide a common (internal) API. Threading support can be disabled at compile time. If enabled, threading is disabled by default and needs to be explicitly enabled by the user. Thread enablement requires an explicit limit on the number of threads that OpenSSL may spawn (non-negative integer/infinity). The limit may be changed. Signed-off-by: Čestmír Kalina Reviewed-by: Hugo Landau Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/12255) --- Configure | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'Configure') diff --git a/Configure b/Configure index 01c2d0bafe..fbafe0e867 100755 --- a/Configure +++ b/Configure @@ -655,6 +655,9 @@ my @disable_cascades = ( "fips" => [ "fips-securitychecks", "acvp-tests" ], + "threads" => [ "thread-pool" ], + "thread-pool" => [ "default-thread-pool" ], + "deprecated-3.0" => [ "engine", "srp" ] ); @@ -812,8 +815,6 @@ while (@argvcopy) s /^-?-?shared$/enable-shared/; s /^sctp$/enable-sctp/; s /^threads$/enable-threads/; - s /^thread-pool$/enable-thread-pool/; - s /^default-thread-pool$/enable-default-thread-pool/; s /^zlib$/enable-zlib/; s /^zlib-dynamic$/enable-zlib-dynamic/; s /^fips$/enable-fips/; @@ -1400,14 +1401,6 @@ if (grep { $_ =~ /(?:^|\s)-static(?:\s|$)/ } @{$config{LDFLAGS}}) { disable('static', 'pic', 'threads'); } -if ($disabled{threads}) { - disable('unavailable', 'thread-pool'); -} - -if ($disabled{"thread-pool"}) { - disable('unavailable', 'default-thread-pool'); -} - # Allow overriding the build file name $config{build_file} = env('BUILDFILE') || $target{build_file} || "Makefile"; @@ -1506,12 +1499,6 @@ foreach (grep /^-fsanitize=/, @{$config{CFLAGS} || []}) { unless($disabled{threads}) { push @{$config{openssl_feature_defines}}, "OPENSSL_THREADS"; } -unless($disabled{"thread-pool"}) { - push @{$config{openssl_feature_defines}}, "OPENSSL_THREAD_POOL"; -} -unless($disabled{"default-thread-pool"}) { - push @{$config{openssl_feature_defines}}, "OPENSSL_DEFAULT_THREAD_POOL"; -} my $no_shared_warn=0; if (($target{shared_target} // '') eq "") -- cgit v1.2.1