mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 14:41:32 +00:00
Fixed emscripten ns collision. Added ctime implementation
This commit is contained in:
@ -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)]
|
||||
|
Reference in New Issue
Block a user