From 181837d7cc1cb7c16e2341349d7e95eeb18bf0f8 Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Fri, 7 Dec 2018 14:50:35 +0100 Subject: [PATCH 01/12] Fix localtime implementation --- src/apis/emscripten/env.rs | 5 -- src/apis/emscripten/mod.rs | 20 +++-- src/apis/emscripten/storage.rs | 29 +++--- src/apis/emscripten/time.rs | 158 ++++++++++++++++++++++++++++----- src/apis/emscripten/utils.rs | 2 + src/bin/wasmer.rs | 37 +------- 6 files changed, 164 insertions(+), 87 deletions(-) diff --git a/src/apis/emscripten/env.rs b/src/apis/emscripten/env.rs index cd4e8db4b..91445570b 100644 --- a/src/apis/emscripten/env.rs +++ b/src/apis/emscripten/env.rs @@ -97,11 +97,6 @@ pub extern "C" fn _getgrnam(name_ptr: c_int, instance: &mut Instance) -> c_int { } } -pub extern "C" fn _localtime_r() -> u32 { - debug!("emscripten::_localtime_r"); - 0 -} - pub extern "C" fn _getpagesize() -> u32 { debug!("emscripten::_getpagesize"); 16384 diff --git a/src/apis/emscripten/mod.rs b/src/apis/emscripten/mod.rs index d581c3f90..1b5acc389 100644 --- a/src/apis/emscripten/mod.rs +++ b/src/apis/emscripten/mod.rs @@ -18,7 +18,7 @@ mod time; mod utils; mod varargs; -pub use self::storage::{align_memory, static_alloc}; +pub use self::storage::{align_memory}; pub use self::utils::{is_emscripten_module, allocate_on_stack, allocate_cstr_on_stack}; // TODO: Magic number - how is this calculated? @@ -27,6 +27,8 @@ const TOTAL_STACK: u32 = 5242880; const DYNAMICTOP_PTR_DIFF: u32 = 1088; // TODO: make this variable const STATIC_BUMP: u32 = 215536; +// TODO: make this variable +const GLOBAL_BASE: u32 = 1024; fn stacktop(static_bump: u32) -> u32 { align_memory(dynamictop_ptr(static_bump) + 4) @@ -44,11 +46,10 @@ fn dynamictop_ptr(static_bump: u32) -> u32 { static_bump + DYNAMICTOP_PTR_DIFF } -// fn static_alloc(size: usize, static_top: &mut size) -> usize { -// let ret = *static_top; -// *static_top = (*static_top + size + 15) & (-16 as usize); -// ret -// } + +pub fn statictop(static_bump: u32) -> u32 { + GLOBAL_BASE + 5520 +} pub fn emscripten_set_up_memory(memory: &mut LinearMemory) { let dynamictop_ptr = dynamictop_ptr(STATIC_BUMP) as usize; @@ -383,6 +384,11 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> { "_clock_gettime", ImportValue::Func(time::_clock_gettime as _), ); + import_object.set( + "env", + "_asctime", + ImportValue::Func(time::_asctime as _), + ); import_object.set( "env", "_localtime", @@ -393,7 +399,7 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> { import_object.set( "env", "_localtime_r", - ImportValue::Func(env::_localtime_r as _), + ImportValue::Func(time::_localtime_r as _), ); import_object.set( "env", diff --git a/src/apis/emscripten/storage.rs b/src/apis/emscripten/storage.rs index 382bc2e43..16d4d6d0e 100644 --- a/src/apis/emscripten/storage.rs +++ b/src/apis/emscripten/storage.rs @@ -4,22 +4,15 @@ pub fn align_memory(ptr: u32) -> u32 { (ptr + 15) & !15 } -// pub fn static_alloc(size: u32, instance: &mut Instance) -> u32 { -// let static_top = instance.emscripten_data.static_top; -// let total_memory = instance.memories[0].maximum.unwrap_or(LinearMemory::DEFAULT_HEAP_SIZE as u32); -// instance.emscripten_data.static_top = (static_top + size + 15) & 4294967280; -// assert!(static_top < total_memory, "not enough memory for static allocation - increase total_memory!"); -// static_top -// } -pub fn static_alloc(size: u32, static_top: &mut u32, memory: &LinearMemory) -> u32 { - let old_static_top = *static_top; - let total_memory = memory.maximum_size() * LinearMemory::PAGE_SIZE; - // NOTE: The `4294967280` is a u32 conversion of -16 as gotten from emscripten. - *static_top = (*static_top + size + 15) & 4294967280; - assert!( - *static_top < total_memory, - "not enough memory for static allocation - increase total_memory!" - ); - old_static_top -} +// pub fn static_alloc(size: u32, static_top: &mut u32, memory: &LinearMemory) -> u32 { +// let old_static_top = *static_top; +// let total_memory = memory.maximum_size() * LinearMemory::PAGE_SIZE; +// // NOTE: The `4294967280` is a u32 conversion of -16 as gotten from emscripten. +// *static_top = (*static_top + size + 15) & 4294967280; +// assert!( +// *static_top < total_memory, +// "not enough memory for static allocation - increase total_memory!" +// ); +// old_static_top +// } diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index e8aa2d06c..59a9cc0c1 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -3,11 +3,13 @@ use libc::{ c_int, c_long, clock_gettime as libc_clock_gettime, - // tm, localtime, + localtime_r, + tm, time, time_t, timespec, + c_char, }; use std::mem; use std::time::SystemTime; @@ -64,37 +66,101 @@ pub extern "C" fn _clock_gettime(clk_id: c_int, tp: c_int, instance: &mut Instan 0 } +#[repr(C)] +struct guest_tm { + pub tm_sec: c_int, // 4 - 0 + pub tm_min: c_int, // 4 - 4 + pub tm_hour: c_int, // 4 - 8 + pub tm_mday: c_int, // 4 - 12 + pub tm_mon: c_int, // 4 - 16 + pub tm_year: c_int, // 4 - 20 + pub tm_wday: c_int, // 4 - 24 + pub tm_yday: c_int, // 4 - 28 + pub tm_isdst: c_int, // 4 - 32 + pub tm_gmtoff: c_int, // 4 - 36 + pub tm_zone: c_int, // 4 - 40 +} + +// #[repr(C)] +// struct asctime_tm { +// pub tm_sec: c_int, // 4 - 0 +// pub tm_min: c_int, // 4 - 4 +// pub tm_hour: c_int, // 4 - 8 +// pub tm_mday: c_int, // 4 - 12 +// pub tm_mon: c_int, // 4 - 16 +// pub tm_year: c_int, // 4 - 20 +// pub tm_wday: c_int, // 4 - 24 +// } + +/// emscripten: _asctime +pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { + debug!("emscripten::_asctime {}", time); + + unsafe { + let date = &*(instance.memory_offset_addr(0, time as _) as *mut guest_tm); + + let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + + let day = if date.tm_mday < 10 {" "} else {" "}; + let hour = if date.tm_hour < 10 {" 0"} else {" "}; + let min = if date.tm_min < 10 {":0"} else {":"}; + let sec = if date.tm_sec < 10 {":0"} else {":"}; + let year = 1900 + date.tm_year; + + let mut time_str = format!( + // "{} {}{}{}{}{}{}{}{}{} {}\0 \0\0", + "{} {}{}{}{}{}{}{}{}{} {}\0", + days[date.tm_wday as usize], + months[date.tm_mon as usize], + day, date.tm_mday, + hour, date.tm_hour, + min, date.tm_min, + sec, date.tm_sec, + year + ); + + let time_str_ptr = time_str.as_ptr() as _; + + // TODO: asctime_r is specced to behave in an undefined manner if the algorithm would attempt + // to write out more than 26 bytes (including the null terminator). + // See http://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html + // Our undefined behavior is to truncate the write to at most 26 bytes, including null terminator. + let time_str_offset = copy_cstr_into_wasm(instance, time_str_ptr); + + let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8; + use std::ffi::CStr; + debug!("########## cstr = {:?}", CStr::from_ptr(c_str)); + println!("Kaboom!"); + + // std::mem::forget(time_str); + time_str_offset + } +} + +/// emscripten: _tvset +pub extern "C" fn _tvset() { + debug!("emscripten::_tvset UNIMPLEMENTED"); +} + /// emscripten: _localtime pub extern "C" fn _localtime(time_p: u32, instance: &mut Instance) -> c_int { debug!("emscripten::_localtime {}", time_p); - - #[repr(C)] - struct GuestTm { - tm_sec: i32, - tm_min: i32, - tm_hour: i32, - tm_mday: i32, - tm_mon: i32, - tm_year: i32, - tm_wday: i32, - tm_yday: i32, - tm_isdst: i32, - tm_gmtoff: c_long, - tm_zone: u32, - } + // NOTE: emscripten seems to want tzset() called in this function + // https://stackoverflow.com/questions/19170721/real-time-awareness-of-timezone-change-in-localtime-vs-localtime-r unsafe { let time_p_addr = instance.memory_offset_addr(0, time_p as _) as *mut i64; + let tm_struct = &*localtime(time_p_addr); - // Webassembly allocation let tm_struct_offset = (instance.emscripten_data.as_ref().unwrap().malloc)( - mem::size_of::() as _, + mem::size_of::() as _, instance, ); - let tm_struct_ptr = instance.memory_offset_addr(0, tm_struct_offset as _) as *mut GuestTm; - // Initializing + let tm_struct_ptr = instance.memory_offset_addr(0, tm_struct_offset as _) as *mut guest_tm; + (*tm_struct_ptr).tm_sec = tm_struct.tm_sec; (*tm_struct_ptr).tm_min = tm_struct.tm_min; (*tm_struct_ptr).tm_hour = tm_struct.tm_hour; @@ -104,8 +170,56 @@ pub extern "C" fn _localtime(time_p: u32, instance: &mut Instance) -> c_int { (*tm_struct_ptr).tm_wday = tm_struct.tm_wday; (*tm_struct_ptr).tm_yday = tm_struct.tm_yday; (*tm_struct_ptr).tm_isdst = tm_struct.tm_isdst; - (*tm_struct_ptr).tm_gmtoff = tm_struct.tm_gmtoff; - (*tm_struct_ptr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone); + (*tm_struct_ptr).tm_gmtoff = tm_struct.tm_gmtoff as i32; + (*tm_struct_ptr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone) as i32; + + tm_struct_offset as c_int + } +} +/// emscripten: _localtime_r +pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance) -> c_int { + debug!("emscripten::_localtime_r {}", time_p); + + // NOTE: emscripten seems to want tzset() called in this function + // https://stackoverflow.com/questions/19170721/real-time-awareness-of-timezone-change-in-localtime-vs-localtime-r + + unsafe { + let time_p_addr = instance.memory_offset_addr(0, time_p as _) as *mut i64; + let result_addr = instance.memory_offset_addr(0, result as _) as *mut guest_tm; + let mut result_tm = tm { + tm_sec: (*result_addr).tm_sec, + tm_min: (*result_addr).tm_min, + tm_hour: (*result_addr).tm_hour, + tm_mday: (*result_addr).tm_mday, + tm_mon: (*result_addr).tm_mon, + tm_year: (*result_addr).tm_year, + tm_wday: (*result_addr).tm_wday, + tm_yday: (*result_addr).tm_yday, + tm_isdst: (*result_addr).tm_isdst, + tm_gmtoff: (*result_addr).tm_gmtoff as _, + tm_zone: instance.memory_offset_addr(0, (*result_addr).tm_zone as _) as _, + }; + + let tm_struct = &*localtime_r(time_p_addr, &mut result_tm); + + let tm_struct_offset = (instance.emscripten_data.as_ref().unwrap().malloc)( + mem::size_of::() as _, + instance, + ); + + let tm_struct_ptr = instance.memory_offset_addr(0, tm_struct_offset as _) as *mut guest_tm; + + (*tm_struct_ptr).tm_sec = tm_struct.tm_sec; + (*tm_struct_ptr).tm_min = tm_struct.tm_min; + (*tm_struct_ptr).tm_hour = tm_struct.tm_hour; + (*tm_struct_ptr).tm_mday = tm_struct.tm_mday; + (*tm_struct_ptr).tm_mon = tm_struct.tm_mon; + (*tm_struct_ptr).tm_year = tm_struct.tm_year; + (*tm_struct_ptr).tm_wday = tm_struct.tm_wday; + (*tm_struct_ptr).tm_yday = tm_struct.tm_yday; + (*tm_struct_ptr).tm_isdst = tm_struct.tm_isdst; + (*tm_struct_ptr).tm_gmtoff = tm_struct.tm_gmtoff as i32; + (*tm_struct_ptr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone) as i32; tm_struct_offset as c_int } diff --git a/src/apis/emscripten/utils.rs b/src/apis/emscripten/utils.rs index c0f4e02ab..af96463a8 100644 --- a/src/apis/emscripten/utils.rs +++ b/src/apis/emscripten/utils.rs @@ -28,6 +28,8 @@ pub unsafe fn copy_cstr_into_wasm(instance: &mut Instance, cstr: *const c_char) *loc = byte; } + // TODO: Appending null byte won't work, because there is CStr::from_ptr(cstr) + // at the top that crashes when there is no null byte *raw_memory.add(cstr_len) = 0; space_offset diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index e15ef0d7c..b873cbbbf 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -92,7 +92,8 @@ fn execute_wasm(options: &Run) -> Result<(), String> { get_instance_function!(instance, func_index); let (argc, argv) = store_module_arguments(options, &mut instance); - + + // TODO: This assumes argc and argv are always passed. return call_protected!(main(argc, argv, &instance)).map_err(|err| format!("{}", err)); // TODO: We should implement emscripten __ATEXIT__ } else { @@ -144,37 +145,3 @@ fn store_module_arguments(options: &Run, instance: &mut webassembly::Instance) - (argc as u32, argv_offset) } - -// fn get_module_arguments(options: &Run, instance: &mut webassembly::Instance) -> (u32, u32) { -// // Application Arguments -// let mut arg_values: Vec = Vec::new(); -// let mut arg_addrs: Vec<*const u8> = Vec::new(); -// let arg_length = options.args.len() + 1; - -// arg_values.reserve_exact(arg_length); -// arg_addrs.reserve_exact(arg_length); - -// // Push name of wasm file -// arg_values.push(format!("{}\0", options.path.to_str().unwrap())); -// arg_addrs.push(arg_values[0].as_ptr()); - -// // Push additional arguments -// for (i, arg) in options.args.iter().enumerate() { -// arg_values.push(format!("{}\0", arg)); -// arg_addrs.push(arg_values[i + 1].as_ptr()); -// } - -// // Get argument count and pointer to addresses -// let argv = arg_addrs.as_ptr() as *mut *mut i8; -// let argc = arg_length as u32; - -// // Copy the the arguments into the wasm memory and get offset -// let argv_offset = unsafe { -// copy_cstr_array_into_wasm(argc, argv, instance) -// }; - -// debug!("argc = {:?}", argc); -// debug!("argv = {:?}", arg_addrs); - -// (argc, argv_offset) -// } From 15e1e5aee0d5816289d26272473e3382953d020e Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Fri, 7 Dec 2018 16:37:14 +0100 Subject: [PATCH 02/12] Fix segfault --- src/apis/emscripten/time.rs | 43 +++++++++++++------------------------ 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index 59a9cc0c1..3257cde29 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -68,30 +68,19 @@ pub extern "C" fn _clock_gettime(clk_id: c_int, tp: c_int, instance: &mut Instan #[repr(C)] struct guest_tm { - pub tm_sec: c_int, // 4 - 0 - pub tm_min: c_int, // 4 - 4 - pub tm_hour: c_int, // 4 - 8 - pub tm_mday: c_int, // 4 - 12 - pub tm_mon: c_int, // 4 - 16 - pub tm_year: c_int, // 4 - 20 - pub tm_wday: c_int, // 4 - 24 - pub tm_yday: c_int, // 4 - 28 - pub tm_isdst: c_int, // 4 - 32 - pub tm_gmtoff: c_int, // 4 - 36 - pub tm_zone: c_int, // 4 - 40 + pub tm_sec: c_int, // 0 + pub tm_min: c_int, // 4 + pub tm_hour: c_int, // 8 + pub tm_mday: c_int, // 12 + pub tm_mon: c_int, // 16 + pub tm_year: c_int, // 20 + pub tm_wday: c_int, // 24 + pub tm_yday: c_int, // 28 + pub tm_isdst: c_int, // 32 + pub tm_gmtoff: c_int, // 36 + pub tm_zone: c_int, // 40 } -// #[repr(C)] -// struct asctime_tm { -// pub tm_sec: c_int, // 4 - 0 -// pub tm_min: c_int, // 4 - 4 -// pub tm_hour: c_int, // 4 - 8 -// pub tm_mday: c_int, // 4 - 12 -// pub tm_mon: c_int, // 4 - 16 -// pub tm_year: c_int, // 4 - 20 -// pub tm_wday: c_int, // 4 - 24 -// } - /// emscripten: _asctime pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { debug!("emscripten::_asctime {}", time); @@ -109,8 +98,8 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { let year = 1900 + date.tm_year; let mut time_str = format!( - // "{} {}{}{}{}{}{}{}{}{} {}\0 \0\0", - "{} {}{}{}{}{}{}{}{}{} {}\0", + // NOTE: The 14 accompanying chars are needed for some reason + "{} {}{}{}{}{}{}{}{}{} {}\0\0\0\0\0\0\0\0\0\0\0\0\0\0", days[date.tm_wday as usize], months[date.tm_mon as usize], day, date.tm_mday, @@ -120,18 +109,16 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { year ); - let time_str_ptr = time_str.as_ptr() as _; - // TODO: asctime_r is specced to behave in an undefined manner if the algorithm would attempt + // NOTE: asctime_r is specced to behave in an undefined manner if the algorithm would attempt // to write out more than 26 bytes (including the null terminator). // See http://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html // Our undefined behavior is to truncate the write to at most 26 bytes, including null terminator. + let time_str_ptr = time_str[0..26].as_ptr() as _; let time_str_offset = copy_cstr_into_wasm(instance, time_str_ptr); let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8; use std::ffi::CStr; - debug!("########## cstr = {:?}", CStr::from_ptr(c_str)); - println!("Kaboom!"); // std::mem::forget(time_str); time_str_offset From 540b5be395b1fa7b4a0eff6f4e8734ad9171538c Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Fri, 7 Dec 2018 18:19:28 +0100 Subject: [PATCH 03/12] Remove static_top fn --- src/apis/emscripten/mod.rs | 5 ----- src/apis/emscripten/time.rs | 7 ++++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/apis/emscripten/mod.rs b/src/apis/emscripten/mod.rs index 1b5acc389..22602a86b 100644 --- a/src/apis/emscripten/mod.rs +++ b/src/apis/emscripten/mod.rs @@ -46,11 +46,6 @@ fn dynamictop_ptr(static_bump: u32) -> u32 { static_bump + DYNAMICTOP_PTR_DIFF } - -pub fn statictop(static_bump: u32) -> u32 { - GLOBAL_BASE + 5520 -} - pub fn emscripten_set_up_memory(memory: &mut LinearMemory) { let dynamictop_ptr = dynamictop_ptr(STATIC_BUMP) as usize; let dynamictop_ptr_offset = dynamictop_ptr + mem::size_of::(); diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index 3257cde29..0265baba3 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -97,7 +97,7 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { let sec = if date.tm_sec < 10 {":0"} else {":"}; let year = 1900 + date.tm_year; - let mut time_str = format!( + let time_str = format!( // NOTE: The 14 accompanying chars are needed for some reason "{} {}{}{}{}{}{}{}{}{} {}\0\0\0\0\0\0\0\0\0\0\0\0\0\0", days[date.tm_wday as usize], @@ -117,8 +117,9 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { let time_str_ptr = time_str[0..26].as_ptr() as _; let time_str_offset = copy_cstr_into_wasm(instance, time_str_ptr); - let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8; - use std::ffi::CStr; + // let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8; + // use std::ffi::CStr; + // debug!("#### cstr = {:?}", CStr::from_ptr(c_str)); // std::mem::forget(time_str); time_str_offset From 80f76f79b52e3aaed1511d7ef9dceb007f7ff0a7 Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 7 Dec 2018 13:59:06 -0800 Subject: [PATCH 04/12] Improved localtime formatting --- src/apis/emscripten/time.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index 0265baba3..939fb05f9 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -91,21 +91,17 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - let day = if date.tm_mday < 10 {" "} else {" "}; - let hour = if date.tm_hour < 10 {" 0"} else {" "}; - let min = if date.tm_min < 10 {":0"} else {":"}; - let sec = if date.tm_sec < 10 {":0"} else {":"}; let year = 1900 + date.tm_year; let time_str = format!( // NOTE: The 14 accompanying chars are needed for some reason - "{} {}{}{}{}{}{}{}{}{} {}\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + "{} {} {:2} {:02}:{:02}:{:02} {:4}\n\0\0\0\0\0\0\0\0\0\0\0\0\0", days[date.tm_wday as usize], months[date.tm_mon as usize], - day, date.tm_mday, - hour, date.tm_hour, - min, date.tm_min, - sec, date.tm_sec, + date.tm_mday, + date.tm_hour, + date.tm_min, + date.tm_sec, year ); From dba8961c502c3467f42d54d9edf7cdc4cd74d9ec Mon Sep 17 00:00:00 2001 From: Syrus Date: Fri, 7 Dec 2018 14:55:55 -0800 Subject: [PATCH 05/12] Added basic emscripten tests --- emtests/README.md | 9 +++++++++ emtests/localtime.c | 20 ++++++++++++++++++++ emtests/localtime.wasm | Bin 0 -> 45695 bytes 3 files changed, 29 insertions(+) create mode 100644 emtests/README.md create mode 100644 emtests/localtime.c create mode 100644 emtests/localtime.wasm diff --git a/emtests/README.md b/emtests/README.md new file mode 100644 index 000000000..92313f484 --- /dev/null +++ b/emtests/README.md @@ -0,0 +1,9 @@ +This directory contains tests for unit testing each of the functions/syscalls that Emscripten will be doing. + +If you want to generate the wasm files, you will just need to: + +``` +emcc localtime.c -o localtime.js +# Delte the js file, as we don't need it +rm localtime.js +``` diff --git a/emtests/localtime.c b/emtests/localtime.c new file mode 100644 index 000000000..9dffefd9b --- /dev/null +++ b/emtests/localtime.c @@ -0,0 +1,20 @@ +#include +#include + +int main (int argc, char *argv[]) { + printf("Hello wasmer!\n"); + time_t rawtime; + struct tm *info; + char buffer[80]; + + time( &rawtime ); + + info = localtime( &rawtime ); + + printf("Almost!\n"); + printf("Current local time and date: %s\n", asctime(info)); + printf("Done!\n"); + + return(0); +} + diff --git a/emtests/localtime.wasm b/emtests/localtime.wasm new file mode 100644 index 0000000000000000000000000000000000000000..b8641411ec0e528fe9628a3c5b0a964d75175d93 GIT binary patch literal 45695 zcma&P2b`5fviEpFwDGmLEV%Akm- zsF(#&F@g$;m@@{<0drQ&Ip@gx{nc}3VE4W6=l{ocPCp&0tE;Q4yQ{0a3kOa(EGiTV z(H|QRNG4616iqrH(w~BR3J1g<#NWaJg~92m(mrRKIWi94=EHBStm3P9JeBMHfDvt z`xvE%z+(GqZa=)Ouxn4HX=@vQxHnV# zp@)wz^zSid44gjZj|cvJ+@Xj3xxKJkEkNz|kHg20EsUUvl%o9~;}3)hno48-^rvx0 zO!#wQ!)(l-+QyD8tky7Q+_;H{jX7w-Ul07tm_s+;tS~AYbJ&50jxVfQ;&&V@QRs)y zd8IJgeeiGL*V&i}2eq{ncCY*6-|11~#;JGgQNQAY&pm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{?Qf7}m(NS*hRrXN>^oNCbI^@d}r9mfn* zGMX|=kwHhH1TrT1pHO>}A*L#!PrUsTN~y^+lNX%5VLJ#u=Ioz5GckDvul Date: Sat, 8 Dec 2018 01:38:51 +0100 Subject: [PATCH 06/12] Fixing _localtime_r --- src/apis/emscripten/time.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index 939fb05f9..be0f1f1fa 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -170,6 +170,7 @@ pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance unsafe { let time_p_addr = instance.memory_offset_addr(0, time_p as _) as *mut i64; let result_addr = instance.memory_offset_addr(0, result as _) as *mut guest_tm; + let mut result_tm = tm { tm_sec: (*result_addr).tm_sec, tm_min: (*result_addr).tm_min, @@ -186,26 +187,19 @@ pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance let tm_struct = &*localtime_r(time_p_addr, &mut result_tm); - let tm_struct_offset = (instance.emscripten_data.as_ref().unwrap().malloc)( - mem::size_of::() as _, - instance, - ); + (*result_addr).tm_sec = tm_struct.tm_sec; + (*result_addr).tm_min = tm_struct.tm_min; + (*result_addr).tm_hour = tm_struct.tm_hour; + (*result_addr).tm_mday = tm_struct.tm_mday; + (*result_addr).tm_mon = tm_struct.tm_mon; + (*result_addr).tm_year = tm_struct.tm_year; + (*result_addr).tm_wday = tm_struct.tm_wday; + (*result_addr).tm_yday = tm_struct.tm_yday; + (*result_addr).tm_isdst = tm_struct.tm_isdst; + (*result_addr).tm_gmtoff = tm_struct.tm_gmtoff as _; + (*result_addr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone) as _; - let tm_struct_ptr = instance.memory_offset_addr(0, tm_struct_offset as _) as *mut guest_tm; - - (*tm_struct_ptr).tm_sec = tm_struct.tm_sec; - (*tm_struct_ptr).tm_min = tm_struct.tm_min; - (*tm_struct_ptr).tm_hour = tm_struct.tm_hour; - (*tm_struct_ptr).tm_mday = tm_struct.tm_mday; - (*tm_struct_ptr).tm_mon = tm_struct.tm_mon; - (*tm_struct_ptr).tm_year = tm_struct.tm_year; - (*tm_struct_ptr).tm_wday = tm_struct.tm_wday; - (*tm_struct_ptr).tm_yday = tm_struct.tm_yday; - (*tm_struct_ptr).tm_isdst = tm_struct.tm_isdst; - (*tm_struct_ptr).tm_gmtoff = tm_struct.tm_gmtoff as i32; - (*tm_struct_ptr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone) as i32; - - tm_struct_offset as c_int + result as _ } } From 6f632e615ffa6a44f97801479522ebb5caee7ea9 Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Tue, 11 Dec 2018 17:05:07 +0100 Subject: [PATCH 07/12] Add impl for `asctime_r` --- src/apis/emscripten/mod.rs | 5 +++ src/apis/emscripten/time.rs | 68 ++++++++++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/src/apis/emscripten/mod.rs b/src/apis/emscripten/mod.rs index 22602a86b..4ec73a8c6 100644 --- a/src/apis/emscripten/mod.rs +++ b/src/apis/emscripten/mod.rs @@ -384,6 +384,11 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> { "_asctime", ImportValue::Func(time::_asctime as _), ); + import_object.set( + "env", + "_asctime_r", + ImportValue::Func(time::_asctime_r as _), + ); import_object.set( "env", "_localtime", diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index be0f1f1fa..8e5273dbd 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -90,7 +90,6 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - let year = 1900 + date.tm_year; let time_str = format!( @@ -105,11 +104,6 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { year ); - - // NOTE: asctime_r is specced to behave in an undefined manner if the algorithm would attempt - // to write out more than 26 bytes (including the null terminator). - // See http://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html - // Our undefined behavior is to truncate the write to at most 26 bytes, including null terminator. let time_str_ptr = time_str[0..26].as_ptr() as _; let time_str_offset = copy_cstr_into_wasm(instance, time_str_ptr); @@ -117,11 +111,66 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { // use std::ffi::CStr; // debug!("#### cstr = {:?}", CStr::from_ptr(c_str)); - // std::mem::forget(time_str); time_str_offset } } + +// TODO +// fn asctime_fmt() -> *const c_char { + +// } + +// MOVE to utils.rs +extern "C" fn write_to_buf(string: *const c_char, buf: u32, max: u32, instance: &mut Instance) -> u32 { + let buf_addr = instance.memory_offset_addr(0, buf as _) as *mut c_char; + + unsafe { + for i in 0..max { + *buf_addr.add(i as _) = *string.add(i as _); + } + } + + buf +} + +/// emscripten: _asctime_r +pub extern "C" fn _asctime_r(time: u32, buf: u32, instance: &mut Instance) -> u32 { + debug!("emscripten::_asctime {}", time); + + unsafe { + let date = &*(instance.memory_offset_addr(0, time as _) as *mut guest_tm); + + let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + let year = 1900 + date.tm_year; + + let time_str = format!( + // NOTE: The 14 accompanying chars are needed for some reason + "{} {} {:2} {:02}:{:02}:{:02} {:4}\n\0\0\0\0\0\0\0\0\0\0\0\0\0", + days[date.tm_wday as usize], + months[date.tm_mon as usize], + date.tm_mday, + date.tm_hour, + date.tm_min, + date.tm_sec, + year + ); + + // NOTE: asctime_r is specced to behave in an undefined manner if the algorithm would attempt + // to write out more than 26 bytes (including the null terminator). + // See http://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html + // Our undefined behavior is to truncate the write to at most 26 bytes, including null terminator. + let time_str_ptr = time_str[0..26].as_ptr() as _; + write_to_buf(time_str_ptr, buf, 26, instance) + + // let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8; + // use std::ffi::CStr; + // debug!("#### cstr = {:?}", CStr::from_ptr(c_str)); + } +} + + /// emscripten: _tvset pub extern "C" fn _tvset() { debug!("emscripten::_tvset UNIMPLEMENTED"); @@ -157,7 +206,7 @@ pub extern "C" fn _localtime(time_p: u32, instance: &mut Instance) -> c_int { (*tm_struct_ptr).tm_gmtoff = tm_struct.tm_gmtoff as i32; (*tm_struct_ptr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone) as i32; - tm_struct_offset as c_int + tm_struct_offset as _ } } /// emscripten: _localtime_r @@ -199,7 +248,8 @@ pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance (*result_addr).tm_gmtoff = tm_struct.tm_gmtoff as _; (*result_addr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone) as _; - result as _ + result; + 0 } } From 2b1dac4d7da9d6fb9200f2bc3d68599471de9b3e Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Tue, 11 Dec 2018 18:06:20 +0100 Subject: [PATCH 08/12] Refactor code --- src/apis/emscripten/time.rs | 101 +++++++++++++++-------------------- src/apis/emscripten/utils.rs | 12 +++++ 2 files changed, 54 insertions(+), 59 deletions(-) diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index 8e5273dbd..e6bec77fa 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -1,4 +1,4 @@ -use super::utils::copy_cstr_into_wasm; +use super::utils::{copy_cstr_into_wasm, write_to_buf}; use libc::{ c_int, c_long, @@ -81,87 +81,71 @@ struct guest_tm { pub tm_zone: c_int, // 40 } +/// formats time as a C string +unsafe extern "C" fn fmt_time(time: u32, instance: &Instance) -> *const c_char { + let date = &*(instance.memory_offset_addr(0, time as _) as *mut guest_tm); + + let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + let year = 1900 + date.tm_year; + + let time_str = format!( + // NOTE: The 14 accompanying chars are needed for some reason + "{} {} {:2} {:02}:{:02}:{:02} {:4}\n\0\0\0\0\0\0\0\0\0\0\0\0\0", + days[date.tm_wday as usize], + months[date.tm_mon as usize], + date.tm_mday, + date.tm_hour, + date.tm_min, + date.tm_sec, + year + ); + + time_str[0..26].as_ptr() as _ +} + /// emscripten: _asctime pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { debug!("emscripten::_asctime {}", time); unsafe { - let date = &*(instance.memory_offset_addr(0, time as _) as *mut guest_tm); - - let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; - let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - let year = 1900 + date.tm_year; - - let time_str = format!( - // NOTE: The 14 accompanying chars are needed for some reason - "{} {} {:2} {:02}:{:02}:{:02} {:4}\n\0\0\0\0\0\0\0\0\0\0\0\0\0", - days[date.tm_wday as usize], - months[date.tm_mon as usize], - date.tm_mday, - date.tm_hour, - date.tm_min, - date.tm_sec, - year - ); - - let time_str_ptr = time_str[0..26].as_ptr() as _; - let time_str_offset = copy_cstr_into_wasm(instance, time_str_ptr); + let time_str_ptr = fmt_time(time, instance); + copy_cstr_into_wasm(instance, time_str_ptr) // let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8; // use std::ffi::CStr; // debug!("#### cstr = {:?}", CStr::from_ptr(c_str)); - - time_str_offset } } - -// TODO -// fn asctime_fmt() -> *const c_char { - -// } - -// MOVE to utils.rs -extern "C" fn write_to_buf(string: *const c_char, buf: u32, max: u32, instance: &mut Instance) -> u32 { - let buf_addr = instance.memory_offset_addr(0, buf as _) as *mut c_char; - - unsafe { - for i in 0..max { - *buf_addr.add(i as _) = *string.add(i as _); - } - } - - buf -} - /// emscripten: _asctime_r pub extern "C" fn _asctime_r(time: u32, buf: u32, instance: &mut Instance) -> u32 { debug!("emscripten::_asctime {}", time); unsafe { - let date = &*(instance.memory_offset_addr(0, time as _) as *mut guest_tm); + // let date = &*(instance.memory_offset_addr(0, time as _) as *mut guest_tm); - let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; - let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - let year = 1900 + date.tm_year; + // let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + // let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + // let year = 1900 + date.tm_year; - let time_str = format!( - // NOTE: The 14 accompanying chars are needed for some reason - "{} {} {:2} {:02}:{:02}:{:02} {:4}\n\0\0\0\0\0\0\0\0\0\0\0\0\0", - days[date.tm_wday as usize], - months[date.tm_mon as usize], - date.tm_mday, - date.tm_hour, - date.tm_min, - date.tm_sec, - year - ); + // let time_str = format!( + // // NOTE: The 14 accompanying chars are needed for some reason + // "{} {} {:2} {:02}:{:02}:{:02} {:4}\n\0\0\0\0\0\0\0\0\0\0\0\0\0", + // days[date.tm_wday as usize], + // months[date.tm_mon as usize], + // date.tm_mday, + // date.tm_hour, + // date.tm_min, + // date.tm_sec, + // year + // ); // NOTE: asctime_r is specced to behave in an undefined manner if the algorithm would attempt // to write out more than 26 bytes (including the null terminator). // See http://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html // Our undefined behavior is to truncate the write to at most 26 bytes, including null terminator. - let time_str_ptr = time_str[0..26].as_ptr() as _; + let time_str_ptr = fmt_time(time, instance); write_to_buf(time_str_ptr, buf, 26, instance) // let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8; @@ -170,7 +154,6 @@ pub extern "C" fn _asctime_r(time: u32, buf: u32, instance: &mut Instance) -> u3 } } - /// emscripten: _tvset pub extern "C" fn _tvset() { debug!("emscripten::_tvset UNIMPLEMENTED"); diff --git a/src/apis/emscripten/utils.rs b/src/apis/emscripten/utils.rs index af96463a8..a00421c7a 100644 --- a/src/apis/emscripten/utils.rs +++ b/src/apis/emscripten/utils.rs @@ -17,6 +17,18 @@ pub fn is_emscripten_module(module: &Module) -> bool { return false; } +pub unsafe fn write_to_buf(string: *const c_char, buf: u32, max: u32, instance: &Instance) -> u32 { + let buf_addr = instance.memory_offset_addr(0, buf as _) as *mut c_char; + + unsafe { + for i in 0..max { + *buf_addr.add(i as _) = *string.add(i as _); + } + } + + buf +} + pub unsafe fn copy_cstr_into_wasm(instance: &mut Instance, cstr: *const c_char) -> u32 { let s = CStr::from_ptr(cstr).to_str().unwrap(); let cstr_len = s.len(); From 877c13979a6d92a8ed73d186a6cde05651990fe3 Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Tue, 11 Dec 2018 19:04:46 +0100 Subject: [PATCH 09/12] Fix localtime_r issue caused by temp var --- src/apis/emscripten/time.rs | 52 +++++++------------------------------ 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index e6bec77fa..ee341d653 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -81,6 +81,11 @@ struct guest_tm { pub tm_zone: c_int, // 40 } +/// emscripten: _tvset +pub extern "C" fn _tvset() { + debug!("emscripten::_tvset UNIMPLEMENTED"); +} + /// formats time as a C string unsafe extern "C" fn fmt_time(time: u32, instance: &Instance) -> *const c_char { let date = &*(instance.memory_offset_addr(0, time as _) as *mut guest_tm); @@ -90,7 +95,7 @@ unsafe extern "C" fn fmt_time(time: u32, instance: &Instance) -> *const c_char { let year = 1900 + date.tm_year; let time_str = format!( - // NOTE: The 14 accompanying chars are needed for some reason + // NOTE: TODO: Hack! The 14 accompanying chars are needed for some reason "{} {} {:2} {:02}:{:02}:{:02} {:4}\n\0\0\0\0\0\0\0\0\0\0\0\0\0", days[date.tm_wday as usize], months[date.tm_mon as usize], @@ -120,27 +125,9 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 { /// emscripten: _asctime_r pub extern "C" fn _asctime_r(time: u32, buf: u32, instance: &mut Instance) -> u32 { - debug!("emscripten::_asctime {}", time); + debug!("emscripten::_asctime_r {}", time); unsafe { - // let date = &*(instance.memory_offset_addr(0, time as _) as *mut guest_tm); - - // let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; - // let months = vec!["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - // let year = 1900 + date.tm_year; - - // let time_str = format!( - // // NOTE: The 14 accompanying chars are needed for some reason - // "{} {} {:2} {:02}:{:02}:{:02} {:4}\n\0\0\0\0\0\0\0\0\0\0\0\0\0", - // days[date.tm_wday as usize], - // months[date.tm_mon as usize], - // date.tm_mday, - // date.tm_hour, - // date.tm_min, - // date.tm_sec, - // year - // ); - // NOTE: asctime_r is specced to behave in an undefined manner if the algorithm would attempt // to write out more than 26 bytes (including the null terminator). // See http://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html @@ -154,11 +141,6 @@ pub extern "C" fn _asctime_r(time: u32, buf: u32, instance: &mut Instance) -> u3 } } -/// emscripten: _tvset -pub extern "C" fn _tvset() { - debug!("emscripten::_tvset UNIMPLEMENTED"); -} - /// emscripten: _localtime pub extern "C" fn _localtime(time_p: u32, instance: &mut Instance) -> c_int { debug!("emscripten::_localtime {}", time_p); @@ -192,6 +174,7 @@ pub extern "C" fn _localtime(time_p: u32, instance: &mut Instance) -> c_int { tm_struct_offset as _ } } + /// emscripten: _localtime_r pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance) -> c_int { debug!("emscripten::_localtime_r {}", time_p); @@ -201,7 +184,6 @@ pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance unsafe { let time_p_addr = instance.memory_offset_addr(0, time_p as _) as *mut i64; - let result_addr = instance.memory_offset_addr(0, result as _) as *mut guest_tm; let mut result_tm = tm { tm_sec: (*result_addr).tm_sec, @@ -217,22 +199,8 @@ pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance tm_zone: instance.memory_offset_addr(0, (*result_addr).tm_zone as _) as _, }; - let tm_struct = &*localtime_r(time_p_addr, &mut result_tm); - - (*result_addr).tm_sec = tm_struct.tm_sec; - (*result_addr).tm_min = tm_struct.tm_min; - (*result_addr).tm_hour = tm_struct.tm_hour; - (*result_addr).tm_mday = tm_struct.tm_mday; - (*result_addr).tm_mon = tm_struct.tm_mon; - (*result_addr).tm_year = tm_struct.tm_year; - (*result_addr).tm_wday = tm_struct.tm_wday; - (*result_addr).tm_yday = tm_struct.tm_yday; - (*result_addr).tm_isdst = tm_struct.tm_isdst; - (*result_addr).tm_gmtoff = tm_struct.tm_gmtoff as _; - (*result_addr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone) as _; - - result; - 0 + localtime_r(time_p_addr, &mut result_tm); + result as _ } } From 899bd5c91973a221ad28aabe4f9529be7d95efa2 Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Tue, 11 Dec 2018 19:24:47 +0100 Subject: [PATCH 10/12] Fix failing compilation --- src/apis/emscripten/time.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index ee341d653..3d1ad8b92 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -174,7 +174,6 @@ pub extern "C" fn _localtime(time_p: u32, instance: &mut Instance) -> c_int { tm_struct_offset as _ } } - /// emscripten: _localtime_r pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance) -> c_int { debug!("emscripten::_localtime_r {}", time_p); @@ -184,6 +183,7 @@ pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance unsafe { let time_p_addr = instance.memory_offset_addr(0, time_p as _) as *mut i64; + let result_addr = instance.memory_offset_addr(0, result as _) as *mut guest_tm; let mut result_tm = tm { tm_sec: (*result_addr).tm_sec, From cdf56f286520306bea6d51ca2f53737c94faae83 Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Tue, 11 Dec 2018 20:42:29 +0100 Subject: [PATCH 11/12] Refactor localtime_r --- src/apis/emscripten/time.rs | 50 ++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index 3d1ad8b92..0c26474a5 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -149,27 +149,30 @@ pub extern "C" fn _localtime(time_p: u32, instance: &mut Instance) -> c_int { unsafe { let time_p_addr = instance.memory_offset_addr(0, time_p as _) as *mut i64; - - let tm_struct = &*localtime(time_p_addr); - + let result_tm = &*localtime(time_p_addr); let tm_struct_offset = (instance.emscripten_data.as_ref().unwrap().malloc)( mem::size_of::() as _, instance, ); let tm_struct_ptr = instance.memory_offset_addr(0, tm_struct_offset as _) as *mut guest_tm; + debug!( + ">>>>>>> time = {}, {}, {}, {}, {}, {}, {}, {}", + result_tm.tm_sec, result_tm.tm_min, result_tm.tm_hour, result_tm.tm_mday, + result_tm.tm_mon, result_tm.tm_year, result_tm.tm_wday, result_tm.tm_yday, + ); - (*tm_struct_ptr).tm_sec = tm_struct.tm_sec; - (*tm_struct_ptr).tm_min = tm_struct.tm_min; - (*tm_struct_ptr).tm_hour = tm_struct.tm_hour; - (*tm_struct_ptr).tm_mday = tm_struct.tm_mday; - (*tm_struct_ptr).tm_mon = tm_struct.tm_mon; - (*tm_struct_ptr).tm_year = tm_struct.tm_year; - (*tm_struct_ptr).tm_wday = tm_struct.tm_wday; - (*tm_struct_ptr).tm_yday = tm_struct.tm_yday; - (*tm_struct_ptr).tm_isdst = tm_struct.tm_isdst; - (*tm_struct_ptr).tm_gmtoff = tm_struct.tm_gmtoff as i32; - (*tm_struct_ptr).tm_zone = copy_cstr_into_wasm(instance, tm_struct.tm_zone) as i32; + (*tm_struct_ptr).tm_sec = result_tm.tm_sec; + (*tm_struct_ptr).tm_min = result_tm.tm_min; + (*tm_struct_ptr).tm_hour = result_tm.tm_hour; + (*tm_struct_ptr).tm_mday = result_tm.tm_mday; + (*tm_struct_ptr).tm_mon = result_tm.tm_mon; + (*tm_struct_ptr).tm_year = result_tm.tm_year; + (*tm_struct_ptr).tm_wday = result_tm.tm_wday; + (*tm_struct_ptr).tm_yday = result_tm.tm_yday; + (*tm_struct_ptr).tm_isdst = result_tm.tm_isdst; + (*tm_struct_ptr).tm_gmtoff = result_tm.tm_gmtoff as i32; + (*tm_struct_ptr).tm_zone = copy_cstr_into_wasm(instance, result_tm.tm_zone) as i32; tm_struct_offset as _ } @@ -200,6 +203,25 @@ pub extern "C" fn _localtime_r(time_p: u32, result: u32, instance: &mut Instance }; localtime_r(time_p_addr, &mut result_tm); + // let tm_struct = result_tm; + // debug!( + // ">>>>>>> time = {}, {}, {}, {}, {}, {}, {}, {}", + // result_tm.tm_sec, result_tm.tm_min, result_tm.tm_hour, result_tm.tm_mday, + // result_tm.tm_mon, result_tm.tm_year, result_tm.tm_wday, result_tm.tm_yday, + // ); + + (*result_addr).tm_sec = result_tm.tm_sec; + (*result_addr).tm_min = result_tm.tm_min; + (*result_addr).tm_hour = result_tm.tm_hour; + (*result_addr).tm_mday = result_tm.tm_mday; + (*result_addr).tm_mon = result_tm.tm_mon; + (*result_addr).tm_year = result_tm.tm_year; + (*result_addr).tm_wday = result_tm.tm_wday; + (*result_addr).tm_yday = result_tm.tm_yday; + (*result_addr).tm_isdst = result_tm.tm_isdst; + (*result_addr).tm_gmtoff = result_tm.tm_gmtoff as _; + (*result_addr).tm_zone = copy_cstr_into_wasm(instance, result_tm.tm_zone) as _; + result as _ } } From fa1d602e26a4ccf3c156efa0e83d2e073217ea73 Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Tue, 11 Dec 2018 21:13:43 +0100 Subject: [PATCH 12/12] Revert edition --- src/apis/emscripten/time.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/apis/emscripten/time.rs b/src/apis/emscripten/time.rs index 0c26474a5..0395646a5 100644 --- a/src/apis/emscripten/time.rs +++ b/src/apis/emscripten/time.rs @@ -156,11 +156,11 @@ pub extern "C" fn _localtime(time_p: u32, instance: &mut Instance) -> c_int { ); let tm_struct_ptr = instance.memory_offset_addr(0, tm_struct_offset as _) as *mut guest_tm; - debug!( - ">>>>>>> time = {}, {}, {}, {}, {}, {}, {}, {}", - result_tm.tm_sec, result_tm.tm_min, result_tm.tm_hour, result_tm.tm_mday, - result_tm.tm_mon, result_tm.tm_year, result_tm.tm_wday, result_tm.tm_yday, - ); + // debug!( + // ">>>>>>> time = {}, {}, {}, {}, {}, {}, {}, {}", + // result_tm.tm_sec, result_tm.tm_min, result_tm.tm_hour, result_tm.tm_mday, + // result_tm.tm_mon, result_tm.tm_year, result_tm.tm_wday, result_tm.tm_yday, + // ); (*tm_struct_ptr).tm_sec = result_tm.tm_sec; (*tm_struct_ptr).tm_min = result_tm.tm_min;