2019-01-11 05:37:59 +00:00
|
|
|
#[macro_use]
|
2019-01-22 19:02:06 +00:00
|
|
|
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};
|
2019-01-19 00:36:28 +00:00
|
|
|
use hashbrown::HashMap;
|
2019-01-18 05:55:44 +00:00
|
|
|
use std::mem;
|
2019-01-23 20:25:56 +00:00
|
|
|
use std::ptr;
|
2019-01-22 19:02:06 +00:00
|
|
|
use wasmer_runtime_core::{
|
2019-01-23 20:25:56 +00:00
|
|
|
export::{Context, Export, FuncPointer, GlobalPointer, MemoryPointer},
|
2019-01-22 00:42:20 +00:00
|
|
|
import::{ImportObject, Namespace},
|
2019-01-18 05:55:44 +00:00
|
|
|
memory::LinearMemory,
|
2019-01-11 16:10:21 +00:00
|
|
|
types::{
|
2019-01-18 05:55:44 +00:00
|
|
|
FuncSig, GlobalDesc,
|
|
|
|
Type::{self, *},
|
2019-01-23 20:25:56 +00:00
|
|
|
Memory,
|
|
|
|
LocalMemoryIndex
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2019-01-23 20:25:56 +00:00
|
|
|
structures::TypedIndex,
|
2019-01-19 00:36:28 +00:00
|
|
|
vm::LocalGlobal,
|
2019-01-23 20:25:56 +00:00
|
|
|
vm::LocalMemory,
|
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-14 03:19:23 +00:00
|
|
|
|
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;
|
2018-12-13 18:28:30 +00:00
|
|
|
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};
|
2018-11-14 03:19:23 +00:00
|
|
|
|
2018-11-26 04:56:21 +00:00
|
|
|
// TODO: Magic number - how is this calculated?
|
2018-12-08 06:19:55 +00:00
|
|
|
const TOTAL_STACK: u32 = 5_242_880;
|
2018-12-07 02:10:26 +00:00
|
|
|
// TODO: Magic number - how is this calculated?
|
2018-11-26 04:56:21 +00:00
|
|
|
const DYNAMICTOP_PTR_DIFF: u32 = 1088;
|
2018-12-07 02:10:26 +00:00
|
|
|
// TODO: make this variable
|
2018-12-08 06:19:55 +00:00
|
|
|
const STATIC_BUMP: u32 = 215_536;
|
2018-11-26 04:56:21 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-01-11 16:10:21 +00:00
|
|
|
//pub struct EmscriptenData {
|
|
|
|
// pub malloc: extern "C" fn(i32, &Instance) -> u32,
|
|
|
|
// pub free: extern "C" fn(i32, &mut Instance),
|
|
|
|
// pub memalign: extern "C" fn(u32, u32, &mut Instance) -> u32,
|
|
|
|
// pub memset: extern "C" fn(u32, i32, u32, &mut Instance) -> u32,
|
|
|
|
// pub stack_alloc: extern "C" fn(u32, &Instance) -> u32,
|
|
|
|
// pub jumps: Vec<UnsafeCell<[c_int; 27]>>,
|
|
|
|
//}
|
2019-01-06 21:21:06 +00:00
|
|
|
|
2018-11-26 04:56:21 +00:00
|
|
|
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-11-28 21:25:08 +00:00
|
|
|
}
|
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];
|
2018-11-26 04:56:21 +00:00
|
|
|
LittleEndian::write_u32(mem, dynamic_base(STATIC_BUMP));
|
|
|
|
}
|
|
|
|
|
2018-11-26 19:15:29 +00:00
|
|
|
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 {
|
2018-11-26 21:21:11 +00:00
|
|
|
debug!("emscripten::{} <mock>", stringify!($name));
|
2018-11-27 03:48:19 +00:00
|
|
|
-1
|
2018-11-26 19:15:29 +00:00
|
|
|
}
|
2019-01-11 19:47:41 +00:00
|
|
|
|
2019-01-17 18:55:25 +00:00
|
|
|
$namespace.insert(
|
2019-01-11 19:47:41 +00:00
|
|
|
stringify!($name),
|
|
|
|
Export::Function {
|
2019-01-17 18:55:25 +00:00
|
|
|
func: unsafe { FuncPointer::new(_mocked_fn as _) },
|
2019-01-11 19:47:41 +00:00
|
|
|
ctx: Context::Internal,
|
|
|
|
signature: FuncSig {
|
2018-12-30 10:23:16 +00:00
|
|
|
params: vec![],
|
2019-01-11 19:47:41 +00:00
|
|
|
returns: vec![I32],
|
2018-12-30 10:23:16 +00:00
|
|
|
},
|
2019-01-11 19:47:41 +00:00
|
|
|
},
|
2018-12-30 10:23:16 +00:00
|
|
|
);
|
2018-11-26 19:15:29 +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 {
|
|
|
|
($value:ident) => {{
|
|
|
|
unsafe {
|
|
|
|
GlobalPointer::new(
|
|
|
|
// NOTE: Taking a shortcut here. LocalGlobal is a struct containing just u64.
|
2019-01-18 05:55:44 +00:00
|
|
|
std::mem::transmute::<&u64, *mut LocalGlobal>($value),
|
2019-01-17 22:10:29 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2019-01-17 18:55:25 +00:00
|
|
|
pub struct EmscriptenGlobals<'a> {
|
|
|
|
pub data: HashMap<&'a str, HashMap<&'a str, (u64, Type)>>, // <namespace, <field_name, (global_value, type)>>
|
2019-01-23 20:25:56 +00:00
|
|
|
// The emscripten memory
|
|
|
|
pub memory: LinearMemory,
|
|
|
|
pub vm_memory: LocalMemory,
|
2019-01-11 16:10:21 +00:00
|
|
|
}
|
|
|
|
|
2019-01-18 05:55:44 +00:00
|
|
|
impl<'a> EmscriptenGlobals<'a> {
|
2019-01-11 20:17:28 +00:00
|
|
|
pub fn new() -> Self {
|
2019-01-17 18:55:25 +00:00
|
|
|
let mut data = HashMap::new();
|
|
|
|
let mut env_namepace = HashMap::new();
|
|
|
|
let mut global_namepace = HashMap::new();
|
|
|
|
|
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);
|
|
|
|
let mut vm_memory = memory.into_vm_memory(LocalMemoryIndex::new(0));
|
|
|
|
|
2019-01-17 18:55:25 +00:00
|
|
|
env_namepace.insert("STACKTOP", (stacktop(STATIC_BUMP) as _, I32));
|
|
|
|
env_namepace.insert("STACK_MAX", (stack_max(STATIC_BUMP) as _, I32));
|
|
|
|
env_namepace.insert("DYNAMICTOP_PTR", (dynamictop_ptr(STATIC_BUMP) as _, I32));
|
|
|
|
env_namepace.insert("tableBase", (0, I32));
|
|
|
|
global_namepace.insert("Infinity", (std::f64::INFINITY.to_bits() as _, F64));
|
|
|
|
global_namepace.insert("NaN", (std::f64::NAN.to_bits() as _, F64));
|
|
|
|
|
|
|
|
data.insert("env", env_namepace);
|
|
|
|
data.insert("global", global_namepace);
|
|
|
|
|
2019-01-23 20:25:56 +00:00
|
|
|
Self { data, memory, vm_memory }
|
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 {
|
2019-01-21 22:43:04 +00:00
|
|
|
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.
|
|
|
|
let env_globals = globals.data.get("env").unwrap();
|
|
|
|
let global_globals = globals.data.get("global").unwrap();
|
|
|
|
|
2019-01-23 20:25:56 +00:00
|
|
|
// Memory
|
|
|
|
|
|
|
|
let local_memory = unsafe {
|
|
|
|
MemoryPointer::new(&mut globals.vm_memory)
|
|
|
|
};
|
|
|
|
|
|
|
|
env_namespace.insert(
|
|
|
|
"memory".to_string(),
|
|
|
|
Export::Memory {
|
|
|
|
local: local_memory,
|
|
|
|
// We generate a fake Context that traps on access
|
|
|
|
ctx: Context::External(ptr::null_mut()),
|
|
|
|
memory: Memory {
|
|
|
|
min: 256,
|
|
|
|
max: Some(256),
|
|
|
|
shared: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2019-01-17 22:10:29 +00:00
|
|
|
let (value, ty) = env_globals.get("STACKTOP").unwrap();
|
|
|
|
env_namespace.insert(
|
|
|
|
"STACKTOP".to_string(),
|
|
|
|
Export::Global {
|
|
|
|
local: global!(value),
|
|
|
|
global: GlobalDesc {
|
|
|
|
mutable: false,
|
|
|
|
ty: ty.clone(),
|
2019-01-18 05:55:44 +00:00
|
|
|
},
|
2019-01-17 22:10:29 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
let (value, ty) = env_globals.get("STACK_MAX").unwrap();
|
|
|
|
env_namespace.insert(
|
|
|
|
"STACK_MAX".to_string(),
|
|
|
|
Export::Global {
|
|
|
|
local: global!(value),
|
|
|
|
global: GlobalDesc {
|
|
|
|
mutable: false,
|
|
|
|
ty: ty.clone(),
|
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
|
|
|
let (value, ty) = env_globals.get("DYNAMICTOP_PTR").unwrap();
|
|
|
|
env_namespace.insert(
|
|
|
|
"DYNAMICTOP_PTR".to_string(),
|
|
|
|
Export::Global {
|
|
|
|
local: global!(value),
|
|
|
|
global: GlobalDesc {
|
|
|
|
mutable: false,
|
|
|
|
ty: ty.clone(),
|
2019-01-18 05:55:44 +00:00
|
|
|
},
|
2019-01-17 22:10:29 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
let (value, ty) = env_globals.get("tableBase").unwrap();
|
|
|
|
env_namespace.insert(
|
|
|
|
"tableBase".to_string(),
|
|
|
|
Export::Global {
|
|
|
|
local: global!(value),
|
|
|
|
global: GlobalDesc {
|
|
|
|
mutable: false,
|
|
|
|
ty: ty.clone(),
|
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
|
|
|
let (value, ty) = global_globals.get("Infinity").unwrap();
|
|
|
|
global_namespace.insert(
|
|
|
|
"Infinity".to_string(),
|
|
|
|
Export::Global {
|
|
|
|
local: global!(value),
|
|
|
|
global: GlobalDesc {
|
|
|
|
mutable: false,
|
|
|
|
ty: ty.clone(),
|
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
|
|
|
let (value, ty) = global_globals.get("NaN").unwrap();
|
|
|
|
global_namespace.insert(
|
|
|
|
"NaN".to_string(),
|
|
|
|
Export::Global {
|
|
|
|
local: global!(value),
|
|
|
|
global: GlobalDesc {
|
|
|
|
mutable: false,
|
|
|
|
ty: ty.clone(),
|
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],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
2018-12-31 20:55:14 +00:00
|
|
|
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
},
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
params: vec![],
|
2019-01-11 16:10:21 +00:00
|
|
|
returns: vec![I32],
|
2018-12-31 20:55:14 +00:00
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
params: vec![],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
params: vec![],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
params: vec![],
|
2019-01-11 16:10:21 +00:00
|
|
|
returns: vec![I32],
|
2018-12-31 20:55:14 +00:00
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
params: vec![],
|
2019-01-23 18:54:03 +00:00
|
|
|
returns: vec![I32],
|
2018-12-31 20:55:14 +00:00
|
|
|
},
|
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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
params: vec![],
|
2019-01-23 18:54:03 +00:00
|
|
|
returns: vec![I32],
|
2018-12-31 20:55:14 +00:00
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
params: vec![],
|
2019-01-11 16:10:21 +00:00
|
|
|
returns: vec![I32],
|
2018-12-31 20:55:14 +00:00
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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],
|
2018-12-31 20:55:14 +00:00
|
|
|
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-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",
|
|
|
|
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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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 {
|
2018-12-31 20:55:14 +00:00
|
|
|
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],
|
|
|
|
},
|
|
|
|
},
|
2018-12-31 20:55:14 +00:00
|
|
|
);
|
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],
|
2018-12-31 20:55:14 +00:00
|
|
|
returns: vec![],
|
|
|
|
},
|
2019-01-11 16:10:21 +00:00
|
|
|
},
|
2018-12-31 20:55:14 +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
|
|
|
|
2019-01-11 19:47:41 +00:00
|
|
|
imports
|
2018-11-14 03:19:23 +00:00
|
|
|
}
|
2019-01-22 23:26:56 +00:00
|
|
|
|
|
|
|
/// The current version of this crate
|
|
|
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|