1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #include <errno.h>
- #include "pthreadP.h"
- int
- attribute_protected
- __pthread_cond_destroy (
- pthread_cond_t *cond)
- {
- int pshared = (cond->__data.__mutex == (void *) ~0l)
- ? LLL_SHARED : LLL_PRIVATE;
-
- lll_lock (cond->__data.__lock, pshared);
- if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
- {
-
- lll_unlock (cond->__data.__lock, pshared);
- return EBUSY;
- }
-
- cond->__data.__total_seq = -1ULL;
-
- unsigned int nwaiters = cond->__data.__nwaiters;
- if (nwaiters >= (1 << COND_NWAITERS_SHIFT))
- {
-
- if (cond->__data.__mutex != NULL
- && cond->__data.__mutex != (void *) ~0l)
- {
- pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
- lll_futex_wake (&mut->__data.__lock, INT_MAX,
- PTHREAD_MUTEX_PSHARED (mut));
- }
- do
- {
- lll_unlock (cond->__data.__lock, pshared);
- lll_futex_wait (&cond->__data.__nwaiters, nwaiters, pshared);
- lll_lock (cond->__data.__lock, pshared);
- nwaiters = cond->__data.__nwaiters;
- }
- while (nwaiters >= (1 << COND_NWAITERS_SHIFT));
- }
- return 0;
- }
- weak_alias(__pthread_cond_destroy, pthread_cond_destroy)
|