mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-03 08:21:04 +00:00
Merge branch 'command/pyodide' of github.com:wasmerio/wasmer into command/pyodide
This commit is contained in:
commit
f12d6f8dd2
@ -76,6 +76,8 @@ 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>,
|
||||||
@ -83,6 +85,7 @@ pub struct EmscriptenData<'a> {
|
|||||||
pub memset: Func<'a, (u32, u32, u32), u32>,
|
pub memset: Func<'a, (u32, u32, u32), u32>,
|
||||||
pub stack_alloc: Func<'a, u32, u32>,
|
pub stack_alloc: Func<'a, u32, u32>,
|
||||||
pub jumps: Vec<UnsafeCell<[u32; 27]>>,
|
pub jumps: Vec<UnsafeCell<[u32; 27]>>,
|
||||||
|
pub opened_dirs: HashMap<i32, Box<*mut libcDIR>>,
|
||||||
|
|
||||||
pub dyn_call_i: Option<Func<'a, i32, i32>>,
|
pub dyn_call_i: Option<Func<'a, i32, i32>>,
|
||||||
pub dyn_call_ii: Option<Func<'a, (i32, i32), i32>>,
|
pub dyn_call_ii: Option<Func<'a, (i32, i32), i32>>,
|
||||||
@ -224,6 +227,8 @@ impl<'a> EmscriptenData<'a> {
|
|||||||
memset,
|
memset,
|
||||||
stack_alloc,
|
stack_alloc,
|
||||||
jumps: Vec::new(),
|
jumps: Vec::new(),
|
||||||
|
opened_dirs: HashMap::new(),
|
||||||
|
|
||||||
dyn_call_i,
|
dyn_call_i,
|
||||||
dyn_call_ii,
|
dyn_call_ii,
|
||||||
dyn_call_iii,
|
dyn_call_iii,
|
||||||
|
@ -631,11 +631,6 @@ pub fn ___syscall218(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
|||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ___syscall220(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
|
||||||
debug!("emscripten::___syscall220");
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
|
|
||||||
// fcntl64
|
// fcntl64
|
||||||
pub fn ___syscall221(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall221(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall221 (fcntl64) {}", _which);
|
debug!("emscripten::___syscall221 (fcntl64) {}", _which);
|
||||||
|
@ -74,6 +74,8 @@ use libc::{
|
|||||||
SO_REUSEADDR,
|
SO_REUSEADDR,
|
||||||
TIOCGWINSZ,
|
TIOCGWINSZ,
|
||||||
};
|
};
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use std::ffi::CStr;
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
@ -849,19 +851,25 @@ pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
|||||||
// dirent structure is
|
// dirent structure is
|
||||||
// i64, i64, u16 (280), i8, [i8; 256]
|
// i64, i64, u16 (280), i8, [i8; 256]
|
||||||
pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||||
debug!("emscripten::___syscall220");
|
use super::super::env::get_emscripten_data;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
let mut opened_dirs = &mut get_emscripten_data(ctx).opened_dirs;
|
||||||
|
|
||||||
// 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 pos = 0;
|
let mut pos = 0;
|
||||||
let offset = 280;
|
let offset = 280;
|
||||||
while pos + offset <= count as usize {
|
while pos + offset <= count as usize {
|
||||||
let dirent = unsafe { readdir(dir) };
|
let dirent = unsafe { readdir(**dir) };
|
||||||
if dirent.is_null() {
|
if dirent.is_null() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -878,6 +886,7 @@ pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
*(dirp.add(pos + 19 + i) as *mut i8) = 0 as i8;
|
*(dirp.add(pos + 19 + i) as *mut i8) = 0 as i8;
|
||||||
|
debug!(" => file {}", CStr::from_ptr(dirp.add(pos + 19) as *const i8).to_str().unwrap());
|
||||||
}
|
}
|
||||||
pos += offset;
|
pos += offset;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
pub fn confstr(_ctx: &mut Ctx, _name: i32, _bufPointer: i32, _len: i32) -> i32 {
|
pub fn confstr(_ctx: &mut Ctx, _name: i32, _buf_pointer: i32, _len: i32) -> i32 {
|
||||||
debug!("unistd::confstr({}, {}, {})", _name, _bufPointer, _len);
|
debug!("unistd::confstr({}, {}, {})", _name, _buf_pointer, _len);
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user