2018-11-20 19:11:58 +00:00
|
|
|
use libc::{
|
|
|
|
c_void,
|
|
|
|
size_t,
|
|
|
|
memcpy,
|
|
|
|
};
|
|
|
|
|
|
|
|
use crate::webassembly::{Instance};
|
|
|
|
|
|
|
|
/// emscripten: _emscripten_memcpy_big
|
|
|
|
pub extern "C" fn _emscripten_memcpy_big(dest: u32, src: u32, len: u32, instance: &mut Instance) -> u32 {
|
2018-11-21 03:24:23 +00:00
|
|
|
debug!("emscripten::_emscripten_memcpy_big");
|
2018-11-20 19:11:58 +00:00
|
|
|
let dest_addr = instance.memory_offset_addr(0, dest as usize) as *mut c_void;
|
|
|
|
let src_addr = instance.memory_offset_addr(0, src as usize) as *mut c_void;
|
|
|
|
unsafe { memcpy(dest_addr, src_addr, len as size_t); }
|
|
|
|
dest
|
|
|
|
}
|
|
|
|
|
|
|
|
/// emscripten: getTotalMemory
|
|
|
|
pub extern "C" fn get_total_memory(instance: &mut Instance) -> u32 {
|
2018-11-21 03:24:23 +00:00
|
|
|
debug!("emscripten::get_total_memory");
|
2018-11-20 19:11:58 +00:00
|
|
|
instance.memories[0].current_size()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// emscripten: enlargeMemory
|
2018-11-21 03:24:23 +00:00
|
|
|
pub extern "C" fn enlarge_memory(instance: &mut Instance) {
|
|
|
|
debug!("emscripten::enlarge_memory");
|
|
|
|
// instance.memories[0].grow(100);
|
2018-11-20 19:11:58 +00:00
|
|
|
}
|