2018-11-24 14:55:21 +00:00
|
|
|
/// NOTE: TODO: These emscripten api implementation only support wasm32 for now because they assume offsets are u32
|
2018-11-26 04:56:21 +00:00
|
|
|
use crate::webassembly::{ImportObject, ImportValue, LinearMemory};
|
2018-12-15 06:46:11 +00:00
|
|
|
use byteorder::{ByteOrder, LittleEndian};
|
2018-11-26 04:56:21 +00:00
|
|
|
use std::mem;
|
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-11-22 04:59:23 +00:00
|
|
|
mod io;
|
2018-11-27 04:29:26 +00:00
|
|
|
mod lock;
|
2018-11-20 19:11:58 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
($import: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
|
|
|
}
|
2018-11-27 04:29:26 +00:00
|
|
|
$import.set("env", stringify!($name), ImportValue::Func(_mocked_fn as _));
|
2018-11-26 19:15:29 +00:00
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2018-11-14 03:19:23 +00:00
|
|
|
pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
|
|
|
let mut import_object = ImportObject::new();
|
2018-12-07 02:10:26 +00:00
|
|
|
// Globals
|
2018-11-26 04:56:21 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"STACKTOP",
|
|
|
|
ImportValue::Global(stacktop(STATIC_BUMP) as _),
|
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"STACK_MAX",
|
|
|
|
ImportValue::Global(stack_max(STATIC_BUMP) as _),
|
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"DYNAMICTOP_PTR",
|
|
|
|
ImportValue::Global(dynamictop_ptr(STATIC_BUMP) as _),
|
|
|
|
);
|
2018-12-16 19:50:54 +00:00
|
|
|
import_object.set(
|
|
|
|
"global",
|
|
|
|
"Infinity",
|
|
|
|
ImportValue::Global(std::f64::INFINITY.to_bits() as _),
|
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"global",
|
|
|
|
"NaN",
|
|
|
|
ImportValue::Global(std::f64::NAN.to_bits() as _),
|
|
|
|
);
|
2018-11-27 04:29:26 +00:00
|
|
|
import_object.set("env", "tableBase", ImportValue::Global(0));
|
2018-11-24 14:55:21 +00:00
|
|
|
// Print functions
|
2018-11-27 05:23:23 +00:00
|
|
|
import_object.set("env", "printf", ImportValue::Func(io::printf as _));
|
2018-11-28 21:25:56 +00:00
|
|
|
import_object.set("env", "putchar", ImportValue::Func(io::putchar as _));
|
2018-11-24 14:55:21 +00:00
|
|
|
// Lock
|
2018-11-28 21:25:56 +00:00
|
|
|
import_object.set("env", "___lock", ImportValue::Func(lock::___lock as _));
|
|
|
|
import_object.set("env", "___unlock", ImportValue::Func(lock::___unlock as _));
|
2018-11-24 14:55:21 +00:00
|
|
|
// Env
|
2018-11-28 21:25:56 +00:00
|
|
|
import_object.set("env", "_getenv", ImportValue::Func(env::_getenv as _));
|
2018-11-27 04:29:26 +00:00
|
|
|
import_object.set("env", "_getpwnam", ImportValue::Func(env::_getpwnam as _));
|
|
|
|
import_object.set("env", "_getgrnam", ImportValue::Func(env::_getgrnam as _));
|
2018-12-15 06:46:11 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___buildEnvironment",
|
|
|
|
ImportValue::Func(env::___build_environment as _),
|
|
|
|
);
|
2018-11-24 14:55:21 +00:00
|
|
|
// Errno
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___setErrNo",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(errno::___seterrno as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
// Syscalls
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall1",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall1 as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
2018-11-22 04:59:23 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall3",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall3 as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall4",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall4 as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall5",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall5 as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
2018-11-24 14:55:21 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall6",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall6 as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
2018-11-22 04:59:23 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall54",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall54 as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
2018-11-24 14:55:21 +00:00
|
|
|
"___syscall140",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall140 as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
2018-11-24 14:55:21 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall145",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall145 as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall146",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall146 as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall221",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall221 as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
2018-11-26 20:48:39 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall20",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall20 as _),
|
2018-11-26 20:48:39 +00:00
|
|
|
);
|
2018-11-26 21:17:44 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall64",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall64 as _),
|
2018-11-26 21:17:44 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall122",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall122 as _),
|
2018-11-26 21:17:44 +00:00
|
|
|
);
|
2018-11-26 21:59:18 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall201",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall201 as _),
|
2018-11-26 21:59:18 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall202",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall202 as _),
|
2018-11-26 21:59:18 +00:00
|
|
|
);
|
2018-11-27 03:48:19 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall340",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall340 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall197",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall197 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall180",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall180 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
2018-11-28 00:10:43 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall181",
|
|
|
|
ImportValue::Func(syscalls::___syscall181 as _),
|
|
|
|
);
|
2018-11-27 03:48:19 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall39",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall39 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall195",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall195 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall212",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall212 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall221",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall221 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall102",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall102 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall54",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(syscalls::___syscall54 as _),
|
2018-11-27 03:48:19 +00:00
|
|
|
);
|
2018-11-27 07:28:37 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall12",
|
|
|
|
ImportValue::Func(syscalls::___syscall12 as _),
|
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall192",
|
|
|
|
ImportValue::Func(syscalls::___syscall192 as _),
|
|
|
|
);
|
2018-11-28 00:10:43 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall63",
|
|
|
|
ImportValue::Func(syscalls::___syscall63 as _),
|
|
|
|
);
|
2018-11-29 20:48:47 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall142",
|
|
|
|
ImportValue::Func(syscalls::___syscall142 as _),
|
|
|
|
);
|
2018-12-01 19:33:17 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"___syscall57",
|
|
|
|
ImportValue::Func(syscalls::___syscall57 as _),
|
|
|
|
);
|
2018-11-27 03:48:19 +00:00
|
|
|
|
2018-11-24 14:55:21 +00:00
|
|
|
// Process
|
2018-11-28 21:25:56 +00:00
|
|
|
import_object.set("env", "abort", ImportValue::Func(process::em_abort as _));
|
|
|
|
import_object.set("env", "_abort", ImportValue::Func(process::_abort as _));
|
2018-11-24 14:55:21 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"abortStackOverflow",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(process::abort_stack_overflow as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
2018-12-02 00:14:16 +00:00
|
|
|
import_object.set("env", "_fork", ImportValue::Func(process::_fork as _));
|
|
|
|
import_object.set("env", "_exit", ImportValue::Func(process::_exit as _));
|
|
|
|
|
2018-11-28 00:47:46 +00:00
|
|
|
// Signal
|
2018-11-28 00:10:43 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"_sigemptyset",
|
2018-11-28 00:47:46 +00:00
|
|
|
ImportValue::Func(signal::_sigemptyset as _),
|
2018-11-28 00:10:43 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"_sigaddset",
|
2018-11-28 00:47:46 +00:00
|
|
|
ImportValue::Func(signal::_sigaddset as _),
|
2018-11-28 00:10:43 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"_sigprocmask",
|
2018-11-28 00:47:46 +00:00
|
|
|
ImportValue::Func(signal::_sigprocmask as _),
|
2018-11-28 00:10:43 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"_sigaction",
|
2018-11-28 00:47:46 +00:00
|
|
|
ImportValue::Func(signal::_sigaction as _),
|
2018-11-28 00:10:43 +00:00
|
|
|
);
|
2018-12-15 06:46:11 +00:00
|
|
|
import_object.set("env", "_signal", ImportValue::Func(signal::_signal as _));
|
2018-11-24 14:55:21 +00:00
|
|
|
// Memory
|
2018-11-22 04:59:23 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"abortOnCannotGrowMemory",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(memory::abort_on_cannot_grow_memory as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"_emscripten_memcpy_big",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(memory::_emscripten_memcpy_big as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"enlargeMemory",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(memory::enlarge_memory as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"getTotalMemory",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(memory::get_total_memory as _),
|
2018-11-22 04:59:23 +00:00
|
|
|
);
|
2018-11-24 14:55:21 +00:00
|
|
|
// NullFuncs
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"nullFunc_ii",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_ii as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
2018-11-24 17:31:38 +00:00
|
|
|
"nullFunc_iii",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_iii as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"nullFunc_iiii",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_iiii as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"nullFunc_iiiii",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_iiiii as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"nullFunc_iiiiii",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_iiiiii as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"nullFunc_vi",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_vi as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"nullFunc_vii",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_vii as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"nullFunc_viii",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_viii as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"nullFunc_viiii",
|
2018-11-27 05:23:23 +00:00
|
|
|
ImportValue::Func(nullfunc::nullfunc_viiii as _),
|
2018-11-24 14:55:21 +00:00
|
|
|
);
|
2018-11-26 21:15:49 +00:00
|
|
|
// Time
|
2018-11-26 06:17:33 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
2018-11-26 21:15:49 +00:00
|
|
|
"_gettimeofday",
|
|
|
|
ImportValue::Func(time::_gettimeofday as _),
|
2018-11-26 06:17:33 +00:00
|
|
|
);
|
2018-11-26 19:15:29 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
2018-11-26 21:15:49 +00:00
|
|
|
"_clock_gettime",
|
|
|
|
ImportValue::Func(time::_clock_gettime as _),
|
2018-11-26 19:15:29 +00:00
|
|
|
);
|
2018-12-15 06:46:11 +00:00
|
|
|
import_object.set("env", "_asctime", ImportValue::Func(time::_asctime as _));
|
2018-12-11 16:05:07 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"_asctime_r",
|
|
|
|
ImportValue::Func(time::_asctime_r as _),
|
|
|
|
);
|
2018-11-26 20:02:29 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
2018-11-26 21:15:49 +00:00
|
|
|
"_localtime",
|
|
|
|
ImportValue::Func(time::_localtime as _),
|
2018-11-26 20:02:29 +00:00
|
|
|
);
|
2018-11-27 04:29:26 +00:00
|
|
|
import_object.set("env", "_time", ImportValue::Func(time::_time as _));
|
|
|
|
import_object.set("env", "_strftime", ImportValue::Func(time::_strftime as _));
|
2018-11-26 20:42:47 +00:00
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"_localtime_r",
|
2018-12-07 13:50:35 +00:00
|
|
|
ImportValue::Func(time::_localtime_r as _),
|
2018-11-26 20:42:47 +00:00
|
|
|
);
|
|
|
|
import_object.set(
|
|
|
|
"env",
|
|
|
|
"_getpagesize",
|
|
|
|
ImportValue::Func(env::_getpagesize as _),
|
2018-11-26 20:28:20 +00:00
|
|
|
);
|
2018-12-15 06:46:11 +00:00
|
|
|
import_object.set("env", "_sysconf", ImportValue::Func(env::_sysconf as _));
|
2018-11-26 20:48:39 +00:00
|
|
|
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, _waitpid);
|
|
|
|
mock_external!(import_object, _utimes);
|
|
|
|
mock_external!(import_object, _usleep);
|
2018-11-26 21:15:49 +00:00
|
|
|
// mock_external!(import_object, _time);
|
2018-12-05 23:14:58 +00:00
|
|
|
// mock_external!(import_object, _sysconf);
|
2018-11-26 22:16:51 +00:00
|
|
|
// mock_external!(import_object, _strftime);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, _sigsuspend);
|
2018-11-28 00:10:43 +00:00
|
|
|
// mock_external!(import_object, _sigprocmask);
|
|
|
|
// mock_external!(import_object, _sigemptyset);
|
|
|
|
// mock_external!(import_object, _sigaddset);
|
|
|
|
// mock_external!(import_object, _sigaction);
|
2018-11-26 19:15:29 +00: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 20:42:47 +00:00
|
|
|
// mock_external!(import_object, _localtime_r);
|
2018-11-26 21:51:24 +00:00
|
|
|
// mock_external!(import_object, _localtime);
|
2018-11-26 19:15:29 +00: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 20:02:29 +00:00
|
|
|
// mock_external!(import_object, _gettimeofday);
|
2018-11-26 20:42:47 +00:00
|
|
|
// mock_external!(import_object, _getpagesize);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, _getgrent);
|
|
|
|
mock_external!(import_object, _getaddrinfo);
|
2018-12-02 00:14:16 +00:00
|
|
|
// mock_external!(import_object, _fork);
|
|
|
|
// mock_external!(import_object, _exit);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, _execve);
|
|
|
|
mock_external!(import_object, _endgrent);
|
2018-11-26 20:28:20 +00:00
|
|
|
// mock_external!(import_object, _clock_gettime);
|
2018-11-26 19:15:29 +00: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 21:17:44 +00:00
|
|
|
// mock_external!(import_object, ___syscall64);
|
2018-11-28 00:10:43 +00:00
|
|
|
// mock_external!(import_object, ___syscall63);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall60);
|
2018-11-27 03:48:19 +00:00
|
|
|
// mock_external!(import_object, ___syscall54);
|
|
|
|
// mock_external!(import_object, ___syscall39);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall38);
|
2018-11-27 03:48:19 +00:00
|
|
|
// mock_external!(import_object, ___syscall340);
|
2018-11-26 19:15:29 +00: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-27 03:48:19 +00:00
|
|
|
// mock_external!(import_object, ___syscall221);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall220);
|
2018-11-27 03:48:19 +00:00
|
|
|
// mock_external!(import_object, ___syscall212);
|
2018-11-26 21:59:18 +00:00
|
|
|
// mock_external!(import_object, ___syscall201);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall199);
|
2018-11-27 03:48:19 +00:00
|
|
|
// mock_external!(import_object, ___syscall197);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall196);
|
2018-11-27 03:48:19 +00:00
|
|
|
// mock_external!(import_object, ___syscall195);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall194);
|
|
|
|
mock_external!(import_object, ___syscall191);
|
2018-11-28 00:10:43 +00:00
|
|
|
// mock_external!(import_object, ___syscall181);
|
2018-11-27 03:48:19 +00:00
|
|
|
// mock_external!(import_object, ___syscall180);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall168);
|
|
|
|
// mock_external!(import_object, ___syscall146);
|
|
|
|
// mock_external!(import_object, ___syscall145);
|
2018-11-29 20:48:47 +00:00
|
|
|
// mock_external!(import_object, ___syscall142);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall140);
|
2018-11-26 21:17:44 +00:00
|
|
|
// mock_external!(import_object, ___syscall122);
|
2018-11-27 03:48:19 +00:00
|
|
|
// mock_external!(import_object, ___syscall102);
|
2018-11-26 20:48:39 +00:00
|
|
|
// mock_external!(import_object, ___syscall20);
|
2018-11-26 19:15:29 +00:00
|
|
|
mock_external!(import_object, ___syscall15);
|
|
|
|
mock_external!(import_object, ___syscall10);
|
2018-11-26 06:17:33 +00:00
|
|
|
|
2018-11-14 03:19:23 +00:00
|
|
|
import_object
|
|
|
|
}
|