Skip to content

Commit da0ea79

Browse files
authored
Merge pull request #2293 from reaperhulk/threads
add ossl3 thread pool bindings
2 parents 30179f6 + 700f6ac commit da0ea79

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

openssl-sys/build/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn check_ssl_kind() {
7474
}
7575

7676
fn main() {
77-
println!("cargo:rustc-check-cfg=cfg(osslconf, values(\"OPENSSL_NO_OCB\", \"OPENSSL_NO_SM4\", \"OPENSSL_NO_SEED\", \"OPENSSL_NO_CHACHA\", \"OPENSSL_NO_CAST\", \"OPENSSL_NO_IDEA\", \"OPENSSL_NO_CAMELLIA\", \"OPENSSL_NO_RC4\", \"OPENSSL_NO_BF\", \"OPENSSL_NO_PSK\", \"OPENSSL_NO_DEPRECATED_3_0\", \"OPENSSL_NO_SCRYPT\", \"OPENSSL_NO_SM3\", \"OPENSSL_NO_RMD160\", \"OPENSSL_NO_EC2M\", \"OPENSSL_NO_OCSP\", \"OPENSSL_NO_CMS\", \"OPENSSL_NO_COMP\", \"OPENSSL_NO_SOCK\", \"OPENSSL_NO_STDIO\", \"OPENSSL_NO_EC\", \"OPENSSL_NO_SSL3_METHOD\", \"OPENSSL_NO_KRB5\", \"OPENSSL_NO_TLSEXT\", \"OPENSSL_NO_SRP\", \"OPENSSL_NO_RFC3779\", \"OPENSSL_NO_SHA\", \"OPENSSL_NO_NEXTPROTONEG\", \"OPENSSL_NO_ENGINE\", \"OPENSSL_NO_BUF_FREELISTS\"))");
77+
println!("cargo:rustc-check-cfg=cfg(osslconf, values(\"OPENSSL_THREADS\", \"OPENSSL_NO_OCB\", \"OPENSSL_NO_SM4\", \"OPENSSL_NO_SEED\", \"OPENSSL_NO_CHACHA\", \"OPENSSL_NO_CAST\", \"OPENSSL_NO_IDEA\", \"OPENSSL_NO_CAMELLIA\", \"OPENSSL_NO_RC4\", \"OPENSSL_NO_BF\", \"OPENSSL_NO_PSK\", \"OPENSSL_NO_DEPRECATED_3_0\", \"OPENSSL_NO_SCRYPT\", \"OPENSSL_NO_SM3\", \"OPENSSL_NO_RMD160\", \"OPENSSL_NO_EC2M\", \"OPENSSL_NO_OCSP\", \"OPENSSL_NO_CMS\", \"OPENSSL_NO_COMP\", \"OPENSSL_NO_SOCK\", \"OPENSSL_NO_STDIO\", \"OPENSSL_NO_EC\", \"OPENSSL_NO_SSL3_METHOD\", \"OPENSSL_NO_KRB5\", \"OPENSSL_NO_TLSEXT\", \"OPENSSL_NO_SRP\", \"OPENSSL_NO_RFC3779\", \"OPENSSL_NO_SHA\", \"OPENSSL_NO_NEXTPROTONEG\", \"OPENSSL_NO_ENGINE\", \"OPENSSL_NO_BUF_FREELISTS\"))");
7878

7979
println!("cargo:rustc-check-cfg=cfg(openssl)");
8080
println!("cargo:rustc-check-cfg=cfg(libressl)");

openssl-sys/build/run_bindgen.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ const INCLUDES: &str = "
6363
#if defined(LIBRESSL_VERSION_NUMBER) || defined(OPENSSL_IS_BORINGSSL)
6464
#include <openssl/poly1305.h>
6565
#endif
66+
67+
#if OPENSSL_VERSION_NUMBER >= 0x30200000 && defined(OPENSSL_THREADS)
68+
#include <openssl/thread.h>
69+
#endif
6670
";
6771

6872
#[cfg(feature = "bindgen")]

openssl-sys/src/handwritten/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pub use self::sha::*;
2929
pub use self::srtp::*;
3030
pub use self::ssl::*;
3131
pub use self::stack::*;
32+
#[cfg(all(ossl320, osslconf = "OPENSSL_THREADS"))]
33+
pub use self::thread::*;
3234
pub use self::tls1::*;
3335
pub use self::types::*;
3436
pub use self::x509::*;
@@ -66,6 +68,8 @@ mod sha;
6668
mod srtp;
6769
mod ssl;
6870
mod stack;
71+
#[cfg(all(ossl320, osslconf = "OPENSSL_THREADS"))]
72+
mod thread;
6973
mod tls1;
7074
mod types;
7175
mod x509;

openssl-sys/src/handwritten/thread.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use super::super::*;
2+
use libc::*;
3+
4+
extern "C" {
5+
pub fn OSSL_set_max_threads(ctx: *mut OSSL_LIB_CTX, max_threads: u64) -> c_int;
6+
pub fn OSSL_get_max_threads(ctx: *mut OSSL_LIB_CTX) -> u64;
7+
}

systest/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ fn main() {
8585
if version >= 0x30000000 {
8686
cfg.header("openssl/provider.h");
8787
}
88+
if version >= 0x30200000 {
89+
// thread is present as a header even if OPENSSL_THREADS is not defined
90+
cfg.header("openssl/thread.h");
91+
}
8892
}
8993

9094
#[allow(clippy::if_same_then_else)]

0 commit comments

Comments
 (0)