]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Made sure that DRD does something meaningful when using another threading library...
authorBart Van Assche <bvanassche@acm.org>
Tue, 21 Jul 2009 12:39:25 +0000 (12:39 +0000)
committerBart Van Assche <bvanassche@acm.org>
Tue, 21 Jul 2009 12:39:25 +0000 (12:39 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10503

drd/drd_mutex.c
drd/drd_pthread_intercepts.c

index 514744c46a2ebaff85b00a1197a6e1f41d4b0de0..65cf04632a1d39b800ce41ccc4480679378b43ac 100644 (file)
@@ -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:
index db33fbdcfede8e16f2f5b1458d61aeb69f1611a1..8c989344cfca568a0b0e5d7ac23d86c287f98bc4 100644 (file)
@@ -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);
 }
 
 /**