optimize imports (#170)

This commit is contained in:
Mackenzie Clark 2019-02-09 13:31:28 -08:00 committed by GitHub
parent e7c3b99ba9
commit 4ef7dc339c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 56 deletions

View File

@ -1,15 +1,14 @@
/// NOTE: These syscalls only support wasm_32 for now because they take u32 offset
use libc::{
c_int, c_long, getenv, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, putenv, setenv,
sysconf, unsetenv,
c_int, getenv, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, putenv, setenv, sysconf,
unsetenv,
};
use std::ffi::CStr;
use std::mem;
use std::os::raw::c_char;
use crate::env::call_malloc;
use crate::utils::{allocate_on_stack, copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
use crate::EmscriptenData;
use crate::utils::{copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
use wasmer_runtime_core::vm::Ctx;
// #[no_mangle]

View File

@ -1,29 +1,20 @@
#[macro_use]
extern crate wasmer_runtime_core;
use byteorder::{ByteOrder, LittleEndian};
use libc::c_int;
use std::cell::UnsafeCell;
use std::{f64, ffi::c_void, fmt, mem, ptr};
use std::{f64, ffi::c_void};
use wasmer_runtime_core::{
error::CallResult,
export::{Context, Export, FuncPointer},
export::Export,
func,
global::Global,
import::{ImportObject, Namespace},
import::ImportObject,
imports,
memory::Memory,
table::Table,
types::{
ElementType, FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor,
Type::{self, *},
Value,
},
types::{ElementType, MemoryDescriptor, TableDescriptor, Value},
units::Pages,
vm::Ctx,
vm::LocalGlobal,
vm::LocalMemory,
vm::LocalTable,
Func, Instance, Module,
};

View File

@ -12,7 +12,7 @@ pub struct StdioCapturer {
}
#[cfg(not(target_os = "windows"))]
use libc::{STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO};
use libc::{STDERR_FILENO, STDOUT_FILENO};
#[cfg(target_os = "windows")]
const STDIN_FILENO: libc::c_int = 0;

View File

@ -16,48 +16,30 @@ use byteorder::{ByteOrder, LittleEndian};
/// NOTE: TODO: These syscalls only support wasm_32 for now because they assume offsets are u32
/// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html
use libc::{
accept,
bind,
// ENOTTY,
c_char,
c_int,
c_void,
chdir,
// fcntl, setsockopt, getppid
close,
connect,
dup2,
exit,
fstat,
getpeername,
getpid,
getsockname,
getsockopt,
// iovec,
listen,
lseek,
mkdir,
off_t,
open,
read,
// readv,
recvfrom,
rmdir,
// writev,
sendto,
setsockopt,
sockaddr,
socket,
ssize_t,
stat,
write,
EINVAL,
// sockaddr_in,
};
use wasmer_runtime_core::vm::Ctx;
use super::env;
use std::mem;
use std::slice;
// use std::sys::fd::FileDesc;

View File

@ -1,5 +1,4 @@
use crate::varargs::VarArgs;
use byteorder::{ByteOrder, LittleEndian};
/// NOTE: TODO: These syscalls only support wasm_32 for now because they assume offsets are u32
/// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html
use libc::{
@ -9,39 +8,28 @@ use libc::{
c_char,
c_int,
c_void,
chdir,
chown,
// fcntl, setsockopt, getppid
close,
connect,
dup2,
exit,
fcntl,
fstat,
getgid,
getpeername,
getpid,
getsockname,
getsockopt,
gid_t,
in_addr_t,
in_port_t,
ioctl,
// iovec,
listen,
lseek,
mkdir,
msghdr,
off_t,
open,
pid_t,
pread,
pwrite,
read,
// readv,
recvfrom,
recvmsg,
rmdir,
// ENOTTY,
rusage,
sa_family_t,
@ -54,11 +42,8 @@ use libc::{
sockaddr,
socket,
socklen_t,
ssize_t,
stat,
uname,
utsname,
write,
EINVAL,
// sockaddr_in,
FIOCLEX,
@ -71,9 +56,7 @@ use libc::{
};
use wasmer_runtime_core::vm::Ctx;
use super::env;
use std::mem;
use std::slice;
// Linking to functions that are not provided by rust libc
#[cfg(target_os = "macos")]

View File

@ -1,11 +1,14 @@
use super::utils::{copy_cstr_into_wasm, write_to_buf};
use libc::{c_char, c_int, time_t};
use libc::{c_char, c_int};
use std::mem;
use std::time::SystemTime;
#[cfg(not(target_os = "windows"))]
use libc::{clockid_t, time as libc_time};
#[cfg(target_os = "windows")]
use libc::time_t;
#[cfg(target_os = "windows")]
type clockid_t = c_int;

View File

@ -2,10 +2,8 @@ use super::env;
use super::env::get_emscripten_data;
use libc::stat;
use std::ffi::CStr;
use std::ffi::CString;
use std::mem::size_of;
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::slice;
use wasmer_runtime_core::memory::Memory;
use wasmer_runtime_core::{