From: Bart Van Assche Date: Sat, 8 Feb 2014 10:55:08 +0000 (+0000) Subject: drd: Avoid that the drd/tests/pth_mutex_reinit test fails with glibc >= 2.18 X-Git-Tag: svn/VALGRIND_3_10_0~644 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea8a9313c2039d704b450202a7e04c251f59d4e3;p=thirdparty%2Fvalgrind.git drd: Avoid that the drd/tests/pth_mutex_reinit test fails with glibc >= 2.18 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 --- diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c index 083e467424..325ad60514 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -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 + * . + */ + 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)