Replaced code for suppressing the stack memory in use at the time a
thread is being created by code for suppressing the memory allocated
from inside the pthread_create() call. The new implementation should be
a more portable solution for suppressing data races triggered by the
thread-local-storage implementation of a Pthreads library.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10584 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/drd/drd_thread.h b/drd/drd_thread.h
index 710f905..ea352b9 100644
--- a/drd/drd_thread.h
+++ b/drd/drd_thread.h
@@ -90,6 +90,8 @@
    Bool      is_recording_loads;
    /** Wether recording of memory load accesses is currently enabled. */
    Bool      is_recording_stores;
+   /** pthread_create() nesting level. */
+   Int       pthread_create_nesting_level;
    /** Nesting level of synchronization functions called by the client. */
    Int       synchr_nesting;
 } ThreadInfo;
@@ -143,6 +145,8 @@
 void DRD_(thread_set_pthreadid)(const DrdThreadId tid, const PThreadId ptid);
 Bool DRD_(thread_get_joinable)(const DrdThreadId tid);
 void DRD_(thread_set_joinable)(const DrdThreadId tid, const Bool joinable);
+void DRD_(thread_entering_pthread_create)(const DrdThreadId tid);
+void DRD_(thread_left_pthread_create)(const DrdThreadId tid);
 const char* DRD_(thread_get_name)(const DrdThreadId tid);
 void DRD_(thread_set_name)(const DrdThreadId tid, const char* const name);
 void DRD_(thread_set_vg_running_tid)(const ThreadId vg_tid);
@@ -209,7 +213,9 @@
 static __inline__
 DrdThreadId DRD_(thread_get_running_tid)(void)
 {
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
    tl_assert(DRD_(g_drd_running_tid) != DRD_INVALID_THREADID);
+#endif
    return DRD_(g_drd_running_tid);
 }
 
@@ -221,8 +227,19 @@
 }
 
 /**
- * Reports whether or not memory access recording is enabled for the 
- * currently running thread.
+ * Reports whether or not the currently running client thread is executing code
+ * inside the pthread_create() function.
+ */
+static __inline__
+Bool DRD_(running_thread_inside_pthread_create)(void)
+{
+   return (DRD_(g_threadinfo)[DRD_(g_drd_running_tid)]
+           .pthread_create_nesting_level > 0);
+}
+
+/**
+ * Reports whether or not recording of memory loads is enabled for the 
+ * currently running client thread.
  */
 static __inline__
 Bool DRD_(running_thread_is_recording_loads)(void)
@@ -236,6 +253,10 @@
            && DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].is_recording_loads);
 }
 
+/**
+ * Reports whether or not recording memory stores is enabled for the 
+ * currently running client thread.
+ */
 static __inline__
 Bool DRD_(running_thread_is_recording_stores)(void)
 {