mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 06:31:32 +00:00
Fix lint errors and windows build
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
use std::mem;
|
|
||||||
use libc::{chroot as _chroot, printf as _printf, getpwuid as _getpwuid};
|
|
||||||
use super::super::utils::copy_cstr_into_wasm;
|
|
||||||
use super::super::env::call_malloc;
|
use super::super::env::call_malloc;
|
||||||
|
use super::super::utils::copy_cstr_into_wasm;
|
||||||
|
use libc::{chroot as _chroot, getpwuid as _getpwuid, printf as _printf};
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
|
@ -24,6 +24,14 @@ use wasmer_runtime_core::{
|
|||||||
Func, Instance, IsExport, Module,
|
Func, Instance, IsExport, Module,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
use ::libc::DIR as libcDIR;
|
||||||
|
|
||||||
|
// We use a placeholder for windows
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
type libcDIR = u8;
|
||||||
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
@ -76,8 +84,6 @@ lazy_static! {
|
|||||||
const GLOBAL_BASE: u32 = 1024;
|
const GLOBAL_BASE: u32 = 1024;
|
||||||
const STATIC_BASE: u32 = GLOBAL_BASE;
|
const STATIC_BASE: u32 = GLOBAL_BASE;
|
||||||
|
|
||||||
use ::libc::DIR as libcDIR;
|
|
||||||
|
|
||||||
pub struct EmscriptenData<'a> {
|
pub struct EmscriptenData<'a> {
|
||||||
pub malloc: Func<'a, u32, u32>,
|
pub malloc: Func<'a, u32, u32>,
|
||||||
pub free: Func<'a, u32>,
|
pub free: Func<'a, u32>,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate wasmer_runtime_core;
|
extern crate wasmer_runtime_core;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
@ -49,12 +50,14 @@ pub fn killpg(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
pub fn pathconf(ctx: &mut Ctx, path_ptr: i32, name: i32) -> i32 {
|
pub fn pathconf(ctx: &mut Ctx, path_ptr: i32, name: i32) -> i32 {
|
||||||
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8;
|
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8;
|
||||||
|
unsafe { libc::pathconf(path, name).try_into().unwrap() }
|
||||||
unsafe {
|
|
||||||
libc::pathconf(path, name).try_into().unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
pub fn pathconf(ctx: &mut Ctx, path_ptr: i32, name: i32) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setpwent(_ctx: &mut Ctx) {
|
pub fn setpwent(_ctx: &mut Ctx) {
|
||||||
|
@ -27,6 +27,8 @@ use libc::{
|
|||||||
exit,
|
exit,
|
||||||
fstat,
|
fstat,
|
||||||
getpid,
|
getpid,
|
||||||
|
getuid,
|
||||||
|
// readlink,
|
||||||
// iovec,
|
// iovec,
|
||||||
lseek,
|
lseek,
|
||||||
off_t,
|
off_t,
|
||||||
@ -39,8 +41,6 @@ use libc::{
|
|||||||
// writev,
|
// writev,
|
||||||
stat,
|
stat,
|
||||||
write,
|
write,
|
||||||
getuid,
|
|
||||||
// readlink,
|
|
||||||
};
|
};
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
memory::ptr::{Array, WasmPtr},
|
memory::ptr::{Array, WasmPtr},
|
||||||
|
@ -26,6 +26,7 @@ use libc::{
|
|||||||
getrusage,
|
getrusage,
|
||||||
getsockname,
|
getsockname,
|
||||||
getsockopt,
|
getsockopt,
|
||||||
|
getuid,
|
||||||
gid_t,
|
gid_t,
|
||||||
in_addr_t,
|
in_addr_t,
|
||||||
in_port_t,
|
in_port_t,
|
||||||
@ -74,6 +75,7 @@ use libc::{
|
|||||||
SO_REUSEADDR,
|
SO_REUSEADDR,
|
||||||
TIOCGWINSZ,
|
TIOCGWINSZ,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
@ -847,6 +849,14 @@ pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getuid
|
||||||
|
pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
|
debug!("emscripten::___syscall199 (getuid)");
|
||||||
|
let uid = unsafe { getuid() as _ };
|
||||||
|
debug!(" => {}", uid);
|
||||||
|
uid
|
||||||
|
}
|
||||||
|
|
||||||
// getdents
|
// getdents
|
||||||
// dirent structure is
|
// dirent structure is
|
||||||
// i64, i64, u16 (280), i8, [i8; 256]
|
// i64, i64, u16 (280), i8, [i8; 256]
|
||||||
@ -856,7 +866,10 @@ pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
|||||||
let fd: i32 = varargs.get(ctx);
|
let fd: i32 = varargs.get(ctx);
|
||||||
let dirp_addr: i32 = varargs.get(ctx);
|
let dirp_addr: i32 = varargs.get(ctx);
|
||||||
let count: u32 = varargs.get(ctx);
|
let count: u32 = varargs.get(ctx);
|
||||||
debug!("emscripten::___syscall220 (getdents) {} {} {}", fd, dirp_addr, count);
|
debug!(
|
||||||
|
"emscripten::___syscall220 (getdents) {} {} {}",
|
||||||
|
fd, dirp_addr, count
|
||||||
|
);
|
||||||
|
|
||||||
let dirp = emscripten_memory_pointer!(ctx.memory(0), dirp_addr) as *mut u8;
|
let dirp = emscripten_memory_pointer!(ctx.memory(0), dirp_addr) as *mut u8;
|
||||||
|
|
||||||
@ -864,7 +877,9 @@ pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
|||||||
|
|
||||||
// need to persist stream across calls?
|
// need to persist stream across calls?
|
||||||
// let dir: *mut libc::DIR = unsafe { libc::fdopendir(fd) };
|
// let dir: *mut libc::DIR = unsafe { libc::fdopendir(fd) };
|
||||||
let mut dir = &*opened_dirs.entry(fd).or_insert_with(|| unsafe { Box::new(libc::fdopendir(fd)) });
|
let mut dir = &*opened_dirs
|
||||||
|
.entry(fd)
|
||||||
|
.or_insert_with(|| unsafe { Box::new(libc::fdopendir(fd)) });
|
||||||
|
|
||||||
let mut pos = 0;
|
let mut pos = 0;
|
||||||
let offset = 256 + 12;
|
let offset = 256 + 12;
|
||||||
@ -887,7 +902,12 @@ pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
|||||||
}
|
}
|
||||||
// We set the termination string char
|
// We set the termination string char
|
||||||
*(dirp.add(pos + 11 + i) as *mut i8) = 0 as i8;
|
*(dirp.add(pos + 11 + i) as *mut i8) = 0 as i8;
|
||||||
debug!(" => file {}", CStr::from_ptr(dirp.add(pos + 11) as *const i8).to_str().unwrap());
|
debug!(
|
||||||
|
" => file {}",
|
||||||
|
CStr::from_ptr(dirp.add(pos + 11) as *const i8)
|
||||||
|
.to_str()
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
pos += offset;
|
pos += offset;
|
||||||
}
|
}
|
||||||
|
@ -261,6 +261,12 @@ pub fn ___syscall196(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
|||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getuid
|
||||||
|
pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
|
debug!("emscripten::___syscall199 (getuid)");
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
|
||||||
// getdents
|
// getdents
|
||||||
pub fn ___syscall220(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
pub fn ___syscall220(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
debug!("emscripten::___syscall220");
|
debug!("emscripten::___syscall220");
|
||||||
|
Reference in New Issue
Block a user