Loading openssl-sys/Cargo.toml +2 −1 Original line number Diff line number Diff line Loading @@ -18,9 +18,10 @@ vendored = ['openssl-src'] libc = "0.2" [build-dependencies] pkg-config = "0.3.9" cc = "1.0" openssl-src = { version = "111.0.1", optional = true } pkg-config = "0.3.9" rustc_version = "0.2" [target.'cfg(target_env = "msvc")'.build-dependencies] vcpkg = "0.2" Loading openssl-sys/build/main.rs +11 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ extern crate cc; #[cfg(feature = "vendored")] extern crate openssl_src; extern crate pkg_config; extern crate rustc_version; #[cfg(target_env = "msvc")] extern crate vcpkg; Loading Loading @@ -41,6 +42,8 @@ fn env(name: &str) -> Option<OsString> { } fn main() { check_rustc_versions(); let target = env::var("TARGET").unwrap(); let (lib_dir, include_dir) = find::get_openssl(&target); Loading Loading @@ -90,6 +93,14 @@ fn main() { } } fn check_rustc_versions() { let version = rustc_version::version().unwrap(); if version >= rustc_version::Version::new(1, 31, 0) { println!("cargo:rustc-cfg=const_fn"); } } /// Validates the header files found in `include_dir` and then returns the /// version string of OpenSSL. fn validate_headers(include_dirs: &[PathBuf]) -> Version { Loading openssl-sys/src/err.rs +18 −10 Original line number Diff line number Diff line Loading @@ -5,17 +5,25 @@ pub const ERR_TXT_STRING: c_int = 0x02; pub const ERR_LIB_PEM: c_int = 9; pub fn ERR_GET_LIB(l: c_ulong) -> c_int { const_fn! { pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong { ((l as c_ulong & 0x0FF) << 24) | ((f as c_ulong & 0xFFF) << 12) | ((r as c_ulong & 0xFFF)) } pub const fn ERR_GET_LIB(l: c_ulong) -> c_int { ((l >> 24) & 0x0FF) as c_int } pub fn ERR_GET_FUNC(l: c_ulong) -> c_int { pub const fn ERR_GET_FUNC(l: c_ulong) -> c_int { ((l >> 12) & 0xFFF) as c_int } pub fn ERR_GET_REASON(l: c_ulong) -> c_int { pub const fn ERR_GET_REASON(l: c_ulong) -> c_int { (l & 0xFFF) as c_int } } #[repr(C)] pub struct ERR_STRING_DATA { Loading openssl-sys/src/macros.rs +18 −0 Original line number Diff line number Diff line Loading @@ -67,3 +67,21 @@ macro_rules! stack { } }; } #[cfg(const_fn)] macro_rules! const_fn { ($(pub const fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty $b:block)*) => { $( pub const fn $name($($arg: $t),*) -> $ret $b )* } } #[cfg(not(const_fn))] macro_rules! const_fn { ($(pub const fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty $b:block)*) => { $( pub fn $name($($arg: $t),*) -> $ret $b )* } } Loading
openssl-sys/Cargo.toml +2 −1 Original line number Diff line number Diff line Loading @@ -18,9 +18,10 @@ vendored = ['openssl-src'] libc = "0.2" [build-dependencies] pkg-config = "0.3.9" cc = "1.0" openssl-src = { version = "111.0.1", optional = true } pkg-config = "0.3.9" rustc_version = "0.2" [target.'cfg(target_env = "msvc")'.build-dependencies] vcpkg = "0.2" Loading
openssl-sys/build/main.rs +11 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ extern crate cc; #[cfg(feature = "vendored")] extern crate openssl_src; extern crate pkg_config; extern crate rustc_version; #[cfg(target_env = "msvc")] extern crate vcpkg; Loading Loading @@ -41,6 +42,8 @@ fn env(name: &str) -> Option<OsString> { } fn main() { check_rustc_versions(); let target = env::var("TARGET").unwrap(); let (lib_dir, include_dir) = find::get_openssl(&target); Loading Loading @@ -90,6 +93,14 @@ fn main() { } } fn check_rustc_versions() { let version = rustc_version::version().unwrap(); if version >= rustc_version::Version::new(1, 31, 0) { println!("cargo:rustc-cfg=const_fn"); } } /// Validates the header files found in `include_dir` and then returns the /// version string of OpenSSL. fn validate_headers(include_dirs: &[PathBuf]) -> Version { Loading
openssl-sys/src/err.rs +18 −10 Original line number Diff line number Diff line Loading @@ -5,17 +5,25 @@ pub const ERR_TXT_STRING: c_int = 0x02; pub const ERR_LIB_PEM: c_int = 9; pub fn ERR_GET_LIB(l: c_ulong) -> c_int { const_fn! { pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong { ((l as c_ulong & 0x0FF) << 24) | ((f as c_ulong & 0xFFF) << 12) | ((r as c_ulong & 0xFFF)) } pub const fn ERR_GET_LIB(l: c_ulong) -> c_int { ((l >> 24) & 0x0FF) as c_int } pub fn ERR_GET_FUNC(l: c_ulong) -> c_int { pub const fn ERR_GET_FUNC(l: c_ulong) -> c_int { ((l >> 12) & 0xFFF) as c_int } pub fn ERR_GET_REASON(l: c_ulong) -> c_int { pub const fn ERR_GET_REASON(l: c_ulong) -> c_int { (l & 0xFFF) as c_int } } #[repr(C)] pub struct ERR_STRING_DATA { Loading
openssl-sys/src/macros.rs +18 −0 Original line number Diff line number Diff line Loading @@ -67,3 +67,21 @@ macro_rules! stack { } }; } #[cfg(const_fn)] macro_rules! const_fn { ($(pub const fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty $b:block)*) => { $( pub const fn $name($($arg: $t),*) -> $ret $b )* } } #[cfg(not(const_fn))] macro_rules! const_fn { ($(pub const fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty $b:block)*) => { $( pub fn $name($($arg: $t),*) -> $ret $b )* } }