Skip to content

Commit

Permalink
Add ___syscall12 (chdir())
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhunter committed Sep 25, 2018
1 parent ec28cd6 commit 1a823f8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/wasmjit/emscripten_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -2643,6 +2643,25 @@ uint32_t wasmjit_emscripten____syscall221(uint32_t which, uint32_t varargs,
return -SYS_EINVAL;
}

/* chdir */
uint32_t wasmjit_emscripten____syscall12(uint32_t which, uint32_t varargs,
struct FuncInst *funcinst)
{
char *base;

LOAD_ARGS(funcinst, varargs, 1,
uint32_t, pathname);

(void) which;

base = wasmjit_emscripten_get_base_address(funcinst);

if (!_wasmjit_emscripten_check_string(funcinst, args.pathname, PATH_MAX))
return -SYS_EFAULT;

return check_ret(sys_chdir(base + args.pathname));
}

void wasmjit_emscripten_cleanup(struct ModuleInst *moduleinst) {
(void)moduleinst;
/* TODO: implement */
Expand Down
1 change: 1 addition & 0 deletions src/wasmjit/emscripten_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void wasmjit_emscripten____buildEnvironment(uint32_t, struct FuncInst *);
uint32_t wasmjit_emscripten____syscall10(uint32_t which, uint32_t varargs, struct FuncInst *funcinst);
uint32_t wasmjit_emscripten____syscall102(uint32_t which, uint32_t varargs, struct FuncInst *funcinst);
uint32_t wasmjit_emscripten____syscall221(uint32_t which, uint32_t varargs, struct FuncInst *funcinst);
uint32_t wasmjit_emscripten____syscall12(uint32_t which, uint32_t varargs, struct FuncInst *funcinst);
void wasmjit_emscripten_start_func(struct FuncInst *funcinst);

struct EmscriptenContext *wasmjit_emscripten_get_context(struct ModuleInst *);
Expand Down
1 change: 1 addition & 0 deletions src/wasmjit/emscripten_runtime_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ DEFINE_EMSCRIPTEN_FUNCTION(___buildEnvironment, VALTYPE_NULL, 1, VALTYPE_I32)
DEFINE_EMSCRIPTEN_FUNCTION(___syscall10, VALTYPE_I32, 2, VALTYPE_I32, VALTYPE_I32)
DEFINE_EMSCRIPTEN_FUNCTION(___syscall102, VALTYPE_I32, 2, VALTYPE_I32, VALTYPE_I32)
DEFINE_EMSCRIPTEN_FUNCTION(___syscall221, VALTYPE_I32, 2, VALTYPE_I32, VALTYPE_I32)
DEFINE_EMSCRIPTEN_FUNCTION(___syscall12, VALTYPE_I32, 2, VALTYPE_I32, VALTYPE_I32)
END_FUNCTION_DEFS()

DEFINE_WASM_START_FUNCTION(wasmjit_emscripten_start_func)
Expand Down
1 change: 1 addition & 0 deletions src/wasmjit/emscripten_runtime_sys_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ KWSC5(setsockopt, int, int, int, const void *, socklen_t)
KWSC5(getsockopt, int, int, int, void *, socklen_t *)
KWSC3(sendmsg, int, const struct msghdr *, int)
KWSC3(recvmsg, int, struct msghdr *, int)
KWSC1(chdir, const char *)

0 comments on commit 1a823f8

Please sign in to comment.