]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Remove "pre-history" handling for mutexes -- now that Valgrind has full control
authorNicholas Nethercote <n.nethercote@gmail.com>
Sat, 10 Apr 2004 00:54:42 +0000 (00:54 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Sat, 10 Apr 2004 00:54:42 +0000 (00:54 +0000)
from the very beginning (thanks to FV) it's no longer necessary.

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

coregrind/vg_include.h
coregrind/vg_libpthread.c
coregrind/vg_scheduler.c

index b6c1a8d705113eac8614d91ce45af00dcc3f9b7b..50a706889a12bb5e58423f790654f8911b0abc25 100644 (file)
@@ -1014,14 +1014,6 @@ extern Int     VG_(longjmpd_on_signal);
    SET_THREAD_REG(zztid, zzval, edx, EDX, post_reg_write_pthread_return)
 
 
-/* This is or'd into a pthread mutex's __m_kind field if it is used
-   before Valgrind is up and running (prehistory).  This is used so
-   that if some early code (like the dynamic linker) takes a lock
-   before Valgrind starts and then releases it afterwards, we can work
-   out what's happening. */
-#define VG_PTHREAD_PREHISTORY          0x80000000
-
-
 /* ---------------------------------------------------------------------
    Exports of vg_signals.c
    ------------------------------------------------------------------ */
index 339808a5c364ded10053249784a43e13811bcf76..e893016835329fea2860c83c4ae35f2d395ffd4f 100644 (file)
@@ -1162,20 +1162,10 @@ int __pthread_mutex_lock(pthread_mutex_t *mutex)
    vg_pthread_mutex_t* vg_mutex;
    CONVERT(mutex, mutex, vg_mutex);
    
-   if (RUNNING_ON_VALGRIND) {
-      VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
-                              VG_USERREQ__PTHREAD_MUTEX_LOCK,
-                              vg_mutex, 0, 0, 0);
-      return res;
-   } else {
-      /* Play at locking */
-      if (0)
-        kludged("prehistoric lock", NULL);
-      vg_mutex->__vg_m_owner = (/*_pthread_descr*/void*)1;
-      vg_mutex->__vg_m_count = 1;
-      vg_mutex->__vg_m_kind |= VG_PTHREAD_PREHISTORY;
-      return 0; /* success */
-   }
+   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
+                           VG_USERREQ__PTHREAD_MUTEX_LOCK,
+                           vg_mutex, 0, 0, 0);
+   return res;
 }
 
 
@@ -1185,20 +1175,10 @@ int __pthread_mutex_trylock(pthread_mutex_t *mutex)
    vg_pthread_mutex_t* vg_mutex;
    CONVERT(mutex, mutex, vg_mutex);
    
-   if (RUNNING_ON_VALGRIND) {
-      VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
-                              VG_USERREQ__PTHREAD_MUTEX_TRYLOCK,
-                              vg_mutex, 0, 0, 0);
-      return res;
-   } else {
-      /* Play at locking */
-      if (0)
-        kludged("prehistoric trylock", NULL);
-      vg_mutex->__vg_m_owner = (/*_pthread_descr*/void*)1;
-      vg_mutex->__vg_m_count = 1;
-      vg_mutex->__vg_m_kind |= VG_PTHREAD_PREHISTORY;
-      return 0; /* success */
-   }
+   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
+                           VG_USERREQ__PTHREAD_MUTEX_TRYLOCK,
+                           vg_mutex, 0, 0, 0);
+   return res;
 }
 
 
@@ -1208,20 +1188,10 @@ int __pthread_mutex_unlock(pthread_mutex_t *mutex)
    vg_pthread_mutex_t* vg_mutex;
    CONVERT(mutex, mutex, vg_mutex);
    
-   if (RUNNING_ON_VALGRIND) {
-      VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
-                              VG_USERREQ__PTHREAD_MUTEX_UNLOCK,
-                              vg_mutex, 0, 0, 0);
-      return res;
-   } else {
-      /* Play at locking */
-      if (0)
-        kludged("prehistoric unlock", NULL);
-      vg_mutex->__vg_m_owner = 0;
-      vg_mutex->__vg_m_count = 0;
-      vg_mutex->__vg_m_kind &= ~VG_PTHREAD_PREHISTORY;
-      return 0; /* success */
-   }
+   VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */,
+                           VG_USERREQ__PTHREAD_MUTEX_UNLOCK,
+                           vg_mutex, 0, 0, 0);
+   return res;
 }
 
 
index 9fc4ec12eb6e28e80b889d83c7bd5dfc2785ded2..6959d31b69e7ace41b9e7d6b446ea1e7235ca9ca 100644 (file)
@@ -2149,14 +2149,6 @@ void do_pthread_mutex_unlock ( ThreadId tid,
       return;
    }
 
-   /* If this was locked before the dawn of time, pretend it was
-      locked now so that it balances with unlocks */
-   if (mutex->__vg_m_kind & VG_PTHREAD_PREHISTORY) {
-      mutex->__vg_m_kind &= ~VG_PTHREAD_PREHISTORY;
-      VG_TRACK( pre_mutex_lock, (ThreadId)mutex->__vg_m_owner, mutex );
-      VG_TRACK( post_mutex_lock, (ThreadId)mutex->__vg_m_owner, mutex );
-   }
-
    /* More paranoia ... */
    switch (mutex->__vg_m_kind) {
 #     ifndef GLIBC_2_1