mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-14 06:35:40 +00:00
Merge pull request #96 from wasmerio/fix/improve-emscripten-portability
Improve Emscripten Portability
This commit is contained in:
commit
00d5dd8c89
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
/artifacts
|
/artifacts
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
1
examples/nginx/.gitignore
vendored
1
examples/nginx/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
*_temp
|
*_temp
|
||||||
|
logs/error.log
|
@ -1 +1 @@
|
|||||||
96248
|
21011
|
||||||
|
@ -68,6 +68,7 @@ use libc::{
|
|||||||
F_GETFD,
|
F_GETFD,
|
||||||
F_SETFD,
|
F_SETFD,
|
||||||
SOL_SOCKET,
|
SOL_SOCKET,
|
||||||
|
SO_REUSEADDR,
|
||||||
TIOCGWINSZ,
|
TIOCGWINSZ,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -335,7 +336,7 @@ pub extern "C" fn ___syscall102(
|
|||||||
unsafe {
|
unsafe {
|
||||||
ioctl(fd, FIOCLEX);
|
ioctl(fd, FIOCLEX);
|
||||||
};
|
};
|
||||||
if cfg!(target_os = "darwin") {
|
|
||||||
type T = u32;
|
type T = u32;
|
||||||
let payload = 1 as *const T as *const c_void;
|
let payload = 1 as *const T as *const c_void;
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -347,7 +348,6 @@ pub extern "C" fn ___syscall102(
|
|||||||
mem::size_of::<T>() as socklen_t,
|
mem::size_of::<T>() as socklen_t,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"=> domain: {} (AF_INET/2), type: {} (SOCK_STREAM/1), protocol: {} = fd: {}",
|
"=> domain: {} (AF_INET/2), type: {} (SOCK_STREAM/1), protocol: {} = fd: {}",
|
||||||
@ -363,14 +363,6 @@ pub extern "C" fn ___syscall102(
|
|||||||
let address: u32 = socket_varargs.get(instance);
|
let address: u32 = socket_varargs.get(instance);
|
||||||
let address_len: u32 = socket_varargs.get(instance);
|
let address_len: u32 = socket_varargs.get(instance);
|
||||||
let address = instance.memory_offset_addr(0, address as usize) as *mut sockaddr;
|
let address = instance.memory_offset_addr(0, address as usize) as *mut sockaddr;
|
||||||
// unsafe {
|
|
||||||
// debug!(
|
|
||||||
// "=> address.sin_family: {:?}, address.sin_port: {:?}, address.sin_addr.s_addr: {:?}",
|
|
||||||
// (*address).sin_family, (*address).sin_port, (*address).sin_addr.s_addr
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// we convert address as a sockaddr (even if this is incorrect), to bypass the type
|
|
||||||
// issue with libc bind
|
|
||||||
|
|
||||||
// Debug received address
|
// Debug received address
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -436,25 +428,14 @@ pub extern "C" fn ___syscall102(
|
|||||||
(*address_linux).sa_family = (*address).sa_family as u16;
|
(*address_linux).sa_family = (*address).sa_family as u16;
|
||||||
(*address_linux).sa_data = (*address).sa_data;
|
(*address_linux).sa_data = (*address).sa_data;
|
||||||
};
|
};
|
||||||
// // Debug received address
|
|
||||||
// unsafe {
|
|
||||||
// let proper_address = address as *const GuestSockaddrIn;
|
|
||||||
// debug!(
|
|
||||||
// "=> address.sin_family: {:?}, address.sin_port: {:?}, address.sin_addr.s_addr: {:?}",
|
|
||||||
// (*proper_address).sin_family, (*proper_address).sin_port, (*proper_address).sin_addr.s_addr
|
|
||||||
// );
|
|
||||||
// debug!(
|
|
||||||
// "=> address.sa_family: {:?}",
|
|
||||||
// (*address).sa_family
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// set_cloexec
|
// set_cloexec
|
||||||
unsafe {
|
unsafe {
|
||||||
ioctl(fd, FIOCLEX);
|
ioctl(fd, FIOCLEX);
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("fd: {}", fd);
|
debug!("fd: {}", fd);
|
||||||
// nix::unistd::write(fd, "Hello, World!".as_bytes()).unwrap();
|
|
||||||
// nix::unistd::fsync(fd).unwrap();
|
|
||||||
fd
|
fd
|
||||||
}
|
}
|
||||||
6 => {
|
6 => {
|
||||||
@ -514,12 +495,13 @@ pub extern "C" fn ___syscall102(
|
|||||||
// name: Em passes SO_ACCEPTCONN, but Nginx complains about REUSEADDR
|
// name: Em passes SO_ACCEPTCONN, but Nginx complains about REUSEADDR
|
||||||
// https://github.com/openbsd/src/blob/master/sys/sys/socket.h#L156
|
// https://github.com/openbsd/src/blob/master/sys/sys/socket.h#L156
|
||||||
// setsockopt (socket: c_int, level: c_int, name: c_int, value: *const c_void, option_len: socklen_t) -> c_int
|
// setsockopt (socket: c_int, level: c_int, name: c_int, value: *const c_void, option_len: socklen_t) -> c_int
|
||||||
|
|
||||||
let socket: i32 = socket_varargs.get(instance);
|
let socket: i32 = socket_varargs.get(instance);
|
||||||
// SOL_SOCKET = 0xffff in BSD
|
// SOL_SOCKET = 0xffff (BSD, Linux)
|
||||||
let level: i32 = 0xffff;
|
let level: i32 = SOL_SOCKET;
|
||||||
let _: u32 = socket_varargs.get(instance);
|
let _: u32 = socket_varargs.get(instance);
|
||||||
// SO_ACCEPTCONN = 0x4
|
// SO_REUSEADDR = 0x4 (BSD, Linux)
|
||||||
let name: i32 = 0x4;
|
let name: i32 = SO_REUSEADDR;
|
||||||
let _: u32 = socket_varargs.get(instance);
|
let _: u32 = socket_varargs.get(instance);
|
||||||
let value: u32 = socket_varargs.get(instance);
|
let value: u32 = socket_varargs.get(instance);
|
||||||
let option_len: u32 = socket_varargs.get(instance);
|
let option_len: u32 = socket_varargs.get(instance);
|
||||||
|
Loading…
Reference in New Issue
Block a user