mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Merge branch 'feature/compile-and-run-nginx-wasm' of github.com:wasmerio/wasmer into feature/compile-and-run-nginx-wasm
This commit is contained in:
commit
0d6d91159e
@ -265,6 +265,11 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
"___syscall63",
|
||||
ImportValue::Func(syscalls::___syscall63 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall142",
|
||||
ImportValue::Func(syscalls::___syscall142 as _),
|
||||
);
|
||||
|
||||
// Process
|
||||
import_object.set("env", "abort", ImportValue::Func(process::em_abort as _));
|
||||
@ -458,7 +463,7 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
mock_external!(import_object, ___syscall168);
|
||||
// mock_external!(import_object, ___syscall146);
|
||||
// mock_external!(import_object, ___syscall145);
|
||||
mock_external!(import_object, ___syscall142);
|
||||
// mock_external!(import_object, ___syscall142);
|
||||
mock_external!(import_object, ___syscall140);
|
||||
// mock_external!(import_object, ___syscall122);
|
||||
// mock_external!(import_object, ___syscall102);
|
||||
|
@ -50,6 +50,7 @@ use libc::{
|
||||
utsname,
|
||||
write,
|
||||
writev,
|
||||
select,
|
||||
FIONBIO,
|
||||
};
|
||||
|
||||
@ -183,7 +184,9 @@ pub extern "C" fn ___syscall54(
|
||||
21537 => { // FIONBIO
|
||||
let argp: u32 = varargs.get(instance);
|
||||
let argp_ptr = instance.memory_offset_addr(0, argp as _);
|
||||
unsafe { ioctl(fd, FIONBIO, argp_ptr) }
|
||||
let ret = unsafe { ioctl(fd, FIONBIO, argp_ptr) };
|
||||
debug!("ret: {}", ret);
|
||||
ret
|
||||
},
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
@ -276,7 +279,11 @@ pub extern "C" fn ___syscall102(
|
||||
let address = instance.memory_offset_addr(0, address as usize) as *mut sockaddr;
|
||||
let address_len_addr =
|
||||
instance.memory_offset_addr(0, address_len as usize) as *mut socklen_t;
|
||||
unsafe { accept(socket, address, address_len_addr) }
|
||||
let fd = unsafe { accept(socket, address, address_len_addr) };
|
||||
debug!("fd: {}", fd);
|
||||
// nix::unistd::write(fd, "Hello, World!".as_bytes()).unwrap();
|
||||
// nix::unistd::fsync(fd).unwrap();
|
||||
fd
|
||||
}
|
||||
6 => {
|
||||
debug!("socket: getsockname");
|
||||
@ -676,3 +683,26 @@ pub extern "C" fn ___syscall63(
|
||||
|
||||
unsafe { dup2(src, dst) }
|
||||
}
|
||||
|
||||
// newselect
|
||||
pub extern "C" fn ___syscall142(
|
||||
_which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall142");
|
||||
|
||||
let nfds: i32 = varargs.get(instance);
|
||||
let readfds: u32 = varargs.get(instance);
|
||||
let writefds: u32 = varargs.get(instance);
|
||||
let exceptfds: u32 = varargs.get(instance);
|
||||
let _timeout: i32 = varargs.get(instance);
|
||||
|
||||
assert!(nfds <= 64, "`nfds` must be less than or equal to 64");
|
||||
assert!(exceptfds == 0, "`exceptfds` is not supporrted");
|
||||
|
||||
let readfds_ptr = instance.memory_offset_addr(0, readfds as _) as _;
|
||||
let writefds_ptr = instance.memory_offset_addr(0, writefds as _) as _;
|
||||
|
||||
unsafe { select(nfds, readfds_ptr, writefds_ptr, 0 as _, 0 as _) }
|
||||
}
|
@ -60,15 +60,18 @@ impl LinearMemory {
|
||||
unsafe {
|
||||
mprotect(
|
||||
base,
|
||||
(initial * Self::PAGE_SIZE) as _,
|
||||
// (initial * Self::PAGE_SIZE) as _,
|
||||
Self::DEFAULT_HEAP_SIZE,
|
||||
PROT_READ | PROT_WRITE,
|
||||
)
|
||||
},
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
debug!("LinearMemory instantiated");
|
||||
debug!(" - usable: {:#x}..{:#x}", base as usize, (base as usize) + LinearMemory::DEFAULT_HEAP_SIZE);
|
||||
debug!(" - guard: {:#x}..{:#x}", (base as usize) + LinearMemory::DEFAULT_HEAP_SIZE, (base as usize) + LinearMemory::DEFAULT_SIZE);
|
||||
Self {
|
||||
base,
|
||||
current: initial,
|
||||
|
Loading…
Reference in New Issue
Block a user