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;
/// 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::mem;
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) });
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) }
}

View File

@ -1,5 +1,5 @@
use crate::webassembly::Instance;
use super::process::_abort;
use crate::webassembly::Instance;
/// emscripten: ___cxa_allocate_exception
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 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
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
-1
}

View File

@ -6,11 +6,11 @@ use std::mem;
// EMSCRIPTEN APIS
mod env;
mod errno;
mod exception;
mod io;
mod lock;
mod memory;
mod math;
mod exception;
mod memory;
mod nullfunc;
mod process;
mod signal;
@ -440,16 +440,8 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
"___clock_gettime",
ImportValue::Func(time::___clock_gettime as _),
);
import_object.set(
"env",
"_clock",
ImportValue::Func(time::_clock as _),
);
import_object.set(
"env",
"_difftime",
ImportValue::Func(time::_difftime as _),
);
import_object.set("env", "_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",
@ -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 _));
// Math
import_object.set("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(
"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 _));
mock_external!(import_object, _waitpid);
mock_external!(import_object, _utimes);
mock_external!(import_object, _usleep);

View File

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

View File

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