mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 22:05:33 +00:00
Fixed emscripten ns collision. Added ctime implementation
This commit is contained in:
parent
d0b186b939
commit
9c96f01494
@ -804,6 +804,8 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
"_strftime_l" => func!(crate::time::_strftime_l),
|
||||
"_localtime_r" => func!(crate::time::_localtime_r),
|
||||
"_gmtime_r" => func!(crate::time::_gmtime_r),
|
||||
"_ctime" => func!(crate::time::_ctime),
|
||||
"_ctime_r" => func!(crate::time::_ctime_r),
|
||||
"_mktime" => func!(crate::time::_mktime),
|
||||
"_gmtime" => func!(crate::time::_gmtime),
|
||||
|
||||
@ -981,7 +983,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
for (k, v) in env_ns.get_exports() {
|
||||
if k.starts_with("_") {
|
||||
let k = &k[1..];
|
||||
env_ns.insert(k, v.to_export());
|
||||
if !env_ns.contains_key(k) {
|
||||
env_ns.insert(k, v.to_export());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
use super::utils::{copy_cstr_into_wasm, write_to_buf};
|
||||
use crate::allocate_on_stack;
|
||||
use libc::{c_char, c_int};
|
||||
// use libc::{c_char, c_int, clock_getres, clock_settime};
|
||||
use std::mem;
|
||||
@ -313,6 +314,23 @@ pub fn _time(ctx: &mut Ctx, time_p: u32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _ctime_r(ctx: &mut Ctx, time_p: u32, buf: u32) -> u32 {
|
||||
debug!("emscripten::_ctime_r {} {}", time_p, buf);
|
||||
|
||||
// var stack = stackSave();
|
||||
let (result_offset, _result_slice): (u32, &mut [u8]) = unsafe { allocate_on_stack(ctx, 44) };
|
||||
let time = _localtime_r(ctx, time_p, result_offset) as u32;
|
||||
let rv = _asctime_r(ctx, time, buf);
|
||||
// stackRestore(stack);
|
||||
rv
|
||||
}
|
||||
|
||||
pub fn _ctime(ctx: &mut Ctx, time_p: u32) -> u32 {
|
||||
debug!("emscripten::_ctime {}", time_p);
|
||||
let tm_current = 2414544;
|
||||
_ctime_r(ctx, time_p, tm_current)
|
||||
}
|
||||
|
||||
/// emscripten: _timegm
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
|
Loading…
Reference in New Issue
Block a user