* pthread_mutex_init.c (__pthread_mutex_init): Move some

computations to compile time.
This commit is contained in:
Ulrich Drepper 2006-07-01 07:31:09 +00:00
parent 361a3706e1
commit f3be81a91c
2 changed files with 31 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2006-07-01 Ulrich Drepper <drepper@redhat.com>
* pthread_mutex_init.c (__pthread_mutex_init): Move some
computations to compile time.
2006-06-04 Ulrich Drepper <drepper@redhat.com> 2006-06-04 Ulrich Drepper <drepper@redhat.com>
* sysdeps/pthread/pthread.h: Add pthread_equal inline version. * sysdeps/pthread/pthread.h: Add pthread_equal inline version.

View File

@ -41,11 +41,25 @@ __pthread_mutex_init (mutex, mutexattr)
imutexattr = (const struct pthread_mutexattr *) mutexattr ?: &default_attr; imutexattr = (const struct pthread_mutexattr *) mutexattr ?: &default_attr;
/* Sanity checks. */ /* Sanity checks. */
// XXX For now we don't support priority inherited or priority protected // XXX For now we don't support priority protected mutexes.
// XXX mutexes. switch (__builtin_expect (imutexattr->mutexkind
if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) & PTHREAD_MUTEXATTR_PROTOCOL_MASK,
!= (PTHREAD_PRIO_NONE << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT)) PTHREAD_PRIO_NONE
return ENOTSUP; << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT))
{
case PTHREAD_PRIO_NONE << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
break;
case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
#ifndef __ASSUME_SET_ROBUST_LIST
if (__set_robust_list_avail < 0)
return ENOTSUP;
#endif
break;
default:
return ENOTSUP;
}
/* Clear the whole variable. */ /* Clear the whole variable. */
memset (mutex, '\0', __SIZEOF_PTHREAD_MUTEX_T); memset (mutex, '\0', __SIZEOF_PTHREAD_MUTEX_T);
@ -64,14 +78,14 @@ __pthread_mutex_init (mutex, mutexattr)
mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_NORMAL_NP; mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_NORMAL_NP;
} }
switch ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) switch (imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK)
>> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT)
{ {
case PTHREAD_PRIO_INHERIT: case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP; mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_NP;
break; break;
case PTHREAD_PRIO_PROTECT:
mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP; case PTHREAD_PRIO_PROTECT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_PROTECT_NP;
if (PTHREAD_MUTEX_PRIO_CEILING_MASK if (PTHREAD_MUTEX_PRIO_CEILING_MASK
== PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) == PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
mutex->__data.__kind |= (imutexattr->mutexkind mutex->__data.__kind |= (imutexattr->mutexkind
@ -82,6 +96,7 @@ __pthread_mutex_init (mutex, mutexattr)
>> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT) >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT)
<< PTHREAD_MUTEX_PRIO_CEILING_SHIFT; << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
break; break;
default: default:
break; break;
} }