Fix formatting

This commit is contained in:
Syrus
2018-12-18 09:43:59 -08:00
parent 2d5a1fd170
commit 903e3223dd
6 changed files with 36 additions and 34 deletions

View File

@ -1,6 +1,6 @@
use super::super::host; use super::super::host;
/// NOTE: These syscalls only support wasm_32 for now because they take u32 offset /// NOTE: These syscalls only support wasm_32 for now because they take u32 offset
use libc::{c_int, c_long, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, sysconf, getenv}; use libc::{c_int, c_long, getenv, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, sysconf};
use std::ffi::CStr; use std::ffi::CStr;
use std::mem; use std::mem;
use std::os::raw::c_char; use std::os::raw::c_char;
@ -18,7 +18,9 @@ pub extern "C" fn _getenv(name: c_int, instance: &mut Instance) -> u32 {
debug!("=> name({:?})", unsafe { CStr::from_ptr(name_addr) }); debug!("=> name({:?})", unsafe { CStr::from_ptr(name_addr) });
let c_str = unsafe { getenv(name_addr) }; let c_str = unsafe { getenv(name_addr) };
if c_str.is_null() { return 0; } if c_str.is_null() {
return 0;
}
unsafe { copy_cstr_into_wasm(instance, c_str) } unsafe { copy_cstr_into_wasm(instance, c_str) }
} }

View File

@ -1,5 +1,5 @@
use crate::webassembly::Instance;
use super::process::_abort; use super::process::_abort;
use crate::webassembly::Instance;
/// emscripten: ___cxa_allocate_exception /// emscripten: ___cxa_allocate_exception
pub extern "C" fn ___cxa_allocate_exception(size: u32, instance: &mut Instance) -> u32 { pub extern "C" fn ___cxa_allocate_exception(size: u32, instance: &mut Instance) -> u32 {

View File

@ -1,6 +1,6 @@
use super::process::abort_with_message; use super::process::abort_with_message;
use crate::webassembly::Instance; use crate::webassembly::Instance;
use libc::{c_void, memcpy, size_t, c_int}; use libc::{c_int, c_void, memcpy, size_t};
/// emscripten: _emscripten_memcpy_big /// emscripten: _emscripten_memcpy_big
pub extern "C" fn _emscripten_memcpy_big( pub extern "C" fn _emscripten_memcpy_big(
@ -46,4 +46,3 @@ pub extern "C" fn ___map_file() -> c_int {
// NOTE: TODO: Em returns -1 here as well. May need to implement properly // NOTE: TODO: Em returns -1 here as well. May need to implement properly
-1 -1
} }

View File

@ -6,11 +6,11 @@ use std::mem;
// EMSCRIPTEN APIS // EMSCRIPTEN APIS
mod env; mod env;
mod errno; mod errno;
mod exception;
mod io; mod io;
mod lock; mod lock;
mod memory;
mod math; mod math;
mod exception; mod memory;
mod nullfunc; mod nullfunc;
mod process; mod process;
mod signal; mod signal;
@ -440,16 +440,8 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
"___clock_gettime", "___clock_gettime",
ImportValue::Func(time::___clock_gettime as _), ImportValue::Func(time::___clock_gettime as _),
); );
import_object.set( import_object.set("env", "_clock", ImportValue::Func(time::_clock as _));
"env", import_object.set("env", "_difftime", ImportValue::Func(time::_difftime as _));
"_clock",
ImportValue::Func(time::_clock as _),
);
import_object.set(
"env",
"_difftime",
ImportValue::Func(time::_difftime as _),
);
import_object.set("env", "_asctime", ImportValue::Func(time::_asctime as _)); import_object.set("env", "_asctime", ImportValue::Func(time::_asctime as _));
import_object.set( import_object.set(
"env", "env",
@ -475,11 +467,18 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
); );
import_object.set("env", "_sysconf", ImportValue::Func(env::_sysconf as _)); import_object.set("env", "_sysconf", ImportValue::Func(env::_sysconf as _));
// Math // Math
import_object.set("env", "_llvm_log10_f64", ImportValue::Func(math::_llvm_log10_f64 as _)); import_object.set(
import_object.set("env", "_llvm_log2_f64", ImportValue::Func(math::_llvm_log2_f64 as _)); "env",
"_llvm_log10_f64",
ImportValue::Func(math::_llvm_log10_f64 as _),
);
import_object.set(
"env",
"_llvm_log2_f64",
ImportValue::Func(math::_llvm_log2_f64 as _),
);
import_object.set("asm2wasm", "f64-rem", ImportValue::Func(math::f64_rem as _)); import_object.set("asm2wasm", "f64-rem", ImportValue::Func(math::f64_rem as _));
mock_external!(import_object, _waitpid); mock_external!(import_object, _waitpid);
mock_external!(import_object, _utimes); mock_external!(import_object, _utimes);
mock_external!(import_object, _usleep); mock_external!(import_object, _usleep);

View File

@ -63,5 +63,7 @@ pub extern "C" fn _popen() -> c_int {
debug!("emscripten::_popen"); debug!("emscripten::_popen");
// TODO: May need to change this Em impl to a working version // TODO: May need to change this Em impl to a working version
eprintln!("Missing function: popen"); eprintln!("Missing function: popen");
unsafe { abort(); } unsafe {
abort();
}
} }

View File

@ -18,6 +18,7 @@ use libc::{
connect, connect,
dup2, dup2,
exit, exit,
fcntl,
fstat, fstat,
getgid, getgid,
getpeername, getpeername,
@ -42,6 +43,9 @@ use libc::{
// readv, // readv,
recvfrom, recvfrom,
recvmsg, recvmsg,
rmdir,
// ENOTTY,
rusage,
sa_family_t, sa_family_t,
// writev, // writev,
select, select,
@ -57,18 +61,14 @@ use libc::{
uname, uname,
utsname, utsname,
write, write,
EINVAL,
// sockaddr_in, // sockaddr_in,
FIOCLEX, FIOCLEX,
FIONBIO, FIONBIO,
F_GETFD,
F_SETFD,
SOL_SOCKET, SOL_SOCKET,
TIOCGWINSZ, TIOCGWINSZ,
// ENOTTY,
rusage,
rmdir,
EINVAL,
fcntl,
F_SETFD,
F_GETFD,
}; };
use std::mem; use std::mem;
@ -78,7 +78,7 @@ use std::slice;
// Linking to functions that are not provided by rust libc // Linking to functions that are not provided by rust libc
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
#[link(name = "c")] #[link(name = "c")]
extern { extern "C" {
pub fn wait4(pid: pid_t, status: *mut c_int, options: c_int, rusage: *mut rusage) -> pid_t; pub fn wait4(pid: pid_t, status: *mut c_int, options: c_int, rusage: *mut rusage) -> pid_t;
} }
@ -266,9 +266,7 @@ pub extern "C" fn ___syscall57(
debug!("emscripten::___syscall57 (setpgid) {}", which); debug!("emscripten::___syscall57 (setpgid) {}", which);
let pid: i32 = varargs.get(instance); let pid: i32 = varargs.get(instance);
let pgid: i32 = varargs.get(instance); let pgid: i32 = varargs.get(instance);
unsafe { unsafe { setpgid(pid, pgid) }
setpgid(pid, pgid)
}
} }
// dup2 // dup2
@ -938,7 +936,9 @@ pub extern "C" fn ___syscall330(
old_flags &= !flags; old_flags &= !flags;
} }
unsafe { fcntl (newfd, F_SETFD, old_flags); } unsafe {
fcntl(newfd, F_SETFD, old_flags);
}
debug!( debug!(
"=> oldfd: {}, newfd: {}, flags: {} = pid: {}", "=> oldfd: {}, newfd: {}, flags: {} = pid: {}",