Wrapped DRD_() macro around all segment function names.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9160 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/drd/drd_barrier.c b/drd/drd_barrier.c
index fd4ecfa..689e582 100644
--- a/drd/drd_barrier.c
+++ b/drd/drd_barrier.c
@@ -85,8 +85,8 @@
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,
diff --git a/drd/drd_main.c b/drd/drd_main.c
index fb7934d..49efafd 100644
--- a/drd/drd_main.c
+++ b/drd/drd_main.c
@@ -143,7 +143,7 @@
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 @@
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)",
diff --git a/drd/drd_mutex.c b/drd/drd_mutex.c
index e4ae3b1..4860fed 100644
--- a/drd/drd_mutex.c
+++ b/drd/drd_mutex.c
@@ -107,7 +107,7 @@
&MEI);
}
- sg_put(p->last_locked_segment);
+ DRD_(sg_put)(p->last_locked_segment);
p->last_locked_segment = 0;
}
diff --git a/drd/drd_rwlock.c b/drd/drd_rwlock.c
index c7d0fc6..824e459 100644
--- a/drd/drd_rwlock.c
+++ b/drd/drd_rwlock.c
@@ -215,7 +215,7 @@
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);
}
diff --git a/drd/drd_segment.c b/drd/drd_segment.c
index 6cb3246..0c7cf03 100644
--- a/drd/drd_segment.c
+++ b/drd/drd_segment.c
@@ -36,23 +36,24 @@
#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 @@
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 @@
}
/** 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 @@
}
/** 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 @@
}
#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 @@
}
/** 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 @@
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 @@
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 @@
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 @@
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);
}
diff --git a/drd/drd_segment.h b/drd/drd_segment.h
index 487dc22..5cbcb60 100644
--- a/drd/drd_segment.h
+++ b/drd/drd_segment.h
@@ -27,9 +27,11 @@
#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"
@@ -40,26 +42,34 @@
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
diff --git a/drd/drd_semaphore.c b/drd/drd_semaphore.c
index 1637cfe..bc6b4fe 100644
--- a/drd/drd_semaphore.c
+++ b/drd/drd_semaphore.c
@@ -120,7 +120,7 @@
&sei);
}
while ((sg = segment_pop(p)))
- sg_put(sg);
+ DRD_(sg_put)(sg);
VG_(deleteXA)(p->last_sem_post_seg);
}
@@ -176,7 +176,7 @@
// Remove all segments from the segment stack.
while ((sg = segment_pop(p)))
{
- sg_put(sg);
+ DRD_(sg_put)(sg);
}
}
else
@@ -283,7 +283,7 @@
{
thread_combine_vc2(tid, &sg->vc);
}
- sg_put(sg);
+ DRD_(sg_put)(sg);
thread_new_segment(tid);
s_semaphore_segment_creation_count++;
}
diff --git a/drd/drd_thread.c b/drd/drd_thread.c
index 2523d7b..707f7bb 100644
--- a/drd/drd_thread.c
+++ b/drd/drd_thread.c
@@ -225,7 +225,7 @@
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 @@
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 @@
" 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 @@
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 @@
&& 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 @@
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 @@
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 @@
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 @@
s_threadinfo[i].detached_posix_thread);
for (p = s_threadinfo[i].first; p; p = p->next)
{
- sg_print(p);
+ DRD_(sg_print)(p);
}
}
}