mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 14:25:32 +00:00
optimize imports (#170)
This commit is contained in:
parent
e7c3b99ba9
commit
4ef7dc339c
7
lib/emscripten/src/env/unix/mod.rs
vendored
7
lib/emscripten/src/env/unix/mod.rs
vendored
@ -1,15 +1,14 @@
|
|||||||
/// 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::{
|
use libc::{
|
||||||
c_int, c_long, getenv, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, putenv, setenv,
|
c_int, getenv, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, putenv, setenv, sysconf,
|
||||||
sysconf, unsetenv,
|
unsetenv,
|
||||||
};
|
};
|
||||||
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;
|
||||||
|
|
||||||
use crate::env::call_malloc;
|
use crate::env::call_malloc;
|
||||||
use crate::utils::{allocate_on_stack, copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
use crate::utils::{copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
||||||
use crate::EmscriptenData;
|
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
// #[no_mangle]
|
// #[no_mangle]
|
||||||
|
@ -1,29 +1,20 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate wasmer_runtime_core;
|
extern crate wasmer_runtime_core;
|
||||||
|
|
||||||
use byteorder::{ByteOrder, LittleEndian};
|
|
||||||
use libc::c_int;
|
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::{f64, ffi::c_void, fmt, mem, ptr};
|
use std::{f64, ffi::c_void};
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
error::CallResult,
|
error::CallResult,
|
||||||
export::{Context, Export, FuncPointer},
|
export::Export,
|
||||||
func,
|
func,
|
||||||
global::Global,
|
global::Global,
|
||||||
import::{ImportObject, Namespace},
|
import::ImportObject,
|
||||||
imports,
|
imports,
|
||||||
memory::Memory,
|
memory::Memory,
|
||||||
table::Table,
|
table::Table,
|
||||||
types::{
|
types::{ElementType, MemoryDescriptor, TableDescriptor, Value},
|
||||||
ElementType, FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor,
|
|
||||||
Type::{self, *},
|
|
||||||
Value,
|
|
||||||
},
|
|
||||||
units::Pages,
|
units::Pages,
|
||||||
vm::Ctx,
|
vm::Ctx,
|
||||||
vm::LocalGlobal,
|
|
||||||
vm::LocalMemory,
|
|
||||||
vm::LocalTable,
|
|
||||||
Func, Instance, Module,
|
Func, Instance, Module,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ pub struct StdioCapturer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
use libc::{STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO};
|
use libc::{STDERR_FILENO, STDOUT_FILENO};
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const STDIN_FILENO: libc::c_int = 0;
|
const STDIN_FILENO: libc::c_int = 0;
|
||||||
|
@ -16,48 +16,30 @@ use byteorder::{ByteOrder, LittleEndian};
|
|||||||
/// NOTE: TODO: These syscalls only support wasm_32 for now because they assume offsets are u32
|
/// 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
|
/// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html
|
||||||
use libc::{
|
use libc::{
|
||||||
accept,
|
|
||||||
bind,
|
|
||||||
// ENOTTY,
|
// ENOTTY,
|
||||||
c_char,
|
|
||||||
c_int,
|
c_int,
|
||||||
c_void,
|
c_void,
|
||||||
chdir,
|
chdir,
|
||||||
// fcntl, setsockopt, getppid
|
// fcntl, setsockopt, getppid
|
||||||
close,
|
close,
|
||||||
connect,
|
|
||||||
dup2,
|
dup2,
|
||||||
exit,
|
exit,
|
||||||
fstat,
|
fstat,
|
||||||
getpeername,
|
|
||||||
getpid,
|
getpid,
|
||||||
getsockname,
|
|
||||||
getsockopt,
|
|
||||||
// iovec,
|
// iovec,
|
||||||
listen,
|
|
||||||
lseek,
|
lseek,
|
||||||
mkdir,
|
|
||||||
off_t,
|
|
||||||
open,
|
open,
|
||||||
read,
|
read,
|
||||||
// readv,
|
// readv,
|
||||||
recvfrom,
|
|
||||||
rmdir,
|
rmdir,
|
||||||
// writev,
|
// writev,
|
||||||
sendto,
|
|
||||||
setsockopt,
|
|
||||||
sockaddr,
|
|
||||||
socket,
|
|
||||||
ssize_t,
|
|
||||||
stat,
|
stat,
|
||||||
write,
|
write,
|
||||||
EINVAL,
|
|
||||||
// sockaddr_in,
|
// sockaddr_in,
|
||||||
};
|
};
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
use super::env;
|
use super::env;
|
||||||
use std::mem;
|
|
||||||
use std::slice;
|
use std::slice;
|
||||||
// use std::sys::fd::FileDesc;
|
// use std::sys::fd::FileDesc;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use crate::varargs::VarArgs;
|
use crate::varargs::VarArgs;
|
||||||
use byteorder::{ByteOrder, LittleEndian};
|
|
||||||
/// NOTE: TODO: These syscalls only support wasm_32 for now because they assume offsets are u32
|
/// 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
|
/// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html
|
||||||
use libc::{
|
use libc::{
|
||||||
@ -9,39 +8,28 @@ use libc::{
|
|||||||
c_char,
|
c_char,
|
||||||
c_int,
|
c_int,
|
||||||
c_void,
|
c_void,
|
||||||
chdir,
|
|
||||||
chown,
|
chown,
|
||||||
// fcntl, setsockopt, getppid
|
// fcntl, setsockopt, getppid
|
||||||
close,
|
|
||||||
connect,
|
connect,
|
||||||
dup2,
|
dup2,
|
||||||
exit,
|
|
||||||
fcntl,
|
fcntl,
|
||||||
fstat,
|
|
||||||
getgid,
|
getgid,
|
||||||
getpeername,
|
getpeername,
|
||||||
getpid,
|
|
||||||
getsockname,
|
getsockname,
|
||||||
getsockopt,
|
getsockopt,
|
||||||
gid_t,
|
|
||||||
in_addr_t,
|
in_addr_t,
|
||||||
in_port_t,
|
in_port_t,
|
||||||
ioctl,
|
ioctl,
|
||||||
// iovec,
|
// iovec,
|
||||||
listen,
|
listen,
|
||||||
lseek,
|
|
||||||
mkdir,
|
mkdir,
|
||||||
msghdr,
|
msghdr,
|
||||||
off_t,
|
|
||||||
open,
|
|
||||||
pid_t,
|
pid_t,
|
||||||
pread,
|
pread,
|
||||||
pwrite,
|
pwrite,
|
||||||
read,
|
|
||||||
// readv,
|
// readv,
|
||||||
recvfrom,
|
recvfrom,
|
||||||
recvmsg,
|
recvmsg,
|
||||||
rmdir,
|
|
||||||
// ENOTTY,
|
// ENOTTY,
|
||||||
rusage,
|
rusage,
|
||||||
sa_family_t,
|
sa_family_t,
|
||||||
@ -54,11 +42,8 @@ use libc::{
|
|||||||
sockaddr,
|
sockaddr,
|
||||||
socket,
|
socket,
|
||||||
socklen_t,
|
socklen_t,
|
||||||
ssize_t,
|
|
||||||
stat,
|
|
||||||
uname,
|
uname,
|
||||||
utsname,
|
utsname,
|
||||||
write,
|
|
||||||
EINVAL,
|
EINVAL,
|
||||||
// sockaddr_in,
|
// sockaddr_in,
|
||||||
FIOCLEX,
|
FIOCLEX,
|
||||||
@ -71,9 +56,7 @@ use libc::{
|
|||||||
};
|
};
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
use super::env;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
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")]
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
use super::utils::{copy_cstr_into_wasm, write_to_buf};
|
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::mem;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
use libc::{clockid_t, time as libc_time};
|
use libc::{clockid_t, time as libc_time};
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use libc::time_t;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
type clockid_t = c_int;
|
type clockid_t = c_int;
|
||||||
|
|
||||||
|
@ -2,10 +2,8 @@ use super::env;
|
|||||||
use super::env::get_emscripten_data;
|
use super::env::get_emscripten_data;
|
||||||
use libc::stat;
|
use libc::stat;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::ffi::CString;
|
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
use std::os::raw::c_char;
|
use std::os::raw::c_char;
|
||||||
use std::os::raw::c_int;
|
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use wasmer_runtime_core::memory::Memory;
|
use wasmer_runtime_core::memory::Memory;
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
|
Loading…
Reference in New Issue
Block a user