]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Wrapped DRD_() macro around global and static variables in drd_thread.[ch].
authorBart Van Assche <bvanassche@acm.org>
Sun, 15 Feb 2009 12:14:52 +0000 (12:14 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 15 Feb 2009 12:14:52 +0000 (12:14 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9167

drd/drd_thread.c
drd/drd_thread.h

index 0892118f014f2703ef16407ae612f478ed4f482f..cdb02822e34a1c0485bfe58182ca95eee41b90d7 100644 (file)
@@ -45,7 +45,7 @@
 
 
 
-// Local functions.
+/* Local functions. */
 
 static void thread_append_segment(const DrdThreadId tid,
                                   Segment* const sg);
@@ -55,60 +55,60 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set,
                                         const DrdThreadId tid);
 
 
-// Local variables.
+/* Local variables. */
 
-static ULong s_context_switch_count;
-static ULong s_discard_ordered_segments_count;
-static ULong s_update_conflict_set_count;
-static ULong s_conflict_set_new_segment_count;
-static ULong s_conflict_set_combine_vc_count;
-static ULong s_conflict_set_bitmap_creation_count;
-static ULong s_conflict_set_bitmap2_creation_count;
-static ThreadId    s_vg_running_tid  = VG_INVALID_THREADID;
-DrdThreadId s_drd_running_tid = DRD_INVALID_THREADID;
-ThreadInfo s_threadinfo[DRD_N_THREADS];
-struct bitmap* s_conflict_set;
-static Bool s_trace_context_switches = False;
-static Bool s_trace_conflict_set = False;
-static Bool s_trace_fork_join = False;
-static Bool s_segment_merging = True;
+static ULong    DRD_(s_context_switch_count);
+static ULong    DRD_(s_discard_ordered_segments_count);
+static ULong    DRD_(s_update_conflict_set_count);
+static ULong    DRD_(s_conflict_set_new_segment_count);
+static ULong    DRD_(s_conflict_set_combine_vc_count);
+static ULong    DRD_(s_conflict_set_bitmap_creation_count);
+static ULong    DRD_(s_conflict_set_bitmap2_creation_count);
+static ThreadId DRD_(s_vg_running_tid)  = VG_INVALID_THREADID;
+DrdThreadId     DRD_(g_drd_running_tid) = DRD_INVALID_THREADID;
+ThreadInfo      DRD_(g_threadinfo)[DRD_N_THREADS];
+struct bitmap*  DRD_(g_conflict_set);
+static Bool     DRD_(s_trace_context_switches) = False;
+static Bool     DRD_(s_trace_conflict_set) = False;
+static Bool     DRD_(s_trace_fork_join) = False;
+static Bool     DRD_(s_segment_merging) = True;
 
 
-// Function definitions.
+/* Function definitions. */
 
 void thread_trace_context_switches(const Bool t)
 {
   tl_assert(t == False || t == True);
-  s_trace_context_switches = t;
+  DRD_(s_trace_context_switches) = t;
 }
 
 void thread_trace_conflict_set(const Bool t)
 {
   tl_assert(t == False || t == True);
-  s_trace_conflict_set = t;
+  DRD_(s_trace_conflict_set) = t;
 }
 
 Bool DRD_(thread_get_trace_fork_join)(void)
 {
-  return s_trace_fork_join;
+  return DRD_(s_trace_fork_join);
 }
 
 void DRD_(thread_set_trace_fork_join)(const Bool t)
 {
   tl_assert(t == False || t == True);
-  s_trace_fork_join = t;
+  DRD_(s_trace_fork_join) = t;
 }
 
 void thread_set_segment_merging(const Bool m)
 {
   tl_assert(m == False || m == True);
-  s_segment_merging = m;
+  DRD_(s_segment_merging) = m;
 }
 
 /**
  * Convert Valgrind's ThreadId into a DrdThreadId. Report failure if
  * Valgrind's ThreadId does not yet exist.
- **/
+ */
 DrdThreadId VgThreadIdToDrdThreadId(const ThreadId tid)
 {
   int i;
@@ -118,8 +118,8 @@ DrdThreadId VgThreadIdToDrdThreadId(const ThreadId tid)
 
   for (i = 1; i < DRD_N_THREADS; i++)
   {
-    if (s_threadinfo[i].vg_thread_exists == True
-        && s_threadinfo[i].vg_threadid == tid)
+    if (DRD_(g_threadinfo)[i].vg_thread_exists == True
+        && DRD_(g_threadinfo)[i].vg_threadid == tid)
     {
       return i;
     }
@@ -137,23 +137,23 @@ DrdThreadId VgThreadIdToNewDrdThreadId(const ThreadId tid)
 
   for (i = 1; i < DRD_N_THREADS; i++)
   {
-    if (s_threadinfo[i].vg_thread_exists == False
-        && s_threadinfo[i].posix_thread_exists == False
-        && s_threadinfo[i].detached_posix_thread == False)
+    if (DRD_(g_threadinfo)[i].vg_thread_exists == False
+        && DRD_(g_threadinfo)[i].posix_thread_exists == False
+        && DRD_(g_threadinfo)[i].detached_posix_thread == False)
     {
-      s_threadinfo[i].vg_thread_exists = True;
-      s_threadinfo[i].vg_threadid   = tid;
-      s_threadinfo[i].pt_threadid   = INVALID_POSIX_THREADID;
-      s_threadinfo[i].stack_min     = 0;
-      s_threadinfo[i].stack_min_min = 0;
-      s_threadinfo[i].stack_startup = 0;
-      s_threadinfo[i].stack_max     = 0;
-      s_threadinfo[i].is_recording  = True;
-      s_threadinfo[i].synchr_nesting = 0;
-      if (s_threadinfo[i].first != 0)
+      DRD_(g_threadinfo)[i].vg_thread_exists = True;
+      DRD_(g_threadinfo)[i].vg_threadid   = tid;
+      DRD_(g_threadinfo)[i].pt_threadid   = INVALID_POSIX_THREADID;
+      DRD_(g_threadinfo)[i].stack_min     = 0;
+      DRD_(g_threadinfo)[i].stack_min_min = 0;
+      DRD_(g_threadinfo)[i].stack_startup = 0;
+      DRD_(g_threadinfo)[i].stack_max     = 0;
+      DRD_(g_threadinfo)[i].is_recording  = True;
+      DRD_(g_threadinfo)[i].synchr_nesting = 0;
+      if (DRD_(g_threadinfo)[i].first != 0)
         VG_(printf)("drd thread id = %d\n", i);
-      tl_assert(s_threadinfo[i].first == 0);
-      tl_assert(s_threadinfo[i].last == 0);
+      tl_assert(DRD_(g_threadinfo)[i].first == 0);
+      tl_assert(DRD_(g_threadinfo)[i].last == 0);
       return i;
     }
   }
@@ -171,8 +171,8 @@ DrdThreadId PtThreadIdToDrdThreadId(const PThreadId tid)
 
   for (i = 1; i < DRD_N_THREADS; i++)
   {
-    if (s_threadinfo[i].posix_thread_exists
-        && s_threadinfo[i].pt_threadid == tid)
+    if (DRD_(g_threadinfo)[i].posix_thread_exists
+        && DRD_(g_threadinfo)[i].pt_threadid == tid)
     {
       return i;
     }
@@ -184,15 +184,16 @@ ThreadId DrdThreadIdToVgThreadId(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  return (s_threadinfo[tid].vg_thread_exists
-          ? s_threadinfo[tid].vg_threadid
+  return (DRD_(g_threadinfo)[tid].vg_thread_exists
+          ? DRD_(g_threadinfo)[tid].vg_threadid
           : VG_INVALID_THREADID);
 }
 
 #if 0
-/** Sanity check of the doubly linked list of segments referenced by a
- *  ThreadInfo struct.
- *  @return True if sane, False if not.
+/**
+ * Sanity check of the doubly linked list of segments referenced by a
+ * ThreadInfo struct.
+ * @return True if sane, False if not.
  */
 static Bool sane_ThreadInfo(const ThreadInfo* const ti)
 {
@@ -231,15 +232,15 @@ DrdThreadId thread_pre_create(const DrdThreadId creator,
   tl_assert(0 <= (int)created && created < DRD_N_THREADS
             && created != DRD_INVALID_THREADID);
 
-  tl_assert(s_threadinfo[created].first == 0);
-  tl_assert(s_threadinfo[created].last == 0);
+  tl_assert(DRD_(g_threadinfo)[created].first == 0);
+  tl_assert(DRD_(g_threadinfo)[created].last == 0);
   thread_append_segment(created, DRD_(sg_new)(creator, created));
 
   return created;
 }
 
 /**
- * Initialize s_threadinfo[] for a newly created thread. Must be called after
+ * Initialize DRD_(g_threadinfo)[] for a newly created thread. Must be called after
  * the thread has been created and before any client instructioins are run
  * on the newly created thread, e.g. from the handler installed via
  * VG_(track_pre_thread_first_insn)().
@@ -251,18 +252,20 @@ DrdThreadId thread_post_create(const ThreadId vg_created)
   tl_assert(0 <= (int)created && created < DRD_N_THREADS
             && created != DRD_INVALID_THREADID);
 
-  s_threadinfo[created].stack_max     = VG_(thread_get_stack_max)(vg_created);
-  s_threadinfo[created].stack_startup = s_threadinfo[created].stack_max;
-  s_threadinfo[created].stack_min     = s_threadinfo[created].stack_max;
-  s_threadinfo[created].stack_min_min = s_threadinfo[created].stack_max;
-  s_threadinfo[created].stack_size    = VG_(thread_get_stack_size)(vg_created);
-  tl_assert(s_threadinfo[created].stack_max != 0);
+  DRD_(g_threadinfo)[created].stack_max     = VG_(thread_get_stack_max)(vg_created);
+  DRD_(g_threadinfo)[created].stack_startup = DRD_(g_threadinfo)[created].stack_max;
+  DRD_(g_threadinfo)[created].stack_min     = DRD_(g_threadinfo)[created].stack_max;
+  DRD_(g_threadinfo)[created].stack_min_min = DRD_(g_threadinfo)[created].stack_max;
+  DRD_(g_threadinfo)[created].stack_size    = VG_(thread_get_stack_size)(vg_created);
+  tl_assert(DRD_(g_threadinfo)[created].stack_max != 0);
 
   return created;
 }
 
-/* Process VG_USERREQ__POST_THREAD_JOIN. This client request is invoked just */
-/* after thread drd_joiner joined thread drd_joinee.                         */
+/**
+ * Process VG_USERREQ__POST_THREAD_JOIN. This client request is invoked just
+ * after thread drd_joiner joined thread drd_joinee.
+ */
 void DRD_(thread_post_join)(DrdThreadId drd_joiner, DrdThreadId drd_joinee)
 {
   tl_assert(IsValidDrdThreadId(drd_joiner));
@@ -271,7 +274,7 @@ void DRD_(thread_post_join)(DrdThreadId drd_joiner, DrdThreadId drd_joinee)
   thread_combine_vc(drd_joiner, drd_joinee);
   thread_new_segment(drd_joiner);
 
-  if (s_trace_fork_join)
+  if (DRD_(s_trace_fork_join))
   {
     const ThreadId joiner = DrdThreadIdToVgThreadId(drd_joiner);
     const ThreadId joinee = DrdThreadIdToVgThreadId(drd_joinee);
@@ -307,45 +310,47 @@ void DRD_(thread_post_join)(DrdThreadId drd_joiner, DrdThreadId drd_joinee)
   DRD_(barrier_thread_delete)(drd_joinee);
 }
 
-/* NPTL hack: NPTL allocates the 'struct pthread' on top of the stack,     */
-/* and accesses this data structure from multiple threads without locking. */
-/* Any conflicting accesses in the range stack_startup..stack_max will be  */
-/* ignored.                                                                */
+/**
+ * NPTL hack: NPTL allocates the 'struct pthread' on top of the stack,
+ * and accesses this data structure from multiple threads without locking.
+ * Any conflicting accesses in the range stack_startup..stack_max will be
+ * ignored.
+ */
 void thread_set_stack_startup(const DrdThreadId tid, const Addr stack_startup)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].stack_min <= stack_startup);
-  tl_assert(stack_startup <= s_threadinfo[tid].stack_max);
-  s_threadinfo[tid].stack_startup = stack_startup;
+  tl_assert(DRD_(g_threadinfo)[tid].stack_min <= stack_startup);
+  tl_assert(stack_startup <= DRD_(g_threadinfo)[tid].stack_max);
+  DRD_(g_threadinfo)[tid].stack_startup = stack_startup;
 }
 
 Addr thread_get_stack_min(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  return s_threadinfo[tid].stack_min;
+  return DRD_(g_threadinfo)[tid].stack_min;
 }
 
 Addr thread_get_stack_min_min(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  return s_threadinfo[tid].stack_min_min;
+  return DRD_(g_threadinfo)[tid].stack_min_min;
 }
 
 Addr thread_get_stack_max(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  return s_threadinfo[tid].stack_max;
+  return DRD_(g_threadinfo)[tid].stack_max;
 }
 
 SizeT thread_get_stack_size(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  return s_threadinfo[tid].stack_size;
+  return DRD_(g_threadinfo)[tid].stack_size;
 }
 
 /**
@@ -359,42 +364,44 @@ void thread_delete(const DrdThreadId tid)
 
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].synchr_nesting >= 0);
-  for (sg = s_threadinfo[tid].last; sg; sg = sg_prev)
+  tl_assert(DRD_(g_threadinfo)[tid].synchr_nesting >= 0);
+  for (sg = DRD_(g_threadinfo)[tid].last; sg; sg = sg_prev)
   {
     sg_prev = sg->prev;
     sg->prev = 0;
     sg->next = 0;
     DRD_(sg_put)(sg);
   }
-  s_threadinfo[tid].vg_thread_exists = False;
-  s_threadinfo[tid].posix_thread_exists = False;
-  tl_assert(s_threadinfo[tid].detached_posix_thread == False);
-  s_threadinfo[tid].first = 0;
-  s_threadinfo[tid].last = 0;
+  DRD_(g_threadinfo)[tid].vg_thread_exists = False;
+  DRD_(g_threadinfo)[tid].posix_thread_exists = False;
+  tl_assert(DRD_(g_threadinfo)[tid].detached_posix_thread == False);
+  DRD_(g_threadinfo)[tid].first = 0;
+  DRD_(g_threadinfo)[tid].last = 0;
 }
 
-/* Called after a thread performed its last memory access and before   */
-/* thread_delete() is called. Note: thread_delete() is only called for */
-/* joinable threads, not for detached threads.                         */
+/**
+ * Called after a thread performed its last memory access and before
+ * thread_delete() is called. Note: thread_delete() is only called for
+ * joinable threads, not for detached threads.
+ */
 void thread_finished(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
 
-  s_threadinfo[tid].vg_thread_exists = False;
+  DRD_(g_threadinfo)[tid].vg_thread_exists = False;
 
-  if (s_threadinfo[tid].detached_posix_thread)
+  if (DRD_(g_threadinfo)[tid].detached_posix_thread)
   {
     /* Once a detached thread has finished, its stack is deallocated and   */
     /* should no longer be taken into account when computing the conflict set*/
-    s_threadinfo[tid].stack_min = s_threadinfo[tid].stack_max;
+    DRD_(g_threadinfo)[tid].stack_min = DRD_(g_threadinfo)[tid].stack_max;
 
     /* For a detached thread, calling pthread_exit() invalidates the     */
     /* POSIX thread ID associated with the detached thread. For joinable */
     /* POSIX threads however, the POSIX thread ID remains live after the */
     /* pthread_exit() call until pthread_join() is called.               */
-    s_threadinfo[tid].posix_thread_exists = False;
+    DRD_(g_threadinfo)[tid].posix_thread_exists = False;
   }
 }
 
@@ -403,26 +410,26 @@ void thread_pre_cancel(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].pt_threadid != INVALID_POSIX_THREADID);
+  tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID);
 
-  s_threadinfo[tid].synchr_nesting = 0;
+  DRD_(g_threadinfo)[tid].synchr_nesting = 0;
 }
 
 void thread_set_pthreadid(const DrdThreadId tid, const PThreadId ptid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].pt_threadid == INVALID_POSIX_THREADID);
+  tl_assert(DRD_(g_threadinfo)[tid].pt_threadid == INVALID_POSIX_THREADID);
   tl_assert(ptid != INVALID_POSIX_THREADID);
-  s_threadinfo[tid].posix_thread_exists = True;
-  s_threadinfo[tid].pt_threadid         = ptid;
+  DRD_(g_threadinfo)[tid].posix_thread_exists = True;
+  DRD_(g_threadinfo)[tid].pt_threadid         = ptid;
 }
 
 Bool thread_get_joinable(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  return ! s_threadinfo[tid].detached_posix_thread;
+  return ! DRD_(g_threadinfo)[tid].detached_posix_thread;
 }
 
 void thread_set_joinable(const DrdThreadId tid, const Bool joinable)
@@ -430,28 +437,28 @@ void thread_set_joinable(const DrdThreadId tid, const Bool joinable)
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
   tl_assert(!! joinable == joinable);
-  tl_assert(s_threadinfo[tid].pt_threadid != INVALID_POSIX_THREADID);
+  tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID);
 #if 0
   VG_(message)(Vg_DebugMsg,
                "thread_set_joinable(%d/%d, %s)",
                tid,
-               s_threadinfo[tid].vg_threadid,
+               DRD_(g_threadinfo)[tid].vg_threadid,
                joinable ? "joinable" : "detached");
 #endif
-  s_threadinfo[tid].detached_posix_thread = ! joinable;
+  DRD_(g_threadinfo)[tid].detached_posix_thread = ! joinable;
 }
 
 void thread_set_vg_running_tid(const ThreadId vg_tid)
 {
   tl_assert(vg_tid != VG_INVALID_THREADID);
 
-  if (vg_tid != s_vg_running_tid)
+  if (vg_tid != DRD_(s_vg_running_tid))
   {
     thread_set_running_tid(vg_tid, VgThreadIdToDrdThreadId(vg_tid));
   }
 
-  tl_assert(s_vg_running_tid != VG_INVALID_THREADID);
-  tl_assert(s_drd_running_tid != DRD_INVALID_THREADID);
+  tl_assert(DRD_(s_vg_running_tid) != VG_INVALID_THREADID);
+  tl_assert(DRD_(g_drd_running_tid) != DRD_INVALID_THREADID);
 }
 
 void thread_set_running_tid(const ThreadId vg_tid, const DrdThreadId drd_tid)
@@ -459,45 +466,45 @@ void thread_set_running_tid(const ThreadId vg_tid, const DrdThreadId drd_tid)
   tl_assert(vg_tid != VG_INVALID_THREADID);
   tl_assert(drd_tid != DRD_INVALID_THREADID);
    
-  if (vg_tid != s_vg_running_tid)
+  if (vg_tid != DRD_(s_vg_running_tid))
   {
-    if (s_trace_context_switches
-        && s_drd_running_tid != DRD_INVALID_THREADID)
+    if (DRD_(s_trace_context_switches)
+        && DRD_(g_drd_running_tid) != DRD_INVALID_THREADID)
     {
       VG_(message)(Vg_DebugMsg,
                    "Context switch from thread %d/%d to thread %d/%d;"
                    " segments: %llu",
-                   s_vg_running_tid, s_drd_running_tid,
+                   DRD_(s_vg_running_tid), DRD_(g_drd_running_tid),
                    DrdThreadIdToVgThreadId(drd_tid), drd_tid,
                    DRD_(sg_get_segments_alive_count)());
     }
-    s_vg_running_tid = vg_tid;
-    s_drd_running_tid = drd_tid;
-    thread_compute_conflict_set(&s_conflict_set, drd_tid);
-    s_context_switch_count++;
+    DRD_(s_vg_running_tid) = vg_tid;
+    DRD_(g_drd_running_tid) = drd_tid;
+    thread_compute_conflict_set(&DRD_(g_conflict_set), drd_tid);
+    DRD_(s_context_switch_count)++;
   }
 
-  tl_assert(s_vg_running_tid != VG_INVALID_THREADID);
-  tl_assert(s_drd_running_tid != DRD_INVALID_THREADID);
+  tl_assert(DRD_(s_vg_running_tid) != VG_INVALID_THREADID);
+  tl_assert(DRD_(g_drd_running_tid) != DRD_INVALID_THREADID);
 }
 
 int thread_enter_synchr(const DrdThreadId tid)
 {
   tl_assert(IsValidDrdThreadId(tid));
-  return s_threadinfo[tid].synchr_nesting++;
+  return DRD_(g_threadinfo)[tid].synchr_nesting++;
 }
 
 int thread_leave_synchr(const DrdThreadId tid)
 {
   tl_assert(IsValidDrdThreadId(tid));
-  tl_assert(s_threadinfo[tid].synchr_nesting >= 1);
-  return --s_threadinfo[tid].synchr_nesting;
+  tl_assert(DRD_(g_threadinfo)[tid].synchr_nesting >= 1);
+  return --DRD_(g_threadinfo)[tid].synchr_nesting;
 }
 
 int thread_get_synchr_nesting_count(const DrdThreadId tid)
 {
   tl_assert(IsValidDrdThreadId(tid));
-  return s_threadinfo[tid].synchr_nesting;
+  return DRD_(g_threadinfo)[tid].synchr_nesting;
 }
 
 /** Append a new segment at the end of the segment list. */
@@ -505,59 +512,60 @@ static void thread_append_segment(const DrdThreadId tid, Segment* const sg)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  // tl_assert(sane_ThreadInfo(&s_threadinfo[tid]));
-  sg->prev = s_threadinfo[tid].last;
+  // tl_assert(sane_ThreadInfo(&DRD_(g_threadinfo)[tid]));
+  sg->prev = DRD_(g_threadinfo)[tid].last;
   sg->next = 0;
-  if (s_threadinfo[tid].last)
-    s_threadinfo[tid].last->next = sg;
-  s_threadinfo[tid].last = sg;
-  if (s_threadinfo[tid].first == 0)
-    s_threadinfo[tid].first = sg;
-  // tl_assert(sane_ThreadInfo(&s_threadinfo[tid]));
+  if (DRD_(g_threadinfo)[tid].last)
+    DRD_(g_threadinfo)[tid].last->next = sg;
+  DRD_(g_threadinfo)[tid].last = sg;
+  if (DRD_(g_threadinfo)[tid].first == 0)
+    DRD_(g_threadinfo)[tid].first = sg;
+  // tl_assert(sane_ThreadInfo(&DRD_(g_threadinfo)[tid]));
 }
 
-/** Remove a segment from the segment list of thread threadid, and free the
- *  associated memory.
+/**
+ * Remove a segment from the segment list of thread threadid, and free the
+ * associated memory.
  */
 static void thread_discard_segment(const DrdThreadId tid, Segment* const sg)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  //tl_assert(sane_ThreadInfo(&s_threadinfo[tid]));
+  //tl_assert(sane_ThreadInfo(&DRD_(g_threadinfo)[tid]));
 
   if (sg->prev)
     sg->prev->next = sg->next;
   if (sg->next)
     sg->next->prev = sg->prev;
-  if (sg == s_threadinfo[tid].first)
-    s_threadinfo[tid].first = sg->next;
-  if (sg == s_threadinfo[tid].last)
-    s_threadinfo[tid].last = sg->prev;
+  if (sg == DRD_(g_threadinfo)[tid].first)
+    DRD_(g_threadinfo)[tid].first = sg->next;
+  if (sg == DRD_(g_threadinfo)[tid].last)
+    DRD_(g_threadinfo)[tid].last = sg->prev;
   DRD_(sg_put)(sg);
 
-  //tl_assert(sane_ThreadInfo(&s_threadinfo[tid]));
+  //tl_assert(sane_ThreadInfo(&DRD_(g_threadinfo)[tid]));
 }
 
 VectorClock* thread_get_vc(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].last);
-  return &s_threadinfo[tid].last->vc;
+  tl_assert(DRD_(g_threadinfo)[tid].last);
+  return &DRD_(g_threadinfo)[tid].last->vc;
 }
 
-/** Return the latest segment of thread 'tid' and increment its reference
- *  count.
+/**
+ * Return the latest segment of thread 'tid' and increment its reference count.
  */
 void thread_get_latest_segment(Segment** sg, const DrdThreadId tid)
 {
   tl_assert(sg);
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].last);
+  tl_assert(DRD_(g_threadinfo)[tid].last);
 
   DRD_(sg_put)(*sg);
-  *sg = DRD_(sg_get)(s_threadinfo[tid].last);
+  *sg = DRD_(sg_get)(DRD_(g_threadinfo)[tid].last);
 }
 
 /**
@@ -572,9 +580,9 @@ static void thread_compute_minimum_vc(VectorClock* vc)
   Segment* latest_sg;
 
   first = True;
-  for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
+  for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); i++)
   {
-    latest_sg = s_threadinfo[i].last;
+    latest_sg = DRD_(g_threadinfo)[i].last;
     if (latest_sg)
     {
       if (first)
@@ -593,9 +601,9 @@ static void thread_compute_maximum_vc(VectorClock* vc)
   Segment* latest_sg;
 
   first = True;
-  for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
+  for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); i++)
   {
-    latest_sg = s_threadinfo[i].last;
+    latest_sg = DRD_(g_threadinfo)[i].last;
     if (latest_sg)
     {
       if (first)
@@ -617,7 +625,7 @@ static void thread_discard_ordered_segments(void)
   unsigned i;
   VectorClock thread_vc_min;
 
-  s_discard_ordered_segments_count++;
+  DRD_(s_discard_ordered_segments_count)++;
 
   DRD_(vc_init)(&thread_vc_min, 0, 0);
   thread_compute_minimum_vc(&thread_vc_min);
@@ -640,11 +648,11 @@ static void thread_discard_ordered_segments(void)
     DRD_(vc_cleanup)(&thread_vc_max);
   }
 
-  for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
+  for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); i++)
   {
     Segment* sg;
     Segment* sg_next;
-    for (sg = s_threadinfo[i].first;
+    for (sg = DRD_(g_threadinfo)[i].first;
          sg && (sg_next = sg->next) && DRD_(vc_lte)(&sg->vc, &thread_vc_min);
          sg = sg_next)
     {
@@ -654,25 +662,26 @@ static void thread_discard_ordered_segments(void)
   DRD_(vc_cleanup)(&thread_vc_min);
 }
 
-/** Merge all segments that may be merged without triggering false positives
- *  or discarding real data races. For the theoretical background of segment
- *  merging, see also the following paper:
- *  Mark Christiaens, Michiel Ronsse and Koen De Bosschere.
- *  Bounding the number of segment histories during data race detection.
- *  Parallel Computing archive, Volume 28, Issue 9, pp 1221-1238,
- *  September 2002.
+/**
+ * Merge all segments that may be merged without triggering false positives
+ * or discarding real data races. For the theoretical background of segment
+ * merging, see also the following paper:
+ * Mark Christiaens, Michiel Ronsse and Koen De Bosschere.
+ * Bounding the number of segment histories during data race detection.
+ * Parallel Computing archive, Volume 28, Issue 9, pp 1221-1238,
+ * September 2002.
  */
 static void thread_merge_segments(void)
 {
   unsigned i;
 
-  for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
+  for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); i++)
   {
     Segment* sg;
 
-    // tl_assert(sane_ThreadInfo(&s_threadinfo[i]));
+    // tl_assert(sane_ThreadInfo(&DRD_(g_threadinfo)[i]));
 
-    for (sg = s_threadinfo[i].first; sg; sg = sg->next)
+    for (sg = DRD_(g_threadinfo)[i].first; sg; sg = sg->next)
     {
       if (DRD_(sg_get_refcnt)(sg) == 1
           && sg->next
@@ -685,19 +694,20 @@ static void thread_merge_segments(void)
       }
     }
 
-    // tl_assert(sane_ThreadInfo(&s_threadinfo[i]));
+    // tl_assert(sane_ThreadInfo(&DRD_(g_threadinfo)[i]));
   }
 }
 
-/** Every change in the vector clock of a thread may cause segments that
- *  were previously ordered to this thread to become unordered. Hence,
- *  it may be necessary to recalculate the conflict set if the vector clock 
- *  of the current thread is updated. This function check whether such a
- *  recalculation is necessary.
+/**
+ * Every change in the vector clock of a thread may cause segments that
+ * were previously ordered to this thread to become unordered. Hence,
+ * it may be necessary to recalculate the conflict set if the vector clock 
+ * of the current thread is updated. This function check whether such a
+ * recalculation is necessary.
  *
- *  @param tid    Thread ID of the thread to which a new segment has been
- *                appended.
- *  @param new_sg Pointer to the most recent segment of thread tid.
+ * @param tid    Thread ID of the thread to which a new segment has been
+ *               appended.
+ * @param new_sg Pointer to the most recent segment of thread tid.
  */
 static Bool conflict_set_update_needed(const DrdThreadId tid,
                                        const Segment* const new_sg)
@@ -710,7 +720,7 @@ static Bool conflict_set_update_needed(const DrdThreadId tid,
 
   /* If a new segment was added to another thread than the running thread, */
   /* just tell the caller to update the conflict set.                        */
-  if (tid != s_drd_running_tid)
+  if (tid != DRD_(g_drd_running_tid))
     return True;
 
   /* Always let the caller update the conflict set after creation of the */
@@ -719,14 +729,14 @@ static Bool conflict_set_update_needed(const DrdThreadId tid,
   if (old_sg == 0)
     return True;
 
-  for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
+  for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); i++)
   {
     Segment* q;
 
-    if (i == s_drd_running_tid)
+    if (i == DRD_(g_drd_running_tid))
       continue;
 
-    for (q = s_threadinfo[i].last; q; q = q->prev)
+    for (q = DRD_(g_threadinfo)[i].last; q; q = q->prev)
     {
       /* If the expression below evaluates to false, this expression will */
       /* also evaluate to false for all subsequent iterations. So stop    */
@@ -756,8 +766,9 @@ static Bool conflict_set_update_needed(const DrdThreadId tid,
 #endif
 }
 
-/** Create a new segment for the specified thread, and discard any segments
- *  that cannot cause races anymore.
+/**
+ * Create a new segment for the specified thread, and discard any segments
+ * that cannot cause races anymore.
  */
 void thread_new_segment(const DrdThreadId tid)
 {
@@ -771,18 +782,21 @@ void thread_new_segment(const DrdThreadId tid)
 
   if (conflict_set_update_needed(tid, new_sg))
   {
-    thread_compute_conflict_set(&s_conflict_set, s_drd_running_tid);
-    s_conflict_set_new_segment_count++;
+    thread_compute_conflict_set(&DRD_(g_conflict_set),
+                                DRD_(g_drd_running_tid));
+    DRD_(s_conflict_set_new_segment_count)++;
   }
-  else if (tid == s_drd_running_tid)
+  else if (tid == DRD_(g_drd_running_tid))
   {
-    tl_assert(thread_conflict_set_up_to_date(s_drd_running_tid));
+    tl_assert(thread_conflict_set_up_to_date(DRD_(g_drd_running_tid)));
   }
 
   thread_discard_ordered_segments();
 
-  if (s_segment_merging)
+  if (DRD_(s_segment_merging))
+  {
     thread_merge_segments();
+  }
 }
 
 /** Call this function after thread 'joiner' joined thread 'joinee'. */
@@ -793,36 +807,39 @@ void thread_combine_vc(DrdThreadId joiner, DrdThreadId joinee)
             && joiner != DRD_INVALID_THREADID);
   tl_assert(0 <= (int)joinee && joinee < DRD_N_THREADS
             && joinee != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[joiner].last);
-  tl_assert(s_threadinfo[joinee].last);
-  DRD_(vc_combine)(&s_threadinfo[joiner].last->vc, &s_threadinfo[joinee].last->vc);
+  tl_assert(DRD_(g_threadinfo)[joiner].last);
+  tl_assert(DRD_(g_threadinfo)[joinee].last);
+  DRD_(vc_combine)(&DRD_(g_threadinfo)[joiner].last->vc,
+                   &DRD_(g_threadinfo)[joinee].last->vc);
   thread_discard_ordered_segments();
 
-  if (joiner == s_drd_running_tid)
+  if (joiner == DRD_(g_drd_running_tid))
   {
-    thread_compute_conflict_set(&s_conflict_set, joiner);
+    thread_compute_conflict_set(&DRD_(g_conflict_set), joiner);
   }
 }
 
-/** Call this function after thread 'tid' had to wait because of thread
- *  synchronization until the memory accesses in the segment with vector clock
- *  'vc' finished.
+/**
+ * Call this function after thread 'tid' had to wait because of thread
+ * synchronization until the memory accesses in the segment with vector clock
+ * 'vc' finished.
  */
 void thread_combine_vc2(DrdThreadId tid, const VectorClock* const vc)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].last);
+  tl_assert(DRD_(g_threadinfo)[tid].last);
   tl_assert(vc);
-  DRD_(vc_combine)(&s_threadinfo[tid].last->vc, vc);
-  thread_compute_conflict_set(&s_conflict_set, tid);
+  DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc, vc);
+  thread_compute_conflict_set(&DRD_(g_conflict_set), tid);
   thread_discard_ordered_segments();
-  s_conflict_set_combine_vc_count++;
+  DRD_(s_conflict_set_combine_vc_count)++;
 }
 
-/** Call this function whenever a thread is no longer using the memory
- *  [ a1, a2 [, e.g. because of a call to free() or a stack pointer
- *  increase.
+/**
+ * Call this function whenever a thread is no longer using the memory
+ * [ a1, a2 [, e.g. because of a call to free() or a stack pointer
+ * increase.
  */
 void thread_stop_using_mem(const Addr a1, const Addr a2)
 {
@@ -831,13 +848,13 @@ void thread_stop_using_mem(const Addr a1, const Addr a2)
 
   /* For all threads, mark the range [ a1, a2 [ as no longer in use. */
   other_user = DRD_INVALID_THREADID;
-  for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
+  for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); i++)
   {
     Segment* p;
-    for (p = s_threadinfo[i].first; p; p = p->next)
+    for (p = DRD_(g_threadinfo)[i].first; p; p = p->next)
     {
       if (other_user == DRD_INVALID_THREADID
-          && i != s_drd_running_tid)
+          && i != DRD_(g_drd_running_tid))
       {
         if (UNLIKELY(bm_test_and_clear(p->bm, a1, a2)))
         {
@@ -849,12 +866,14 @@ void thread_stop_using_mem(const Addr a1, const Addr a2)
     }
   }
 
-  /* If any other thread had accessed memory in [ a1, a2 [, update the */
-  /* conflict set. */
+  /*
+   * If any other thread had accessed memory in [ a1, a2 [, update the
+   * conflict set.
+   */
   if (other_user != DRD_INVALID_THREADID
-      && bm_has_any_access(s_conflict_set, a1, a2))
+      && bm_has_any_access(DRD_(g_conflict_set), a1, a2))
   {
-    thread_compute_conflict_set(&s_conflict_set, thread_get_running_tid());
+    thread_compute_conflict_set(&DRD_(g_conflict_set), thread_get_running_tid());
   }
 }
 
@@ -862,16 +881,16 @@ void thread_start_recording(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(! s_threadinfo[tid].is_recording);
-  s_threadinfo[tid].is_recording = True;
+  tl_assert(! DRD_(g_threadinfo)[tid].is_recording);
+  DRD_(g_threadinfo)[tid].is_recording = True;
 }
 
 void thread_stop_recording(const DrdThreadId tid)
 {
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].is_recording);
-  s_threadinfo[tid].is_recording = False;
+  tl_assert(DRD_(g_threadinfo)[tid].is_recording);
+  DRD_(g_threadinfo)[tid].is_recording = False;
 }
 
 void thread_print_all(void)
@@ -879,20 +898,20 @@ void thread_print_all(void)
   unsigned i;
   Segment* p;
 
-  for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
+  for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); i++)
   {
-    if (s_threadinfo[i].first)
+    if (DRD_(g_threadinfo)[i].first)
     {
       VG_(printf)("**************\n"
                   "* thread %3d (%d/%d/%d/0x%lx/%d) *\n"
                   "**************\n",
                   i,
-                  s_threadinfo[i].vg_thread_exists,
-                  s_threadinfo[i].vg_threadid,
-                  s_threadinfo[i].posix_thread_exists,
-                  s_threadinfo[i].pt_threadid,
-                  s_threadinfo[i].detached_posix_thread);
-      for (p = s_threadinfo[i].first; p; p = p->next)
+                  DRD_(g_threadinfo)[i].vg_thread_exists,
+                  DRD_(g_threadinfo)[i].vg_threadid,
+                  DRD_(g_threadinfo)[i].posix_thread_exists,
+                  DRD_(g_threadinfo)[i].pt_threadid,
+                  DRD_(g_threadinfo)[i].detached_posix_thread);
+      for (p = DRD_(g_threadinfo)[i].first; p; p = p->next)
       {
         DRD_(sg_print)(p);
       }
@@ -939,17 +958,19 @@ thread_report_conflicting_segments_segment(const DrdThreadId tid,
             && tid != DRD_INVALID_THREADID);
   tl_assert(p);
 
-  for (i = 0; i < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); i++)
+  for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); i++)
   {
     if (i != tid)
     {
       Segment* q;
-      for (q = s_threadinfo[i].last; q; q = q->prev)
+      for (q = DRD_(g_threadinfo)[i].last; q; q = q->prev)
       {
-        // Since q iterates over the segments of thread i in order of 
-        // decreasing vector clocks, if q->vc <= p->vc, then 
-        // q->next->vc <= p->vc will also hold. Hence, break out of the
-        // loop once this condition is met.
+        /*
+         * Since q iterates over the segments of thread i in order of 
+         * decreasing vector clocks, if q->vc <= p->vc, then 
+         * q->next->vc <= p->vc will also hold. Hence, break out of the
+         * loop once this condition is met.
+         */
         if (DRD_(vc_lte)(&q->vc, &p->vc))
           break;
         if (! DRD_(vc_lte)(&p->vc, &q->vc))
@@ -978,7 +999,7 @@ void thread_report_conflicting_segments(const DrdThreadId tid,
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
 
-  for (p = s_threadinfo[tid].first; p; p = p->next)
+  for (p = DRD_(g_threadinfo)[tid].first; p; p = p->next)
   {
     if (bm_has(p->bm, addr, addr + size, access_type))
     {
@@ -988,8 +1009,9 @@ void thread_report_conflicting_segments(const DrdThreadId tid,
   }
 }
 
-/** Verify whether the conflict set for thread tid is up to date. Only perform
- *  the check if the environment variable DRD_VERIFY_CONFLICT_SET has been set.
+/**
+ * Verify whether the conflict set for thread tid is up to date. Only perform
+ * the check if the environment variable DRD_VERIFY_CONFLICT_SET has been set.
  */
 static Bool thread_conflict_set_up_to_date(const DrdThreadId tid)
 {
@@ -1006,13 +1028,14 @@ static Bool thread_conflict_set_up_to_date(const DrdThreadId tid)
     return True;
 
   thread_compute_conflict_set(&computed_conflict_set, tid);
-  result = bm_equal(s_conflict_set, computed_conflict_set);
+  result = bm_equal(DRD_(g_conflict_set), computed_conflict_set);
   bm_delete(computed_conflict_set);
   return result;
 }
 
-/** Compute a bitmap that represents the union of all memory accesses of all
- *  segments that are unordered to the current segment of the thread tid.
+/**
+ * Compute a bitmap that represents the union of all memory accesses of all
+ * segments that are unordered to the current segment of the thread tid.
  */
 static void thread_compute_conflict_set(struct bitmap** conflict_set,
                                         const DrdThreadId tid)
@@ -1021,11 +1044,11 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set,
 
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(tid == s_drd_running_tid);
+  tl_assert(tid == DRD_(g_drd_running_tid));
 
-  s_update_conflict_set_count++;
-  s_conflict_set_bitmap_creation_count  -= bm_get_bitmap_creation_count();
-  s_conflict_set_bitmap2_creation_count -= bm_get_bitmap2_creation_count();
+  DRD_(s_update_conflict_set_count)++;
+  DRD_(s_conflict_set_bitmap_creation_count)  -= bm_get_bitmap_creation_count();
+  DRD_(s_conflict_set_bitmap2_creation_count) -= bm_get_bitmap2_creation_count();
 
   if (*conflict_set)
   {
@@ -1033,7 +1056,7 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set,
   }
   *conflict_set = bm_new();
 
-  if (s_trace_conflict_set)
+  if (DRD_(s_trace_conflict_set))
   {
     char msg[256];
 
@@ -1042,15 +1065,15 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set,
                   DrdThreadIdToVgThreadId(tid), tid);
     DRD_(vc_snprint)(msg + VG_(strlen)(msg),
                      sizeof(msg) - VG_(strlen)(msg),
-                     &s_threadinfo[tid].last->vc);
+                     &DRD_(g_threadinfo)[tid].last->vc);
     VG_(message)(Vg_UserMsg, "%s", msg);
   }
 
-  p = s_threadinfo[tid].last;
+  p = DRD_(g_threadinfo)[tid].last;
   {
     unsigned j;
 
-    if (s_trace_conflict_set)
+    if (DRD_(s_trace_conflict_set))
     {
       char msg[256];
 
@@ -1063,16 +1086,16 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set,
       VG_(message)(Vg_UserMsg, "%s", msg);
     }
 
-    for (j = 0; j < sizeof(s_threadinfo) / sizeof(s_threadinfo[0]); j++)
+    for (j = 0; j < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]); j++)
     {
       if (j != tid && IsValidDrdThreadId(j))
       {
         const Segment* q;
-        for (q = s_threadinfo[j].last; q; q = q->prev)
+        for (q = DRD_(g_threadinfo)[j].last; q; q = q->prev)
         {
           if (! DRD_(vc_lte)(&q->vc, &p->vc) && ! DRD_(vc_lte)(&p->vc, &q->vc))
           {
-            if (s_trace_conflict_set)
+            if (DRD_(s_trace_conflict_set))
             {
               char msg[256];
               VG_(snprintf)(msg, sizeof(msg),
@@ -1086,7 +1109,7 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set,
           }
           else
           {
-            if (s_trace_conflict_set)
+            if (DRD_(s_trace_conflict_set))
             {
               char msg[256];
               VG_(snprintf)(msg, sizeof(msg),
@@ -1102,10 +1125,10 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set,
     }
   }
 
-  s_conflict_set_bitmap_creation_count  += bm_get_bitmap_creation_count();
-  s_conflict_set_bitmap2_creation_count += bm_get_bitmap2_creation_count();
+  DRD_(s_conflict_set_bitmap_creation_count)  += bm_get_bitmap_creation_count();
+  DRD_(s_conflict_set_bitmap2_creation_count) += bm_get_bitmap2_creation_count();
 
-  if (0 && s_trace_conflict_set)
+  if (0 && DRD_(s_trace_conflict_set))
   {
     VG_(message)(Vg_UserMsg, "[%d] new conflict set:", tid);
     bm_print(*conflict_set);
@@ -1115,29 +1138,29 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set,
 
 ULong thread_get_context_switch_count(void)
 {
-  return s_context_switch_count;
+  return DRD_(s_context_switch_count);
 }
 
 ULong thread_get_discard_ordered_segments_count(void)
 {
-  return s_discard_ordered_segments_count;
+  return DRD_(s_discard_ordered_segments_count);
 }
 
 ULong thread_get_update_conflict_set_count(ULong* dsnsc, ULong* dscvc)
 {
   tl_assert(dsnsc);
   tl_assert(dscvc);
-  *dsnsc = s_conflict_set_new_segment_count;
-  *dscvc = s_conflict_set_combine_vc_count;
-  return s_update_conflict_set_count;
+  *dsnsc = DRD_(s_conflict_set_new_segment_count);
+  *dscvc = DRD_(s_conflict_set_combine_vc_count);
+  return DRD_(s_update_conflict_set_count);
 }
 
 ULong thread_get_conflict_set_bitmap_creation_count(void)
 {
-  return s_conflict_set_bitmap_creation_count;
+  return DRD_(s_conflict_set_bitmap_creation_count);
 }
 
 ULong thread_get_conflict_set_bitmap2_creation_count(void)
 {
-  return s_conflict_set_bitmap2_creation_count;
+  return DRD_(s_conflict_set_bitmap2_creation_count);
 }
index d7eecab7287f7f280dbd149eb3befe1d79ed3eae..b4534c37b7959c2d0df4830df3c5faa87f022c8a 100644 (file)
@@ -27,7 +27,7 @@
 #define __THREAD_H
 
 
-// Includes.
+/* Include directives. */
 
 #include "drd_basics.h"
 #include "drd_segment.h"
@@ -37,7 +37,7 @@
 #include "pub_tool_threadstate.h" // VG_N_THREADS
 
 
-// Defines.
+/* Defines. */
 
 #define DRD_N_THREADS VG_N_THREADS
 
@@ -51,7 +51,7 @@
 #define INVALID_POSIX_THREADID ((PThreadId)0)
 
 
-// Type definitions.
+/* Type definitions. */
 
 typedef UWord PThreadId;
 
@@ -61,34 +61,38 @@ typedef struct
   Segment*  last;
   ThreadId  vg_threadid;
   PThreadId pt_threadid;
-  Addr      stack_min_min; /** Lowest value stack pointer ever had. */
-  Addr      stack_min;     /** Current stack pointer. */
-  Addr      stack_startup; /** Stack pointer after pthread_create() finished.*/
-  Addr      stack_max;     /** Top of stack. */
-  SizeT     stack_size;    /** Maximum size of stack. */
-  /// Indicates whether the Valgrind core knows about this thread.
+  Addr      stack_min_min; /**< Lowest value stack pointer ever had. */
+  Addr      stack_min;     /**< Current stack pointer. */
+  Addr      stack_startup; /**<Stack pointer after pthread_create() finished.*/
+  Addr      stack_max;     /**< Top of stack. */
+  SizeT     stack_size;    /**< Maximum size of stack. */
+  /** Indicates whether the Valgrind core knows about this thread. */
   Bool      vg_thread_exists;
-  /// Indicates whether there is an associated POSIX thread ID.
+  /** Indicates whether there is an associated POSIX thread ID. */
   Bool      posix_thread_exists;
-  /// If true, indicates that there is a corresponding POSIX thread ID and
-  /// a corresponding OS thread that is detached.
+  /**
+   * If true, indicates that there is a corresponding POSIX thread ID and
+   * a corresponding OS thread that is detached.
+   */
   Bool      detached_posix_thread;
-  /// Wether recording of memory accesses is active.
+  /** Wether recording of memory accesses is active. */
   Bool      is_recording;
-  /// Nesting level of synchronization functions called by the client.
+  /** Nesting level of synchronization functions called by the client. */
   Int       synchr_nesting;
 } ThreadInfo;
 
 
-// Local variables of drd_thread.c that are declared here such that these
-// can be accessed by inline functions.
+/*
+ * Local variables of drd_thread.c that are declared here such that these
+ * can be accessed by inline functions.
+ */
 
-extern DrdThreadId s_drd_running_tid;
-extern ThreadInfo s_threadinfo[DRD_N_THREADS];
-extern struct bitmap* s_conflict_set;
+extern DrdThreadId    DRD_(g_drd_running_tid);
+extern ThreadInfo     DRD_(g_threadinfo)[DRD_N_THREADS];
+extern struct bitmap* DRD_(g_conflict_set);
 
 
-// Function declarations.
+/* Function declarations. */
 
 void thread_trace_context_switches(const Bool t);
 void thread_trace_conflict_set(const Bool t);
@@ -147,37 +151,39 @@ ULong thread_get_conflict_set_bitmap_creation_count(void);
 ULong thread_get_conflict_set_bitmap2_creation_count(void);
 
 
+/* Inline function definitions. */
+
 static __inline__
 Bool IsValidDrdThreadId(const DrdThreadId tid)
 {
   return (0 <= (int)tid && tid < DRD_N_THREADS && tid != DRD_INVALID_THREADID
-          && ! (s_threadinfo[tid].vg_thread_exists == False
-                && s_threadinfo[tid].posix_thread_exists == False
-                && s_threadinfo[tid].detached_posix_thread == False));
+          && ! (DRD_(g_threadinfo)[tid].vg_thread_exists == False
+                && DRD_(g_threadinfo)[tid].posix_thread_exists == False
+                && DRD_(g_threadinfo)[tid].detached_posix_thread == False));
 }
 
 static __inline__
 DrdThreadId thread_get_running_tid(void)
 {
-  tl_assert(s_drd_running_tid != DRD_INVALID_THREADID);
-  return s_drd_running_tid;
+  tl_assert(DRD_(g_drd_running_tid) != DRD_INVALID_THREADID);
+  return DRD_(g_drd_running_tid);
 }
 
 static __inline__
 struct bitmap* thread_get_conflict_set(void)
 {
-  return s_conflict_set;
+  return DRD_(g_conflict_set);
 }
 
 static __inline__
 Bool running_thread_is_recording(void)
 {
 #ifdef ENABLE_DRD_CONSISTENCY_CHECKS
-  tl_assert(0 <= (int)s_drd_running_tid && s_drd_running_tid < DRD_N_THREADS
-            && s_drd_running_tid != DRD_INVALID_THREADID);
+  tl_assert(0 <= (int)DRD_(g_drd_running_tid) && DRD_(g_drd_running_tid) < DRD_N_THREADS
+            && DRD_(g_drd_running_tid) != DRD_INVALID_THREADID);
 #endif
-  return (s_threadinfo[s_drd_running_tid].synchr_nesting == 0
-          && s_threadinfo[s_drd_running_tid].is_recording);
+  return (DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].synchr_nesting == 0
+          && DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].is_recording);
 }
 
 static __inline__
@@ -188,27 +194,28 @@ void thread_set_stack_min(const DrdThreadId tid, const Addr stack_min)
             && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
 #endif
-  s_threadinfo[tid].stack_min = stack_min;
+  DRD_(g_threadinfo)[tid].stack_min = stack_min;
 #ifdef ENABLE_DRD_CONSISTENCY_CHECKS
   /* This function can be called after the thread has been created but */
   /* before drd_post_thread_create() has filled in stack_max.          */
-  tl_assert(s_threadinfo[tid].stack_min < s_threadinfo[tid].stack_max
-            || s_threadinfo[tid].stack_max == 0);
+  tl_assert(DRD_(g_threadinfo)[tid].stack_min < DRD_(g_threadinfo)[tid].stack_max
+            || DRD_(g_threadinfo)[tid].stack_max == 0);
 #endif
-  if (UNLIKELY(stack_min < s_threadinfo[tid].stack_min_min))
+  if (UNLIKELY(stack_min < DRD_(g_threadinfo)[tid].stack_min_min))
   {
-    s_threadinfo[tid].stack_min_min = stack_min;
+    DRD_(g_threadinfo)[tid].stack_min_min = stack_min;
   }
 }
 
-/** Return true if and only if the specified address is on the stack of the
- *  currently scheduled thread.
+/**
+ * Return true if and only if the specified address is on the stack of the
+ * currently scheduled thread.
  */
 static __inline__
 Bool thread_address_on_stack(const Addr a)
 {
-  return (s_threadinfo[s_drd_running_tid].stack_min <= a
-         && a < s_threadinfo[s_drd_running_tid].stack_max);
+  return (DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].stack_min <= a
+         && a < DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].stack_max);
 }
 
 /** Return a pointer to the latest segment for the specified thread. */
@@ -218,16 +225,16 @@ Segment* thread_get_segment(const DrdThreadId tid)
 #ifdef ENABLE_DRD_CONSISTENCY_CHECKS
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
-  tl_assert(s_threadinfo[tid].last);
+  tl_assert(DRD_(g_threadinfo)[tid].last);
 #endif
-  return s_threadinfo[tid].last;
+  return DRD_(g_threadinfo)[tid].last;
 }
 
 /** Return a pointer to the latest segment for the running thread. */
 static __inline__
 Segment* running_thread_get_segment(void)
 {
-  return thread_get_segment(s_drd_running_tid);
+  return thread_get_segment(DRD_(g_drd_running_tid));
 }
 
 #endif // __THREAD_H