summaryrefslogtreecommitdiff
path: root/src/kernel/syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r--src/kernel/syscalls.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index e639d1f..cfd895e 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -11,8 +11,10 @@
#include <stdint.h>
#define SYSCALL_RETURN(val) do { \
+ uint32_t ret = (uint32_t)val; \
assert(process_current->state == PS_RUNNING); \
- return regs_savereturn(&process_current->regs, val); \
+ regs_savereturn(&process_current->regs, ret); \
+ return 0; \
} while (0)
_Noreturn void _syscall_exit(int ret) {
@@ -29,7 +31,7 @@ int _syscall_await(void) {
{
if (iter->noreap) continue;
has_children = true;
- if (iter->state == PS_DEAD) // TODO this path crashes
+ if (iter->state == PS_DEAD) // TODO this path used to crash, still untested
SYSCALL_RETURN(process_try2collect(iter));
}
@@ -272,7 +274,8 @@ void __user *_syscall_memflag(void __user *addr, size_t len, int flags) {
if (flags & MEMFLAG_FINDFREE) {
addr = pagedir_findfree(pages, addr, len);
- if (!(flags & MEMFLAG_PRESENT)) goto ret;
+ if (!(flags & MEMFLAG_PRESENT))
+ SYSCALL_RETURN((uintptr_t)addr);
}
@@ -296,11 +299,7 @@ void __user *_syscall_memflag(void __user *addr, size_t len, int flags) {
pagedir_map(pages, iter, phys, true, true);
}
}
-
-ret: // the macro is too stupid to handle returning pointers
- assert(process_current->state == PS_RUNNING); // TODO move to regs_savereturn
- regs_savereturn(&process_current->regs, (uintptr_t)addr);
- return addr;
+ SYSCALL_RETURN((uintptr_t)addr);
}
handle_t _syscall_pipe(int flags) {