Handle VG_USERREQ__PTHREAD_GET_THREADID and VG_USERREQ__RUNNING_ON_VALGRIND
cheaply, with the trivial-client-request mechanism. The latter is called
once per pthread call, even simple ones like pthread_mutex_[un]lock.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@88 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/vg_scheduler.c b/vg_scheduler.c
index 9dd5562..33cb157 100644
--- a/vg_scheduler.c
+++ b/vg_scheduler.c
@@ -549,6 +549,13 @@
SIMPLE_RETURN(
(UInt)VG_(client_memalign) ( tst, arg[1], arg[2] )
);
+
+ /* These are heavily used. */
+ case VG_USERREQ__PTHREAD_GET_THREADID:
+ SIMPLE_RETURN(tid);
+ case VG_USERREQ__RUNNING_ON_VALGRIND:
+ SIMPLE_RETURN(1);
+
default:
/* Too hard; wimp out. */
return False;
@@ -1743,13 +1750,6 @@
do_pthread_join( tid, arg[1], (void**)(arg[2]) );
break;
- /* Sigh ... this probably will cause huge numbers of major
- (expensive) scheduling events, for no real reason.
- Perhaps should be classified as a trivial-request. */
- case VG_USERREQ__PTHREAD_GET_THREADID:
- vg_threads[tid].m_edx = tid;
- break;
-
case VG_USERREQ__PTHREAD_MUTEX_INIT:
do_pthread_mutex_init( tid,
(pthread_mutex_t *)(arg[1]),