]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Made spinlocks work again.
authorBart Van Assche <bvanassche@acm.org>
Mon, 7 Jul 2008 08:10:56 +0000 (08:10 +0000)
committerBart Van Assche <bvanassche@acm.org>
Mon, 7 Jul 2008 08:10:56 +0000 (08:10 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8372

drd/drd_clientreq.c
drd/drd_clientreq.h
drd/drd_pthread_intercepts.c

index e83d0e67d9881b39767cd0e2eee5e244fbe9c9da..9a267e541df1bb9d7b215a2141452a22d2115715 100644 (file)
@@ -247,9 +247,13 @@ static Bool drd_handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret)
     thread_leave_synchr(drd_tid);
     break;
 
-  case VG_USERREQ__SPIN_INIT_OR_UNLOCK:
-    tl_assert(thread_get_synchr_nesting_count(drd_tid) == 0);
-    drd_spin_init_or_unlock(arg[1]);
+  case VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK:
+    if (thread_enter_synchr(drd_tid) == 0)
+      drd_spin_init_or_unlock(arg[1]);
+    break;
+
+  case VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK:
+    thread_leave_synchr(drd_tid);
     break;
 
   case VG_USERREQ__PRE_COND_INIT:
index 57bd9d13d363d763d10ebdffca90a566734f065e..24033827ad68103d0542e8763ea781d2a3415bd4 100644 (file)
@@ -83,8 +83,12 @@ enum {
   /* to notify the drd tool of pthread_mutex_unlock calls */
   VG_USERREQ__POST_MUTEX_UNLOCK,
   /* args: Addr */
-  VG_USERREQ__SPIN_INIT_OR_UNLOCK,
-  /* args: Addr spinlock */
+  /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */
+  VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK,
+  /* args: Addr */
+  /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */
+  VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK,
+  /* args: Addr */
 
 
   /* to notify the drd tool of a pthread_cond_init call. */
index cd642f1a37f25e8648065cbabbd116fb86246707..62dd1d9d5663a959af24d6620ebf6f0485b34e6f 100644 (file)
@@ -550,9 +550,11 @@ PTH_FUNC(int, pthreadZuspinZuinit, // pthread_spin_init
   int res;
   OrigFn fn;
   VALGRIND_GET_ORIG_FN(fn);
-  VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SPIN_INIT_OR_UNLOCK,
-                             spinlock, mutex_type_spinlock, 0, 0, 0);
+  VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK,
+                             spinlock, 0, 0, 0, 0);
   CALL_FN_W_WW(ret, fn, spinlock, pshared);
+  VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK,
+                             spinlock, 0, 0, 0, 0);
   return ret;
 }
 
@@ -564,6 +566,8 @@ PTH_FUNC(int, pthreadZuspinZudestroy, // pthread_spin_destroy
   int res;
   OrigFn fn;
   VALGRIND_GET_ORIG_FN(fn);
+  VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_MUTEX_DESTROY,
+                             spinlock, 0, 0, 0, 0);
   CALL_FN_W_W(ret, fn, spinlock);
   VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_DESTROY,
                              spinlock, mutex_type_spinlock, 0, 0, 0);
@@ -610,9 +614,11 @@ PTH_FUNC(int, pthreadZuspinZuunlock, // pthread_spin_unlock
   int   res;
   OrigFn fn;
   VALGRIND_GET_ORIG_FN(fn);
-  VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SPIN_INIT_OR_UNLOCK,
+  VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK,
                              spinlock, mutex_type_spinlock, 0, 0, 0);
   CALL_FN_W_W(ret, fn, spinlock);
+  VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK,
+                             spinlock, 0, 0, 0, 0);
   return ret;
 }