]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Wrapped DRD_() macro around all segment function names.
authorBart Van Assche <bvanassche@acm.org>
Sat, 14 Feb 2009 17:19:58 +0000 (17:19 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 14 Feb 2009 17:19:58 +0000 (17:19 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9160

drd/drd_barrier.c
drd/drd_main.c
drd/drd_mutex.c
drd/drd_rwlock.c
drd/drd_segment.c
drd/drd_segment.h
drd/drd_semaphore.c
drd/drd_thread.c

index fd4ecfa3b1820fcafebfcdb5deaa64c64a0eb09d..689e582fec287ff21d8eef0d327a5d9055f90916 100644 (file)
@@ -85,8 +85,8 @@ static void barrier_thread_initialize(struct barrier_thread_info* const p,
 static void barrier_thread_destroy(struct barrier_thread_info* const p)
 {
   tl_assert(p);
-  sg_put(p->sg[0]);
-  sg_put(p->sg[1]);
+  DRD_(sg_put)(p->sg[0]);
+  DRD_(sg_put)(p->sg[1]);
 }
 
 /** Initialize the structure *p with the specified client-side barrier address,
index fb7934d609272d997872c641a12fba37aeb37f61..49efafd96b4b0c51109f7e254f57a3a9f59c284b 100644 (file)
@@ -143,7 +143,7 @@ static Bool DRD_(process_cmd_line_option)(Char* arg)
   if (trace_rwlock != -1)
     rwlock_set_trace(trace_rwlock);
   if (trace_segment != -1)
-    sg_set_trace(trace_segment);
+    DRD_(sg_set_trace)(trace_segment);
   if (trace_semaphore != -1)
     semaphore_set_trace(trace_semaphore);
   if (trace_suppression != -1)
@@ -542,8 +542,8 @@ static void DRD_(fini)(Int exitcode)
     VG_(message)(Vg_UserMsg,
                  " segments: created %lld segments, max %lld alive,"
                  " %lld discard points.",
-                 sg_get_created_segments_count(),
-                 sg_get_max_alive_segments_count(),
+                 DRD_(sg_get_segments_created_count)(),
+                 DRD_(sg_get_max_segments_alive_count)(),
                  thread_get_discard_ordered_segments_count());
     VG_(message)(Vg_UserMsg,
                  "           (%lld m, %lld rw, %lld s, %lld b)",
index e4ae3b1543f1a43775b1318d55f25c3991935664..4860fedfe82023f28419b60139898550a7bc29b9 100644 (file)
@@ -107,7 +107,7 @@ static void mutex_cleanup(struct mutex_info* p)
                             &MEI);
   }
 
-  sg_put(p->last_locked_segment);
+  DRD_(sg_put)(p->last_locked_segment);
   p->last_locked_segment = 0;
 }
 
index c7d0fc682b752d32db02f00ebc6e8a566cbf50aa..824e459882ce5bb38c6f7c6b6663e8649d6e71ec 100644 (file)
@@ -215,7 +215,7 @@ static void rwlock_cleanup(struct rwlock_info* p)
   VG_(OSetGen_ResetIter)(p->thread_info);
   for ( ; (q = VG_(OSetGen_Next)(p->thread_info)) != 0; )
   {
-    sg_put(q->last_unlock_segment);
+    DRD_(sg_put)(q->last_unlock_segment);
   }
   VG_(OSetGen_Destroy)(p->thread_info);
 }
index 6cb3246249517538159c37cb1422b144e58ae038..0c7cf034e7fbdc46cb324f82608bd131cbc91b44 100644 (file)
 #include "pub_tool_threadstate.h" // VG_INVALID_THREADID
 
 
-// Local variables.
+/* Local variables. */
 
-static ULong s_created_segments_count;
-static ULong s_alive_segments_count;
-static ULong s_max_alive_segments_count;
-static Bool drd_trace_segment = False;
+static ULong DRD_(s_segments_created_count);
+static ULong DRD_(s_segments_alive_count);
+static ULong DRD_(s_max_segments_alive_count);
+static Bool DRD_(s_trace_segment) = False;
 
 
-// Function definitions.
+/* Function definitions. */
 
-/** Initialize the memory pointed at by sg.
+/**
+ * Initialize the memory 'sg' points at.
  *  @note The creator and created thread ID's may be equal.
  */
 static
-void sg_init(Segment* const sg,
-             DrdThreadId const creator,
-             DrdThreadId const created)
+void DRD_(sg_init)(Segment* const sg,
+                   DrdThreadId const creator,
+                   DrdThreadId const created)
 {
   Segment* creator_sg;
   ThreadId vg_created = DrdThreadIdToVgThreadId(created);
@@ -79,7 +80,7 @@ void sg_init(Segment* const sg,
   DRD_(vc_increment)(&sg->vc, created);
   sg->bm = bm_new();
 
-  if (drd_trace_segment)
+  if (DRD_(s_trace_segment))
   {
     char msg[256];
     VG_(snprintf)(msg, sizeof(msg),
@@ -95,8 +96,7 @@ void sg_init(Segment* const sg,
 }
 
 /** Deallocate the memory that was allocated by sg_init(). */
-static
-void sg_cleanup(Segment* const sg)
+static void DRD_(sg_cleanup)(Segment* const sg)
 {
   tl_assert(sg);
   tl_assert(sg->refcnt == 0);
@@ -107,26 +107,25 @@ void sg_cleanup(Segment* const sg)
 }
 
 /** Allocate and initialize a new segment. */
-Segment* sg_new(ThreadId const creator, ThreadId const created)
+Segment* DRD_(sg_new)(ThreadId const creator, ThreadId const created)
 {
   Segment* sg;
 
-  s_created_segments_count++;
-  s_alive_segments_count++;
-  if (s_max_alive_segments_count < s_alive_segments_count)
-    s_max_alive_segments_count = s_alive_segments_count;
+  DRD_(s_segments_created_count)++;
+  DRD_(s_segments_alive_count)++;
+  if (DRD_(s_max_segments_alive_count) < DRD_(s_segments_alive_count))
+    DRD_(s_max_segments_alive_count) = DRD_(s_segments_alive_count);
 
   sg = VG_(malloc)("drd.segment.sn.1", sizeof(*sg));
   tl_assert(sg);
-  sg_init(sg, creator, created);
+  DRD_(sg_init)(sg, creator, created);
   return sg;
 }
 
-static
-void sg_delete(Segment* const sg)
+static void DRD_(sg_delete)(Segment* const sg)
 {
 #if 1
-  if (sg_get_trace())
+  if (DRD_(sg_get_trace)())
   {
     char msg[256];
     VG_(snprintf)(msg, sizeof(msg),
@@ -137,15 +136,15 @@ void sg_delete(Segment* const sg)
   }
 #endif
 
-  s_alive_segments_count--;
+  DRD_(s_segments_alive_count)--;
 
   tl_assert(sg);
-  sg_cleanup(sg);
+  DRD_(sg_cleanup)(sg);
   VG_(free)(sg);
 }
 
 /** Query the reference count of the specified segment. */
-int sg_get_refcnt(const Segment* const sg)
+int DRD_(sg_get_refcnt)(const Segment* const sg)
 {
   tl_assert(sg);
 
@@ -153,7 +152,7 @@ int sg_get_refcnt(const Segment* const sg)
 }
 
 /** Increment the reference count of the specified segment. */
-Segment* sg_get(Segment* const sg)
+Segment* DRD_(sg_get)(Segment* const sg)
 {
   tl_assert(sg);
 
@@ -161,15 +160,16 @@ Segment* sg_get(Segment* const sg)
   return sg;
 }
 
-/** Decrement the reference count of the specified segment and deallocate the
- *  segment if the reference count became zero.
+/**
+ * Decrement the reference count of the specified segment and deallocate the
+ * segment if the reference count became zero.
  */
-void sg_put(Segment* const sg)
+void DRD_(sg_put)(Segment* const sg)
 {
   if (sg == 0)
     return;
 
-  if (drd_trace_segment)
+  if (DRD_(s_trace_segment))
   {
     char msg[256];
     VG_(snprintf)(msg, sizeof(msg),
@@ -184,19 +184,19 @@ void sg_put(Segment* const sg)
 
   if (--sg->refcnt == 0)
   {
-    sg_delete(sg);
+    DRD_(sg_delete)(sg);
   }
 }
 
 /** Merge sg1 and sg2 into sg1. */
-void sg_merge(const Segment* const sg1, Segment* const sg2)
+void DRD_(sg_merge)(const Segment* const sg1, Segment* const sg2)
 {
   tl_assert(sg1);
   tl_assert(sg1->refcnt == 1);
   tl_assert(sg2);
   tl_assert(sg2->refcnt == 1);
 
-  if (drd_trace_segment)
+  if (DRD_(s_trace_segment))
   {
       char msg[256];
 
@@ -216,7 +216,8 @@ void sg_merge(const Segment* const sg1, Segment* const sg2)
   bm_merge2(sg1->bm, sg2->bm);
 }
 
-void sg_print(const Segment* const sg)
+/** Print the vector clock and the bitmap of the specified segment. */
+void DRD_(sg_print)(const Segment* const sg)
 {
   tl_assert(sg);
   VG_(printf)("vc: ");
@@ -225,28 +226,30 @@ void sg_print(const Segment* const sg)
   bm_print(sg->bm);
 }
 
-Bool sg_get_trace(void)
+/** Query whether segment tracing has been enabled. */
+Bool DRD_(sg_get_trace)(void)
 {
-  return drd_trace_segment;
+  return DRD_(s_trace_segment);
 }
 
-void sg_set_trace(Bool const trace_segment)
+/** Enable or disable segment tracing. */
+void DRD_(sg_set_trace)(Bool const trace_segment)
 {
   tl_assert(trace_segment == False || trace_segment == True);
-  drd_trace_segment = trace_segment;
+  DRD_(s_trace_segment) = trace_segment;
 }
 
-ULong sg_get_created_segments_count(void)
+ULong DRD_(sg_get_segments_created_count)(void)
 {
-  return s_created_segments_count;
+  return DRD_(s_segments_created_count);
 }
 
-ULong sg_get_alive_segments_count(void)
+ULong DRD_(sg_get_segments_alive_count)(void)
 {
-  return s_alive_segments_count;
+  return DRD_(s_segments_alive_count);
 }
 
-ULong sg_get_max_alive_segments_count(void)
+ULong DRD_(sg_get_max_segments_alive_count)(void)
 {
-  return s_max_alive_segments_count;
+  return DRD_(s_max_segments_alive_count);
 }
index 487dc2293fd7098c3c663b19affb2458c1dada13..5cbcb602cb1434be1679420bcf2d3410654872e9 100644 (file)
 #define __SEGMENT_H
 
 
-// Segments and segment lists. A segment represents information about 
-// a contiguous group of statements of a specific thread. There is a vector
-// clock associated with each segment.
+/*
+ * Segments and segment lists. A segment represents information about 
+ * a contiguous group of statements of a specific thread. There is a vector
+ * clock associated with each segment.
+ */
 
 
 #include "drd_vc.h"
 
 typedef struct segment
 {
+  /** Pointers to next and previous segments executed by the same thread. */
   struct segment*    next;
   struct segment*    prev;
+  /** Reference count: number of pointers that point to this segment. */
   int                refcnt;
+  /** Stack trace of the first instruction of the segment. */
   ExeContext*        stacktrace;
+  /** Vector clock associated with the segment. */
   VectorClock        vc;
+  /**
+   * Bitmap representing the memory accesses by the instructions associated
+   * with the segment.
+   */
   struct bitmap*     bm;
 } Segment;
 
 
-Segment* sg_new(const ThreadId creator, const ThreadId created);
-int sg_get_refcnt(const Segment* const sg);
-Segment* sg_get(Segment* const sg);
-void sg_put(Segment* const sg);
-void sg_merge(const Segment* const sg1, Segment* const sg2);
-void sg_print(const Segment* const sg);
-Bool sg_get_trace(void);
-void sg_set_trace(const Bool trace_segment);
-ULong sg_get_created_segments_count(void);
-ULong sg_get_alive_segments_count(void);
-ULong sg_get_max_alive_segments_count(void);
+Segment* DRD_(sg_new)(const ThreadId creator, const ThreadId created);
+int DRD_(sg_get_refcnt)(const Segment* const sg);
+Segment* DRD_(sg_get)(Segment* const sg);
+void DRD_(sg_put)(Segment* const sg);
+void DRD_(sg_merge)(const Segment* const sg1, Segment* const sg2);
+void DRD_(sg_print)(const Segment* const sg);
+Bool DRD_(sg_get_trace)(void);
+void DRD_(sg_set_trace)(const Bool trace_segment);
+ULong DRD_(sg_get_segments_created_count)(void);
+ULong DRD_(sg_get_segments_alive_count)(void);
+ULong DRD_(sg_get_max_segments_alive_count)(void);
 
 
 #endif // __SEGMENT_H
index 1637cfe47f33ac02a43161175aab0f8880577ef9..bc6b4febcb699d34ea42771193c6df167c29512e 100644 (file)
@@ -120,7 +120,7 @@ static void semaphore_cleanup(struct semaphore_info* p)
                             &sei);
   }
   while ((sg = segment_pop(p)))
-    sg_put(sg);
+    DRD_(sg_put)(sg);
   VG_(deleteXA)(p->last_sem_post_seg);
 }
 
@@ -176,7 +176,7 @@ struct semaphore_info* semaphore_init(const Addr semaphore,
     // Remove all segments from the segment stack.
     while ((sg = segment_pop(p)))
     {
-      sg_put(sg);
+      DRD_(sg_put)(sg);
     }
   }
   else
@@ -283,7 +283,7 @@ void semaphore_post_wait(const DrdThreadId tid, const Addr semaphore,
       {
         thread_combine_vc2(tid, &sg->vc);
       }
-      sg_put(sg);
+      DRD_(sg_put)(sg);
       thread_new_segment(tid);
       s_semaphore_segment_creation_count++;
     }
index 2523d7beb4cac1ce50a76ddf1519b718d640d117..707f7bb3b480098056291e624fa448d64ec7f389 100644 (file)
@@ -225,7 +225,7 @@ DrdThreadId thread_pre_create(const DrdThreadId creator,
 
   tl_assert(s_threadinfo[created].first == 0);
   tl_assert(s_threadinfo[created].last == 0);
-  thread_append_segment(created, sg_new(creator, created));
+  thread_append_segment(created, DRD_(sg_new)(creator, created));
 
   return created;
 }
@@ -355,7 +355,7 @@ void thread_delete(const DrdThreadId tid)
     sg_prev = sg->prev;
     sg->prev = 0;
     sg->next = 0;
-    sg_put(sg);
+    DRD_(sg_put)(sg);
   }
   s_threadinfo[tid].vg_thread_exists = False;
   s_threadinfo[tid].posix_thread_exists = False;
@@ -459,7 +459,7 @@ void thread_set_running_tid(const ThreadId vg_tid, const DrdThreadId drd_tid)
                    " segments: %llu",
                    s_vg_running_tid, s_drd_running_tid,
                    DrdThreadIdToVgThreadId(drd_tid), drd_tid,
-                   sg_get_alive_segments_count());
+                   DRD_(sg_get_segments_alive_count)());
     }
     s_vg_running_tid = vg_tid;
     s_drd_running_tid = drd_tid;
@@ -523,7 +523,7 @@ static void thread_discard_segment(const DrdThreadId tid, Segment* const sg)
     s_threadinfo[tid].first = sg->next;
   if (sg == s_threadinfo[tid].last)
     s_threadinfo[tid].last = sg->prev;
-  sg_put(sg);
+  DRD_(sg_put)(sg);
 
   //tl_assert(sane_ThreadInfo(&s_threadinfo[tid]));
 }
@@ -546,8 +546,8 @@ void thread_get_latest_segment(Segment** sg, const DrdThreadId tid)
             && tid != DRD_INVALID_THREADID);
   tl_assert(s_threadinfo[tid].last);
 
-  sg_put(*sg);
-  *sg = sg_get(s_threadinfo[tid].last);
+  DRD_(sg_put)(*sg);
+  *sg = DRD_(sg_get)(s_threadinfo[tid].last);
 }
 
 /**
@@ -611,7 +611,7 @@ static void thread_discard_ordered_segments(void)
 
   DRD_(vc_init)(&thread_vc_min, 0, 0);
   thread_compute_minimum_vc(&thread_vc_min);
-  if (sg_get_trace())
+  if (DRD_(sg_get_trace)())
   {
     char msg[256];
     VectorClock thread_vc_max;
@@ -664,13 +664,13 @@ static void thread_merge_segments(void)
 
     for (sg = s_threadinfo[i].first; sg; sg = sg->next)
     {
-      if (sg_get_refcnt(sg) == 1
+      if (DRD_(sg_get_refcnt)(sg) == 1
           && sg->next
-          && sg_get_refcnt(sg->next) == 1
+          && DRD_(sg_get_refcnt)(sg->next) == 1
           && sg->next->next)
       {
         /* Merge sg and sg->next into sg. */
-        sg_merge(sg, sg->next);
+        DRD_(sg_merge)(sg, sg->next);
         thread_discard_segment(i, sg->next);
       }
     }
@@ -756,7 +756,7 @@ void thread_new_segment(const DrdThreadId tid)
   tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
             && tid != DRD_INVALID_THREADID);
 
-  new_sg = sg_new(tid, tid);
+  new_sg = DRD_(sg_new)(tid, tid);
   thread_append_segment(tid, new_sg);
 
   if (conflict_set_update_needed(tid, new_sg))
@@ -884,7 +884,7 @@ void thread_print_all(void)
                   s_threadinfo[i].detached_posix_thread);
       for (p = s_threadinfo[i].first; p; p = p->next)
       {
-        sg_print(p);
+        DRD_(sg_print)(p);
       }
     }
   }