mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-12 16:41:21 +00:00
Add typed functions and weird type parameter things
This commit is contained in:
@ -11,20 +11,14 @@ use super::utils::{allocate_on_stack, copy_cstr_into_wasm, copy_terminated_array
|
||||
use super::EmscriptenData;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
pub extern "C" fn _getaddrinfo(
|
||||
_one: i32,
|
||||
_two: i32,
|
||||
_three: i32,
|
||||
_four: i32,
|
||||
_ctx: &mut Ctx,
|
||||
) -> i32 {
|
||||
pub fn _getaddrinfo(_one: i32, _two: i32, _three: i32, _four: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_getaddrinfo");
|
||||
-1
|
||||
}
|
||||
|
||||
// #[no_mangle]
|
||||
/// emscripten: _getenv // (name: *const char) -> *const c_char;
|
||||
pub extern "C" fn _getenv(name: i32, ctx: &mut Ctx) -> u32 {
|
||||
pub fn _getenv(name: i32, ctx: &mut Ctx) -> u32 {
|
||||
debug!("emscripten::_getenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
@ -40,7 +34,7 @@ pub extern "C" fn _getenv(name: i32, ctx: &mut Ctx) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int);
|
||||
pub extern "C" fn _setenv(name: c_int, value: c_int, overwrite: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _setenv(name: c_int, value: c_int, overwrite: c_int, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_setenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
@ -53,7 +47,7 @@ pub extern "C" fn _setenv(name: c_int, value: c_int, overwrite: c_int, ctx: &mut
|
||||
}
|
||||
|
||||
/// emscripten: _putenv // (name: *const char);
|
||||
pub extern "C" fn _putenv(name: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _putenv(name: c_int, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_putenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
@ -64,7 +58,7 @@ pub extern "C" fn _putenv(name: c_int, ctx: &mut Ctx) -> c_int {
|
||||
}
|
||||
|
||||
/// emscripten: _unsetenv // (name: *const char);
|
||||
pub extern "C" fn _unsetenv(name: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _unsetenv(name: c_int, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_unsetenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
@ -75,7 +69,7 @@ pub extern "C" fn _unsetenv(name: c_int, ctx: &mut Ctx) -> c_int {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _getpwnam(name_ptr: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _getpwnam(name_ptr: c_int, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_getpwnam {}", name_ptr);
|
||||
|
||||
#[repr(C)]
|
||||
@ -113,7 +107,7 @@ pub extern "C" fn _getpwnam(name_ptr: c_int, ctx: &mut Ctx) -> c_int {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _getgrnam(name_ptr: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _getgrnam(name_ptr: c_int, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_getgrnam {}", name_ptr);
|
||||
|
||||
#[repr(C)]
|
||||
@ -144,29 +138,35 @@ pub extern "C" fn _getgrnam(name_ptr: c_int, ctx: &mut Ctx) -> c_int {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn call_malloc(size: i32, ctx: &mut Ctx) -> u32 {
|
||||
(get_emscripten_data(ctx).malloc)(size, ctx)
|
||||
pub fn call_malloc(size: u32, ctx: &mut Ctx) -> u32 {
|
||||
get_emscripten_data(ctx).malloc.call(size).unwrap()
|
||||
}
|
||||
|
||||
pub fn call_memalign(alignment: u32, size: u32, ctx: &mut Ctx) -> u32 {
|
||||
(get_emscripten_data(ctx).memalign)(alignment, size, ctx)
|
||||
get_emscripten_data(ctx)
|
||||
.memalign
|
||||
.call(alignment, size)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn call_memset(pointer: u32, value: i32, size: u32, ctx: &mut Ctx) -> u32 {
|
||||
(get_emscripten_data(ctx).memset)(pointer, value, size, ctx)
|
||||
pub fn call_memset(pointer: u32, value: u32, size: u32, ctx: &mut Ctx) -> u32 {
|
||||
get_emscripten_data(ctx)
|
||||
.memset
|
||||
.call(pointer, value, size)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn get_emscripten_data(ctx: &mut Ctx) -> &mut EmscriptenData {
|
||||
unsafe { &mut *(ctx.data as *mut EmscriptenData) }
|
||||
}
|
||||
|
||||
pub extern "C" fn _getpagesize(_ctx: &mut Ctx) -> u32 {
|
||||
pub fn _getpagesize(_ctx: &mut Ctx) -> u32 {
|
||||
debug!("emscripten::_getpagesize");
|
||||
16384
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn ___build_environment(environ: c_int, ctx: &mut Ctx) {
|
||||
pub fn ___build_environment(environ: c_int, ctx: &mut Ctx) {
|
||||
debug!("emscripten::___build_environment {}", environ);
|
||||
const MAX_ENV_VALUES: u32 = 64;
|
||||
const TOTAL_ENV_SIZE: u32 = 1024;
|
||||
@ -188,13 +188,13 @@ pub extern "C" fn ___build_environment(environ: c_int, ctx: &mut Ctx) {
|
||||
// };
|
||||
}
|
||||
|
||||
pub extern "C" fn _sysconf(name: c_int, _ctx: &mut Ctx) -> c_long {
|
||||
pub fn _sysconf(name: c_int, _ctx: &mut Ctx) -> c_long {
|
||||
debug!("emscripten::_sysconf {}", name);
|
||||
// TODO: Implement like emscripten expects regarding memory/page size
|
||||
unsafe { sysconf(name) }
|
||||
}
|
||||
|
||||
pub extern "C" fn ___assert_fail(a: c_int, b: c_int, c: c_int, d: c_int, _ctx: &mut Ctx) {
|
||||
pub fn ___assert_fail(a: c_int, b: c_int, c: c_int, d: c_int, _ctx: &mut Ctx) {
|
||||
debug!("emscripten::___assert_fail {} {} {} {}", a, b, c, d);
|
||||
// TODO: Implement like emscripten expects regarding memory/page size
|
||||
// TODO raise an error
|
||||
|
@ -1,7 +1,7 @@
|
||||
// use std::collections::HashMap;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
pub extern "C" fn ___seterrno(value: i32, _ctx: &mut Ctx) {
|
||||
pub fn ___seterrno(value: i32, _ctx: &mut Ctx) {
|
||||
debug!("emscripten::___seterrno {}", value);
|
||||
// TODO: Incomplete impl
|
||||
eprintln!("failed to set errno!");
|
||||
|
@ -3,14 +3,14 @@ use super::process::_abort;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
/// emscripten: ___cxa_allocate_exception
|
||||
pub extern "C" fn ___cxa_allocate_exception(size: u32, ctx: &mut Ctx) -> u32 {
|
||||
pub fn ___cxa_allocate_exception(size: u32, ctx: &mut Ctx) -> u32 {
|
||||
debug!("emscripten::___cxa_allocate_exception");
|
||||
env::call_malloc(size as _, ctx)
|
||||
}
|
||||
|
||||
/// emscripten: ___cxa_throw
|
||||
/// TODO: We don't have support for exceptions yet
|
||||
pub extern "C" fn ___cxa_throw(_ptr: u32, _ty: u32, _destructor: u32, ctx: &mut Ctx) {
|
||||
pub fn ___cxa_throw(_ptr: u32, _ty: u32, _destructor: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::___cxa_throw");
|
||||
_abort(ctx);
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ use libc::printf as _printf;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
/// putchar
|
||||
pub extern "C" fn putchar(chr: i32, ctx: &mut Ctx) {
|
||||
pub fn putchar(chr: i32, ctx: &mut Ctx) {
|
||||
unsafe { libc::putchar(chr) };
|
||||
}
|
||||
|
||||
/// printf
|
||||
pub extern "C" fn printf(memory_offset: i32, extra: i32, ctx: &mut Ctx) -> i32 {
|
||||
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 _;
|
||||
|
@ -4,7 +4,7 @@ use std::cell::UnsafeCell;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
/// setjmp
|
||||
pub extern "C" fn __setjmp(env_addr: u32, ctx: &mut Ctx) -> c_int {
|
||||
pub fn __setjmp(env_addr: u32, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::__setjmp (setjmp)");
|
||||
unsafe {
|
||||
unimplemented!()
|
||||
@ -26,7 +26,7 @@ pub extern "C" fn __setjmp(env_addr: u32, ctx: &mut Ctx) -> c_int {
|
||||
|
||||
/// longjmp
|
||||
#[allow(unreachable_code)]
|
||||
pub extern "C" fn __longjmp(env_addr: u32, val: c_int, ctx: &mut Ctx) {
|
||||
pub fn __longjmp(env_addr: u32, val: c_int, ctx: &mut Ctx) {
|
||||
debug!("emscripten::__longjmp (longmp)");
|
||||
unsafe {
|
||||
// We retrieve the jump index from the env address
|
||||
|
@ -24,7 +24,7 @@ use wasmer_runtime_core::{
|
||||
vm::LocalGlobal,
|
||||
vm::LocalMemory,
|
||||
vm::LocalTable,
|
||||
Instance, Module,
|
||||
Func, Instance, Module,
|
||||
};
|
||||
|
||||
#[macro_use]
|
||||
@ -88,69 +88,43 @@ fn dynamictop_ptr(static_bump: u32) -> u32 {
|
||||
static_bump + DYNAMICTOP_PTR_DIFF
|
||||
}
|
||||
|
||||
pub struct EmscriptenData {
|
||||
pub malloc: extern "C" fn(i32, &mut Ctx) -> u32,
|
||||
pub free: extern "C" fn(i32, &mut Ctx),
|
||||
pub memalign: extern "C" fn(u32, u32, &mut Ctx) -> u32,
|
||||
pub memset: extern "C" fn(u32, i32, u32, &mut Ctx) -> u32,
|
||||
pub stack_alloc: extern "C" fn(u32, &mut Ctx) -> u32,
|
||||
pub jumps: Vec<UnsafeCell<[c_int; 27]>>,
|
||||
pub struct EmscriptenData<'a> {
|
||||
pub malloc: Func<'a, u32, u32>,
|
||||
pub free: Func<'a, u32>,
|
||||
pub memalign: Func<'a, (u32, u32), u32>,
|
||||
pub memset: Func<'a, (u32, u32, u32), u32>,
|
||||
pub stack_alloc: Func<'a, u32, u32>,
|
||||
|
||||
pub jumps: Vec<UnsafeCell<[u8; 27]>>,
|
||||
}
|
||||
|
||||
impl EmscriptenData {
|
||||
pub fn new(instance: &mut Instance) -> Self {
|
||||
unsafe {
|
||||
let malloc_func = instance.func("_malloc");
|
||||
let malloc_addr = if let Ok(malloc_func) = malloc_func {
|
||||
malloc_func.raw() as *const u8
|
||||
} else {
|
||||
0 as *const u8
|
||||
};
|
||||
let free_func = instance.func("_free");
|
||||
let free_addr = if let Ok(free_func) = free_func {
|
||||
free_func.raw() as *const u8
|
||||
} else {
|
||||
0 as *const u8
|
||||
};
|
||||
let memalign_func = instance.func("_memalign");
|
||||
let memalign_addr = if let Ok(memalign_func) = memalign_func {
|
||||
memalign_func.raw() as *const u8
|
||||
} else {
|
||||
0 as *const u8
|
||||
};
|
||||
let memset_func = instance.func("_memset");
|
||||
let memset_addr = if let Ok(memset_func) = memset_func {
|
||||
memset_func.raw() as *const u8
|
||||
} else {
|
||||
0 as *const u8
|
||||
};
|
||||
let stack_alloc_func = instance.func("stackAlloc");
|
||||
let stack_alloc_addr = if let Ok(stack_alloc_func) = stack_alloc_func {
|
||||
stack_alloc_func.raw() as *const u8
|
||||
} else {
|
||||
0 as *const u8
|
||||
};
|
||||
impl<'a> EmscriptenData<'a> {
|
||||
pub fn new(instance: &'a mut Instance) -> EmscriptenData<'a> {
|
||||
let malloc = instance.func("_malloc").unwrap();
|
||||
let free = instance.func("_free").unwrap();
|
||||
let memalign = instance.func("_memalign").unwrap();
|
||||
let memset = instance.func("_memset").unwrap();
|
||||
let stack_alloc = instance.func("stackAlloc").unwrap();
|
||||
|
||||
EmscriptenData {
|
||||
malloc: mem::transmute(malloc_addr),
|
||||
free: mem::transmute(free_addr),
|
||||
memalign: mem::transmute(memalign_addr),
|
||||
memset: mem::transmute(memset_addr),
|
||||
stack_alloc: mem::transmute(stack_alloc_addr),
|
||||
jumps: Vec::new(),
|
||||
}
|
||||
EmscriptenData {
|
||||
malloc,
|
||||
free,
|
||||
memalign,
|
||||
memset,
|
||||
stack_alloc,
|
||||
jumps: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for EmscriptenData {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("EmscriptenData")
|
||||
.field("malloc", &(self.malloc as usize))
|
||||
.field("free", &(self.free as usize))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
// impl<'a> fmt::Debug for EmscriptenData<'a> {
|
||||
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
// f.debug_struct("EmscriptenData")
|
||||
// .field("malloc", &(self.malloc as usize))
|
||||
// .field("free", &(self.free as usize))
|
||||
// .finish()
|
||||
// }
|
||||
// }
|
||||
|
||||
pub fn run_emscripten_instance(
|
||||
_module: &Module,
|
||||
@ -162,7 +136,7 @@ pub fn run_emscripten_instance(
|
||||
let data_ptr = &mut data as *mut _ as *mut c_void;
|
||||
instance.context_mut().data = data_ptr;
|
||||
|
||||
let main_func = instance.func("_main")?;
|
||||
let main_func = instance.dyn_func("_main")?;
|
||||
let num_params = main_func.signature().params().len();
|
||||
let _result = match num_params {
|
||||
2 => {
|
||||
@ -179,7 +153,7 @@ pub fn run_emscripten_instance(
|
||||
};
|
||||
|
||||
// TODO atinit and atexit for emscripten
|
||||
println!("{:?}", data);
|
||||
// println!("{:?}", data);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -225,7 +199,7 @@ pub fn emscripten_set_up_memory(memory: &mut Memory) {
|
||||
|
||||
macro_rules! mock_external {
|
||||
($namespace:ident, $name:ident) => {{
|
||||
extern "C" fn _mocked_fn() -> i32 {
|
||||
fn _mocked_fn() -> i32 {
|
||||
debug!("emscripten::{} <mock>", stringify!($name));
|
||||
-1
|
||||
}
|
||||
@ -365,174 +339,174 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
"tempDoublePtr" => Global::new(Value::I32(0)),
|
||||
|
||||
// IO
|
||||
"printf" => func!(crate::io::printf, [i32, i32] -> [i32]),
|
||||
"putchar" => func!(crate::io::putchar, [i32] -> []),
|
||||
"___lock" => func!(crate::lock::___lock, [i32] -> []),
|
||||
"___unlock" => func!(crate::lock::___unlock, [i32] -> []),
|
||||
"___wait" => func!(crate::lock::___wait, [u32, u32, u32, u32] -> []),
|
||||
"printf" => func!(crate::io::printf),
|
||||
"putchar" => func!(crate::io::putchar),
|
||||
"___lock" => func!(crate::lock::___lock),
|
||||
"___unlock" => func!(crate::lock::___unlock),
|
||||
"___wait" => func!(crate::lock::___wait),
|
||||
|
||||
// Env
|
||||
"___assert_fail" => func!(crate::env::___assert_fail, [i32, i32, i32, i32] -> []),
|
||||
"_getenv" => func!(crate::env::_getenv, [i32] -> [u32]),
|
||||
"_setenv" => func!(crate::env::_setenv, [i32, i32, i32] -> [i32]),
|
||||
"_putenv" => func!(crate::env::_putenv, [i32] -> [i32]),
|
||||
"_unsetenv" => func!(crate::env::_unsetenv, [i32] -> [i32]),
|
||||
"_getpwnam" => func!(crate::env::_getpwnam, [i32] -> [i32]),
|
||||
"_getgrnam" => func!(crate::env::_getgrnam, [i32] -> [i32]),
|
||||
"___buildEnvironment" => func!(crate::env::___build_environment, [i32] -> []),
|
||||
"___setErrNo" => func!(crate::errno::___seterrno, [i32] -> []),
|
||||
"_getpagesize" => func!(crate::env::_getpagesize, [] -> [u32]),
|
||||
"_sysconf" => func!(crate::env::_sysconf, [i32] -> [i64]),
|
||||
"_getaddrinfo" => func!(crate::env::_getaddrinfo, [i32, i32, i32, i32] -> [i32]),
|
||||
"___assert_fail" => func!(crate::env::___assert_fail),
|
||||
"_getenv" => func!(crate::env::_getenv),
|
||||
"_setenv" => func!(crate::env::_setenv),
|
||||
"_putenv" => func!(crate::env::_putenv),
|
||||
"_unsetenv" => func!(crate::env::_unsetenv),
|
||||
"_getpwnam" => func!(crate::env::_getpwnam),
|
||||
"_getgrnam" => func!(crate::env::_getgrnam),
|
||||
"___buildEnvironment" => func!(crate::env::___build_environment),
|
||||
"___setErrNo" => func!(crate::errno::___seterrno),
|
||||
"_getpagesize" => func!(crate::env::_getpagesize),
|
||||
"_sysconf" => func!(crate::env::_sysconf),
|
||||
"_getaddrinfo" => func!(crate::env::_getaddrinfo),
|
||||
|
||||
// Null func
|
||||
"nullFunc_i" => func!(crate::nullfunc::nullfunc_i, [u32] -> []),
|
||||
"nullFunc_ii" => func!(crate::nullfunc::nullfunc_ii, [u32] -> []),
|
||||
"nullFunc_iii" => func!(crate::nullfunc::nullfunc_iii, [u32] -> []),
|
||||
"nullFunc_iiii" => func!(crate::nullfunc::nullfunc_iiii, [u32] -> []),
|
||||
"nullFunc_iiiii" => func!(crate::nullfunc::nullfunc_iiiii, [u32] -> []),
|
||||
"nullFunc_iiiiii" => func!(crate::nullfunc::nullfunc_iiiiii, [u32] -> []),
|
||||
"nullFunc_v" => func!(crate::nullfunc::nullfunc_v, [u32] -> []),
|
||||
"nullFunc_vi" => func!(crate::nullfunc::nullfunc_vi, [u32] -> []),
|
||||
"nullFunc_vii" => func!(crate::nullfunc::nullfunc_vii, [u32] -> []),
|
||||
"nullFunc_viii" => func!(crate::nullfunc::nullfunc_viii, [u32] -> []),
|
||||
"nullFunc_viiii" => func!(crate::nullfunc::nullfunc_viiii, [u32] -> []),
|
||||
"nullFunc_viiiii" => func!(crate::nullfunc::nullfunc_viiiii, [u32] -> []),
|
||||
"nullFunc_viiiiii" => func!(crate::nullfunc::nullfunc_viiiiii, [u32] -> []),
|
||||
"nullFunc_i" => func!(crate::nullfunc::nullfunc_i),
|
||||
"nullFunc_ii" => func!(crate::nullfunc::nullfunc_ii),
|
||||
"nullFunc_iii" => func!(crate::nullfunc::nullfunc_iii),
|
||||
"nullFunc_iiii" => func!(crate::nullfunc::nullfunc_iiii),
|
||||
"nullFunc_iiiii" => func!(crate::nullfunc::nullfunc_iiiii),
|
||||
"nullFunc_iiiiii" => func!(crate::nullfunc::nullfunc_iiiiii),
|
||||
"nullFunc_v" => func!(crate::nullfunc::nullfunc_v),
|
||||
"nullFunc_vi" => func!(crate::nullfunc::nullfunc_vi),
|
||||
"nullFunc_vii" => func!(crate::nullfunc::nullfunc_vii),
|
||||
"nullFunc_viii" => func!(crate::nullfunc::nullfunc_viii),
|
||||
"nullFunc_viiii" => func!(crate::nullfunc::nullfunc_viiii),
|
||||
"nullFunc_viiiii" => func!(crate::nullfunc::nullfunc_viiiii),
|
||||
"nullFunc_viiiiii" => func!(crate::nullfunc::nullfunc_viiiiii),
|
||||
|
||||
// Syscalls
|
||||
"___syscall1" => func!(crate::syscalls::___syscall1, [i32, VarArgs] -> []),
|
||||
"___syscall3" => func!(crate::syscalls::___syscall3, [i32, VarArgs] -> [i32]),
|
||||
"___syscall4" => func!(crate::syscalls::___syscall4, [i32, VarArgs] -> [i32]),
|
||||
"___syscall5" => func!(crate::syscalls::___syscall5, [i32, VarArgs] -> [i32]),
|
||||
"___syscall6" => func!(crate::syscalls::___syscall6, [i32, VarArgs] -> [i32]),
|
||||
"___syscall10" => func!(crate::syscalls::___syscall10, [i32, i32] -> [i32]),
|
||||
"___syscall12" => func!(crate::syscalls::___syscall12, [i32, VarArgs] -> [i32]),
|
||||
"___syscall15" => func!(crate::syscalls::___syscall15, [i32, i32] -> [i32]),
|
||||
"___syscall20" => func!(crate::syscalls::___syscall20, [i32, i32] -> [i32]),
|
||||
"___syscall39" => func!(crate::syscalls::___syscall39, [i32, VarArgs] -> [i32]),
|
||||
"___syscall38" => func!(crate::syscalls::___syscall38, [i32, i32] -> [i32]),
|
||||
"___syscall40" => func!(crate::syscalls::___syscall40, [i32, VarArgs] -> [i32]),
|
||||
"___syscall54" => func!(crate::syscalls::___syscall54, [i32, VarArgs] -> [i32]),
|
||||
"___syscall57" => func!(crate::syscalls::___syscall57, [i32, VarArgs] -> [i32]),
|
||||
"___syscall60" => func!(crate::syscalls::___syscall60, [i32, i32] -> [i32]),
|
||||
"___syscall63" => func!(crate::syscalls::___syscall63, [i32, VarArgs] -> [i32]),
|
||||
"___syscall64" => func!(crate::syscalls::___syscall64, [i32, i32] -> [i32]),
|
||||
"___syscall66" => func!(crate::syscalls::___syscall66, [i32, i32] -> [i32]),
|
||||
"___syscall75" => func!(crate::syscalls::___syscall75, [i32, i32] -> [i32]),
|
||||
"___syscall85" => func!(crate::syscalls::___syscall85, [i32, i32] -> [i32]),
|
||||
"___syscall91" => func!(crate::syscalls::___syscall91, [i32, i32] -> [i32]),
|
||||
"___syscall97" => func!(crate::syscalls::___syscall97, [i32, i32] -> [i32]),
|
||||
"___syscall102" => func!(crate::syscalls::___syscall102, [i32, VarArgs] -> [i32]),
|
||||
"___syscall110" => func!(crate::syscalls::___syscall110, [i32, i32] -> [i32]),
|
||||
"___syscall114" => func!(crate::syscalls::___syscall114, [i32, VarArgs] -> [i32]),
|
||||
"___syscall122" => func!(crate::syscalls::___syscall122, [i32, VarArgs] -> [i32]),
|
||||
"___syscall140" => func!(crate::syscalls::___syscall140, [i32, VarArgs] -> [i32]),
|
||||
"___syscall142" => func!(crate::syscalls::___syscall142, [i32, VarArgs] -> [i32]),
|
||||
"___syscall145" => func!(crate::syscalls::___syscall145, [i32, VarArgs] -> [i32]),
|
||||
"___syscall146" => func!(crate::syscalls::___syscall146, [i32, VarArgs] -> [i32]),
|
||||
"___syscall168" => func!(crate::syscalls::___syscall168, [i32, i32] -> [i32]),
|
||||
"___syscall180" => func!(crate::syscalls::___syscall180, [i32, VarArgs] -> [i32]),
|
||||
"___syscall181" => func!(crate::syscalls::___syscall181, [i32, VarArgs] -> [i32]),
|
||||
"___syscall191" => func!(crate::syscalls::___syscall191, [i32, i32] -> [i32]),
|
||||
"___syscall192" => func!(crate::syscalls::___syscall192, [i32, VarArgs] -> [i32]),
|
||||
"___syscall194" => func!(crate::syscalls::___syscall194, [i32, i32] -> [i32]),
|
||||
"___syscall195" => func!(crate::syscalls::___syscall195, [i32, VarArgs] -> [i32]),
|
||||
"___syscall196" => func!(crate::syscalls::___syscall196, [i32, i32] -> [i32]),
|
||||
"___syscall197" => func!(crate::syscalls::___syscall197, [i32, VarArgs] -> [i32]),
|
||||
"___syscall199" => func!(crate::syscalls::___syscall199, [i32, i32] -> [i32]),
|
||||
"___syscall201" => func!(crate::syscalls::___syscall201, [i32, i32] -> [i32]),
|
||||
"___syscall202" => func!(crate::syscalls::___syscall202, [i32, i32] -> [i32]),
|
||||
"___syscall212" => func!(crate::syscalls::___syscall212, [i32, VarArgs] -> [i32]),
|
||||
"___syscall220" => func!(crate::syscalls::___syscall220, [i32, i32] -> [i32]),
|
||||
"___syscall221" => func!(crate::syscalls::___syscall221, [i32, VarArgs] -> [i32]),
|
||||
"___syscall268" => func!(crate::syscalls::___syscall268, [i32, i32] -> [i32]),
|
||||
"___syscall272" => func!(crate::syscalls::___syscall272, [i32, i32] -> [i32]),
|
||||
"___syscall295" => func!(crate::syscalls::___syscall295, [i32, i32] -> [i32]),
|
||||
"___syscall300" => func!(crate::syscalls::___syscall300, [i32, i32] -> [i32]),
|
||||
"___syscall330" => func!(crate::syscalls::___syscall330, [i32, VarArgs] -> [i32]),
|
||||
"___syscall334" => func!(crate::syscalls::___syscall334, [i32, i32] -> [i32]),
|
||||
"___syscall340" => func!(crate::syscalls::___syscall340, [i32, VarArgs] -> [i32]),
|
||||
"___syscall1" => func!(crate::syscalls::___syscall1),
|
||||
"___syscall3" => func!(crate::syscalls::___syscall3),
|
||||
"___syscall4" => func!(crate::syscalls::___syscall4),
|
||||
"___syscall5" => func!(crate::syscalls::___syscall5),
|
||||
"___syscall6" => func!(crate::syscalls::___syscall6),
|
||||
"___syscall10" => func!(crate::syscalls::___syscall10),
|
||||
"___syscall12" => func!(crate::syscalls::___syscall12),
|
||||
"___syscall15" => func!(crate::syscalls::___syscall15),
|
||||
"___syscall20" => func!(crate::syscalls::___syscall20),
|
||||
"___syscall39" => func!(crate::syscalls::___syscall39),
|
||||
"___syscall38" => func!(crate::syscalls::___syscall38),
|
||||
"___syscall40" => func!(crate::syscalls::___syscall40),
|
||||
"___syscall54" => func!(crate::syscalls::___syscall54),
|
||||
"___syscall57" => func!(crate::syscalls::___syscall57),
|
||||
"___syscall60" => func!(crate::syscalls::___syscall60),
|
||||
"___syscall63" => func!(crate::syscalls::___syscall63),
|
||||
"___syscall64" => func!(crate::syscalls::___syscall64),
|
||||
"___syscall66" => func!(crate::syscalls::___syscall66),
|
||||
"___syscall75" => func!(crate::syscalls::___syscall75),
|
||||
"___syscall85" => func!(crate::syscalls::___syscall85),
|
||||
"___syscall91" => func!(crate::syscalls::___syscall191),
|
||||
"___syscall97" => func!(crate::syscalls::___syscall97),
|
||||
"___syscall102" => func!(crate::syscalls::___syscall102),
|
||||
"___syscall110" => func!(crate::syscalls::___syscall110),
|
||||
"___syscall114" => func!(crate::syscalls::___syscall114),
|
||||
"___syscall122" => func!(crate::syscalls::___syscall122),
|
||||
"___syscall140" => func!(crate::syscalls::___syscall140),
|
||||
"___syscall142" => func!(crate::syscalls::___syscall142),
|
||||
"___syscall145" => func!(crate::syscalls::___syscall145),
|
||||
"___syscall146" => func!(crate::syscalls::___syscall146),
|
||||
"___syscall168" => func!(crate::syscalls::___syscall168),
|
||||
"___syscall180" => func!(crate::syscalls::___syscall180),
|
||||
"___syscall181" => func!(crate::syscalls::___syscall181),
|
||||
"___syscall191" => func!(crate::syscalls::___syscall191),
|
||||
"___syscall192" => func!(crate::syscalls::___syscall192),
|
||||
"___syscall194" => func!(crate::syscalls::___syscall194),
|
||||
"___syscall195" => func!(crate::syscalls::___syscall195),
|
||||
"___syscall196" => func!(crate::syscalls::___syscall196),
|
||||
"___syscall197" => func!(crate::syscalls::___syscall197),
|
||||
"___syscall199" => func!(crate::syscalls::___syscall199),
|
||||
"___syscall201" => func!(crate::syscalls::___syscall201),
|
||||
"___syscall202" => func!(crate::syscalls::___syscall202),
|
||||
"___syscall212" => func!(crate::syscalls::___syscall212),
|
||||
"___syscall220" => func!(crate::syscalls::___syscall220),
|
||||
"___syscall221" => func!(crate::syscalls::___syscall221),
|
||||
"___syscall268" => func!(crate::syscalls::___syscall268),
|
||||
"___syscall272" => func!(crate::syscalls::___syscall272),
|
||||
"___syscall295" => func!(crate::syscalls::___syscall295),
|
||||
"___syscall300" => func!(crate::syscalls::___syscall300),
|
||||
"___syscall330" => func!(crate::syscalls::___syscall330),
|
||||
"___syscall334" => func!(crate::syscalls::___syscall334),
|
||||
"___syscall340" => func!(crate::syscalls::___syscall340),
|
||||
|
||||
// Process
|
||||
"abort" => func!(crate::process::em_abort, [u32] -> []),
|
||||
"_abort" => func!(crate::process::_abort, [] -> []),
|
||||
"abortStackOverflow" => func!(crate::process::abort_stack_overflow, [i32] -> []),
|
||||
"_llvm_trap" => func!(crate::process::_llvm_trap, [] -> []),
|
||||
"_fork" => func!(crate::process::_fork, [] -> [i32]),
|
||||
"_exit" => func!(crate::process::_exit, [i32] -> []),
|
||||
"_system" => func!(crate::process::_system, [i32] -> [i32]),
|
||||
"_popen" => func!(crate::process::_popen, [i32, i32] -> [i32]),
|
||||
"_endgrent" => func!(crate::process::_endgrent, [] -> []),
|
||||
"_execve" => func!(crate::process::_execve, [i32, i32, i32] -> [i32]),
|
||||
"_kill" => func!(crate::process::_kill, [i32, i32] -> [i32]),
|
||||
"_llvm_stackrestore" => func!(crate::process::_llvm_stackrestore, [i32] -> []),
|
||||
"_raise" => func!(crate::process::_raise, [i32] -> [i32]),
|
||||
"_sem_init" => func!(crate::process::_sem_init, [i32, i32, i32] -> [i32]),
|
||||
"_sem_post" => func!(crate::process::_sem_post, [i32] -> [i32]),
|
||||
"_sem_wait" => func!(crate::process::_sem_wait, [i32] -> [i32]),
|
||||
"_setgrent" => func!(crate::process::_setgrent, [] -> []),
|
||||
"_setgroups" => func!(crate::process::_setgroups, [i32, i32] -> [i32]),
|
||||
"_setitimer" => func!(crate::process::_setitimer, [i32, i32, i32] -> [i32]),
|
||||
"_usleep" => func!(crate::process::_usleep, [i32] -> [i32]),
|
||||
"_utimes" => func!(crate::process::_utimes, [i32, i32] -> [i32]),
|
||||
"_waitpid" => func!(crate::process::_waitpid, [i32, i32, i32] -> [i32]),
|
||||
"abort" => func!(crate::process::em_abort),
|
||||
"_abort" => func!(crate::process::_abort),
|
||||
"abortStackOverflow" => func!(crate::process::abort_stack_overflow),
|
||||
"_llvm_trap" => func!(crate::process::_llvm_trap),
|
||||
"_fork" => func!(crate::process::_fork),
|
||||
"_exit" => func!(crate::process::_exit),
|
||||
"_system" => func!(crate::process::_system),
|
||||
"_popen" => func!(crate::process::_popen),
|
||||
"_endgrent" => func!(crate::process::_endgrent),
|
||||
"_execve" => func!(crate::process::_execve),
|
||||
"_kill" => func!(crate::process::_kill),
|
||||
"_llvm_stackrestore" => func!(crate::process::_llvm_stackrestore),
|
||||
"_raise" => func!(crate::process::_raise),
|
||||
"_sem_init" => func!(crate::process::_sem_init),
|
||||
"_sem_post" => func!(crate::process::_sem_post),
|
||||
"_sem_wait" => func!(crate::process::_sem_wait),
|
||||
"_setgrent" => func!(crate::process::_setgrent),
|
||||
"_setgroups" => func!(crate::process::_setgroups),
|
||||
"_setitimer" => func!(crate::process::_setitimer),
|
||||
"_usleep" => func!(crate::process::_usleep),
|
||||
"_utimes" => func!(crate::process::_utimes),
|
||||
"_waitpid" => func!(crate::process::_waitpid),
|
||||
|
||||
// Signal
|
||||
"_sigemptyset" => func!(crate::signal::_sigemptyset, [u32] -> [i32]),
|
||||
"_sigaddset" => func!(crate::signal::_sigaddset, [u32, u32] -> [i32]),
|
||||
"_sigprocmask" => func!(crate::signal::_sigprocmask, [i32, i32, i32] -> [i32]),
|
||||
"_sigaction" => func!(crate::signal::_sigaction, [u32, u32, u32] -> [i32]),
|
||||
"_signal" => func!(crate::signal::_signal, [u32, i32] -> [i32]),
|
||||
"_sigsuspend" => func!(crate::signal::_sigsuspend, [i32] -> [i32]),
|
||||
"_sigemptyset" => func!(crate::signal::_sigemptyset),
|
||||
"_sigaddset" => func!(crate::signal::_sigaddset),
|
||||
"_sigprocmask" => func!(crate::signal::_sigprocmask),
|
||||
"_sigaction" => func!(crate::signal::_sigaction),
|
||||
"_signal" => func!(crate::signal::_signal),
|
||||
"_sigsuspend" => func!(crate::signal::_sigsuspend),
|
||||
|
||||
// Memory
|
||||
"abortOnCannotGrowMemory" => func!(crate::memory::abort_on_cannot_grow_memory, [] -> [u32]),
|
||||
"_emscripten_memcpy_big" => func!(crate::memory::_emscripten_memcpy_big, [u32, u32, u32] -> [u32]),
|
||||
"enlargeMemory" => func!(crate::memory::enlarge_memory, [] -> [u32]),
|
||||
"getTotalMemory" => func!(crate::memory::get_total_memory, [] -> [u32]),
|
||||
"___map_file" => func!(crate::memory::___map_file, [u32, u32] -> [i32]),
|
||||
"abortOnCannotGrowMemory" => func!(crate::memory::abort_on_cannot_grow_memory),
|
||||
"_emscripten_memcpy_big" => func!(crate::memory::_emscripten_memcpy_big),
|
||||
"enlargeMemory" => func!(crate::memory::enlarge_memory),
|
||||
"getTotalMemory" => func!(crate::memory::get_total_memory),
|
||||
"___map_file" => func!(crate::memory::___map_file),
|
||||
|
||||
// Exception
|
||||
"___cxa_allocate_exception" => func!(crate::exception::___cxa_allocate_exception, [u32] -> [u32]),
|
||||
"___cxa_throw" => func!(crate::exception::___cxa_throw, [u32, u32, u32] -> []),
|
||||
"___cxa_allocate_exception" => func!(crate::exception::___cxa_allocate_exception),
|
||||
"___cxa_throw" => func!(crate::exception::___cxa_throw),
|
||||
|
||||
// Time
|
||||
"_gettimeofday" => func!(crate::time::_gettimeofday, [i32, i32] -> [i32]),
|
||||
"_clock_gettime" => func!(crate::time::_clock_gettime, [u32, i32] -> [i32]),
|
||||
"___clock_gettime" => func!(crate::time::_clock_gettime, [u32, i32] -> [i32]),
|
||||
"_clock" => func!(crate::time::_clock, [] -> [i32]),
|
||||
"_difftime" => func!(crate::time::_difftime, [u32, u32] -> [f64]),
|
||||
"_asctime" => func!(crate::time::_asctime, [u32] -> [u32]),
|
||||
"_asctime_r" => func!(crate::time::_asctime_r, [u32, u32] -> [u32]),
|
||||
"_localtime" => func!(crate::time::_localtime, [u32] -> [i32]),
|
||||
"_time" => func!(crate::time::_time, [u32] -> [i64]),
|
||||
"_strftime" => func!(crate::time::_strftime, [i32, u32, i32, i32] -> [i64]),
|
||||
"_localtime_r" => func!(crate::time::_localtime_r, [u32, u32] -> [i32]),
|
||||
"_gmtime_r" => func!(crate::time::_gmtime_r, [i32, i32] -> [i32]),
|
||||
"_mktime" => func!(crate::time::_mktime, [i32] -> [i32]),
|
||||
"_gmtime" => func!(crate::time::_gmtime, [i32] -> [i32]),
|
||||
"_gettimeofday" => func!(crate::time::_gettimeofday),
|
||||
"_clock_gettime" => func!(crate::time::_clock_gettime),
|
||||
"___clock_gettime" => func!(crate::time::_clock_gettime),
|
||||
"_clock" => func!(crate::time::_clock),
|
||||
"_difftime" => func!(crate::time::_difftime),
|
||||
"_asctime" => func!(crate::time::_asctime),
|
||||
"_asctime_r" => func!(crate::time::_asctime_r),
|
||||
"_localtime" => func!(crate::time::_localtime),
|
||||
"_time" => func!(crate::time::_time),
|
||||
"_strftime" => func!(crate::time::_strftime),
|
||||
"_localtime_r" => func!(crate::time::_localtime_r),
|
||||
"_gmtime_r" => func!(crate::time::_gmtime_r),
|
||||
"_mktime" => func!(crate::time::_mktime),
|
||||
"_gmtime" => func!(crate::time::_gmtime),
|
||||
|
||||
// Math
|
||||
"f64-rem" => func!(crate::math::f64_rem, [f64, f64] -> [f64]),
|
||||
"_llvm_log10_f64" => func!(crate::math::_llvm_log10_f64, [f64] -> [f64]),
|
||||
"_llvm_log2_f64" => func!(crate::math::_llvm_log2_f64, [f64] -> [f64]),
|
||||
"_llvm_log10_f32" => func!(crate::math::_llvm_log10_f32, [f64] -> [f64]),
|
||||
"_llvm_log2_f32" => func!(crate::math::_llvm_log2_f64, [f64] -> [f64]),
|
||||
"_emscripten_random" => func!(crate::math::_emscripten_random, [] -> [f64]),
|
||||
"f64-rem" => func!(crate::math::f64_rem),
|
||||
"_llvm_log10_f64" => func!(crate::math::_llvm_log10_f64),
|
||||
"_llvm_log2_f64" => func!(crate::math::_llvm_log2_f64),
|
||||
"_llvm_log10_f32" => func!(crate::math::_llvm_log10_f32),
|
||||
"_llvm_log2_f32" => func!(crate::math::_llvm_log2_f64),
|
||||
"_emscripten_random" => func!(crate::math::_emscripten_random),
|
||||
|
||||
// Jump
|
||||
"__setjmp" => func!(crate::jmp::__setjmp, [u32] -> [i32]),
|
||||
"__longjmp" => func!(crate::jmp::__longjmp, [u32, i32] -> []),
|
||||
"__setjmp" => func!(crate::jmp::__setjmp),
|
||||
"__longjmp" => func!(crate::jmp::__longjmp),
|
||||
|
||||
// Linking
|
||||
"_dlclose" => func!(crate::linking::_dlclose, [u32] -> [i32]),
|
||||
"_dlopen" => func!(crate::linking::_dlopen, [u32, u32] -> [i32]),
|
||||
"_dlsym" => func!(crate::linking::_dlopen, [u32, u32] -> [i32]),
|
||||
"_dlclose" => func!(crate::linking::_dlclose),
|
||||
"_dlopen" => func!(crate::linking::_dlopen),
|
||||
"_dlsym" => func!(crate::linking::_dlsym),
|
||||
|
||||
},
|
||||
"math" => {
|
||||
"pow" => func!(crate::math::pow, [f64, f64] -> [f64]),
|
||||
"pow" => func!(crate::math::pow),
|
||||
},
|
||||
};
|
||||
// mock_external!(env_namespace, _sched_yield);
|
||||
|
@ -3,25 +3,25 @@ use wasmer_runtime_core::vm::Ctx;
|
||||
// TODO: Need to implement.
|
||||
|
||||
/// emscripten: dlopen(filename: *const c_char, flag: c_int) -> *mut c_void
|
||||
pub extern "C" fn _dlopen(_filename: u32, _flag: u32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _dlopen(_filename: u32, _flag: u32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_dlopen");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlclose(handle: *mut c_void) -> c_int
|
||||
pub extern "C" fn _dlclose(_filename: u32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _dlclose(_filename: u32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_dlclose");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void
|
||||
pub extern "C" fn _dlsym(_filepath: u32, _symbol: u32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _dlsym(_filepath: u32, _symbol: u32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_dlsym");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlerror() -> *mut c_char
|
||||
pub extern "C" fn _dlerror(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn _dlerror(_ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_dlerror");
|
||||
-1
|
||||
}
|
||||
|
@ -2,16 +2,16 @@ use libc::c_int;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub extern "C" fn ___lock(what: c_int, _ctx: &mut Ctx) {
|
||||
pub fn ___lock(what: c_int, _ctx: &mut Ctx) {
|
||||
debug!("emscripten::___lock {}", what);
|
||||
}
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub extern "C" fn ___unlock(what: c_int, _ctx: &mut Ctx) {
|
||||
pub fn ___unlock(what: c_int, _ctx: &mut Ctx) {
|
||||
debug!("emscripten::___unlock {}", what);
|
||||
}
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub extern "C" fn ___wait(_which: u32, _varargs: u32, _three: u32, _four: u32, _ctx: &mut Ctx) {
|
||||
pub fn ___wait(_which: u32, _varargs: u32, _three: u32, _four: u32, _ctx: &mut Ctx) {
|
||||
debug!("emscripten::___wait");
|
||||
}
|
||||
|
@ -1,39 +1,39 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
/// emscripten: _llvm_log10_f64
|
||||
pub extern "C" fn _llvm_log10_f64(value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
pub fn _llvm_log10_f64(value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::_llvm_log10_f64");
|
||||
value.log10()
|
||||
}
|
||||
|
||||
/// emscripten: _llvm_log2_f64
|
||||
pub extern "C" fn _llvm_log2_f64(value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
pub fn _llvm_log2_f64(value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::_llvm_log2_f64");
|
||||
value.log2()
|
||||
}
|
||||
|
||||
pub extern "C" fn _llvm_log10_f32(_value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
pub fn _llvm_log10_f32(_value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::_llvm_log10_f32");
|
||||
-1.0
|
||||
}
|
||||
|
||||
pub extern "C" fn _llvm_log2_f32(_value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
pub fn _llvm_log2_f32(_value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::_llvm_log10_f32");
|
||||
-1.0
|
||||
}
|
||||
|
||||
pub extern "C" fn _emscripten_random(_ctx: &mut Ctx) -> f64 {
|
||||
pub fn _emscripten_random(_ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::_emscripten_random");
|
||||
-1.0
|
||||
}
|
||||
|
||||
// emscripten: f64-rem
|
||||
pub extern "C" fn f64_rem(x: f64, y: f64, _ctx: &mut Ctx) -> f64 {
|
||||
pub fn f64_rem(x: f64, y: f64, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::f64-rem");
|
||||
x % y
|
||||
}
|
||||
|
||||
// emscripten: global.Math pow
|
||||
pub extern "C" fn pow(x: f64, y: f64, _ctx: &mut Ctx) -> f64 {
|
||||
pub fn pow(x: f64, y: f64, _ctx: &mut Ctx) -> f64 {
|
||||
x.powf(y)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use libc::{c_int, c_void, memcpy, size_t};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
/// emscripten: _emscripten_memcpy_big
|
||||
pub extern "C" fn _emscripten_memcpy_big(dest: u32, src: u32, len: u32, ctx: &mut Ctx) -> u32 {
|
||||
pub fn _emscripten_memcpy_big(dest: u32, src: u32, len: u32, ctx: &mut Ctx) -> u32 {
|
||||
debug!(
|
||||
"emscripten::_emscripten_memcpy_big {}, {}, {}",
|
||||
dest, src, len
|
||||
@ -17,7 +17,7 @@ pub extern "C" fn _emscripten_memcpy_big(dest: u32, src: u32, len: u32, ctx: &mu
|
||||
}
|
||||
|
||||
/// emscripten: getTotalMemory
|
||||
pub extern "C" fn get_total_memory(_ctx: &mut Ctx) -> u32 {
|
||||
pub fn get_total_memory(_ctx: &mut Ctx) -> u32 {
|
||||
debug!("emscripten::get_total_memory");
|
||||
// instance.memories[0].current_pages()
|
||||
// TODO: Fix implementation
|
||||
@ -25,7 +25,7 @@ pub extern "C" fn get_total_memory(_ctx: &mut Ctx) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: enlargeMemory
|
||||
pub extern "C" fn enlarge_memory(_ctx: &mut Ctx) -> u32 {
|
||||
pub fn enlarge_memory(_ctx: &mut Ctx) -> u32 {
|
||||
debug!("emscripten::enlarge_memory");
|
||||
// instance.memories[0].grow(100);
|
||||
// TODO: Fix implementation
|
||||
@ -33,14 +33,14 @@ pub extern "C" fn enlarge_memory(_ctx: &mut Ctx) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: abortOnCannotGrowMemory
|
||||
pub extern "C" fn abort_on_cannot_grow_memory(ctx: &mut Ctx) -> u32 {
|
||||
pub fn abort_on_cannot_grow_memory(ctx: &mut Ctx) -> u32 {
|
||||
debug!("emscripten::abort_on_cannot_grow_memory");
|
||||
abort_with_message("Cannot enlarge memory arrays!", ctx);
|
||||
0
|
||||
}
|
||||
|
||||
/// emscripten: ___map_file
|
||||
pub extern "C" fn ___map_file(_one: u32, _two: u32, _ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___map_file(_one: u32, _two: u32, _ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___map_file");
|
||||
// NOTE: TODO: Em returns -1 here as well. May need to implement properly
|
||||
-1
|
||||
|
@ -1,67 +1,67 @@
|
||||
use super::process::abort_with_message;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
pub extern "C" fn nullfunc_i(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_i(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_i {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'i'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_ii(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_ii(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_ii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'ii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_iii(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_iii(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_iii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'iii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_iiii(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_iiii(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_iiii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'iiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_iiiii(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_iiiii(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_iiiii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'iiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_iiiiii(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_iiiiii(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_iiiiii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'iiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_v(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_v(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_v {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_vi(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_vi(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_vi {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'vi'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_vii(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_vii(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_vii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'vii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_viii(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_viii(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_viii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'viii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_viiii(x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_viiii(x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_viiii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'viiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_viiiii(_x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_viiiii(_x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_viiiii");
|
||||
abort_with_message("Invalid function pointer called with signature 'viiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_viiiiii(_x: u32, ctx: &mut Ctx) {
|
||||
pub fn nullfunc_viiiiii(_x: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::nullfunc_viiiiii");
|
||||
abort_with_message("Invalid function pointer called with signature 'viiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)", ctx);
|
||||
}
|
||||
|
@ -3,20 +3,20 @@ use libc::{abort, c_char, c_int, exit, pid_t, EAGAIN};
|
||||
use std::ffi::CStr;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
pub extern "C" fn abort_with_message(message: &str, ctx: &mut Ctx) {
|
||||
pub fn abort_with_message(message: &str, ctx: &mut Ctx) {
|
||||
debug!("emscripten::abort_with_message");
|
||||
println!("{}", message);
|
||||
_abort(ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn _abort(_ctx: &mut Ctx) {
|
||||
pub fn _abort(_ctx: &mut Ctx) {
|
||||
debug!("emscripten::_abort");
|
||||
unsafe {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
pub extern "C" fn _fork(_ctx: &mut Ctx) -> pid_t {
|
||||
pub fn _fork(_ctx: &mut Ctx) -> pid_t {
|
||||
debug!("emscripten::_fork");
|
||||
// unsafe {
|
||||
// fork()
|
||||
@ -24,23 +24,23 @@ pub extern "C" fn _fork(_ctx: &mut Ctx) -> pid_t {
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _endgrent(_ctx: &mut Ctx) {
|
||||
pub fn _endgrent(_ctx: &mut Ctx) {
|
||||
debug!("emscripten::_endgrent");
|
||||
}
|
||||
|
||||
pub extern "C" fn _execve(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _execve(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_execve");
|
||||
-1
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub extern "C" fn _exit(status: c_int, _ctx: &mut Ctx) {
|
||||
pub fn _exit(status: c_int, _ctx: &mut Ctx) {
|
||||
// -> !
|
||||
debug!("emscripten::_exit {}", status);
|
||||
unsafe { exit(status) }
|
||||
}
|
||||
|
||||
pub extern "C" fn em_abort(message: u32, ctx: &mut Ctx) {
|
||||
pub fn em_abort(message: u32, ctx: &mut Ctx) {
|
||||
debug!("emscripten::em_abort {}", message);
|
||||
let message_addr = emscripten_memory_pointer!(ctx.memory(0), message) as *mut c_char;
|
||||
unsafe {
|
||||
@ -52,65 +52,65 @@ pub extern "C" fn em_abort(message: u32, ctx: &mut Ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
pub extern "C" fn _kill(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _kill(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_kill");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _llvm_stackrestore(_one: i32, _ctx: &mut Ctx) {
|
||||
pub fn _llvm_stackrestore(_one: i32, _ctx: &mut Ctx) {
|
||||
debug!("emscripten::_llvm_stackrestore");
|
||||
}
|
||||
|
||||
pub extern "C" fn _raise(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _raise(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_raise");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _sem_init(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sem_init(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_sem_init");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _sem_post(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sem_post(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_sem_post");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _sem_wait(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sem_wait(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_sem_post");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _setgrent(_ctx: &mut Ctx) {
|
||||
pub fn _setgrent(_ctx: &mut Ctx) {
|
||||
debug!("emscripten::_setgrent");
|
||||
}
|
||||
|
||||
pub extern "C" fn _setgroups(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _setgroups(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_setgroups");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _setitimer(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _setitimer(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_setitimer");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _usleep(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _usleep(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_usleep");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _utimes(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _utimes(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_utimes");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _waitpid(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _waitpid(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_waitpid");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn abort_stack_overflow(_what: c_int, ctx: &mut Ctx) {
|
||||
pub fn abort_stack_overflow(_what: c_int, ctx: &mut Ctx) {
|
||||
debug!("emscripten::abort_stack_overflow");
|
||||
// TODO: Message incomplete. Need to finish em runtime data first
|
||||
abort_with_message(
|
||||
@ -119,19 +119,19 @@ pub extern "C" fn abort_stack_overflow(_what: c_int, ctx: &mut Ctx) {
|
||||
);
|
||||
}
|
||||
|
||||
pub extern "C" fn _llvm_trap(ctx: &mut Ctx) {
|
||||
pub fn _llvm_trap(ctx: &mut Ctx) {
|
||||
debug!("emscripten::_llvm_trap");
|
||||
abort_with_message("abort!", ctx);
|
||||
}
|
||||
|
||||
pub extern "C" fn _system(_one: i32, _ctx: &mut Ctx) -> c_int {
|
||||
pub fn _system(_one: i32, _ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_system");
|
||||
// TODO: May need to change this Em impl to a working version
|
||||
eprintln!("Can't call external programs");
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
pub extern "C" fn _popen(_one: i32, _two: i32, _ctx: &mut Ctx) -> c_int {
|
||||
pub fn _popen(_one: i32, _two: i32, _ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_popen");
|
||||
// TODO: May need to change this Em impl to a working version
|
||||
eprintln!("Missing function: popen");
|
||||
|
@ -2,7 +2,7 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _sigemptyset(set: u32, ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sigemptyset(set: u32, ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_sigemptyset");
|
||||
let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32;
|
||||
unsafe {
|
||||
@ -11,13 +11,13 @@ pub extern "C" fn _sigemptyset(set: u32, ctx: &mut Ctx) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub extern "C" fn _sigaction(signum: u32, act: u32, oldact: u32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sigaction(signum: u32, act: u32, oldact: u32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_sigaction {}, {}, {}", signum, act, oldact);
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _sigaddset(set: u32, signum: u32, ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sigaddset(set: u32, signum: u32, ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_sigaddset {}, {}", set, signum);
|
||||
let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32;
|
||||
unsafe {
|
||||
@ -26,17 +26,17 @@ pub extern "C" fn _sigaddset(set: u32, signum: u32, ctx: &mut Ctx) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub extern "C" fn _sigsuspend(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sigsuspend(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_sigsuspend");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _sigprocmask(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sigprocmask(_one: i32, _two: i32, _three: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_sigprocmask");
|
||||
0
|
||||
}
|
||||
|
||||
pub extern "C" fn _signal(sig: u32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _signal(sig: u32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_signal ({})", sig);
|
||||
0
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ use libc::SO_NOSIGPIPE;
|
||||
const SO_NOSIGPIPE: c_int = 0;
|
||||
|
||||
/// exit
|
||||
pub extern "C" fn ___syscall1(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) {
|
||||
pub fn ___syscall1(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) {
|
||||
debug!("emscripten::___syscall1 (exit) {}", which);
|
||||
let status: i32 = varargs.get(ctx);
|
||||
unsafe {
|
||||
@ -105,7 +105,7 @@ pub extern "C" fn ___syscall1(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx)
|
||||
}
|
||||
|
||||
/// read
|
||||
pub extern "C" fn ___syscall3(which: i32, mut varargs: VarArgs, ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall3(which: i32, mut varargs: VarArgs, ctx: &mut Ctx) -> i32 {
|
||||
// -> ssize_t
|
||||
debug!("emscripten::___syscall3 (read) {}", which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@ -119,7 +119,7 @@ pub extern "C" fn ___syscall3(which: i32, mut varargs: VarArgs, ctx: &mut Ctx) -
|
||||
}
|
||||
|
||||
/// write
|
||||
pub extern "C" fn ___syscall4(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall4(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall4 (write) {}", which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
@ -130,7 +130,7 @@ pub extern "C" fn ___syscall4(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx)
|
||||
}
|
||||
|
||||
/// open
|
||||
pub extern "C" fn ___syscall5(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall5(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall5 (open) {}", which);
|
||||
let pathname: u32 = varargs.get(ctx);
|
||||
let flags: i32 = varargs.get(ctx);
|
||||
@ -146,7 +146,7 @@ pub extern "C" fn ___syscall5(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx)
|
||||
}
|
||||
|
||||
/// close
|
||||
pub extern "C" fn ___syscall6(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall6(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall6 (close) {}", which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
debug!("fd: {}", fd);
|
||||
@ -154,7 +154,7 @@ pub extern "C" fn ___syscall6(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx)
|
||||
}
|
||||
|
||||
// chdir
|
||||
pub extern "C" fn ___syscall12(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall12(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall12 (chdir) {}", which);
|
||||
let path_addr: i32 = varargs.get(ctx);
|
||||
unsafe {
|
||||
@ -166,29 +166,29 @@ pub extern "C" fn ___syscall12(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx
|
||||
}
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall10(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall10(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall10");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall15(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall15(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall15");
|
||||
-1
|
||||
}
|
||||
|
||||
// getpid
|
||||
pub extern "C" fn ___syscall20(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall20(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall20 (getpid)");
|
||||
unsafe { getpid() }
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall38(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall38(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall38");
|
||||
-1
|
||||
}
|
||||
|
||||
// mkdir
|
||||
pub extern "C" fn ___syscall39(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall39(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall39 (mkdir) {}", which);
|
||||
let pathname: u32 = varargs.get(ctx);
|
||||
let mode: u32 = varargs.get(ctx);
|
||||
@ -197,7 +197,7 @@ pub extern "C" fn ___syscall39(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx
|
||||
}
|
||||
|
||||
// rmdir
|
||||
pub extern "C" fn ___syscall40(_which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall40(_which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall40 (rmdir)");
|
||||
let pathname: u32 = varargs.get(ctx);
|
||||
let pathname_addr = emscripten_memory_pointer!(ctx.memory(0), pathname) as *const i8;
|
||||
@ -205,7 +205,7 @@ pub extern "C" fn ___syscall40(_which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
}
|
||||
|
||||
/// ioctl
|
||||
pub extern "C" fn ___syscall54(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall54(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall54 (ioctl) {}", which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let request: u32 = varargs.get(ctx);
|
||||
@ -247,20 +247,20 @@ pub extern "C" fn ___syscall54(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx
|
||||
}
|
||||
|
||||
// setpgid
|
||||
pub extern "C" fn ___syscall57(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall57(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall57 (setpgid) {}", which);
|
||||
let pid: i32 = varargs.get(ctx);
|
||||
let pgid: i32 = varargs.get(ctx);
|
||||
unsafe { setpgid(pid, pgid) }
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall60(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall60(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall60");
|
||||
-1
|
||||
}
|
||||
|
||||
// dup2
|
||||
pub extern "C" fn ___syscall63(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall63(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall63 (dup2) {}", which);
|
||||
|
||||
let src: i32 = varargs.get(ctx);
|
||||
@ -270,39 +270,39 @@ pub extern "C" fn ___syscall63(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx
|
||||
}
|
||||
|
||||
// getppid
|
||||
pub extern "C" fn ___syscall64(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall64(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall64 (getppid)");
|
||||
unsafe { getpid() }
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall66(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall66(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall66");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall75(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall75(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall75");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall85(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall85(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall85");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall91(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall91(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall91");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall97(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall97(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall97");
|
||||
-1
|
||||
}
|
||||
|
||||
// socketcall
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn ___syscall102(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall102(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall102 (socketcall) {}", which);
|
||||
let call: u32 = varargs.get(ctx);
|
||||
let mut socket_varargs: VarArgs = varargs.get(ctx);
|
||||
@ -553,14 +553,14 @@ pub extern "C" fn ___syscall102(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
}
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall110(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall110(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall110");
|
||||
-1
|
||||
}
|
||||
|
||||
/// wait4
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn ___syscall114(_which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> pid_t {
|
||||
pub fn ___syscall114(_which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> pid_t {
|
||||
debug!("emscripten::___syscall114 (wait4)");
|
||||
let pid: pid_t = varargs.get(ctx);
|
||||
let status: u32 = varargs.get(ctx);
|
||||
@ -578,7 +578,7 @@ pub extern "C" fn ___syscall114(_which: c_int, mut varargs: VarArgs, ctx: &mut C
|
||||
|
||||
/// uname
|
||||
// NOTE: Wondering if we should return custom utsname, like Emscripten.
|
||||
pub extern "C" fn ___syscall122(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall122(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall122 (uname) {}", which);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
debug!("=> buf: {}", buf);
|
||||
@ -588,7 +588,7 @@ pub extern "C" fn ___syscall122(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
|
||||
// select
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn ___syscall142(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall142(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall142 (newselect) {}", which);
|
||||
|
||||
let nfds: i32 = varargs.get(ctx);
|
||||
@ -607,7 +607,7 @@ pub extern "C" fn ___syscall142(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
}
|
||||
|
||||
// mmap2
|
||||
pub extern "C" fn ___syscall192(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall192(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall192 (mmap2) {}", which);
|
||||
let addr: i32 = varargs.get(ctx);
|
||||
let len: u32 = varargs.get(ctx);
|
||||
@ -633,7 +633,7 @@ pub extern "C" fn ___syscall192(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
}
|
||||
|
||||
/// lseek
|
||||
pub extern "C" fn ___syscall140(which: i32, mut varargs: VarArgs, ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall140(which: i32, mut varargs: VarArgs, ctx: &mut Ctx) -> i32 {
|
||||
// -> c_int
|
||||
debug!("emscripten::___syscall140 (lseek) {}", which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@ -645,7 +645,7 @@ pub extern "C" fn ___syscall140(which: i32, mut varargs: VarArgs, ctx: &mut Ctx)
|
||||
|
||||
/// readv
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn ___syscall145(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall145(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> i32 {
|
||||
// -> ssize_t
|
||||
debug!("emscripten::___syscall145 (readv) {}", which);
|
||||
// let fd: i32 = varargs.get(ctx);
|
||||
@ -688,7 +688,7 @@ pub extern "C" fn ___syscall145(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
|
||||
// writev
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn ___syscall146(which: i32, mut varargs: VarArgs, ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall146(which: i32, mut varargs: VarArgs, ctx: &mut Ctx) -> i32 {
|
||||
// -> ssize_t
|
||||
debug!("emscripten::___syscall146 (writev) {}", which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@ -722,13 +722,13 @@ pub extern "C" fn ___syscall146(which: i32, mut varargs: VarArgs, ctx: &mut Ctx)
|
||||
}
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall168(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall168(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall168");
|
||||
-1
|
||||
}
|
||||
|
||||
// pread
|
||||
pub extern "C" fn ___syscall180(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall180(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall180 (pread) {}", which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
@ -745,7 +745,7 @@ pub extern "C" fn ___syscall180(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
}
|
||||
|
||||
// pwrite
|
||||
pub extern "C" fn ___syscall181(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall181(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall181 (pwrite) {}", which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
@ -765,28 +765,28 @@ pub extern "C" fn ___syscall181(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
status
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall191(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall191(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall191 - stub");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall194(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall194(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall194 - stub");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall196(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall196(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall194 - stub");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall199(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall199(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall199 - stub");
|
||||
-1
|
||||
}
|
||||
|
||||
// stat64
|
||||
pub extern "C" fn ___syscall195(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall195(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall195 (stat64) {}", which);
|
||||
let pathname: u32 = varargs.get(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
@ -806,7 +806,7 @@ pub extern "C" fn ___syscall195(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
}
|
||||
|
||||
// fstat64
|
||||
pub extern "C" fn ___syscall197(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall197(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall197 (fstat64) {}", which);
|
||||
let fd: c_int = varargs.get(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
@ -825,7 +825,7 @@ pub extern "C" fn ___syscall197(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
}
|
||||
|
||||
// getgid
|
||||
pub extern "C" fn ___syscall201(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall201(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall201 (getgid)");
|
||||
unsafe {
|
||||
// Maybe fix: Emscripten returns 0 always
|
||||
@ -834,7 +834,7 @@ pub extern "C" fn ___syscall201(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
}
|
||||
|
||||
// getgid32
|
||||
pub extern "C" fn ___syscall202(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall202(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
// gid_t
|
||||
debug!("emscripten::___syscall202 (getgid32)");
|
||||
unsafe {
|
||||
@ -844,7 +844,7 @@ pub extern "C" fn ___syscall202(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
}
|
||||
|
||||
// chown
|
||||
pub extern "C" fn ___syscall212(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall212(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall212 (chown) {}", which);
|
||||
|
||||
let pathname: u32 = varargs.get(ctx);
|
||||
@ -856,13 +856,13 @@ pub extern "C" fn ___syscall212(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
unsafe { chown(pathname_addr, owner, group) }
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall220(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall220(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall220");
|
||||
-1
|
||||
}
|
||||
|
||||
// fcntl64
|
||||
pub extern "C" fn ___syscall221(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall221(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall221 (fcntl64) {}", which);
|
||||
// fcntl64
|
||||
let _fd: i32 = varargs.get(ctx);
|
||||
@ -873,33 +873,33 @@ pub extern "C" fn ___syscall221(which: c_int, mut varargs: VarArgs, ctx: &mut Ct
|
||||
}
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall268(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall268(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall268");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall272(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall272(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall272");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall295(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall295(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall295");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall300(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall300(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall300");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn ___syscall334(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___syscall334(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::___syscall334");
|
||||
-1
|
||||
}
|
||||
|
||||
/// dup3
|
||||
pub extern "C" fn ___syscall330(_which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> pid_t {
|
||||
pub fn ___syscall330(_which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> pid_t {
|
||||
// Implementation based on description at https://linux.die.net/man/2/dup3
|
||||
debug!("emscripten::___syscall330 (dup3)");
|
||||
let oldfd: c_int = varargs.get(ctx);
|
||||
@ -933,7 +933,7 @@ pub extern "C" fn ___syscall330(_which: c_int, mut varargs: VarArgs, ctx: &mut C
|
||||
}
|
||||
|
||||
// prlimit64
|
||||
pub extern "C" fn ___syscall340(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___syscall340(which: c_int, mut varargs: VarArgs, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___syscall340 (prlimit64), {}", which);
|
||||
// NOTE: Doesn't really matter. Wasm modules cannot exceed WASM_PAGE_SIZE anyway.
|
||||
let _pid: i32 = varargs.get(ctx);
|
||||
|
@ -26,7 +26,7 @@ const CLOCK_MONOTONIC_COARSE: libc::clockid_t = 6;
|
||||
|
||||
/// emscripten: _gettimeofday
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _gettimeofday(tp: c_int, tz: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _gettimeofday(tp: c_int, tz: c_int, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_gettimeofday {} {}", tp, tz);
|
||||
#[repr(C)]
|
||||
struct GuestTimeVal {
|
||||
@ -51,7 +51,7 @@ pub extern "C" fn _gettimeofday(tp: c_int, tz: c_int, ctx: &mut Ctx) -> c_int {
|
||||
|
||||
/// emscripten: _clock_gettime
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _clock_gettime(clk_id: libc::clockid_t, tp: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _clock_gettime(clk_id: libc::clockid_t, tp: c_int, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_clock_gettime {} {}", clk_id, tp);
|
||||
// debug!("Memory {:?}", ctx.memory(0)[..]);
|
||||
#[repr(C)]
|
||||
@ -82,34 +82,34 @@ pub extern "C" fn _clock_gettime(clk_id: libc::clockid_t, tp: c_int, ctx: &mut C
|
||||
}
|
||||
|
||||
/// emscripten: ___clock_gettime
|
||||
pub extern "C" fn ___clock_gettime(clk_id: libc::clockid_t, tp: c_int, ctx: &mut Ctx) -> c_int {
|
||||
pub fn ___clock_gettime(clk_id: libc::clockid_t, tp: c_int, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::___clock_gettime {} {}", clk_id, tp);
|
||||
_clock_gettime(clk_id, tp, ctx)
|
||||
}
|
||||
|
||||
/// emscripten: _clock
|
||||
pub extern "C" fn _clock(_ctx: &mut Ctx) -> c_int {
|
||||
pub fn _clock(_ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_clock");
|
||||
0 // TODO: unimplemented
|
||||
}
|
||||
|
||||
/// emscripten: _difftime
|
||||
pub extern "C" fn _difftime(t0: u32, t1: u32, _ctx: &mut Ctx) -> f64 {
|
||||
pub fn _difftime(t0: u32, t1: u32, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::_difftime");
|
||||
(t0 - t1) as _
|
||||
}
|
||||
|
||||
pub extern "C" fn _gmtime_r(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _gmtime_r(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_gmtime_r");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _mktime(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _mktime(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_mktime");
|
||||
-1
|
||||
}
|
||||
|
||||
pub extern "C" fn _gmtime(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
pub fn _gmtime(_one: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_gmtime");
|
||||
-1
|
||||
}
|
||||
@ -130,13 +130,13 @@ struct guest_tm {
|
||||
}
|
||||
|
||||
/// emscripten: _tvset
|
||||
pub extern "C" fn _tvset(_ctx: &mut Ctx) {
|
||||
pub fn _tvset(_ctx: &mut Ctx) {
|
||||
debug!("emscripten::_tvset UNIMPLEMENTED");
|
||||
}
|
||||
|
||||
/// formats time as a C string
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
unsafe extern "C" fn fmt_time(time: u32, ctx: &mut Ctx) -> *const c_char {
|
||||
unsafe fn fmt_time(time: u32, ctx: &mut Ctx) -> *const c_char {
|
||||
let date = &*(emscripten_memory_pointer!(ctx.memory(0), time) as *mut guest_tm);
|
||||
|
||||
let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||
@ -161,7 +161,7 @@ unsafe extern "C" fn fmt_time(time: u32, ctx: &mut Ctx) -> *const c_char {
|
||||
}
|
||||
|
||||
/// emscripten: _asctime
|
||||
pub extern "C" fn _asctime(time: u32, ctx: &mut Ctx) -> u32 {
|
||||
pub fn _asctime(time: u32, ctx: &mut Ctx) -> u32 {
|
||||
debug!("emscripten::_asctime {}", time);
|
||||
|
||||
unsafe {
|
||||
@ -175,7 +175,7 @@ pub extern "C" fn _asctime(time: u32, ctx: &mut Ctx) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: _asctime_r
|
||||
pub extern "C" fn _asctime_r(time: u32, buf: u32, ctx: &mut Ctx) -> u32 {
|
||||
pub fn _asctime_r(time: u32, buf: u32, ctx: &mut Ctx) -> u32 {
|
||||
debug!("emscripten::_asctime_r {}, {}", time, buf);
|
||||
|
||||
unsafe {
|
||||
@ -194,7 +194,7 @@ pub extern "C" fn _asctime_r(time: u32, buf: u32, ctx: &mut Ctx) -> u32 {
|
||||
|
||||
/// emscripten: _localtime
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _localtime(time_p: u32, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _localtime(time_p: u32, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_localtime {}", 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
|
||||
@ -232,7 +232,7 @@ pub extern "C" fn _localtime(time_p: u32, ctx: &mut Ctx) -> c_int {
|
||||
}
|
||||
/// emscripten: _localtime_r
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _localtime_r(time_p: u32, result: u32, ctx: &mut Ctx) -> c_int {
|
||||
pub fn _localtime_r(time_p: u32, result: u32, ctx: &mut Ctx) -> c_int {
|
||||
debug!("emscripten::_localtime_r {}", time_p);
|
||||
|
||||
// NOTE: emscripten seems to want tzset() called in this function
|
||||
@ -269,7 +269,7 @@ pub extern "C" fn _localtime_r(time_p: u32, result: u32, ctx: &mut Ctx) -> c_int
|
||||
|
||||
/// emscripten: _time
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub extern "C" fn _time(time_p: u32, ctx: &mut Ctx) -> time_t {
|
||||
pub fn _time(time_p: u32, ctx: &mut Ctx) -> time_t {
|
||||
debug!("emscripten::_time {}", time_p);
|
||||
|
||||
unsafe {
|
||||
@ -279,7 +279,7 @@ pub extern "C" fn _time(time_p: u32, ctx: &mut Ctx) -> time_t {
|
||||
}
|
||||
|
||||
/// emscripten: _strftime
|
||||
pub extern "C" fn _strftime(
|
||||
pub fn _strftime(
|
||||
s_ptr: c_int,
|
||||
maxsize: u32,
|
||||
format_ptr: c_int,
|
||||
|
@ -47,7 +47,7 @@ pub unsafe fn write_to_buf(string: *const c_char, buf: u32, max: u32, ctx: &mut
|
||||
pub unsafe fn copy_cstr_into_wasm(ctx: &mut Ctx, cstr: *const c_char) -> u32 {
|
||||
let s = CStr::from_ptr(cstr).to_str().unwrap();
|
||||
let cstr_len = s.len();
|
||||
let space_offset = env::call_malloc((cstr_len as i32) + 1, ctx);
|
||||
let space_offset = env::call_malloc((cstr_len as u32) + 1, ctx);
|
||||
let raw_memory = emscripten_memory_pointer!(ctx.memory(0), space_offset) as *mut u8;
|
||||
let slice = slice::from_raw_parts_mut(raw_memory, cstr_len);
|
||||
|
||||
@ -63,7 +63,10 @@ pub unsafe fn copy_cstr_into_wasm(ctx: &mut Ctx, cstr: *const c_char) -> u32 {
|
||||
}
|
||||
|
||||
pub unsafe fn allocate_on_stack<'a, T: Copy>(count: u32, ctx: &'a mut Ctx) -> (u32, &'a mut [T]) {
|
||||
let offset = (get_emscripten_data(ctx).stack_alloc)(count * (size_of::<T>() as u32), ctx);
|
||||
let offset = get_emscripten_data(ctx)
|
||||
.stack_alloc
|
||||
.call(count * (size_of::<T>() as u32))
|
||||
.unwrap();
|
||||
let addr = emscripten_memory_pointer!(ctx.memory(0), offset) as *mut T;
|
||||
let slice = slice::from_raw_parts_mut(addr, count as usize);
|
||||
|
||||
|
Reference in New Issue
Block a user