mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-14 09:21:20 +00:00
Update imports for lua example
This commit is contained in:
@ -38,6 +38,7 @@ mod errno;
|
||||
mod exception;
|
||||
mod io;
|
||||
mod jmp;
|
||||
mod linking;
|
||||
mod lock;
|
||||
mod math;
|
||||
mod memory;
|
||||
@ -705,7 +706,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
func: func!(lock, ___wait),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![I32, I32],
|
||||
params: vec![I32, I32, I32, I32],
|
||||
returns: vec![],
|
||||
},
|
||||
},
|
||||
@ -1293,7 +1294,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
func: func!(process, _system),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![],
|
||||
params: vec![I32],
|
||||
returns: vec![I32],
|
||||
},
|
||||
},
|
||||
@ -1305,7 +1306,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
func: func!(process, _popen),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![],
|
||||
params: vec![I32, I32],
|
||||
returns: vec![I32],
|
||||
},
|
||||
},
|
||||
@ -1365,7 +1366,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
func: func!(signal, _signal),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![I32],
|
||||
params: vec![I32, I32],
|
||||
returns: vec![I32],
|
||||
},
|
||||
},
|
||||
@ -1425,7 +1426,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
func: func!(memory, ___map_file),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![],
|
||||
params: vec![I32, I32],
|
||||
returns: vec![I32],
|
||||
},
|
||||
},
|
||||
@ -1678,7 +1679,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![I32, I32],
|
||||
returns: vec![I32],
|
||||
returns: vec![F64],
|
||||
},
|
||||
},
|
||||
);
|
||||
@ -2283,6 +2284,66 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
},
|
||||
);
|
||||
|
||||
env_namespace.insert(
|
||||
"_dlclose",
|
||||
Export::Function {
|
||||
func: func!(linking, _dlclose),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![I32],
|
||||
returns: vec![I32],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
env_namespace.insert(
|
||||
"_dlopen",
|
||||
Export::Function {
|
||||
func: func!(linking, _dlopen),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![I32, I32],
|
||||
returns: vec![I32],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
env_namespace.insert(
|
||||
"_dlsym",
|
||||
Export::Function {
|
||||
func: func!(linking, _dlsym),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![I32, I32],
|
||||
returns: vec![I32],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
env_namespace.insert(
|
||||
"_llvm_log10_f32",
|
||||
Export::Function {
|
||||
func: func!(math, _llvm_log10_f32),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![F64],
|
||||
returns: vec![F64],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
env_namespace.insert(
|
||||
"_llvm_log2_f32",
|
||||
Export::Function {
|
||||
func: func!(math, _llvm_log2_f32),
|
||||
ctx: Context::Internal,
|
||||
signature: FuncSig {
|
||||
params: vec![F64],
|
||||
returns: vec![F64],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// mock_external!(env_namespace, _time);
|
||||
// mock_external!(env_namespace, _sysconf);
|
||||
// mock_external!(env_namespace, _strftime);
|
||||
@ -2321,9 +2382,6 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
// mock_external!(env_namespace, ___syscall122);
|
||||
// mock_external!(env_namespace, ___syscall102);
|
||||
// mock_external!(env_namespace, ___syscall20);
|
||||
mock_external!(env_namespace, _dlopen);
|
||||
mock_external!(env_namespace, _dlclose);
|
||||
mock_external!(env_namespace, _dlsym);
|
||||
mock_external!(env_namespace, _dlerror);
|
||||
|
||||
imports.register("env", env_namespace);
|
||||
|
@ -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: c_int, _ctx: &mut Ctx) -> u32 {
|
||||
pub extern "C" 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) -> u32 {
|
||||
pub extern "C" 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) -> u32 {
|
||||
debug!("emscripten::_dlerror");
|
||||
pub extern "C" 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) -> u32 {
|
||||
pub extern "C" fn _dlerror(_ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_dlerror");
|
||||
-1
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ pub extern "C" fn ___unlock(what: c_int, _ctx: &mut Ctx) {
|
||||
}
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub extern "C" fn ___wait(_which: c_int, _varargs: c_int, _ctx: &mut Ctx) {
|
||||
pub extern "C" fn ___wait(_which: c_int, _varargs: c_int, three: u32, four: u32, _ctx: &mut Ctx) {
|
||||
debug!("emscripten::___wait");
|
||||
}
|
||||
|
@ -12,6 +12,16 @@ pub extern "C" fn _llvm_log2_f64(value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
value.log2()
|
||||
}
|
||||
|
||||
pub extern "C" fn _llvm_log10_f32(value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::_llvm_log10_f32");
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub extern "C" fn _llvm_log2_f32(value: f64, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::_llvm_log10_f32");
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
// emscripten: f64-rem
|
||||
pub extern "C" fn f64_rem(x: f64, y: f64, _ctx: &mut Ctx) -> f64 {
|
||||
debug!("emscripten::f64-rem");
|
||||
|
@ -40,7 +40,7 @@ pub extern "C" fn abort_on_cannot_grow_memory(_ctx: &mut Ctx) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: ___map_file
|
||||
pub extern "C" fn ___map_file(_ctx: &mut Ctx) -> c_int {
|
||||
pub extern "C" 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
|
||||
|
@ -119,14 +119,14 @@ pub extern "C" fn _llvm_trap(_ctx: &mut Ctx) {
|
||||
abort_with_message("abort!");
|
||||
}
|
||||
|
||||
pub extern "C" fn _system(_ctx: &mut Ctx) -> c_int {
|
||||
pub extern "C" 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(_ctx: &mut Ctx) -> c_int {
|
||||
pub extern "C" 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");
|
||||
|
@ -36,7 +36,7 @@ pub extern "C" fn _sigprocmask(one: i32, two: i32, three: i32, ctx: &mut Ctx) ->
|
||||
0
|
||||
}
|
||||
|
||||
pub extern "C" fn _signal(sig: u32, _ctx: &mut Ctx) -> i32 {
|
||||
pub extern "C" fn _signal(sig: u32, two: i32, _ctx: &mut Ctx) -> i32 {
|
||||
debug!("emscripten::_signal ({})", sig);
|
||||
0
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ pub extern "C" fn _clock() -> c_int {
|
||||
}
|
||||
|
||||
/// emscripten: _difftime
|
||||
pub extern "C" fn _difftime(t0: u32, t1: u32) -> c_int {
|
||||
pub extern "C" fn _difftime(t0: u32, t1: u32) -> f64 {
|
||||
debug!("emscripten::_difftime");
|
||||
(t0 - t1) as _
|
||||
}
|
||||
|
Reference in New Issue
Block a user