1 #define _GNU_SOURCE
2 #include "usr_lib_define.h"
3 #include "pthread_impl.h"
4
__pthread_timedjoin_np(pthread_t t,void ** res,const struct timespec * at)5 _LIBC_TEXT_SECTION static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec *at)
6 {
7 int state, cs, r = 0;
8 unsigned int tid;
9 pthread_t self = __pthread_self();
10 if (t == self) {
11 r = EINVAL;
12 goto out;
13 }
14
15 switch (t->detach_state) {
16 case DT_JOINABLE: {
17 r = __syscall(SYS_pthread_join, t->tid);
18 break;
19 }
20 case DT_EXITING:
21 break;
22 case DT_DETACHED:
23 default:
24 r = EINVAL;
25 break;
26 }
27
28 out:
29 if (r == ESRCH || r == EINVAL) return r;
30 if (res) *res = t->result;
31 tid = t->tid;
32 t->tid = 0;
33 return __syscall(SYS_pthread_deatch, tid);
34 }
35
__pthread_join(pthread_t t,void ** res)36 _LIBC_TEXT_SECTION int __pthread_join(pthread_t t, void **res)
37 {
38 return __pthread_timedjoin_np(t, res, 0);
39 }
40
41 weak_alias(__pthread_join, pthread_join);
42