Skip to content

Commit

Permalink
Kernel: Use Userspace<T> for the exit_thread syscall
Browse files Browse the repository at this point in the history
Userspace<void*> is a bit strange here, as it would appear to the
user that we intend to de-refrence the pointer in kernel mode.

However I think it does a good join of illustrating that we are
treating the void* as a value type,  instead of a pointer type.
  • Loading branch information
bgianfo authored and awesomekling committed Aug 10, 2020
1 parent d3847b3 commit 0e627b0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Kernel/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class Process
int sys$sched_setparam(pid_t pid, Userspace<const struct sched_param*>);
int sys$sched_getparam(pid_t pid, Userspace<struct sched_param*>);
int sys$create_thread(void* (*)(void*), Userspace<const Syscall::SC_create_thread_params*>);
void sys$exit_thread(void*);
void sys$exit_thread(Userspace<void*>);
int sys$join_thread(pid_t tid, Userspace<void**> exit_value);
int sys$detach_thread(pid_t tid);
int sys$set_thread_name(pid_t tid, Userspace<const char*> buffer, size_t buffer_size);
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Syscall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int handle(RegisterState& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
if (function == SC_exit)
process.sys$exit((int)arg1);
else
process.sys$exit_thread((void*)arg1);
process.sys$exit_thread(arg1);
ASSERT_NOT_REACHED();
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Syscalls/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ int Process::sys$create_thread(void* (*entry)(void*), Userspace<const Syscall::S
return thread->tid().value();
}

void Process::sys$exit_thread(void* exit_value)
void Process::sys$exit_thread(Userspace<void*> exit_value)
{
REQUIRE_PROMISE(thread);
cli();
auto current_thread = Thread::current();
current_thread->m_exit_value = exit_value;
current_thread->m_exit_value = reinterpret_cast<void*>(exit_value.ptr());
current_thread->set_should_die();
big_lock().force_unlock_if_locked();
current_thread->die_if_needed();
Expand Down

0 comments on commit 0e627b0

Please sign in to comment.