diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-14 20:58:23 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-14 20:58:23 +0100 |
commit | 69efa3f630141a74ced338b07d8466a5a0e7557f (patch) | |
tree | fb61f96e27eecceb66952c9c03e783eeeb80284c /Libraries | |
parent | c6a8b956432370500df4c19cdccd13806bc18d79 (diff) | |
download | serenity-69efa3f630141a74ced338b07d8466a5a0e7557f.zip |
Kernel+LibPthread: Implement pthread_join()
It's now possible to block until another thread in the same process has
exited. We can also retrieve its exit value, which is whatever value it
passed to pthread_exit(). :^)
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibPthread/pthread.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Libraries/LibPthread/pthread.cpp b/Libraries/LibPthread/pthread.cpp index 26761b8a02..b659d376d1 100644 --- a/Libraries/LibPthread/pthread.cpp +++ b/Libraries/LibPthread/pthread.cpp @@ -1,10 +1,11 @@ #include <AK/StdLibExtras.h> +#include <Kernel/Syscall.h> #include <pthread.h> #include <unistd.h> extern "C" { -int pthread_create(pthread_t* thread, pthread_attr_t* attributes, void *(*start_routine)(void*), void* argument_to_start_routine) +int pthread_create(pthread_t* thread, pthread_attr_t* attributes, void* (*start_routine)(void*), void* argument_to_start_routine) { if (!thread) return -EINVAL; @@ -21,4 +22,9 @@ void pthread_exit(void* value_ptr) exit_thread(value_ptr); } +int pthread_join(pthread_t thread, void** exit_value_ptr) +{ + int rc = syscall(SC_join_thread, thread, exit_value_ptr); + __RETURN_WITH_ERRNO(rc, rc, -1); +} } |