Преглед на файлове

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.
Brian Gianforcaro преди 5 години
родител
ревизия
0e627b0273
променени са 3 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. 1 1
      Kernel/Process.h
  2. 1 1
      Kernel/Syscall.cpp
  3. 2 2
      Kernel/Syscalls/thread.cpp

+ 1 - 1
Kernel/Process.h

@@ -305,7 +305,7 @@ public:
     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);

+ 1 - 1
Kernel/Syscall.cpp

@@ -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;
     }

+ 2 - 2
Kernel/Syscalls/thread.cpp

@@ -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();