diff options
Diffstat (limited to 'nptl/pthread_mutex_init.c')
-rw-r--r-- | nptl/pthread_mutex_init.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c index 17d1c99575..f984d90ae4 100644 --- a/nptl/pthread_mutex_init.c +++ b/nptl/pthread_mutex_init.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -46,6 +46,11 @@ __pthread_mutex_init (mutex, mutexattr) if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0 && (imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_PSHARED) != 0) return ENOTSUP; + // XXX For now we don't support priority inherited or priority protected + // XXX mutexes. + if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) + != (PTHREAD_PRIO_NONE << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT)) + return ENOTSUP; /* Clear the whole variable. */ memset (mutex, '\0', __SIZEOF_PTHREAD_MUTEX_T); @@ -54,6 +59,27 @@ __pthread_mutex_init (mutex, mutexattr) mutex->__data.__kind = imutexattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS; if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0) mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_PRIVATE_NP; + switch ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) + >> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT) + { + case PTHREAD_PRIO_INHERIT: + mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP; + break; + case PTHREAD_PRIO_PROTECT: + mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP; + if (PTHREAD_MUTEX_PRIO_CEILING_MASK + == PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + mutex->__data.__kind |= (imutexattr->mutexkind + & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK); + else + mutex->__data.__kind |= ((imutexattr->mutexkind + & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT) + << PTHREAD_MUTEX_PRIO_CEILING_SHIFT; + break; + default: + break; + } /* Default values: mutex not used yet. */ // mutex->__count = 0; already done by memset |