Skip to content

Commit

Permalink
time_t is 64 bits on Emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Feb 3, 2024
1 parent 7d19eed commit 2b10b44
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 8 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::string::String;
// make sure to add it to this list as well.
const ALLOWED_CFGS: &'static [&'static str] = &[
"emscripten_new_stat_abi",
"emscripten_64_bit_time_t",
"freebsd10",
"freebsd11",
"freebsd12",
Expand Down Expand Up @@ -56,7 +57,13 @@ fn main() {
}

match emcc_version_code() {
Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"),
Some(v) if (v >= 30142) => {
set_cfg("emscripten_new_stat_abi");
set_cfg("emscripten_64_bit_time_t");
}
Some(v) if (v >= 30116) => {
set_cfg("emscripten_64_bit_time_t");
}
// Non-Emscripten or version < 3.1.42.
Some(_) | None => (),
}
Expand Down
19 changes: 18 additions & 1 deletion src/unix/linux_like/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,24 @@ pub type loff_t = i64;
pub type pthread_key_t = ::c_uint;

pub type clock_t = c_long;
pub type time_t = c_long;

// time_t was type:
//
// - long from v1.5.4 (2013/08/08) until v3.1.11
// - int from v3.1.11 (2022/05/20) until v3.1.16
// - _Int64 from v3.1.16 (2022/07/14)
//
// And it's still int64 today. The change from long to int was marked as a
// nonfunctional change since wasm64 was considered to be not working yet in
// v3.1.11. So it suffices to say it's 32 bit until v3.1.16 and 64 bit after.
cfg_if! {
if #[cfg(emscripten_64_bit_time_t)] {
pub type time_t = i64;
} else {
pub type time_t = i32;
}
}

pub type suseconds_t = c_long;
pub type ino_t = u64;
pub type off_t = i64;
Expand Down

0 comments on commit 2b10b44

Please sign in to comment.