create the windows io mod and link printf (#144)

This commit is contained in:
Mackenzie Clark
2019-02-06 17:56:01 -08:00
committed by GitHub
parent 0a7b9b26b8
commit ac286b708b
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,17 @@
use libc::printf as _printf;
use wasmer_runtime_core::vm::Ctx;
/// putchar
pub fn putchar(chr: i32, ctx: &mut Ctx) {
unsafe { libc::putchar(chr) };
}
/// printf
pub fn printf(memory_offset: i32, extra: i32, ctx: &mut Ctx) -> i32 {
debug!("emscripten::printf {}, {}", memory_offset, extra);
unsafe {
let addr = emscripten_memory_pointer!(ctx.memory(0), memory_offset) as _;
_printf(addr, extra)
}
}