12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include <errno.h>
- #include "pthreadP.h"
- #include <atomic.h>
- int
- pthread_detach (pthread_t th)
- {
- struct pthread *pd = (struct pthread *) th;
-
- if (INVALID_NOT_TERMINATED_TD_P (pd))
-
- return ESRCH;
- int result = 0;
-
- if (atomic_compare_and_exchange_bool_acq (&pd->joinid, pd, NULL))
- {
-
- if (IS_DETACHED (pd))
- result = EINVAL;
- }
- else
-
- if ((pd->cancelhandling & EXITING_BITMASK) != 0)
-
- __free_tcb (pd);
- return result;
- }
|