Skip to content

Commit

Permalink
fix: update code to be compile in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Taowyoo committed Sep 8, 2023
1 parent 2dd834b commit 34888df
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
21 changes: 10 additions & 11 deletions mbedtls-platform-support/src/self_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ cfg_if::cfg_if! {
}
}
}
cfg_if::cfg_if! {
if #[cfg(any(not(feature = "std"), target_env = "sgx"))] {
#[allow(non_upper_case_globals)]
static mut rand_f: Option<fn() -> c_int> = None;

// needs to be pub for global visiblity
#[doc(hidden)]
#[no_mangle]
pub unsafe extern "C" fn rand() -> c_int {
rand_f.expect("Called self-test rand without enabling self-test")()
}
}
#[cfg(any(not(feature = "std"), target_env = "sgx"))]
#[allow(non_upper_case_globals)]
static mut rand_f: Option<fn() -> c_int> = None;

// needs to be pub for global visiblity
#[cfg(all(any(not(feature = "std"), target_env = "sgx"), not(target_env = "msvc")))]
#[doc(hidden)]
#[no_mangle]
pub unsafe extern "C" fn rand() -> c_int {
rand_f.expect("Called self-test rand without enabling self-test")()
}

/// Set callback functions to enable the MbedTLS self tests.
Expand Down
2 changes: 1 addition & 1 deletion mbedtls-sys/build/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ impl super::BuildConfig {
.clang_args(cc.get_compiler().args().iter().map(|arg| arg.to_str().unwrap()))
.header_contents("bindgen-input.h", &header)
.allowlist_function("^(?i)mbedtls_.*")
.allowlist_function("^(?i)psa_.*")
.wrap_static_fns(true)
.wrap_static_fns_path(&self.static_wrappers_c)
.generate().expect("bindgen error");
Expand Down Expand Up @@ -160,6 +159,7 @@ fn bindgen_builder(cc: &cc::Build, header: &String) -> bindgen::Builder {
.header_contents("bindgen-input.h", header)
.allowlist_recursively(false)
.blocklist_type("^mbedtls_time_t$")
.blocklist_item("^(?i)mbedtls_.*vsnprintf")
.use_core()
.ctypes_prefix("::types::raw_types")
.parse_callbacks(Box::new(MbedtlsParseCallbacks))
Expand Down
2 changes: 2 additions & 0 deletions mbedtls-sys/build/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ impl super::BuildConfig {
))
.define("ENABLE_PROGRAMS", "OFF")
.define("ENABLE_TESTING", "OFF")
// This is turn off on windows by default
.define("GEN_FILES", "ON")
// Prefer unix-style over Apple-style Python3 on macOS, required for the Github Actions CI
.define("Python3_FIND_FRAMEWORK", "LAST")
.build_target("install");
Expand Down
2 changes: 1 addition & 1 deletion mbedtls/src/ssl/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ define!(
impl From<u32> for Version {
fn from(value: u32) -> Self {
use Version::*;
match value {
match value as ssl_protocol_version {
SSL_VERSION_TLS1_2 => Tls12,
#[cfg(feature = "tls13")]
SSL_VERSION_TLS1_3 => Tls13,
Expand Down
1 change: 1 addition & 0 deletions mbedtls/tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#![allow(dead_code)]
pub mod entropy;
pub mod keys;
#[cfg(unix)]
#[cfg(sys_std_component = "net")]
pub mod net;
pub mod rand;
Expand Down

0 comments on commit 34888df

Please sign in to comment.