From: Bart Van Assche Date: Tue, 21 Jul 2009 12:39:25 +0000 (+0000) Subject: Made sure that DRD does something meaningful when using another threading library... X-Git-Tag: svn/VALGRIND_3_5_0~345 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8af98b77e33ace4e7869484487cd8d0a2cbd64de;p=thirdparty%2Fvalgrind.git Made sure that DRD does something meaningful when using another threading library than LinuxThreads or the NPTL. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10503 --- diff --git a/drd/drd_mutex.c b/drd/drd_mutex.c index 514744c46a..65cf04632a 100644 --- a/drd/drd_mutex.c +++ b/drd/drd_mutex.c @@ -70,7 +70,6 @@ void DRD_(mutex_initialize)(struct mutex_info* const p, const Addr mutex, const MutexT mutex_type) { tl_assert(mutex); - tl_assert(mutex_type != mutex_type_unknown); tl_assert(p->a1 == mutex); p->cleanup = (void(*)(DrdClientobj*))mutex_cleanup; @@ -146,8 +145,6 @@ DRD_(mutex_get_or_allocate)(const Addr mutex, const MutexT mutex_type) return 0; } - tl_assert(mutex_type != mutex_type_unknown); - p = &(DRD_(clientobj_add)(mutex, ClientMutex)->mutex); DRD_(mutex_initialize)(p, mutex, mutex_type); return p; @@ -165,8 +162,6 @@ DRD_(mutex_init)(const Addr mutex, const MutexT mutex_type) { struct mutex_info* p; - tl_assert(mutex_type != mutex_type_unknown); - if (s_trace_mutex) { VG_(message)(Vg_UserMsg, @@ -349,7 +344,7 @@ void DRD_(mutex_unlock)(const Addr mutex, MutexT mutex_type) struct mutex_info* p; p = DRD_(mutex_get)(mutex); - if (mutex_type == mutex_type_unknown) + if (p && mutex_type == mutex_type_unknown) mutex_type = p->mutex_type; if (s_trace_mutex) @@ -457,6 +452,8 @@ const char* DRD_(mutex_type_name)(const MutexT mt) { switch (mt) { + case mutex_type_unknown: + return "mutex"; case mutex_type_invalid_mutex: return "invalid mutex"; case mutex_type_recursive_mutex: diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c index db33fbdcfe..8c989344cf 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -166,17 +166,18 @@ static __inline__ MutexT DRD_(mutex_type)(pthread_mutex_t* mutex) #if defined(HAVE_PTHREAD_MUTEX_T__M_KIND) /* glibc + LinuxThreads. */ const int kind = mutex->__m_kind & 3; + return DRD_(pthread_to_drd_mutex_type)(kind); #elif defined(HAVE_PTHREAD_MUTEX_T__DATA__KIND) /* glibc + NPTL. */ const int kind = mutex->__data.__kind & 3; + return DRD_(pthread_to_drd_mutex_type)(kind); #else - /* Another POSIX threads implementation. Regression tests will fail. */ - const int kind = PTHREAD_MUTEX_DEFAULT; - fprintf(stderr, - "Did not recognize your POSIX threads implementation. Giving up.\n"); - assert(0); + /* + * Another POSIX threads implementation. The mutex type won't be printed + * when enabling --trace-mutex=yes. + */ + return mutex_type_unknown; #endif - return DRD_(pthread_to_drd_mutex_type)(kind); } /**