about summary refs log tree commit diff
path: root/nptl/pthread_mutex_init.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2006-02-28 09:57:07 +0000
committerRoland McGrath <roland@gnu.org>2006-02-28 09:57:07 +0000
commita5f2bd861c4c84ac66164951a7f32e1d6f57849c (patch)
tree513c87adf7cf9e919713fc3e0f55959a6b2f6d3b /nptl/pthread_mutex_init.c
parent8d2e6a0383b6958311f021ee0b8b7eba44110f5a (diff)
downloadglibc-a5f2bd861c4c84ac66164951a7f32e1d6f57849c.tar.gz
glibc-a5f2bd861c4c84ac66164951a7f32e1d6f57849c.tar.xz
glibc-a5f2bd861c4c84ac66164951a7f32e1d6f57849c.zip
* elf/rtld-Rules (subdir-args): New variable.
	(rtld-subdir-make): Use it.
Diffstat (limited to 'nptl/pthread_mutex_init.c')
-rw-r--r--nptl/pthread_mutex_init.c28
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