summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authordzwdz2021-09-08 19:45:50 +0200
committerdzwdz2021-09-08 19:45:50 +0200
commitf44b80c3f0004418c4953f0a2f32f7bec2e26e36 (patch)
treef5258a5d90316d8ea033eb09bf7220a0271fd808 /src/kernel
parent67c847f8660ed73db1017f2ca8b01bfe4eb9ba1b (diff)
process struct: replace the generic saved_addr with an union
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/proc.h12
-rw-r--r--src/kernel/syscalls.c16
2 files changed, 15 insertions, 13 deletions
diff --git a/src/kernel/proc.h b/src/kernel/proc.h
index 0efccde..5d9e7eb 100644
--- a/src/kernel/proc.h
+++ b/src/kernel/proc.h
@@ -24,11 +24,13 @@ struct process {
uint32_t id; // only for debugging, don't expose to userland
- // meaning changes depending on the state
- // PS_DEAD - death message
- // PS_WAITS4CHILDDEATH - buffer for said message
- user_ptr saved_addr;
- size_t saved_len;
+ // saved value, meaning depends on .state
+ union {
+ struct { // PS_DEAD, PS_WAITS4CHILDDEATH
+ user_ptr buf;
+ size_t len;
+ } death_msg;
+ };
struct vfs_mount *mount;
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index ddc3d4b..124333a 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -17,11 +17,11 @@ _Noreturn static void await_finish(struct process *dead, struct process *listene
dead->state = PS_DEADER;
listener->state = PS_RUNNING;
- len = listener->saved_len < dead->saved_len
- ? listener->saved_len : dead->saved_len;
+ len = listener->death_msg.len < dead->death_msg.len
+ ? listener->death_msg.len : dead->death_msg.len;
res = virt_cpy(
- listener->pages, listener->saved_addr,
- dead->pages, dead->saved_addr, len);
+ listener->pages, listener->death_msg.buf,
+ dead->pages, dead->death_msg.buf, len);
regs_savereturn(&listener->regs, res ? len : -1);
process_switch(listener);
}
@@ -29,8 +29,8 @@ _Noreturn static void await_finish(struct process *dead, struct process *listene
_Noreturn void _syscall_exit(const user_ptr msg, size_t len) {
process_current->state = PS_DEAD;
- process_current->saved_addr = msg;
- process_current->saved_len = len;
+ process_current->death_msg.buf = msg;
+ process_current->death_msg.len = len;
if (process_current->parent->state == PS_WAITS4CHILDDEATH)
await_finish(process_current, process_current->parent);
@@ -44,8 +44,8 @@ _Noreturn void _syscall_exit(const user_ptr msg, size_t len) {
int _syscall_await(user_ptr buf, int len) {
process_current->state = PS_WAITS4CHILDDEATH;
- process_current->saved_addr = buf;
- process_current->saved_len = len;
+ process_current->death_msg.buf = buf;
+ process_current->death_msg.len = len;
// find any already dead children
for (struct process *iter = process_current->child;