2019-03-20 16:46:42 -07:00
|
|
|
use libc::{chroot as _chroot, printf as _printf};
|
2018-11-13 19:19:23 -08:00
|
|
|
|
2019-01-24 15:44:08 -08:00
|
|
|
use wasmer_runtime_core::vm::Ctx;
|
2018-11-13 19:19:23 -08:00
|
|
|
|
2018-11-20 20:11:58 +01:00
|
|
|
/// putchar
|
2019-03-12 22:00:33 +01:00
|
|
|
pub fn putchar(_ctx: &mut Ctx, chr: i32) {
|
2019-01-30 20:03:54 -06:00
|
|
|
unsafe { libc::putchar(chr) };
|
|
|
|
}
|
2018-11-20 20:11:58 +01:00
|
|
|
|
|
|
|
/// printf
|
2019-02-09 13:58:05 -08:00
|
|
|
pub fn printf(ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
2018-12-17 23:54:00 -06:00
|
|
|
debug!("emscripten::printf {}, {}", memory_offset, extra);
|
2018-11-25 13:51:21 -05:00
|
|
|
unsafe {
|
2019-01-24 15:44:08 -08:00
|
|
|
let addr = emscripten_memory_pointer!(ctx.memory(0), memory_offset) as _;
|
2018-11-25 13:51:21 -05:00
|
|
|
_printf(addr, extra)
|
|
|
|
}
|
2018-11-13 19:19:23 -08:00
|
|
|
}
|
2019-03-20 16:46:42 -07:00
|
|
|
|
|
|
|
/// chroot
|
|
|
|
pub fn chroot(ctx: &mut Ctx, name_ptr: i32) -> i32 {
|
|
|
|
let name = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const i8;
|
|
|
|
unsafe { _chroot(name) }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getprotobyname
|
|
|
|
pub fn getprotobyname(ctx: &mut Ctx, name_ptr: i32) -> i32 {
|
|
|
|
debug!("emscripten::getprotobyname");
|
|
|
|
// TODO: actually do this logic to return correctly
|
|
|
|
let _name = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const i8;
|
|
|
|
//unsafe { _getprotobyname(name) as i32 }
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getprotobynumber
|
|
|
|
pub fn getprotobynumber(_ctx: &mut Ctx, _one: i32) -> i32 {
|
|
|
|
debug!("emscripten::getprotobynumber");
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getpwuid
|
|
|
|
pub fn getpwuid(_ctx: &mut Ctx, _uid: i32) -> i32 {
|
|
|
|
debug!("emscripten::getpwuid");
|
|
|
|
// TODO: actually do this logic to return correctly
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
/// longjmp
|
|
|
|
pub fn longjmp(_ctx: &mut Ctx, _one: i32, _two: i32) {
|
|
|
|
debug!("emscripten::longjump");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// sigdelset
|
|
|
|
pub fn sigdelset(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
|
|
|
debug!("emscripten::sigdelset");
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
/// sigfillset
|
|
|
|
pub fn sigfillset(_ctx: &mut Ctx, _one: i32) -> i32 {
|
|
|
|
debug!("emscripten::sigfillset");
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
/// tzset
|
|
|
|
pub fn tzset(_ctx: &mut Ctx) {
|
|
|
|
debug!("emscripten::tzset");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// strptime
|
|
|
|
pub fn strptime(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
|
|
|
debug!("emscripten::strptime");
|
|
|
|
0
|
|
|
|
}
|