]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
drd: Avoid that the drd/tests/pth_mutex_reinit test fails with glibc >= 2.18
authorBart Van Assche <bvanassche@acm.org>
Sat, 8 Feb 2014 10:55:08 +0000 (10:55 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 8 Feb 2014 10:55:08 +0000 (10:55 +0000)
Apparently with glibc >= 2.18 the value returned by pthread_mutexattr_gettype()
is not the same as the value passed to pthread_mutexattr_settype(). Add a
workaround for this glibc bug.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13792

drd/drd_pthread_intercepts.c

index 083e46742448f1afd70dd80df083721b38056948..325ad60514796ad6679577ff049bf4959bee88e2 100644 (file)
@@ -243,8 +243,14 @@ static void DRD_(sema_up)(DrdSema* sema)
  * statement because some of the PTHREAD_MUTEX_ macro's may have the same
  * value.
  */
-static MutexT DRD_(pthread_to_drd_mutex_type)(const int kind)
+static MutexT DRD_(pthread_to_drd_mutex_type)(int kind)
 {
+   /*
+    * See also PTHREAD_MUTEX_KIND_MASK_NP in glibc source file
+    * <nptl/pthreadP.h>.
+    */
+   kind &= 3;
+
    if (kind == PTHREAD_MUTEX_RECURSIVE)
       return mutex_type_recursive_mutex;
    else if (kind == PTHREAD_MUTEX_ERRORCHECK)
@@ -258,9 +264,7 @@ static MutexT DRD_(pthread_to_drd_mutex_type)(const int kind)
       return mutex_type_default_mutex;
 #endif
    else
-   {
       return mutex_type_invalid_mutex;
-   }
 }
 
 #define IS_ALIGNED(p) (((uintptr_t)(p) & (sizeof(*(p)) - 1)) == 0)