2019-01-10 21:37:59 -08:00
|
|
|
#[macro_use]
|
|
|
|
extern crate wasmer_runtime;
|
|
|
|
|
2019-01-09 00:49:11 -06:00
|
|
|
use wasmer_runtime::LinearMemory;
|
|
|
|
use wasmer_runtime::types::{FuncSig, Type, Value};
|
|
|
|
use wasmer_runtime::{Import, Imports, Instance, FuncRef};
|
2018-11-24 15:55:21 +01:00
|
|
|
/// NOTE: TODO: These emscripten api implementation only support wasm32 for now because they assume offsets are u32
|
2018-12-15 00:46:11 -06:00
|
|
|
use byteorder::{ByteOrder, LittleEndian};
|
2019-01-06 15:21:06 -06:00
|
|
|
use libc::c_int;
|
|
|
|
use std::cell::UnsafeCell;
|
2018-11-25 23:56:21 -05:00
|
|
|
use std::mem;
|
2018-11-13 19:19:23 -08:00
|
|
|
|
2018-11-20 20:11:58 +01:00
|
|
|
// EMSCRIPTEN APIS
|
2018-11-21 15:10:03 -08:00
|
|
|
mod env;
|
2018-11-26 20:29:26 -08:00
|
|
|
mod errno;
|
2018-12-18 09:43:59 -08:00
|
|
|
mod exception;
|
2018-11-21 20:59:23 -08:00
|
|
|
mod io;
|
2018-12-18 17:21:12 -08:00
|
|
|
mod jmp;
|
2018-11-26 20:29:26 -08:00
|
|
|
mod lock;
|
2018-12-13 19:28:30 +01:00
|
|
|
mod math;
|
2018-12-18 09:43:59 -08:00
|
|
|
mod memory;
|
2018-11-26 20:29:26 -08:00
|
|
|
mod nullfunc;
|
2018-11-20 20:11:58 +01:00
|
|
|
mod process;
|
2018-11-28 13:25:56 -08:00
|
|
|
mod signal;
|
2018-11-26 20:29:26 -08:00
|
|
|
mod storage;
|
2018-11-21 15:10:03 -08:00
|
|
|
mod syscalls;
|
2018-11-26 20:29:26 -08:00
|
|
|
mod time;
|
2018-11-21 20:59:23 -08:00
|
|
|
mod utils;
|
2018-11-23 00:13:01 -05:00
|
|
|
mod varargs;
|
2018-11-20 20:11:58 +01:00
|
|
|
|
2018-12-15 00:46:11 -06:00
|
|
|
pub use self::storage::align_memory;
|
|
|
|
pub use self::utils::{allocate_cstr_on_stack, allocate_on_stack, is_emscripten_module};
|
2018-11-13 19:19:23 -08:00
|
|
|
|
2018-11-25 23:56:21 -05:00
|
|
|
// TODO: Magic number - how is this calculated?
|
2018-12-08 00:19:55 -06:00
|
|
|
const TOTAL_STACK: u32 = 5_242_880;
|
2018-12-07 03:10:26 +01:00
|
|
|
// TODO: Magic number - how is this calculated?
|
2018-11-25 23:56:21 -05:00
|
|
|
const DYNAMICTOP_PTR_DIFF: u32 = 1088;
|
2018-12-07 03:10:26 +01:00
|
|
|
// TODO: make this variable
|
2018-12-08 00:19:55 -06:00
|
|
|
const STATIC_BUMP: u32 = 215_536;
|
2018-11-25 23:56:21 -05: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-06 15:21:06 -06: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]>>,
|
|
|
|
}
|
|
|
|
|
2018-11-25 23:56:21 -05:00
|
|
|
pub fn emscripten_set_up_memory(memory: &mut LinearMemory) {
|
|
|
|
let dynamictop_ptr = dynamictop_ptr(STATIC_BUMP) as usize;
|
2018-11-28 13:29:50 -08:00
|
|
|
let dynamictop_ptr_offset = dynamictop_ptr + mem::size_of::<u32>();
|
|
|
|
|
2018-12-07 03:10:26 +01:00
|
|
|
// println!("value = {:?}");
|
|
|
|
|
2018-11-28 13:29:50 -08: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 03:10:26 +01:00
|
|
|
return; // TODO: We should panic instead?
|
2018-11-28 13:25:08 -08:00
|
|
|
}
|
2018-12-07 03:10:26 +01:00
|
|
|
|
|
|
|
// debug!("###### dynamic_base = {:?}", dynamic_base(STATIC_BUMP));
|
|
|
|
// debug!("###### dynamictop_ptr = {:?}", dynamictop_ptr);
|
|
|
|
// debug!("###### dynamictop_ptr_offset = {:?}", dynamictop_ptr_offset);
|
|
|
|
|
2018-11-28 13:29:50 -08:00
|
|
|
let mem = &mut memory[dynamictop_ptr..dynamictop_ptr_offset];
|
2018-11-25 23:56:21 -05:00
|
|
|
LittleEndian::write_u32(mem, dynamic_base(STATIC_BUMP));
|
|
|
|
}
|
|
|
|
|
2018-11-26 11:15:29 -08:00
|
|
|
macro_rules! mock_external {
|
|
|
|
($import:ident, $name:ident) => {{
|
2019-01-09 00:49:11 -06:00
|
|
|
use wasmer_runtime::types::{FuncSig, Type};
|
|
|
|
use wasmer_runtime::Import;
|
2018-11-26 20:29:26 -08:00
|
|
|
extern "C" fn _mocked_fn() -> i32 {
|
2018-11-26 13:21:11 -08:00
|
|
|
debug!("emscripten::{} <mock>", stringify!($name));
|
2018-11-26 22:48:19 -05:00
|
|
|
-1
|
2018-11-26 11:15:29 -08:00
|
|
|
}
|
2018-12-30 11:23:16 +01:00
|
|
|
$import.add(
|
|
|
|
"env".to_string(),
|
|
|
|
stringify!($name).to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(_mocked_fn as _) },
|
2018-12-30 11:23:16 +01:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-11-26 11:15:29 -08:00
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2018-12-30 11:23:16 +01:00
|
|
|
pub fn generate_emscripten_env() -> Imports {
|
|
|
|
let mut import_object = Imports::new();
|
|
|
|
|
2018-12-31 14:55:14 -06:00
|
|
|
// import_object.add(
|
|
|
|
// "spectest".to_string(),
|
|
|
|
// "print_i32".to_string(),
|
|
|
|
// Import::Func(
|
|
|
|
// print_i32 as _,
|
|
|
|
// FuncSig {
|
|
|
|
// params: vec![Type::I32],
|
|
|
|
// returns: vec![],
|
|
|
|
// },
|
|
|
|
// ),
|
2018-12-30 11:23:16 +01:00
|
|
|
// );
|
2018-12-31 14:55:14 -06:00
|
|
|
//
|
|
|
|
// import_object.add(
|
|
|
|
// "spectest".to_string(),
|
|
|
|
// "global_i32".to_string(),
|
|
|
|
// Import::Global(Value::I64(GLOBAL_I32 as _)),
|
2018-12-30 11:23:16 +01:00
|
|
|
// );
|
2018-12-31 14:55:14 -06:00
|
|
|
|
|
|
|
// Globals
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"STACKTOP".to_string(),
|
|
|
|
Import::Global(Value::I64(stacktop(STATIC_BUMP) as _)),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"STACK_MAX".to_string(),
|
|
|
|
Import::Global(Value::I64(stack_max(STATIC_BUMP) as _)),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"DYNAMICTOP_PTR".to_string(),
|
|
|
|
Import::Global(Value::I64(dynamictop_ptr(STATIC_BUMP) as _)),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"global".to_string(),
|
|
|
|
"Infinity".to_string(),
|
|
|
|
Import::Global(Value::I64(std::f64::INFINITY.to_bits() as _)),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"global".to_string(),
|
|
|
|
"NaN".to_string(),
|
|
|
|
Import::Global(Value::I64(std::f64::NAN.to_bits() as _)),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"tableBase".to_string(),
|
|
|
|
Import::Global(Value::I64(0)),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Print functions
|
2018-12-31 14:55:14 -06:00
|
|
|
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"printf".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(io::printf as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"putchar".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(io::putchar as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Lock
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___lock".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(lock::___lock as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___unlock".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(lock::___unlock as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___wait".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(lock::___wait as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Env
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_getenv".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::_getenv as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_setenv".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::_setenv as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32, Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_putenv".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::_putenv as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_unsetenv".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::_unsetenv as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_getpwnam".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::_getpwnam as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_getgrnam".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::_getgrnam as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___buildEnvironment".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::___build_environment as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Errno
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___setErrNo".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(errno::___seterrno as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Syscalls
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall1".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall1 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall3".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall3 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall4".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall4 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall5".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall5 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall6".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall6 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall12".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall12 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall20".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall20 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall39".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall39 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall40".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall40 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall54".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall54 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall57".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall57 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall63".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall63 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall64".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall64 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall102".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall102 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall114".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall114 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall122".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall122 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall140".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall140 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall142".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall142 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall145".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall145 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall146".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall146 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall180".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall180 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall181".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall181 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall192".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall192 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall195".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall195 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall197".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall197 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall201".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall201 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall202".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall202 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall212".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall212 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall221".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall221 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall330".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall330 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___syscall340".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(syscalls::___syscall340 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Process
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"abort".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(process::em_abort as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_abort".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(process::_abort as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"abortStackOverflow".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(process::abort_stack_overflow as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_llvm_trap".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(process::_llvm_trap as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_fork".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(process::_fork as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_exit".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(process::_exit as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_system".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(process::_system as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_popen".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(process::_popen as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Signal
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_sigemptyset".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(signal::_sigemptyset as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_sigaddset".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(signal::_sigaddset as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_sigprocmask".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(signal::_sigprocmask as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_sigaction".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(signal::_sigaction as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_signal".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(signal::_signal as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Memory
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"abortOnCannotGrowMemory".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(memory::abort_on_cannot_grow_memory as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_emscripten_memcpy_big".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(memory::_emscripten_memcpy_big as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"enlargeMemory".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(memory::enlarge_memory as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"getTotalMemory".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(memory::get_total_memory as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___map_file".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(memory::___map_file as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Exception
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___cxa_allocate_exception".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(exception::___cxa_allocate_exception as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___cxa_allocate_exception".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(exception::___cxa_throw as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32, Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___cxa_throw".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(exception::___cxa_throw as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32, Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // NullFuncs
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_ii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_ii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_iii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_iii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_iiii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_iiii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_iiiii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_iiiii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_iiiiii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_iiiiii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_v".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_v as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_vi".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_vi as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_vii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_vii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_viii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_viii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_viiii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_viiii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_viiiii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_viiiii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"nullFunc_viiiiii".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(nullfunc::nullfunc_viiiiii as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Time
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_gettimeofday".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_gettimeofday as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_clock_gettime".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_clock_gettime as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"___clock_gettime".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::___clock_gettime as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_clock".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_clock as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_difftime".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_difftime as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_asctime".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_asctime as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_asctime_r".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_asctime_r as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_localtime".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_localtime as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_time".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_time as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_strftime".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_strftime as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32, Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_localtime_r".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(time::_localtime_r as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_getpagesize".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::_getpagesize as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_sysconf".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(env::_sysconf as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
// // Math
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_llvm_log10_f64".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(math::_llvm_log10_f64 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::F64],
|
|
|
|
returns: vec![Type::F64],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"_llvm_log2_f64".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new( math::_llvm_log2_f64 as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::F64],
|
|
|
|
returns: vec![Type::F64],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"asm2wasm".to_string(),
|
|
|
|
"f64-rem".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(math::f64_rem as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::F64, Type::F64],
|
|
|
|
returns: vec![Type::F64],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-30 11:23:16 +01:00
|
|
|
//
|
2018-12-31 14:55:14 -06:00
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"__setjmp".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(jmp::__setjmp as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32],
|
|
|
|
returns: vec![Type::I32],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
import_object.add(
|
|
|
|
"env".to_string(),
|
|
|
|
"__longjmp".to_string(),
|
|
|
|
Import::Func(
|
2019-01-09 00:49:11 -06:00
|
|
|
unsafe { FuncRef::new(jmp::__longjmp as _) },
|
2018-12-31 14:55:14 -06:00
|
|
|
FuncSig {
|
|
|
|
params: vec![Type::I32, Type::I32],
|
|
|
|
returns: vec![],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2018-12-18 17:21:12 -08:00
|
|
|
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, _waitpid);
|
|
|
|
mock_external!(import_object, _utimes);
|
|
|
|
mock_external!(import_object, _usleep);
|
2018-11-26 22:15:49 +01:00
|
|
|
// mock_external!(import_object, _time);
|
2018-12-05 15:14:58 -08:00
|
|
|
// mock_external!(import_object, _sysconf);
|
2018-11-26 14:16:51 -08:00
|
|
|
// mock_external!(import_object, _strftime);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, _sigsuspend);
|
2018-11-27 19:10:43 -05:00
|
|
|
// mock_external!(import_object, _sigprocmask);
|
|
|
|
// mock_external!(import_object, _sigemptyset);
|
|
|
|
// mock_external!(import_object, _sigaddset);
|
|
|
|
// mock_external!(import_object, _sigaction);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, _setitimer);
|
|
|
|
mock_external!(import_object, _setgroups);
|
|
|
|
mock_external!(import_object, _setgrent);
|
|
|
|
mock_external!(import_object, _sem_wait);
|
|
|
|
mock_external!(import_object, _sem_post);
|
|
|
|
mock_external!(import_object, _sem_init);
|
|
|
|
mock_external!(import_object, _sched_yield);
|
|
|
|
mock_external!(import_object, _raise);
|
|
|
|
mock_external!(import_object, _mktime);
|
2018-11-26 15:42:47 -05:00
|
|
|
// mock_external!(import_object, _localtime_r);
|
2018-11-26 13:51:24 -08:00
|
|
|
// mock_external!(import_object, _localtime);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, _llvm_stacksave);
|
|
|
|
mock_external!(import_object, _llvm_stackrestore);
|
|
|
|
mock_external!(import_object, _kill);
|
|
|
|
mock_external!(import_object, _gmtime_r);
|
2018-11-26 12:02:29 -08:00
|
|
|
// mock_external!(import_object, _gettimeofday);
|
2018-11-26 15:42:47 -05:00
|
|
|
// mock_external!(import_object, _getpagesize);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, _getgrent);
|
|
|
|
mock_external!(import_object, _getaddrinfo);
|
2018-12-01 16:14:16 -08:00
|
|
|
// mock_external!(import_object, _fork);
|
|
|
|
// mock_external!(import_object, _exit);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, _execve);
|
|
|
|
mock_external!(import_object, _endgrent);
|
2018-11-26 12:28:20 -08:00
|
|
|
// mock_external!(import_object, _clock_gettime);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall97);
|
|
|
|
mock_external!(import_object, ___syscall91);
|
|
|
|
mock_external!(import_object, ___syscall85);
|
|
|
|
mock_external!(import_object, ___syscall75);
|
|
|
|
mock_external!(import_object, ___syscall66);
|
2018-11-26 13:17:44 -08:00
|
|
|
// mock_external!(import_object, ___syscall64);
|
2018-11-27 19:10:43 -05:00
|
|
|
// mock_external!(import_object, ___syscall63);
|
2018-12-14 00:09:07 +01:00
|
|
|
// mock_external!(import_object, ___syscall60);
|
2018-11-26 22:48:19 -05:00
|
|
|
// mock_external!(import_object, ___syscall54);
|
|
|
|
// mock_external!(import_object, ___syscall39);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall38);
|
2018-11-26 22:48:19 -05:00
|
|
|
// mock_external!(import_object, ___syscall340);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall334);
|
|
|
|
mock_external!(import_object, ___syscall300);
|
|
|
|
mock_external!(import_object, ___syscall295);
|
|
|
|
mock_external!(import_object, ___syscall272);
|
|
|
|
mock_external!(import_object, ___syscall268);
|
2018-11-26 22:48:19 -05:00
|
|
|
// mock_external!(import_object, ___syscall221);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall220);
|
2018-11-26 22:48:19 -05:00
|
|
|
// mock_external!(import_object, ___syscall212);
|
2018-11-26 13:59:18 -08:00
|
|
|
// mock_external!(import_object, ___syscall201);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall199);
|
2018-11-26 22:48:19 -05:00
|
|
|
// mock_external!(import_object, ___syscall197);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall196);
|
2018-11-26 22:48:19 -05:00
|
|
|
// mock_external!(import_object, ___syscall195);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall194);
|
|
|
|
mock_external!(import_object, ___syscall191);
|
2018-11-27 19:10:43 -05:00
|
|
|
// mock_external!(import_object, ___syscall181);
|
2018-11-26 22:48:19 -05:00
|
|
|
// mock_external!(import_object, ___syscall180);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall168);
|
|
|
|
// mock_external!(import_object, ___syscall146);
|
|
|
|
// mock_external!(import_object, ___syscall145);
|
2018-11-29 15:48:47 -05:00
|
|
|
// mock_external!(import_object, ___syscall142);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall140);
|
2018-11-26 13:17:44 -08:00
|
|
|
// mock_external!(import_object, ___syscall122);
|
2018-11-26 22:48:19 -05:00
|
|
|
// mock_external!(import_object, ___syscall102);
|
2018-11-26 12:48:39 -08:00
|
|
|
// mock_external!(import_object, ___syscall20);
|
2018-11-26 11:15:29 -08:00
|
|
|
mock_external!(import_object, ___syscall15);
|
|
|
|
mock_external!(import_object, ___syscall10);
|
2018-12-14 00:09:07 +01:00
|
|
|
mock_external!(import_object, _dlopen);
|
|
|
|
mock_external!(import_object, _dlclose);
|
|
|
|
mock_external!(import_object, _dlsym);
|
|
|
|
mock_external!(import_object, _dlerror);
|
2018-11-26 01:17:33 -05:00
|
|
|
|
2018-11-13 19:19:23 -08:00
|
|
|
import_object
|
|
|
|
}
|