xref: /aosp_15_r20/external/musl/src/thread/pthread_cond_destroy.c (revision c9945492fdd68bbe62686c5b452b4dc1be3f8453)
1*c9945492SAndroid Build Coastguard Worker #include "pthread_impl.h"
2*c9945492SAndroid Build Coastguard Worker 
pthread_cond_destroy(pthread_cond_t * c)3*c9945492SAndroid Build Coastguard Worker int pthread_cond_destroy(pthread_cond_t *c)
4*c9945492SAndroid Build Coastguard Worker {
5*c9945492SAndroid Build Coastguard Worker 	if (c->_c_shared && c->_c_waiters) {
6*c9945492SAndroid Build Coastguard Worker 		int cnt;
7*c9945492SAndroid Build Coastguard Worker 		a_or(&c->_c_waiters, 0x80000000);
8*c9945492SAndroid Build Coastguard Worker 		a_inc(&c->_c_seq);
9*c9945492SAndroid Build Coastguard Worker 		__wake(&c->_c_seq, -1, 0);
10*c9945492SAndroid Build Coastguard Worker 		while ((cnt = c->_c_waiters) & 0x7fffffff)
11*c9945492SAndroid Build Coastguard Worker 			__wait(&c->_c_waiters, 0, cnt, 0);
12*c9945492SAndroid Build Coastguard Worker 	}
13*c9945492SAndroid Build Coastguard Worker 	return 0;
14*c9945492SAndroid Build Coastguard Worker }
15