wasmer/lib/emscripten/src/lib.rs

1838 lines
48 KiB
Rust
Raw Normal View History

2019-01-11 05:37:59 +00:00
#[macro_use]
extern crate wasmer_runtime_core;
2019-01-11 05:37:59 +00:00
2019-01-18 05:55:44 +00:00
use byteorder::{ByteOrder, LittleEndian};
use libc::c_int;
use std::cell::UnsafeCell;
use std::{ffi::c_void, mem, ptr};
2019-01-24 06:17:43 +00:00
use std::{fmt, mem::size_of, slice};
use wasmer_runtime_core::{
2019-01-24 06:00:38 +00:00
error::{CallResult, ResolveError},
2019-01-23 20:34:56 +00:00
export::{Context, Export, FuncPointer, GlobalPointer, MemoryPointer, TablePointer},
2019-01-22 00:42:20 +00:00
import::{ImportObject, Namespace},
instance::Instance,
2019-01-18 05:55:44 +00:00
memory::LinearMemory,
module::Module,
2019-01-23 20:35:14 +00:00
structures::TypedIndex,
2019-01-23 20:34:56 +00:00
table::TableBacking,
2019-01-11 16:10:21 +00:00
types::{
2019-01-23 20:35:14 +00:00
ElementType, FuncSig, GlobalDesc, LocalMemoryIndex, Memory, Table,
2019-01-18 05:55:44 +00:00
Type::{self, *},
Value,
2019-01-11 16:10:21 +00:00
},
vm::Ctx,
2019-01-19 00:36:28 +00:00
vm::LocalGlobal,
2019-01-23 20:25:56 +00:00
vm::LocalMemory,
2019-01-23 20:34:56 +00:00
vm::LocalTable,
2019-01-11 16:10:21 +00:00
};
2019-01-18 05:55:44 +00:00
2019-01-22 00:42:20 +00:00
#[macro_use]
mod macros;
2019-01-18 05:55:44 +00:00
//#[cfg(test)]
mod file_descriptor;
pub mod stdio;
2018-11-20 19:11:58 +00:00
// EMSCRIPTEN APIS
2018-11-21 23:10:03 +00:00
mod env;
2018-11-27 04:29:26 +00:00
mod errno;
2018-12-18 17:43:59 +00:00
mod exception;
2018-11-22 04:59:23 +00:00
mod io;
2018-12-19 01:21:12 +00:00
mod jmp;
2018-11-27 04:29:26 +00:00
mod lock;
mod math;
2018-12-18 17:43:59 +00:00
mod memory;
2018-11-27 04:29:26 +00:00
mod nullfunc;
2018-11-20 19:11:58 +00:00
mod process;
2018-11-28 21:25:56 +00:00
mod signal;
2018-11-27 04:29:26 +00:00
mod storage;
2018-11-21 23:10:03 +00:00
mod syscalls;
2018-11-27 04:29:26 +00:00
mod time;
2018-11-22 04:59:23 +00:00
mod utils;
2018-11-23 05:13:01 +00:00
mod varargs;
2018-11-20 19:11:58 +00:00
2018-12-15 06:46:11 +00:00
pub use self::storage::align_memory;
pub use self::utils::{allocate_cstr_on_stack, allocate_on_stack, is_emscripten_module};
// TODO: Magic number - how is this calculated?
const TOTAL_STACK: u32 = 5_242_880;
2018-12-07 02:10:26 +00:00
// TODO: Magic number - how is this calculated?
const DYNAMICTOP_PTR_DIFF: u32 = 1088;
2018-12-07 02:10:26 +00:00
// TODO: make this variable
const STATIC_BUMP: u32 = 215_536;
2019-01-23 20:43:41 +00:00
// The address globals begin at. Very low in memory, for code size and optimization opportunities.
// Above 0 is static memory, starting with globals.
// Then the stack.
// Then 'dynamic' memory for sbrk.
const GLOBAL_BASE: u32 = 1024;
const STATIC_BASE: u32 = GLOBAL_BASE;
fn stacktop(static_bump: u32) -> u32 {
align_memory(dynamictop_ptr(static_bump) + 4)
}
fn stack_max(static_bump: u32) -> u32 {
stacktop(static_bump) + TOTAL_STACK
}
fn dynamic_base(static_bump: u32) -> u32 {
align_memory(stack_max(static_bump))
}
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]>>,
}
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
};
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(),
}
}
}
}
2019-01-06 21:21:06 +00:00
2019-01-24 06:17:43 +00:00
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()
}
}
pub fn run_emscripten_instance(
2019-01-24 06:00:38 +00:00
_module: &Module,
instance: &mut Instance,
_path: &str,
args: Vec<&str>,
) -> CallResult<()> {
let mut data = EmscriptenData::new(instance);
let data_ptr = &mut data as *mut _ as *mut c_void;
instance.ctx().data = data_ptr;
// Get main arguments.
let main_args = get_main_args("_main", args, instance).unwrap();
// Call main function with the arguments.
instance.call("_main", &main_args)?;
// TODO atinit and atexit for emscripten
2019-01-24 06:17:43 +00:00
println!("{:?}", data);
Ok(())
}
/// Passes arguments from the host to the WebAssembly instance.
fn get_main_args(
main_name: &str,
args: Vec<&str>,
instance: &mut Instance,
) -> CallResult<Vec<Value>> {
// Getting main function signature.
let func = instance.func(main_name)?;
let func_sig = func.signature();
let params = &func_sig.params;
// Check for a () or (i32, i32) sig.
match params.as_slice() {
&[Type::I32, Type::I32] => {
// Copy strings into wasm memory and get addresses to them.
let string_addresses = args
.iter()
.map(|string| copy_string_into_wasm(instance, (*string).to_string()).unwrap())
.collect();
// Create a wasm array to the strings.
let array = create_wasm_array(instance, string_addresses).unwrap();
Ok(vec![
Value::I32(array as i32),
Value::I32(args.len() as i32),
])
}
&[] => Ok(vec![]),
_ => Err(ResolveError::Signature {
expected: FuncSig {
params: vec![Type::I32, Type::I32],
returns: vec![],
},
found: params.to_vec(),
}
.into()),
}
}
/// Copy rust string to wasm instance.
fn copy_string_into_wasm(instance: &mut Instance, string: String) -> CallResult<u32> {
let string_len = string.len();
let space_offset = instance
.call("_malloc", &[Value::I32((string_len as i32) + 1)])
.unwrap();
let space_offset = match space_offset.as_slice() {
&[Value::I32(res)] => Some(res as u32),
_ => None,
}
.unwrap();
let raw_memory = instance.ctx().memory(0)[space_offset as usize] as *mut u8;
let slice = unsafe { slice::from_raw_parts_mut(raw_memory, string_len) };
for (byte, loc) in string.bytes().zip(slice.iter_mut()) {
*loc = byte;
}
unsafe { *raw_memory.add(string_len) = 0 };
Ok(space_offset)
}
/// Create a pointer to an array of items in a wasm memory
fn create_wasm_array(instance: &mut Instance, values: Vec<u32>) -> CallResult<u32> {
let values_len = values.len();
// Space to store pointers to values
let values_offset = instance
.call(
"_malloc",
&[Value::I32((size_of::<u32>() * values.len()) as i32)],
)
.unwrap();
let values_offset = match values_offset.as_slice() {
&[Value::I32(res)] => Some(res as u32),
_ => None,
}
.unwrap();
let raw_memory = instance.ctx().memory(0)[values_offset as usize] as *mut u32;
let slice = unsafe { slice::from_raw_parts_mut(raw_memory, values_len) };
for (value, loc) in values.iter().zip(slice.iter_mut()) {
*loc = value.clone();
}
// Space to store pointer to array
let array_offset = instance
.call("_malloc", &[Value::I32(size_of::<u32>() as i32)])
.unwrap();
let array_offset = match array_offset.as_slice() {
&[Value::I32(res)] => Some(res as u32),
_ => None,
}
.unwrap();
let raw_memory = instance.ctx().memory(0)[values_offset as usize] as *mut u32;
unsafe { *raw_memory = values_offset };
Ok(array_offset)
}
pub fn emscripten_set_up_memory(memory: &mut LinearMemory) {
let dynamictop_ptr = dynamictop_ptr(STATIC_BUMP) as usize;
2018-11-28 21:29:50 +00:00
let dynamictop_ptr_offset = dynamictop_ptr + mem::size_of::<u32>();
2018-12-07 02:10:26 +00:00
// println!("value = {:?}");
2018-11-28 21:29:50 +00:00
// We avoid failures of setting the u32 in our memory if it's out of bounds
if dynamictop_ptr_offset > memory.len() {
2018-12-07 02:10:26 +00:00
return; // TODO: We should panic instead?
}
2018-12-07 02:10:26 +00:00
// debug!("###### dynamic_base = {:?}", dynamic_base(STATIC_BUMP));
// debug!("###### dynamictop_ptr = {:?}", dynamictop_ptr);
// debug!("###### dynamictop_ptr_offset = {:?}", dynamictop_ptr_offset);
2018-11-28 21:29:50 +00:00
let mem = &mut memory[dynamictop_ptr..dynamictop_ptr_offset];
LittleEndian::write_u32(mem, dynamic_base(STATIC_BUMP));
}
macro_rules! mock_external {
2019-01-17 18:55:25 +00:00
($namespace:ident, $name:ident) => {{
2018-11-27 04:29:26 +00:00
extern "C" fn _mocked_fn() -> i32 {
debug!("emscripten::{} <mock>", stringify!($name));
-1
}
2019-01-17 18:55:25 +00:00
$namespace.insert(
stringify!($name),
Export::Function {
2019-01-17 18:55:25 +00:00
func: unsafe { FuncPointer::new(_mocked_fn as _) },
ctx: Context::Internal,
signature: FuncSig {
2018-12-30 10:23:16 +00:00
params: vec![],
returns: vec![I32],
2018-12-30 10:23:16 +00:00
},
},
2018-12-30 10:23:16 +00:00
);
}};
}
2019-01-17 18:55:25 +00:00
macro_rules! func {
($namespace:ident, $function:ident) => {{
unsafe { FuncPointer::new($namespace::$function as _) }
}};
}
2019-01-17 22:10:29 +00:00
macro_rules! global {
2019-01-25 00:45:22 +00:00
($value:expr) => {{
2019-01-17 22:10:29 +00:00
unsafe {
GlobalPointer::new(
// NOTE: Taking a shortcut here. LocalGlobal is a struct containing just u64.
std::mem::transmute::<&u64, *mut LocalGlobal>(&$value),
2019-01-17 22:10:29 +00:00
)
}
}};
}
pub struct EmscriptenGlobalsData {
// Env namespace
2019-01-25 00:45:22 +00:00
stacktop: u64,
stack_max: u64,
dynamictop_ptr: u64,
memory_base: u64,
table_base: u64,
temp_double_ptr: u64,
// Global namespace
2019-01-25 00:45:22 +00:00
infinity: u64,
nan: u64,
}
pub struct EmscriptenGlobals {
// The emscripten data
pub data: EmscriptenGlobalsData,
2019-01-23 20:25:56 +00:00
// The emscripten memory
pub memory: LinearMemory,
pub vm_memory: LocalMemory,
2019-01-23 20:34:56 +00:00
// The emscripten table
pub table: TableBacking,
pub vm_table: LocalTable,
2019-01-11 16:10:21 +00:00
}
2019-01-25 00:46:16 +00:00
impl EmscriptenGlobals {
2019-01-11 20:17:28 +00:00
pub fn new() -> Self {
2019-01-23 20:34:56 +00:00
// Memory initialization
2019-01-23 20:25:56 +00:00
let memory_type = Memory {
min: 256,
max: Some(256),
shared: false,
};
let mut memory = LinearMemory::new(&memory_type);
2019-01-24 06:00:38 +00:00
let vm_memory = memory.into_vm_memory(LocalMemoryIndex::new(0));
2019-01-23 20:25:56 +00:00
2019-01-23 20:34:56 +00:00
let table_type = Table {
ty: ElementType::Anyfunc,
min: 10,
max: Some(10),
};
let mut table = TableBacking::new(&table_type);
2019-01-24 06:00:38 +00:00
let vm_table = table.into_vm_table();
2019-01-23 20:34:56 +00:00
2019-01-25 00:45:22 +00:00
let memory_base = STATIC_BASE as u64;
let table_base = 0 as u64;
let temp_double_ptr = 0 as u64;
let data = EmscriptenGlobalsData {
// env
2019-01-25 00:45:22 +00:00
stacktop: stacktop(STATIC_BUMP) as _,
stack_max: stack_max(STATIC_BUMP) as _,
dynamictop_ptr: dynamictop_ptr(STATIC_BUMP) as _,
memory_base: memory_base,
table_base: table_base,
temp_double_ptr: temp_double_ptr,
// global
2019-01-25 00:45:22 +00:00
infinity: std::f64::INFINITY.to_bits() as _,
nan: std::f64::NAN.to_bits() as _,
};
2019-01-17 18:55:25 +00:00
2019-01-23 20:35:14 +00:00
Self {
data,
memory,
vm_memory,
table,
vm_table,
}
2019-01-11 16:10:21 +00:00
}
}
2019-01-23 20:25:56 +00:00
pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject {
let mut imports = ImportObject::new();
2019-01-22 00:42:20 +00:00
let mut env_namespace = Namespace::new();
let mut asm_namespace = Namespace::new();
let mut global_namespace = Namespace::new();
2019-01-23 18:54:03 +00:00
let mut global_math_namespace = Namespace::new();
2019-01-11 16:10:21 +00:00
// Add globals.
2019-01-17 22:10:29 +00:00
// NOTE: There is really no need for checks, these globals should always be available.
2019-01-23 20:34:56 +00:00
// We generate a fake Context that traps on access
let null_ctx = Context::External(ptr::null_mut());
2019-01-23 20:25:56 +00:00
2019-01-23 20:34:56 +00:00
// Memory
2019-01-23 20:35:14 +00:00
let local_memory = unsafe { MemoryPointer::new(&mut globals.vm_memory) };
2019-01-23 20:25:56 +00:00
env_namespace.insert(
"memory".to_string(),
Export::Memory {
local: local_memory,
2019-01-23 20:34:56 +00:00
ctx: null_ctx,
2019-01-23 20:25:56 +00:00
memory: Memory {
min: 256,
max: Some(256),
shared: false,
2019-01-23 20:35:14 +00:00
},
2019-01-23 20:25:56 +00:00
},
);
2019-01-23 20:34:56 +00:00
// Table
2019-01-23 20:35:14 +00:00
let local_table = unsafe { TablePointer::new(&mut globals.vm_table) };
2019-01-23 20:34:56 +00:00
env_namespace.insert(
"table".to_string(),
Export::Table {
local: local_table,
// We generate a fake Context that traps on access
ctx: null_ctx,
table: Table {
ty: ElementType::Anyfunc,
min: 10,
max: Some(10),
2019-01-23 20:35:14 +00:00
},
2019-01-23 20:34:56 +00:00
},
);
2019-01-17 22:10:29 +00:00
env_namespace.insert(
"STACKTOP".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.stacktop),
2019-01-17 22:10:29 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: I32,
2019-01-18 05:55:44 +00:00
},
2019-01-17 22:10:29 +00:00
},
);
env_namespace.insert(
"STACK_MAX".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.stack_max),
2019-01-17 22:10:29 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: I32,
2019-01-18 05:55:44 +00:00
},
2019-01-17 22:10:29 +00:00
},
);
2019-01-11 16:10:21 +00:00
2019-01-17 22:10:29 +00:00
env_namespace.insert(
"DYNAMICTOP_PTR".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.dynamictop_ptr),
2019-01-17 22:10:29 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: I32,
2019-01-18 05:55:44 +00:00
},
2019-01-17 22:10:29 +00:00
},
);
env_namespace.insert(
"tableBase".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.table_base),
2019-01-17 22:10:29 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: I32,
2019-01-18 05:55:44 +00:00
},
2019-01-17 22:10:29 +00:00
},
);
2019-01-11 16:10:21 +00:00
2019-01-23 20:43:41 +00:00
env_namespace.insert(
"__table_base".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.table_base),
2019-01-23 20:43:41 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: I32,
2019-01-23 20:43:41 +00:00
},
},
);
env_namespace.insert(
"memoryBase".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.memory_base),
2019-01-23 20:43:41 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: I32,
2019-01-23 20:43:41 +00:00
},
},
);
env_namespace.insert(
"__memory_base".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.memory_base),
2019-01-23 20:43:41 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: I32,
2019-01-23 20:43:41 +00:00
},
},
);
2019-01-23 20:46:46 +00:00
env_namespace.insert(
"tempDoublePtr".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.temp_double_ptr),
2019-01-23 20:46:46 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: I32,
2019-01-23 20:46:46 +00:00
},
},
);
2019-01-17 22:10:29 +00:00
global_namespace.insert(
"Infinity".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.infinity),
2019-01-17 22:10:29 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: F64,
2019-01-18 05:55:44 +00:00
},
2019-01-17 22:10:29 +00:00
},
);
2019-01-11 16:10:21 +00:00
2019-01-17 22:10:29 +00:00
global_namespace.insert(
"NaN".to_string(),
Export::Global {
2019-01-25 00:45:22 +00:00
local: global!(globals.data.nan),
2019-01-17 22:10:29 +00:00
global: GlobalDesc {
mutable: false,
2019-01-25 00:45:22 +00:00
ty: F64,
2019-01-18 05:55:44 +00:00
},
2019-01-17 22:10:29 +00:00
},
);
2019-01-17 18:55:25 +00:00
2019-01-23 18:54:03 +00:00
// Global Math
global_math_namespace.insert(
"pow",
Export::Function {
func: func!(math, pow),
ctx: Context::Internal,
signature: FuncSig {
params: vec![F64, F64],
returns: vec![F64],
},
},
);
2019-01-17 18:55:25 +00:00
// Print function
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"printf",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(io, printf),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"putchar",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(io, putchar),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 22:10:29 +00:00
2019-01-23 18:54:03 +00:00
// Assert
env_namespace.insert(
"___assert_fail",
Export::Function {
func: func!(env, ___assert_fail),
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32, I32, I32],
returns: vec![],
},
},
);
2019-01-11 16:10:21 +00:00
// Lock
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___lock",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(lock, ___lock),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
2019-01-23 18:54:03 +00:00
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___unlock",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(lock, ___unlock),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
2019-01-23 18:54:03 +00:00
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___wait",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(lock, ___wait),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
// Env
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_getenv",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, _getenv),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_setenv",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, _setenv),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32, I32],
2019-01-23 18:54:03 +00:00
returns: vec![I32],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_putenv",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, _putenv),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
2019-01-23 18:54:03 +00:00
returns: vec![I32],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_unsetenv",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, _unsetenv),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
2019-01-23 18:54:03 +00:00
returns: vec![I32],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_getpwnam",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, _getpwnam),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_getgrnam",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, _getgrnam),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___buildEnvironment",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, ___build_environment),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
// Errno
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___setErrNo",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(errno, ___seterrno),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
2019-01-23 18:54:03 +00:00
returns: vec![],
2019-01-11 16:10:21 +00:00
},
},
);
// Syscalls
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall1",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall1),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall3",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall3),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall4",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall4),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall5",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall5),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall6",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall6),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall12",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall12),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall20",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall20),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall39",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall39),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall40",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall40),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall54",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall54),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall57",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall57),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall63",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall63),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall64",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall64),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall102",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall102),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall114",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall114),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall122",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall122),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall140",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall140),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall142",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall142),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall145",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall145),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall146",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall146),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall180",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall180),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall181",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall181),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall192",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall192),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall195",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall195),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall197",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall197),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall201",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall201),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall202",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall202),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall212",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall212),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall221",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall221),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall330",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall330),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___syscall340",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(syscalls, ___syscall340),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
// Process
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"abort",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(process, em_abort),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_abort",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(process, _abort),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"abortStackOverflow",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(process, abort_stack_overflow),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
2019-01-23 18:54:03 +00:00
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_llvm_trap",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(process, _llvm_trap),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_fork",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(process, _fork),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_exit",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(process, _exit),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_system",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(process, _system),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_popen",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(process, _popen),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
// Signal
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_sigemptyset",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(signal, _sigemptyset),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_sigaddset",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(signal, _sigaddset),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_sigprocmask",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(signal, _sigprocmask),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_sigaction",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(signal, _sigaction),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_signal",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(signal, _signal),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
// Memory
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"abortOnCannotGrowMemory",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(memory, abort_on_cannot_grow_memory),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-23 18:54:03 +00:00
returns: vec![I32],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_emscripten_memcpy_big",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(memory, _emscripten_memcpy_big),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"enlargeMemory",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(memory, enlarge_memory),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-23 18:54:03 +00:00
returns: vec![I32],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"getTotalMemory",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(memory, get_total_memory),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___map_file",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(memory, ___map_file),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
// Exception
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___cxa_allocate_exception",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(exception, ___cxa_allocate_exception),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___cxa_allocate_exception",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(exception, ___cxa_throw),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32, I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___cxa_throw",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(exception, ___cxa_throw),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32, I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
// NullFuncs
2019-01-23 18:54:03 +00:00
env_namespace.insert(
"nullFunc_i",
Export::Function {
func: func!(nullfunc, nullfunc_i),
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_ii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_ii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_iii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_iii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_iiii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_iiii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_iiiii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_iiiii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_iiiiii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_iiiiii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_v",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_v),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_vi",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_vi),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_vii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_vii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_viii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_viii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_viiii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_viiii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_viiiii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_viiiii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"nullFunc_viiiiii",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(nullfunc, nullfunc_viiiiii),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
// Time
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_gettimeofday",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _gettimeofday),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_clock_gettime",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _clock_gettime),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"___clock_gettime",
Export::Function {
2019-01-24 21:04:12 +00:00
func: func!(time, _clock_gettime),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_clock",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _clock),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_difftime",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _difftime),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_asctime",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _asctime),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_asctime_r",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _asctime_r),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_localtime",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _localtime),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_time",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _time),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_strftime",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _strftime),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32, I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_localtime_r",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(time, _localtime_r),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_getpagesize",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, _getpagesize),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![],
2019-01-11 16:10:21 +00:00
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"_sysconf",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(env, _sysconf),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
2019-01-11 16:10:21 +00:00
// Math
2019-01-17 18:55:25 +00:00
asm_namespace.insert(
"f64-rem",
2019-01-11 16:10:21 +00:00
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(math, f64_rem),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
2019-01-17 18:55:25 +00:00
params: vec![F64, F64],
2019-01-11 16:10:21 +00:00
returns: vec![F64],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
"_llvm_log10_f64",
2019-01-11 16:10:21 +00:00
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(math, _llvm_log10_f64),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![F64],
returns: vec![F64],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
"_llvm_log2_f64",
2019-01-11 16:10:21 +00:00
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(math, _llvm_log2_f64),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
2019-01-17 18:55:25 +00:00
params: vec![F64],
2019-01-11 16:10:21 +00:00
returns: vec![F64],
},
},
);
2019-01-17 18:55:25 +00:00
2018-12-30 10:23:16 +00:00
//
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"__setjmp",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(jmp, __setjmp),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32],
returns: vec![I32],
},
},
);
2019-01-17 18:55:25 +00:00
env_namespace.insert(
2019-01-11 16:10:21 +00:00
"__longjmp",
Export::Function {
2019-01-17 18:55:25 +00:00
func: func!(jmp, __longjmp),
2019-01-11 16:10:21 +00:00
ctx: Context::Internal,
signature: FuncSig {
params: vec![I32, I32],
returns: vec![],
},
2019-01-11 16:10:21 +00:00
},
);
2018-12-19 01:21:12 +00:00
2019-01-17 18:55:25 +00:00
mock_external!(env_namespace, _waitpid);
mock_external!(env_namespace, _utimes);
mock_external!(env_namespace, _usleep);
// mock_external!(env_namespace, _time);
// mock_external!(env_namespace, _sysconf);
// mock_external!(env_namespace, _strftime);
mock_external!(env_namespace, _sigsuspend);
// mock_external!(env_namespace, _sigprocmask);
// mock_external!(env_namespace, _sigemptyset);
// mock_external!(env_namespace, _sigaddset);
// mock_external!(env_namespace, _sigaction);
mock_external!(env_namespace, _setitimer);
mock_external!(env_namespace, _setgroups);
mock_external!(env_namespace, _setgrent);
mock_external!(env_namespace, _sem_wait);
mock_external!(env_namespace, _sem_post);
mock_external!(env_namespace, _sem_init);
mock_external!(env_namespace, _sched_yield);
mock_external!(env_namespace, _raise);
mock_external!(env_namespace, _mktime);
// mock_external!(env_namespace, _localtime_r);
// mock_external!(env_namespace, _localtime);
mock_external!(env_namespace, _llvm_stacksave);
mock_external!(env_namespace, _llvm_stackrestore);
mock_external!(env_namespace, _kill);
mock_external!(env_namespace, _gmtime_r);
// mock_external!(env_namespace, _gettimeofday);
// mock_external!(env_namespace, _getpagesize);
mock_external!(env_namespace, _getgrent);
mock_external!(env_namespace, _getaddrinfo);
// mock_external!(env_namespace, _fork);
// mock_external!(env_namespace, _exit);
mock_external!(env_namespace, _execve);
mock_external!(env_namespace, _endgrent);
// mock_external!(env_namespace, _clock_gettime);
mock_external!(env_namespace, ___syscall97);
mock_external!(env_namespace, ___syscall91);
mock_external!(env_namespace, ___syscall85);
mock_external!(env_namespace, ___syscall75);
mock_external!(env_namespace, ___syscall66);
// mock_external!(env_namespace, ___syscall64);
// mock_external!(env_namespace, ___syscall63);
// mock_external!(env_namespace, ___syscall60);
// mock_external!(env_namespace, ___syscall54);
// mock_external!(env_namespace, ___syscall39);
mock_external!(env_namespace, ___syscall38);
// mock_external!(env_namespace, ___syscall340);
mock_external!(env_namespace, ___syscall334);
mock_external!(env_namespace, ___syscall300);
mock_external!(env_namespace, ___syscall295);
mock_external!(env_namespace, ___syscall272);
mock_external!(env_namespace, ___syscall268);
// mock_external!(env_namespace, ___syscall221);
mock_external!(env_namespace, ___syscall220);
// mock_external!(env_namespace, ___syscall212);
// mock_external!(env_namespace, ___syscall201);
mock_external!(env_namespace, ___syscall199);
// mock_external!(env_namespace, ___syscall197);
mock_external!(env_namespace, ___syscall196);
// mock_external!(env_namespace, ___syscall195);
mock_external!(env_namespace, ___syscall194);
mock_external!(env_namespace, ___syscall191);
// mock_external!(env_namespace, ___syscall181);
// mock_external!(env_namespace, ___syscall180);
mock_external!(env_namespace, ___syscall168);
// mock_external!(env_namespace, ___syscall146);
// mock_external!(env_namespace, ___syscall145);
// mock_external!(env_namespace, ___syscall142);
2019-01-23 18:54:03 +00:00
// mock_external!(env_namespace, ___syscall140);
2019-01-17 18:55:25 +00:00
// mock_external!(env_namespace, ___syscall122);
// mock_external!(env_namespace, ___syscall102);
// mock_external!(env_namespace, ___syscall20);
mock_external!(env_namespace, ___syscall15);
mock_external!(env_namespace, ___syscall10);
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);
imports.register("asm2wasm", asm_namespace);
2019-01-23 18:54:03 +00:00
imports.register("global", global_namespace);
imports.register("global.Math", global_math_namespace);
2018-11-26 06:17:33 +00:00
imports
}
/// The current version of this crate
pub const VERSION: &str = env!("CARGO_PKG_VERSION");