From 3500d5a7c774c60d79e13937b443398421fab0d8 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Mon, 25 Mar 2019 13:09:23 -0700 Subject: [PATCH] add more functions for sqlite compiled from config src --- lib/emscripten/src/emscripten_target.rs | 10 +++++++-- lib/emscripten/src/lib.rs | 4 ++++ lib/emscripten/src/syscalls/unix.rs | 30 ++++++++++++++++++++++++- lib/emscripten/src/syscalls/windows.rs | 12 ++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/lib/emscripten/src/emscripten_target.rs b/lib/emscripten/src/emscripten_target.rs index 5af48a578..0ae8eaab2 100644 --- a/lib/emscripten/src/emscripten_target.rs +++ b/lib/emscripten/src/emscripten_target.rs @@ -283,6 +283,9 @@ pub fn nullFunc_iiij(_ctx: &mut Ctx, _index: i32) { pub fn nullFunc_iijii(_ctx: &mut Ctx, _index: i32) { debug!("emscripten::nullFunc_iijii"); } +pub fn nullFunc_iijj(_ctx: &mut Ctx, _index: i32) { + debug!("emscripten::nullFunc_iijj"); +} pub fn nullFunc_iiiiji(_ctx: &mut Ctx, _index: i32) { debug!("emscripten::nullFunc_iiiiji"); } @@ -337,11 +340,14 @@ pub fn nullFunc_viiijiiiiii(_ctx: &mut Ctx, _index: i32) { pub fn nullFunc_viij(_ctx: &mut Ctx, _index: i32) { debug!("emscripten::nullFunc_viij"); } +pub fn nullFunc_viijii(_ctx: &mut Ctx, _index: i32) { + debug!("emscripten::nullFunc_viijii"); +} pub fn nullFunc_viiji(_ctx: &mut Ctx, _index: i32) { debug!("emscripten::nullFunc_viiji"); } -pub fn nullFunc_viijii(_ctx: &mut Ctx, _index: i32) { - debug!("emscripten::nullFunc_viijii"); +pub fn nullFunc_vijii(_ctx: &mut Ctx, _index: i32) { + debug!("emscripten::nullFunc_vijii"); } pub fn nullFunc_viijiii(_ctx: &mut Ctx, _index: i32) { debug!("emscripten::nullFunc_viijiii"); diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index ec8f4083a..1bf571c53 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -515,6 +515,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "___syscall142" => func!(crate::syscalls::___syscall142), "___syscall145" => func!(crate::syscalls::___syscall145), "___syscall146" => func!(crate::syscalls::___syscall146), + "___syscall148" => func!(crate::syscalls::___syscall148), "___syscall168" => func!(crate::syscalls::___syscall168), "___syscall180" => func!(crate::syscalls::___syscall180), "___syscall181" => func!(crate::syscalls::___syscall181), @@ -540,6 +541,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "___syscall272" => func!(crate::syscalls::___syscall272), "___syscall295" => func!(crate::syscalls::___syscall295), "___syscall300" => func!(crate::syscalls::___syscall300), + "___syscall324" => func!(crate::syscalls::___syscall324), "___syscall330" => func!(crate::syscalls::___syscall330), "___syscall334" => func!(crate::syscalls::___syscall334), "___syscall340" => func!(crate::syscalls::___syscall340), @@ -685,6 +687,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "nullFunc_diiii" => func!(crate::emscripten_target::nullFunc_diiii), "nullFunc_iiid" => func!(crate::emscripten_target::nullFunc_iiid), "nullFunc_iiji" => func!(crate::emscripten_target::nullFunc_iiji), + "nullFunc_iijj" => func!(crate::emscripten_target::nullFunc_iijj), "nullFunc_iij" => func!(crate::emscripten_target::nullFunc_iij), "nullFunc_ij" => func!(crate::emscripten_target::nullFunc_ij), "nullFunc_j" => func!(crate::emscripten_target::nullFunc_j), @@ -710,6 +713,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "nullFunc_viiijiiiiii" => func!(crate::emscripten_target::nullFunc_viiijiiiiii), "nullFunc_viij" => func!(crate::emscripten_target::nullFunc_viij), "nullFunc_viiji" => func!(crate::emscripten_target::nullFunc_viiji), + "nullFunc_vijii" => func!(crate::emscripten_target::nullFunc_vijii), "nullFunc_viijii" => func!(crate::emscripten_target::nullFunc_viijii), "nullFunc_viiiij" => func!(crate::emscripten_target::nullFunc_viiiij), "nullFunc_viijiii" => func!(crate::emscripten_target::nullFunc_viijiii), diff --git a/lib/emscripten/src/syscalls/unix.rs b/lib/emscripten/src/syscalls/unix.rs index b994fa735..fd09220f1 100644 --- a/lib/emscripten/src/syscalls/unix.rs +++ b/lib/emscripten/src/syscalls/unix.rs @@ -36,6 +36,7 @@ use libc::{ mode_t, msghdr, nice, + off_t, open, pid_t, pread, @@ -80,10 +81,11 @@ use std::mem; extern "C" { pub fn wait4(pid: pid_t, status: *mut c_int, options: c_int, rusage: *mut rusage) -> pid_t; pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn fdatasync(fd: c_int) -> c_int; } #[cfg(not(target_os = "macos"))] -use libc::{madvise, wait4}; +use libc::{fallocate, fdatasync, madvise, wait4}; // Another conditional constant for name resolution: Macos et iOS use // SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket. @@ -709,6 +711,15 @@ pub fn ___syscall142(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in unsafe { select(nfds, readfds_ptr, writefds_ptr, 0 as _, 0 as _) } } +/// fdatasync +pub fn ___syscall148(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int { + debug!("emscripten::___syscall148 (fdatasync) {}", _which); + + let fd: i32 = varargs.get(ctx); + + unsafe { fdatasync(fd) } +} + // setpgid pub fn ___syscall57(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall57 (setpgid) {}", _which); @@ -726,3 +737,20 @@ pub fn ___syscall122(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut utsname; unsafe { uname(buf_addr) } } + +/// fallocate +pub fn ___syscall324(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int { + debug!("emscripten::___syscall324 (fallocate) {}", _which); + let _fd: c_int = varargs.get(ctx); + let _mode: c_int = varargs.get(ctx); + let _offset: off_t = varargs.get(ctx); + let _len: off_t = varargs.get(ctx); + #[cfg(not(target_os = "macos"))] + unsafe { + fallocate(_fd, _mode, _offset, _len) + } + #[cfg(target_os = "macos")] + { + unimplemented!() + } +} diff --git a/lib/emscripten/src/syscalls/windows.rs b/lib/emscripten/src/syscalls/windows.rs index 39076761b..641311d9a 100644 --- a/lib/emscripten/src/syscalls/windows.rs +++ b/lib/emscripten/src/syscalls/windows.rs @@ -216,6 +216,12 @@ pub fn ___syscall142(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i -1 } +/// fdatasync +pub fn ___syscall148(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int { + debug!("emscripten::___syscall148 (fdatasync) {}", _which); + unimplemented!(); +} + // setpgid pub fn ___syscall57(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall57 (setpgid) {}", which); @@ -238,3 +244,9 @@ pub fn ___syscall207(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int debug!("emscripten::___syscall207 (fchown) {}", _which); unimplemented!() } + +/// fallocate +pub fn ___syscall324(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int { + debug!("emscripten::___syscall324 (fallocate) {}", _which); + unimplemented!() +}