1*c9945492SAndroid Build Coastguard Worker #include "pthread_impl.h" 2*c9945492SAndroid Build Coastguard Worker #include <threads.h> 3*c9945492SAndroid Build Coastguard Worker __pthread_detach(pthread_t t)4*c9945492SAndroid Build Coastguard Workerstatic int __pthread_detach(pthread_t t) 5*c9945492SAndroid Build Coastguard Worker { 6*c9945492SAndroid Build Coastguard Worker /* If the cas fails, detach state is either already-detached 7*c9945492SAndroid Build Coastguard Worker * or exiting/exited, and pthread_join will trap or cleanup. */ 8*c9945492SAndroid Build Coastguard Worker if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != DT_JOINABLE) { 9*c9945492SAndroid Build Coastguard Worker int cs; 10*c9945492SAndroid Build Coastguard Worker __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); 11*c9945492SAndroid Build Coastguard Worker __pthread_join(t, 0); 12*c9945492SAndroid Build Coastguard Worker __pthread_setcancelstate(cs, 0); 13*c9945492SAndroid Build Coastguard Worker } 14*c9945492SAndroid Build Coastguard Worker return 0; 15*c9945492SAndroid Build Coastguard Worker } 16*c9945492SAndroid Build Coastguard Worker 17*c9945492SAndroid Build Coastguard Worker weak_alias(__pthread_detach, pthread_detach); 18*c9945492SAndroid Build Coastguard Worker weak_alias(__pthread_detach, thrd_detach); 19