diff --git a/Cargo.lock b/Cargo.lock index 5452e14a3..c18b4b273 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -178,25 +178,6 @@ dependencies = [ "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "errno" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "failure" version = "0.1.5" @@ -240,11 +221,6 @@ name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "generic-array" version = "0.12.0" @@ -834,11 +810,11 @@ dependencies = [ name = "wasmer-runtime-core" version = "0.1.2" dependencies = [ - "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "field-offset 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "page_size 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -924,15 +900,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cranelift-native 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "474bee81d620a473bf43411a3d6f10ffbf7965141dc5e5b76d8d2151dde3285d" "checksum cranelift-wasm 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49723365dab9a48b354bdc24cb6d9d5719bc1d3b858ffd2ea179d0d7d885804a" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" -"checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" -"checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum field-offset 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "64e9bc339e426139e02601fa69d101e96a92aee71b58bc01697ec2a63a5c9e68" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" diff --git a/lib/emscripten/src/env/windows/mod.rs b/lib/emscripten/src/env/windows/mod.rs index 0bffaf4a0..081c912c6 100644 --- a/lib/emscripten/src/env/windows/mod.rs +++ b/lib/emscripten/src/env/windows/mod.rs @@ -1,10 +1,5 @@ /// NOTE: These syscalls only support wasm_32 for now because they take u32 offset -use libc::{ - c_int, - c_long, - getenv, - //sysconf, unsetenv, -}; +use libc::{c_int, c_long, getenv}; use core::slice; use std::ffi::{CStr, CString}; @@ -100,24 +95,18 @@ pub fn _getpwnam(name_ptr: c_int, ctx: &mut Ctx) -> c_int { pw_shell: u32, } - let name = unsafe { - let memory_name_ptr = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const c_char; - CStr::from_ptr(memory_name_ptr) - }; - + // stub this in windows as it is not valid unsafe { - let passwd = &*libc_getpwnam(name.as_ptr()); let passwd_struct_offset = call_malloc(mem::size_of::() as _, ctx); - let passwd_struct_ptr = emscripten_memory_pointer!(ctx.memory(0), passwd_struct_offset) as *mut GuestPasswd; - (*passwd_struct_ptr).pw_name = copy_cstr_into_wasm(ctx, passwd.pw_name); - (*passwd_struct_ptr).pw_passwd = copy_cstr_into_wasm(ctx, passwd.pw_passwd); - (*passwd_struct_ptr).pw_gecos = copy_cstr_into_wasm(ctx, passwd.pw_gecos); - (*passwd_struct_ptr).pw_dir = copy_cstr_into_wasm(ctx, passwd.pw_dir); - (*passwd_struct_ptr).pw_shell = copy_cstr_into_wasm(ctx, passwd.pw_shell); - (*passwd_struct_ptr).pw_uid = passwd.pw_uid; - (*passwd_struct_ptr).pw_gid = passwd.pw_gid; + (*passwd_struct_ptr).pw_name = 0; + (*passwd_struct_ptr).pw_passwd = 0; + (*passwd_struct_ptr).pw_gecos = 0; + (*passwd_struct_ptr).pw_dir = 0; + (*passwd_struct_ptr).pw_shell = 0; + (*passwd_struct_ptr).pw_uid = 0; + (*passwd_struct_ptr).pw_gid = 0; passwd_struct_offset as c_int } @@ -135,22 +124,15 @@ pub fn _getgrnam(name_ptr: c_int, ctx: &mut Ctx) -> c_int { gr_mem: u32, } - let name = unsafe { - let memory_name_ptr = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const c_char; - CStr::from_ptr(memory_name_ptr) - }; - + // stub the group struct as it is not supported on windows unsafe { - let group = &*libc_getgrnam(name.as_ptr()); let group_struct_offset = call_malloc(mem::size_of::() as _, ctx); - let group_struct_ptr = emscripten_memory_pointer!(ctx.memory(0), group_struct_offset) as *mut GuestGroup; - (*group_struct_ptr).gr_name = copy_cstr_into_wasm(ctx, group.gr_name); - (*group_struct_ptr).gr_passwd = copy_cstr_into_wasm(ctx, group.gr_passwd); - (*group_struct_ptr).gr_gid = group.gr_gid; - (*group_struct_ptr).gr_mem = copy_terminated_array_of_cstrs(ctx, group.gr_mem); - + (*group_struct_ptr).gr_name = 0; + (*group_struct_ptr).gr_passwd = 0; + (*group_struct_ptr).gr_gid = 0; + (*group_struct_ptr).gr_mem = 0; group_struct_offset as c_int } } @@ -207,8 +189,8 @@ pub fn ___build_environment(environ: c_int, ctx: &mut Ctx) { pub fn _sysconf(name: c_int, _ctx: &mut Ctx) -> c_long { debug!("emscripten::_sysconf {}", name); - // TODO: Implement like emscripten expects regarding memory/page size - unsafe { sysconf(name) } + // stub because sysconf is not valid on windows + 0 } pub fn ___assert_fail(a: c_int, b: c_int, c: c_int, d: c_int, _ctx: &mut Ctx) { diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index f1fc1e537..9a748eb62 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -15,6 +15,8 @@ wasmparser = "0.23.0" parking_lot = "0.7.1" lazy_static = "1.2.0" indexmap = "1.0.2" +errno = "0.2.4" +libc = "0.2.48" # Dependencies for caching. [dependencies.serde] @@ -36,15 +38,9 @@ optional = true version = "0.8.0" optional = true -libc = "0.2.48" -errno = "0.2.4" - [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = ["memoryapi"] } -[target.'cfg(unix)'.dependencies] -errno = "0.2.4" - [dev-dependencies] wasmer-clif-backend = { path = "../clif-backend", version = "0.1.2" } field-offset = "0.1.1"