Made spinlocks work again.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8372
This commit is contained in:
Bart Van Assche 2008-07-07 08:10:56 +00:00
parent 53a4604803
commit def3aa6461
3 changed files with 22 additions and 8 deletions

View 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:

View 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. */

View 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;
}