1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +00:00

Kernel: Use Userspace<T> for the exit_thread syscall

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.
This commit is contained in:
Brian Gianforcaro 2020-08-09 15:45:51 -07:00 committed by Andreas Kling
parent d3847b3489
commit 0e627b0273
3 changed files with 4 additions and 4 deletions

View file

@ -305,7 +305,7 @@ public:
int sys$sched_setparam(pid_t pid, Userspace<const struct sched_param*>); 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$sched_getparam(pid_t pid, Userspace<struct sched_param*>);
int sys$create_thread(void* (*)(void*), Userspace<const Syscall::SC_create_thread_params*>); 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$join_thread(pid_t tid, Userspace<void**> exit_value);
int sys$detach_thread(pid_t tid); int sys$detach_thread(pid_t tid);
int sys$set_thread_name(pid_t tid, Userspace<const char*> buffer, size_t buffer_size); int sys$set_thread_name(pid_t tid, Userspace<const char*> buffer, size_t buffer_size);

View file

@ -95,7 +95,7 @@ int handle(RegisterState& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
if (function == SC_exit) if (function == SC_exit)
process.sys$exit((int)arg1); process.sys$exit((int)arg1);
else else
process.sys$exit_thread((void*)arg1); process.sys$exit_thread(arg1);
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
return 0; return 0;
} }

View file

@ -90,12 +90,12 @@ int Process::sys$create_thread(void* (*entry)(void*), Userspace<const Syscall::S
return thread->tid().value(); return thread->tid().value();
} }
void Process::sys$exit_thread(void* exit_value) void Process::sys$exit_thread(Userspace<void*> exit_value)
{ {
REQUIRE_PROMISE(thread); REQUIRE_PROMISE(thread);
cli(); cli();
auto current_thread = Thread::current(); 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(); current_thread->set_should_die();
big_lock().force_unlock_if_locked(); big_lock().force_unlock_if_locked();
current_thread->die_if_needed(); current_thread->die_if_needed();