summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-14 20:58:23 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-14 20:58:23 +0100
commit69efa3f630141a74ced338b07d8466a5a0e7557f (patch)
treefb61f96e27eecceb66952c9c03e783eeeb80284c /Libraries
parentc6a8b956432370500df4c19cdccd13806bc18d79 (diff)
downloadserenity-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.cpp8
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);
+}
}