#include "pthread.h" #include #include #include #include #include #include #include int pthread_join(struct __pthread *thread, void **retval) { kern_wait_item_t wait; wait.w_handle = thread->thr_handle; wait.w_waitfor = THREAD_SIGNAL_STOPPED; wait.w_observed = 0; kern_status_t status = kern_object_wait(&wait, 1); if (status != KERN_OK) { return __set_errno(EINVAL); } if (retval) { *retval = thread->thr_result; } kern_handle_close(thread->thr_handle); munmap(thread->thr_map_base, thread->thr_map_size); return 0; }