This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PTHREAD_PRIO_{INHERIT,PROTECT} mutexes (so far just stubs)


Hi!

This patch adds stubs for TPI/TPP support (but doesn't enable
the options in bits/posix_opt.h yet).  What is missing is handling
these kind of mutexes in pthread_mutex_{lock,trylock,unlock,timedlock}.c
and adding some corresponding locking for pthread_mutex_setprioceiling.c.

2006-02-27  Jakub Jelinek  <jakub@redhat.com>

	* Makefile (libpthread-routines): Add
	pthread_mutexattr_[sg]etprotocol, pthread_mutexattr_[sg]etprioceiling
	and pthread_mutex_[sg]etprioceiling.
	* Versions (GLIBC_2.4): Export pthread_mutexattr_getprotocol,
	pthread_mutexattr_setprotocol, pthread_mutexattr_getprioceiling,
	pthread_mutexattr_setprioceiling, pthread_mutex_getprioceiling and
	pthread_mutex_setprioceiling.
	* sysdeps/pthread/pthread.h (PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT,
	PTHREAD_PRIO_PROTECT): New enum values.
	(pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol,
	pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling,
	pthread_mutex_getprioceiling, pthread_mutex_setprioceiling): New
	prototypes.
	* pthreadP.h (PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP,
	PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP): New enum values.
	(PTHREAD_MUTEX_PRIO_CEILING_SHIFT, PTHREAD_MUTEX_PRIO_CEILING_MASK):
	Define.
	(PTHREAD_MUTEXATTR_PROTOCOL_SHIFT, PTHREAD_MUTEXATTR_PROTOCOL_MASK,
	PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT,
	PTHREAD_MUTEXATTR_PRIO_CEILING_MASK): Define.
	(PTHREAD_MUTEXATTR_FLAG_BITS): Or in PTHREAD_MUTEXATTR_PROTOCOL_MASK
	and PTHREAD_MUTEXATTR_PRIO_CEILING_MASK.
	* pthread_mutex_init.c (__pthread_mutex_init): For the time being
	return ENOTSUP for PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT
	protocol mutexes.
	* pthread_mutex_getprioceiling.c: New file.
	* pthread_mutex_setprioceiling.c: New file.
	* pthread_mutexattr_getprioceiling.c: New file.
	* pthread_mutexattr_setprioceiling.c: New file.
	* pthread_mutexattr_getprotocol.c: New file.
	* pthread_mutexattr_setprotocol.c: New file.

--- libc/nptl/sysdeps/pthread/pthread.h.jj	2006-02-17 09:09:45.000000000 +0100
+++ libc/nptl/sysdeps/pthread/pthread.h	2006-02-27 18:43:06.000000000 +0100
@@ -71,6 +71,17 @@ enum
 #endif
 
 
+#ifdef __USE_UNIX98
+/* Mutex protocols.  */
+enum
+{
+  PTHREAD_PRIO_NONE,
+  PTHREAD_PRIO_INHERIT,
+  PTHREAD_PRIO_PROTECT
+};
+#endif
+
+
 /* Mutex initializers.  */
 #if __WORDSIZE == 64
 # define PTHREAD_MUTEX_INITIALIZER \
@@ -711,6 +722,22 @@ extern int pthread_mutex_timedlock (pthr
 extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW;
 
 
+#ifdef __USE_UNIX98
+/* Get the priority ceiling of MUTEX.  */
+extern int pthread_mutex_getprioceiling (__const pthread_mutex_t *
+					 __restrict __mutex,
+					 int *__restrict __prioceiling)
+     __THROW;
+
+/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
+   priority ceiling value in *OLD_CEILING.  */
+extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
+					 int __prioceiling,
+					 int *__restrict __old_ceiling)
+     __THROW;
+#endif
+
+
 #ifdef __USE_GNU
 /* Declare the state protected by MUTEX as consistent.  */
 extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex) __THROW;
@@ -745,6 +772,26 @@ extern int pthread_mutexattr_gettype (__
    PTHREAD_MUTEX_DEFAULT).  */
 extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
      __THROW;
+
+/* Return in *PROTOCOL the mutex protocol attribute in *ATTR.  */
+extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t *
+					  __restrict __attr,
+					  int *__restrict __protocol) __THROW;
+
+/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
+   PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT).  */
+extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
+					  int __protocol) __THROW;
+
+/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR.  */
+extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t *
+					     __restrict __attr,
+					     int *__restrict __prioceiling)
+     __THROW;
+
+/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING.  */
+extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
+					     int __prioceiling) __THROW;
 #endif
 
 #ifdef __USE_GNU
--- libc/nptl/Makefile.jj	2006-02-17 09:09:45.000000000 +0100
+++ libc/nptl/Makefile	2006-02-27 18:43:06.000000000 +0100
@@ -118,7 +118,12 @@ libpthread-routines = init vars events v
 		      pthread_attr_getaffinity pthread_attr_setaffinity \
 		      pthread_mutexattr_getrobust pthread_mutexattr_setrobust \
 		      pthread_mutex_consistent \
-		      cleanup_routine unwind-forcedunwind
+		      cleanup_routine unwind-forcedunwind \
+		      pthread_mutexattr_getprotocol \
+		      pthread_mutexattr_setprotocol \
+		      pthread_mutexattr_getprioceiling \
+		      pthread_mutexattr_setprioceiling \
+		      pthread_mutex_getprioceiling pthread_mutex_setprioceiling
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
 #		      pthread_setgid pthread_setegid pthread_setregid \
--- libc/nptl/pthread_mutexattr_getprioceiling.c.jj	2006-02-27 18:43:06.000000000 +0100
+++ libc/nptl/pthread_mutexattr_getprioceiling.c	2006-02-27 18:43:06.000000000 +0100
@@ -0,0 +1,36 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_getprioceiling (attr, prioceiling)
+     const pthread_mutexattr_t *attr;
+     int *prioceiling;
+{
+  const struct pthread_mutexattr *iattr;
+
+  iattr = (const struct pthread_mutexattr *) attr;
+
+  *prioceiling = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+		  >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT);
+
+  return 0;
+}
--- libc/nptl/pthread_mutexattr_getprotocol.c.jj	2006-02-27 18:43:06.000000000 +0100
+++ libc/nptl/pthread_mutexattr_getprotocol.c	2006-02-27 18:43:06.000000000 +0100
@@ -0,0 +1,36 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_getprotocol (attr, protocol)
+     const pthread_mutexattr_t *attr;
+     int *protocol;
+{
+  const struct pthread_mutexattr *iattr;
+
+  iattr = (const struct pthread_mutexattr *) attr;
+
+  *protocol = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK)
+	       >> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT);
+
+  return 0;
+}
--- libc/nptl/pthread_mutex_getprioceiling.c.jj	2006-02-27 18:43:06.000000000 +0100
+++ libc/nptl/pthread_mutex_getprioceiling.c	2006-02-27 18:43:06.000000000 +0100
@@ -0,0 +1,32 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthreadP.h>
+
+
+int
+pthread_mutex_getprioceiling (mutex, prioceiling)
+     const pthread_mutex_t *mutex;
+     int *prioceiling;
+{
+  *prioceiling = (mutex->__data.__kind & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+		 >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+  return 0;
+}
--- libc/nptl/pthread_mutex_init.c.jj	2005-12-30 09:04:04.000000000 +0100
+++ libc/nptl/pthread_mutex_init.c	2006-02-27 18:44:39.000000000 +0100
@@ -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
--- libc/nptl/pthread_mutexattr_setprioceiling.c.jj	2006-02-27 18:43:06.000000000 +0100
+++ libc/nptl/pthread_mutexattr_setprioceiling.c	2006-02-27 18:43:06.000000000 +0100
@@ -0,0 +1,39 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_setprioceiling (attr, prioceiling)
+     pthread_mutexattr_t *attr;
+     int prioceiling;
+{
+  if (prioceiling < 0
+      && __builtin_expect (prioceiling > 255, 0))
+    return EINVAL;
+
+  struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr;
+
+  iattr->mutexkind = (iattr->mutexkind & ~PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+		     | (prioceiling << PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT);
+
+  return 0;
+}
--- libc/nptl/pthreadP.h.jj	2006-02-17 09:09:45.000000000 +0100
+++ libc/nptl/pthreadP.h	2006-02-27 18:43:06.000000000 +0100
@@ -66,15 +66,24 @@ enum
   PTHREAD_MUTEX_ROBUST_PRIVATE_ERRORCHECK_NP
   = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
   PTHREAD_MUTEX_ROBUST_PRIVATE_ADAPTIVE_NP
-  = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ADAPTIVE_NP
+  = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
+  PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP = 32,
+  PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP = 64
 };
+#define PTHREAD_MUTEX_PRIO_CEILING_SHIFT	16
+#define PTHREAD_MUTEX_PRIO_CEILING_MASK		0x00ff0000
 
 
 /* Flags in mutex attr.  */
-#define PTHREAD_MUTEXATTR_FLAG_ROBUST	0x40000000
-#define PTHREAD_MUTEXATTR_FLAG_PSHARED	0x80000000
+#define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT	28
+#define PTHREAD_MUTEXATTR_PROTOCOL_MASK		0x30000000
+#define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT	16
+#define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK	0x00ff0000
+#define PTHREAD_MUTEXATTR_FLAG_ROBUST		0x40000000
+#define PTHREAD_MUTEXATTR_FLAG_PSHARED		0x80000000
 #define PTHREAD_MUTEXATTR_FLAG_BITS \
-  (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED)
+  (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \
+   | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
 
 
 /* Bits used in robust mutex implementation.  */
--- libc/nptl/Versions.jj	2005-12-30 09:04:04.000000000 +0100
+++ libc/nptl/Versions	2006-02-27 18:43:06.000000000 +0100
@@ -235,6 +235,9 @@ libpthread {
   GLIBC_2.4 {
     pthread_mutexattr_getrobust_np; pthread_mutexattr_setrobust_np;
     pthread_mutex_consistent_np;
+    pthread_mutexattr_getprotocol; pthread_mutexattr_setprotocol;
+    pthread_mutexattr_getprioceiling; pthread_mutexattr_setprioceiling;
+    pthread_mutex_getprioceiling; pthread_mutex_setprioceiling;
   };
 
   GLIBC_PRIVATE {
--- libc/nptl/pthread_mutex_setprioceiling.c.jj	2006-02-27 18:43:06.000000000 +0100
+++ libc/nptl/pthread_mutex_setprioceiling.c	2006-02-27 18:43:06.000000000 +0100
@@ -0,0 +1,55 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutex_setprioceiling (mutex, prioceiling, old_ceiling)
+     pthread_mutex_t *mutex;
+     int prioceiling;
+     int *old_ceiling;
+{
+  /* The low bits of __kind aren't ever changed after pthread_mutex_init,
+     so we don't need a lock yet.  */
+  if ((mutex->__data.__kind & PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP) == 0)
+    return EINVAL;
+
+  if (prioceiling < 0
+      && __builtin_expect (prioceiling > 255, 0))
+    return EINVAL;
+
+  /* XXX This needs to lock with TID, but shouldn't obey priority protect
+     protocol.  */
+  /* lll_xxx_mutex_lock (mutex->__data.__lock); */
+
+  if (old_ceiling != NULL)
+    *old_ceiling = (mutex->__data.__kind & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+		   >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+  int newkind = (mutex->__data.__kind & ~PTHREAD_MUTEX_PRIO_CEILING_MASK);
+  mutex->__data.__kind = newkind
+			 | (prioceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT);
+
+  /* XXX This needs to unlock the above special kind of lock.  */
+  /* lll_xxx_mutex_unlock (mutex->__data.__lock); */
+
+  return 0;
+}
--- libc/nptl/pthread_mutexattr_setprotocol.c.jj	2006-02-27 18:43:06.000000000 +0100
+++ libc/nptl/pthread_mutexattr_setprotocol.c	2006-02-27 18:43:06.000000000 +0100
@@ -0,0 +1,40 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_setprotocol (attr, protocol)
+     pthread_mutexattr_t *attr;
+     int protocol;
+{
+  if (protocol != PTHREAD_PRIO_NONE
+      && protocol != PTHREAD_PRIO_INHERIT
+      && __builtin_expect (protocol != PTHREAD_PRIO_PROTECT, 0))
+    return EINVAL;
+
+  struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr;
+
+  iattr->mutexkind = (iattr->mutexkind & ~PTHREAD_MUTEXATTR_PROTOCOL_MASK)
+		     | (protocol << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT);
+
+  return 0;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]