#include "pthread_impl.h" #include #include int __munmap(void *, size_t); /* We have to be careful to not modify memory at res[1], which we * might do on 64 bit archs, if we'd just interpret *res (an int) as * void*. Therefore this can't be a simple tail call to * __pthread_join. * * As additional bonus, C11 threads cannot be canceled, so there is no * need for a cancelation function pointer, here. */ int thrd_join(thrd_t t, int *res) { int tmp; while ((tmp = t->tid)) __timedwait(&t->tid, tmp, 0, 0, 0, 0, 0); if (res) *res = (int)(intptr_t)t->result; if (t->map_base) __munmap(t->map_base, t->map_size); return thrd_success; }