From: Bart Van Assche Date: Sun, 22 Jan 2012 08:40:42 +0000 (+0000) Subject: drd: Source code refactoring - use DRD_(thread_get_vc)() wherever appropriate X-Git-Tag: svn/VALGRIND_3_8_0~504 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61dff515e6be9b9d58599abbdb88ccffd424eb96;p=thirdparty%2Fvalgrind.git drd: Source code refactoring - use DRD_(thread_get_vc)() wherever appropriate git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12349 --- diff --git a/drd/drd_hb.c b/drd/drd_hb.c index 1e522900e3..ff02f9521c 100644 --- a/drd/drd_hb.c +++ b/drd/drd_hb.c @@ -210,14 +210,14 @@ void DRD_(hb_happens_after)(const DrdThreadId tid, const Addr hb) * Combine all vector clocks that were stored because of happens-before * annotations with the vector clock of the current thread. */ - DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[tid].last->vc); + DRD_(vc_copy)(&old_vc, DRD_(thread_get_vc)(tid)); VG_(OSetGen_ResetIter)(p->oset); for ( ; (q = VG_(OSetGen_Next)(p->oset)) != 0; ) { if (q->tid != tid) { tl_assert(q->sg); - DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc, &q->sg->vc); + DRD_(vc_combine)(DRD_(thread_get_vc)(tid), &q->sg->vc); } } DRD_(thread_update_conflict_set)(tid, &old_vc); diff --git a/drd/drd_rwlock.c b/drd/drd_rwlock.c index 1662d8c28b..aaa61e0ddd 100644 --- a/drd/drd_rwlock.c +++ b/drd/drd_rwlock.c @@ -171,7 +171,7 @@ static void DRD_(rwlock_combine_other_vc)(struct rwlock_info* const p, struct rwlock_thread_info* q; VectorClock old_vc; - DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[tid].last->vc); + DRD_(vc_copy)(&old_vc, DRD_(thread_get_vc)(tid)); VG_(OSetGen_ResetIter)(p->thread_info); for ( ; (q = VG_(OSetGen_Next)(p->thread_info)) != 0; ) { @@ -179,12 +179,12 @@ static void DRD_(rwlock_combine_other_vc)(struct rwlock_info* const p, { if (q->latest_wrlocked_segment) { - DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc, + DRD_(vc_combine)(DRD_(thread_get_vc)(tid), &q->latest_wrlocked_segment->vc); } if (readers_too && q->latest_rdlocked_segment) { - DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc, + DRD_(vc_combine)(DRD_(thread_get_vc)(tid), &q->latest_rdlocked_segment->vc); } } diff --git a/drd/drd_thread.c b/drd/drd_thread.c index ec5297d619..c28bcff241 100644 --- a/drd/drd_thread.c +++ b/drd/drd_thread.c @@ -1075,8 +1075,8 @@ void DRD_(thread_combine_vc_join)(DrdThreadId joiner, DrdThreadId joinee) if (DRD_(sg_get_trace)()) { char *str1, *str2; - str1 = DRD_(vc_aprint)(&DRD_(g_threadinfo)[joiner].last->vc); - str2 = DRD_(vc_aprint)(&DRD_(g_threadinfo)[joinee].last->vc); + str1 = DRD_(vc_aprint)(DRD_(thread_get_vc)(joiner)); + str2 = DRD_(vc_aprint)(DRD_(thread_get_vc)(joinee)); VG_(message)(Vg_DebugMsg, "Before join: joiner %s, joinee %s\n", str1, str2); VG_(free)(str1); @@ -1086,17 +1086,17 @@ void DRD_(thread_combine_vc_join)(DrdThreadId joiner, DrdThreadId joinee) { VectorClock old_vc; - DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[joiner].last->vc); - DRD_(vc_combine)(&DRD_(g_threadinfo)[joiner].last->vc, - &DRD_(g_threadinfo)[joinee].last->vc); + DRD_(vc_copy)(&old_vc, DRD_(thread_get_vc)(joiner)); + DRD_(vc_combine)(DRD_(thread_get_vc)(joiner), + DRD_(thread_get_vc)(joinee)); DRD_(thread_update_conflict_set)(joiner, &old_vc); s_update_conflict_set_join_count++; DRD_(vc_cleanup)(&old_vc); } else { - DRD_(vc_combine)(&DRD_(g_threadinfo)[joiner].last->vc, - &DRD_(g_threadinfo)[joinee].last->vc); + DRD_(vc_combine)(DRD_(thread_get_vc)(joiner), + DRD_(thread_get_vc)(joinee)); } thread_discard_ordered_segments(); @@ -1104,7 +1104,7 @@ void DRD_(thread_combine_vc_join)(DrdThreadId joiner, DrdThreadId joinee) if (DRD_(sg_get_trace)()) { char* str; - str = DRD_(vc_aprint)(&DRD_(g_threadinfo)[joiner].last->vc); + str = DRD_(vc_aprint)(DRD_(thread_get_vc)(joiner)); VG_(message)(Vg_DebugMsg, "After join: %s\n", str); VG_(free)(str); } @@ -1128,13 +1128,13 @@ static void thread_combine_vc_sync(DrdThreadId tid, const Segment* sg) { VectorClock old_vc; - DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[tid].last->vc); - DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc, vc); + DRD_(vc_copy)(&old_vc, DRD_(thread_get_vc)(tid)); + DRD_(vc_combine)(DRD_(thread_get_vc)(tid), vc); if (DRD_(sg_get_trace)()) { char *str1, *str2; str1 = DRD_(vc_aprint)(&old_vc); - str2 = DRD_(vc_aprint)(&DRD_(g_threadinfo)[tid].last->vc); + str2 = DRD_(vc_aprint)(DRD_(thread_get_vc)(tid)); VG_(message)(Vg_DebugMsg, "thread %d: vc %s -> %s\n", tid, str1, str2); VG_(free)(str1); VG_(free)(str2); @@ -1149,7 +1149,7 @@ static void thread_combine_vc_sync(DrdThreadId tid, const Segment* sg) } else { - tl_assert(DRD_(vc_lte)(vc, &DRD_(g_threadinfo)[tid].last->vc)); + tl_assert(DRD_(vc_lte)(vc, DRD_(thread_get_vc)(tid))); } } @@ -1407,7 +1407,7 @@ static void thread_compute_conflict_set(struct bitmap** conflict_set, { char* str; - str = DRD_(vc_aprint)(&DRD_(g_threadinfo)[tid].last->vc); + str = DRD_(vc_aprint)(DRD_(thread_get_vc)(tid)); VG_(message)(Vg_DebugMsg, "computing conflict set for thread %d with vc %s\n", tid, str); @@ -1503,14 +1503,14 @@ void DRD_(thread_update_conflict_set)(const DrdThreadId tid, { char* str; - str = DRD_(vc_aprint)(&DRD_(g_threadinfo)[tid].last->vc); + str = DRD_(vc_aprint)(DRD_(thread_get_vc)(tid)); VG_(message)(Vg_DebugMsg, "updating conflict set for thread %d with vc %s\n", tid, str); VG_(free)(str); } - new_vc = &DRD_(g_threadinfo)[tid].last->vc; + new_vc = DRD_(thread_get_vc)(tid); tl_assert(DRD_(vc_lte)(old_vc, new_vc)); DRD_(bm_unmark)(DRD_(g_conflict_set));