00db10
commit 2868e0703d5b8c8e60c6f60de13e876c4d85daa0
00db10
Author: Andreas Schwab <schwab@suse.de>
00db10
Date:   Mon Aug 11 11:18:26 2014 +0200
00db10
00db10
    Filter out PTHREAD_MUTEX_NO_ELISION_NP bit in pthread_mutexattr_gettype (BZ #15790)
00db10
    
00db10
    pthread_mutexattr_settype adds PTHREAD_MUTEX_NO_ELISION_NP to kind,
00db10
    which is an internal flag that pthread_mutexattr_gettype shouldn't
00db10
    expose, since pthread_mutexattr_settype wouldn't accept it.
00db10
Index: glibc-2.17-c758a686/nptl/Makefile
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/nptl/Makefile
00db10
+++ glibc-2.17-c758a686/nptl/Makefile
00db10
@@ -252,6 +252,7 @@ tests = tst-typesizes \
00db10
 	tst-exit1 tst-exit2 tst-exit3 \
00db10
 	tst-stdio1 tst-stdio2 \
00db10
 	tst-stack1 tst-stack2 tst-stack3 tst-stack4 tst-pthread-getattr \
00db10
+	tst-pthread-mutexattr \
00db10
 	tst-unload \
00db10
 	tst-dlsym1 \
00db10
 	tst-sysconf \
00db10
Index: glibc-2.17-c758a686/nptl/pthread_mutexattr_gettype.c
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/nptl/pthread_mutexattr_gettype.c
00db10
+++ glibc-2.17-c758a686/nptl/pthread_mutexattr_gettype.c
00db10
@@ -28,7 +28,8 @@ pthread_mutexattr_gettype (attr, kind)
00db10
 
00db10
   iattr = (const struct pthread_mutexattr *) attr;
00db10
 
00db10
-  *kind = iattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS;
00db10
+  *kind = (iattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS
00db10
+	   & ~PTHREAD_MUTEX_NO_ELISION_NP);
00db10
 
00db10
   return 0;
00db10
 }
00db10
Index: glibc-2.17-c758a686/nptl/tst-pthread-mutexattr.c
00db10
===================================================================
00db10
--- /dev/null
00db10
+++ glibc-2.17-c758a686/nptl/tst-pthread-mutexattr.c
00db10
@@ -0,0 +1,60 @@
00db10
+/* Make sure that pthread_mutexattr_gettype returns a valid kind.
00db10
+
00db10
+   Copyright (C) 2015 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#include <stdio.h>
00db10
+#include <string.h>
00db10
+#include <pthread.h>
00db10
+
00db10
+static int
00db10
+do_test (void)
00db10
+{
00db10
+  pthread_mutexattr_t attr;
00db10
+  int kind;
00db10
+  int error;
00db10
+
00db10
+  error = pthread_mutexattr_init (&attr);
00db10
+  if (error)
00db10
+    {
00db10
+      printf ("pthread_mutexattr_init: %s\n", strerror (error));
00db10
+      return 1;
00db10
+    }
00db10
+  error = pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_DEFAULT);
00db10
+  if (error)
00db10
+    {
00db10
+      printf ("pthread_mutexattr_settype (1): %s\n", strerror (error));
00db10
+      return 1;
00db10
+    }
00db10
+  error = pthread_mutexattr_gettype (&attr, &kind);
00db10
+  if (error)
00db10
+    {
00db10
+      printf ("pthread_mutexattr_gettype: %s\n", strerror (error));
00db10
+      return 1;
00db10
+    }
00db10
+  error = pthread_mutexattr_settype (&attr, kind);
00db10
+  if (error)
00db10
+    {
00db10
+      printf ("pthread_mutexattr_settype (2): %s\n", strerror (error));
00db10
+      return 1;
00db10
+    }
00db10
+  return 0;
00db10
+}
00db10
+
00db10
+
00db10
+#define TEST_FUNCTION do_test ()
00db10
+#include "../test-skeleton.c"