19e6b54861169f9ea7046672632c56f0a0981c2b
[oweals/musl.git] / src / thread / pthread_join.c
1 #include "pthread_impl.h"
2 #include <sys/mman.h>
3
4 int __munmap(void *, size_t);
5
6 static void dummy(void *p)
7 {
8 }
9
10 int __pthread_join(pthread_t t, void **res)
11 {
12         int tmp;
13         pthread_testcancel();
14         while ((tmp = t->tid)) __timedwait(&t->tid, tmp, 0, 0, dummy, 0, 0);
15         if (res) *res = t->result;
16         if (t->map_base) __munmap(t->map_base, t->map_size);
17         return 0;
18 }
19
20 weak_alias(__pthread_join, pthread_join);