mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-27 03:41:23 +08:00
* pthread_mutex_init.c (__pthread_mutex_init): Move some
computations to compile time.
This commit is contained in:
parent
361a3706e1
commit
f3be81a91c
@ -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>
|
||||
|
||||
* sysdeps/pthread/pthread.h: Add pthread_equal inline version.
|
||||
|
@ -41,11 +41,25 @@ __pthread_mutex_init (mutex, mutexattr)
|
||||
imutexattr = (const struct pthread_mutexattr *) mutexattr ?: &default_attr;
|
||||
|
||||
/* Sanity checks. */
|
||||
// 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;
|
||||
// XXX For now we don't support priority protected mutexes.
|
||||
switch (__builtin_expect (imutexattr->mutexkind
|
||||
& PTHREAD_MUTEXATTR_PROTOCOL_MASK,
|
||||
PTHREAD_PRIO_NONE
|
||||
<< 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. */
|
||||
memset (mutex, '\0', __SIZEOF_PTHREAD_MUTEX_T);
|
||||
@ -64,14 +78,14 @@ __pthread_mutex_init (mutex, mutexattr)
|
||||
mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_NORMAL_NP;
|
||||
}
|
||||
|
||||
switch ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK)
|
||||
>> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT)
|
||||
switch (imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK)
|
||||
{
|
||||
case PTHREAD_PRIO_INHERIT:
|
||||
mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP;
|
||||
case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
|
||||
mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_NP;
|
||||
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
|
||||
== PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
|
||||
mutex->__data.__kind |= (imutexattr->mutexkind
|
||||
@ -82,6 +96,7 @@ __pthread_mutex_init (mutex, mutexattr)
|
||||
>> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT)
|
||||
<< PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user