X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fthread%2Fpthread_mutexattr_setrobust.c;h=04db92a626dbd0b05eac4bcd88363a6e31e54207;hb=1ef37aa00ea830dfda76e04e3d941cafa74d8b76;hp=8948cbafbbc88268889d63569abe463fbd11ca71;hpb=b092f1c5fa9c048e12d002c7b972df5ecbe96d1d;p=musl diff --git a/src/thread/pthread_mutexattr_setrobust.c b/src/thread/pthread_mutexattr_setrobust.c index 8948cbaf..04db92a6 100644 --- a/src/thread/pthread_mutexattr_setrobust.c +++ b/src/thread/pthread_mutexattr_setrobust.c @@ -1,31 +1,25 @@ #include "pthread_impl.h" -#include +#include "syscall.h" -void __do_private_robust_list() -{ - pthread_t self = __pthread_self(); - void **p, **prev, **next; - pthread_mutex_t *m; +static pthread_once_t check_robust_once; +static int check_robust_result; - for (prev=0, p=self->robust_list.head; p; p=next) { - next = *p; - m = (void *)((char *)p - offsetof(pthread_mutex_t, _m_next)); - if (!(m->_m_type & 128)) { - int waiters = m->_m_waiters; - if (prev) *prev = next; - else self->robust_list.head = next; - int cont = a_swap(&m->_m_lock, self->tid|0x40000000); - if (cont < 0 || waiters) __wake(&m->_m_lock, 1, 1); - } else { - prev = p; - } - } +static void check_robust() +{ + void *p; + size_t l; + check_robust_result = -__syscall(SYS_get_robust_list, 0, &p, &l); } int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust) { if (robust > 1U) return EINVAL; + if (robust) { + pthread_once(&check_robust_once, check_robust); + if (check_robust_result) return check_robust_result; + a->__attr |= 4; + return 0; + } a->__attr &= ~4; - a->__attr |= robust*4; return 0; }