return 0;
}
+PTHREAD_NOINLINE
static int
-_pthread_cond_check_init(_pthread_cond *cond, bool *inited)
+_pthread_cond_check_init_slow(_pthread_cond *cond, bool *inited)
{
- int res = 0;
- if (cond->sig != _PTHREAD_COND_SIG) {
- res = EINVAL;
+ int res = EINVAL;
+ if (cond->sig == _PTHREAD_COND_SIG_init) {
+ _PTHREAD_LOCK(cond->lock);
if (cond->sig == _PTHREAD_COND_SIG_init) {
- LOCK(cond->lock);
- if (cond->sig == _PTHREAD_COND_SIG_init) {
- res = _pthread_cond_init(cond, NULL, 0);
- if (inited) {
- *inited = true;
- }
- } else if (cond->sig == _PTHREAD_COND_SIG) {
- res = 0;
+ res = _pthread_cond_init(cond, NULL, 0);
+ if (inited) {
+ *inited = true;
}
- UNLOCK(cond->lock);
+ } else if (cond->sig == _PTHREAD_COND_SIG) {
+ res = 0;
}
+ _PTHREAD_UNLOCK(cond->lock);
+ } else if (cond->sig == _PTHREAD_COND_SIG) {
+ res = 0;
+ }
+ return res;
+}
+
+static inline int
+_pthread_cond_check_init(_pthread_cond *cond, bool *inited)
+{
+ int res = 0;
+ if (cond->sig != _PTHREAD_COND_SIG) {
+ return _pthread_cond_check_init_slow(cond, inited);
}
return res;
}
_pthread_cond *cond = (_pthread_cond *)ocond;
int res = EINVAL;
if (cond->sig == _PTHREAD_COND_SIG) {
- LOCK(cond->lock);
+ _PTHREAD_LOCK(cond->lock);
uint64_t oldval64, newval64;
uint32_t lcntval, ucntval, scntval;
cond->sig = _PTHREAD_NO_SIG;
res = 0;
- UNLOCK(cond->lock);
+ _PTHREAD_UNLOCK(cond->lock);
if (needclearpre) {
(void)__psynch_cvclrprepost(cond, lcntval, ucntval, scntval, 0, lcntval, flags);
}
if (isconforming) {
- if (mutex->sig != _PTHREAD_MUTEX_SIG && (mutex->sig & _PTHREAD_MUTEX_SIG_init_MASK) != _PTHREAD_MUTEX_SIG_CMP) {
+ if (!_pthread_mutex_check_signature(mutex) &&
+ !_pthread_mutex_check_signature_init(mutex)) {
return EINVAL;
}
if (isconforming > 0) {
pthread_t thread = pthread_self();
int thcanceled = 0;
- LOCK(thread->lock);
+ _PTHREAD_LOCK(thread->lock);
thcanceled = (thread->detached & _PTHREAD_WASCANCEL);
- UNLOCK(thread->lock);
+ _PTHREAD_UNLOCK(thread->lock);
if (thcanceled == 0) {
return;
#endif /* __DARWIN_UNIX03 */
_pthread_cond *cond = (_pthread_cond *)ocond;
- LOCK_INIT(cond->lock);
+ _PTHREAD_LOCK_INIT(cond->lock);
return _pthread_cond_init(cond, attr, conforming);
}