fix lstat64; increase num returned by heap size

This commit is contained in:
Mark McCaskey 2019-04-05 16:50:50 -07:00 committed by Syrus
parent 3fcc502015
commit e8236cf1c7
3 changed files with 19 additions and 20 deletions

View File

@ -20,7 +20,7 @@ pub fn _emscripten_memcpy_big(ctx: &mut Ctx, dest: u32, src: u32, len: u32) -> u
pub fn _emscripten_get_heap_size(_ctx: &mut Ctx) -> u32 {
debug!("emscripten::_emscripten_get_heap_size",);
// TODO: Fix implementation
162_107_392
162_107_392 * 2
}
/// emscripten: _emscripten_resize_heap

View File

@ -418,6 +418,24 @@ pub fn ___syscall197(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
0
}
/// lstat64
pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall196 (lstat64) {}", _which);
let path_ptr: c_int = varargs.get(ctx);
let buf_ptr: u32 = varargs.get(ctx);
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8;
unsafe {
let mut stat: stat = std::mem::zeroed();
let ret = lstat64(path, &mut stat as *mut stat as *mut c_void);
debug!("ret: {}", ret);
if ret != 0 {
return ret;
}
copy_stat_into_wasm(ctx, buf_ptr, &stat);
}
0
}
pub fn ___syscall220(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall220");
-1

View File

@ -759,25 +759,6 @@ pub fn ___syscall122(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
unsafe { uname(buf_addr) }
}
/// lstat64
pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall196 (lstat64) {}", _which);
let path_ptr: c_int = varargs.get(ctx);
let buf_ptr: c_int = varargs.get(ctx);
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const c_char;
let buf = emscripten_memory_pointer!(ctx.memory(0), buf_ptr) as *mut c_void;
let result = unsafe { lstat64(path, buf as _) };
debug!(
"=> path: {}, buf: {} = fd: {}\npath: {}\nlast os error: {}",
path_ptr,
buf_ptr,
result,
unsafe { std::ffi::CStr::from_ptr(path).to_str().unwrap() },
Error::last_os_error(),
);
result
}
/// fallocate
pub fn ___syscall324(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall324 (fallocate) {}", _which);