Skip to content

Commit d048b59

Browse files
committed
Fix compile error due to missing mbedtls_time declaration
1 parent 2040af1 commit d048b59

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

mbedtls-sys/build/build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ impl BuildConfig {
6262
writeln!(f, "typedef void* mbedtls_threading_mutex_t;")?;
6363
}
6464
if have_feature("custom_time") {
65-
writeln!(f, "#include <time.h>")?;
66-
writeln!(f, "time_t mbedtls_time(time_t *);")?;
65+
writeln!(f, "long long mbedtls_time(long long*);")?;
6766
}
6867
f.write_all(config::SUFFIX.as_bytes())
6968
})

mbedtls-sys/build/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ pub const FEATURE_DEFINES: &'static [(&'static str, CDefine)] = &[
410410
("time", ("MBEDTLS_HAVE_TIME_DATE", Defined)),
411411
("time", ("MBEDTLS_TIMING_C", Defined)),
412412
("custom_time", ("MBEDTLS_PLATFORM_TIME_MACRO", DefinedAs("mbedtls_time"))),
413+
("custom_time", ("MBEDTLS_PLATFORM_TIME_TYPE_MACRO", DefinedAs("long long"))),
413414
("custom_gmtime_r", ("MBEDTLS_PLATFORM_GMTIME_R_ALT", Defined)),
414415
("havege", ("MBEDTLS_HAVEGE_C", Defined)),
415416
("threading", ("MBEDTLS_THREADING_C", Defined)),

mbedtls-sys/src/types.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,27 @@ extern crate libc;
9090
mod libc_types {
9191
pub use super::libc::FILE;
9292

93+
#[cfg(all(feature = "time", not(feature = "custom_time")))]
94+
pub use super::libc::time_t;
95+
96+
#[cfg(feature = "custom_time")]
97+
pub type time_t = super::raw_types::c_longlong;
98+
9399
#[cfg(feature = "time")]
94-
pub use super::libc::{time_t, tm};
100+
pub use super::libc::tm;
95101

96102
}
97103

98104
#[cfg(not(feature = "libc"))]
99105
mod libc_types {
100106
pub enum FILE {}
101107

102-
#[cfg(feature = "time")]
108+
#[cfg(all(feature = "time", not(feature = "custom_time")))]
103109
pub type time_t = i64;
104110

111+
#[cfg(feature = "custom_time")]
112+
pub type time_t = super::raw_types::c_longlong;
113+
105114
#[cfg(feature = "time")]
106115
#[repr(C)]
107116
pub struct tm {

0 commit comments

Comments
 (0)