mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
Kernel+LibPthread: Implement pthread_detach()
This commit is contained in:
parent
9ddfe694f2
commit
95b086f47f
Notes:
sideshowbarker
2024-07-19 10:56:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/95b086f47f4
4 changed files with 29 additions and 1 deletions
|
@ -2915,6 +2915,27 @@ void Process::sys$exit_thread(void* exit_value)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
int Process::sys$detach_thread(int tid)
|
||||
{
|
||||
Thread* thread = nullptr;
|
||||
for_each_thread([&](auto& child_thread) {
|
||||
if (child_thread.tid() == tid) {
|
||||
thread = &child_thread;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
if (!thread)
|
||||
return -ESRCH;
|
||||
|
||||
if (!thread->is_joinable())
|
||||
return -EINVAL;
|
||||
|
||||
thread->set_joinable(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$join_thread(int tid, void** exit_value)
|
||||
{
|
||||
if (exit_value && !validate_write_typed(exit_value))
|
||||
|
|
|
@ -204,6 +204,7 @@ public:
|
|||
int sys$create_thread(void* (*)(void*), void* argument, const Syscall::SC_create_thread_params*);
|
||||
void sys$exit_thread(void*);
|
||||
int sys$join_thread(int tid, void** exit_value);
|
||||
int sys$detach_thread(int tid);
|
||||
int sys$rename(const char* oldpath, const char* newpath);
|
||||
int sys$systrace(pid_t);
|
||||
int sys$mknod(const char* pathname, mode_t, dev_t);
|
||||
|
|
|
@ -141,7 +141,8 @@ typedef u32 socklen_t;
|
|||
__ENUMERATE_SYSCALL(openat) \
|
||||
__ENUMERATE_SYSCALL(join_thread) \
|
||||
__ENUMERATE_SYSCALL(module_load) \
|
||||
__ENUMERATE_SYSCALL(module_unload)
|
||||
__ENUMERATE_SYSCALL(module_unload) \
|
||||
__ENUMERATE_SYSCALL(detach_thread)
|
||||
|
||||
namespace Syscall {
|
||||
|
||||
|
|
|
@ -85,6 +85,11 @@ int pthread_join(pthread_t thread, void** exit_value_ptr)
|
|||
return syscall(SC_join_thread, thread, exit_value_ptr);
|
||||
}
|
||||
|
||||
int pthread_detach(pthread_t thread)
|
||||
{
|
||||
return syscall(SC_detach_thread, thread);
|
||||
}
|
||||
|
||||
int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attributes)
|
||||
{
|
||||
// FIXME: Implement mutex attributes
|
||||
|
|
Loading…
Reference in a new issue