From: Bart Van Assche Date: Sun, 15 Feb 2009 11:34:57 +0000 (+0000) Subject: Wrapped DRD_() macro around all client object function names. X-Git-Tag: svn/VALGRIND_3_5_0~980 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=280e61760d2981de86d3aa89375c26dcace1b0d0;p=thirdparty%2Fvalgrind.git Wrapped DRD_() macro around all client object function names. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9166 --- diff --git a/drd/drd_barrier.c b/drd/drd_barrier.c index 624d318691..0e2e80c794 100644 --- a/drd/drd_barrier.c +++ b/drd/drd_barrier.c @@ -116,8 +116,9 @@ void DRD_(barrier_initialize)(struct barrier_info* const p, VG_(free)); } -/** Deallocate the memory allocated by barrier_initialize() and in p->oset. - * Called by clientobj_destroy(). +/** + * Deallocate the memory allocated by barrier_initialize() and in p->oset. + * Called by clientobj_destroy(). */ void DRD_(barrier_cleanup)(struct barrier_info* p) { @@ -156,10 +157,10 @@ DRD_(barrier_get_or_allocate)(const Addr barrier, tl_assert(barrier_type == pthread_barrier || barrier_type == gomp_barrier); tl_assert(offsetof(DrdClientobj, barrier) == 0); - p = &(clientobj_get(barrier, ClientBarrier)->barrier); + p = &(DRD_(clientobj_get)(barrier, ClientBarrier)->barrier); if (p == 0) { - p = &(clientobj_add(barrier, ClientBarrier)->barrier); + p = &(DRD_(clientobj_add)(barrier, ClientBarrier)->barrier); DRD_(barrier_initialize)(p, barrier, barrier_type, count); } return p; @@ -170,7 +171,7 @@ DRD_(barrier_get_or_allocate)(const Addr barrier, static struct barrier_info* DRD_(barrier_get)(const Addr barrier) { tl_assert(offsetof(DrdClientobj, barrier) == 0); - return &(clientobj_get(barrier, ClientBarrier)->barrier); + return &(DRD_(clientobj_get)(barrier, ClientBarrier)->barrier); } /** Initialize a barrier with client address barrier, client size size, and @@ -288,7 +289,7 @@ void DRD_(barrier_destroy)(const Addr barrier, const BarrierT barrier_type) &bei); } - clientobj_remove(p->a1, ClientBarrier); + DRD_(clientobj_remove)(p->a1, ClientBarrier); } /** Called before pthread_barrier_wait(). */ @@ -415,8 +416,8 @@ void DRD_(barrier_thread_delete)(const DrdThreadId tid) { struct barrier_info* p; - clientobj_resetiter(); - for ( ; (p = &clientobj_next(ClientBarrier)->barrier) != 0; ) + DRD_(clientobj_resetiter)(); + for ( ; (p = &(DRD_(clientobj_next)(ClientBarrier)->barrier)) != 0; ) { struct barrier_thread_info* q; const UWord word_tid = tid; diff --git a/drd/drd_clientobj.c b/drd/drd_clientobj.c index 074bc1634d..6506182908 100644 --- a/drd/drd_clientobj.c +++ b/drd/drd_clientobj.c @@ -36,21 +36,21 @@ #include "pub_tool_threadstate.h" // VG_(get_running_tid)() -// Local variables. +/* Local variables. */ static OSet* s_clientobj; static Bool s_trace_clientobj; -// Function definitions. +/* Function definitions. */ -void clientobj_set_trace(const Bool trace) +void DRD_(clientobj_set_trace)(const Bool trace) { s_trace_clientobj = trace; } /** Initialize the client object set. */ -void clientobj_init(void) +void DRD_(clientobj_init)(void) { tl_assert(s_clientobj == 0); s_clientobj = VG_(OSetGen_Create)(0, 0, VG_(malloc), "drd.clientobj.ci.1", @@ -58,10 +58,12 @@ void clientobj_init(void) tl_assert(s_clientobj); } -/** Free the memory allocated for the client object set. - * @pre Client object set is empty. +/** + * Free the memory allocated for the client object set. + * + * @pre Client object set is empty. */ -void clientobj_cleanup(void) +void DRD_(clientobj_cleanup)(void) { tl_assert(s_clientobj); tl_assert(VG_(OSetGen_Size)(s_clientobj) == 0); @@ -73,7 +75,7 @@ void clientobj_cleanup(void) * Return 0 if there is no client object in the set with the specified start * address. */ -DrdClientobj* clientobj_get_any(const Addr addr) +DrdClientobj* DRD_(clientobj_get_any)(const Addr addr) { return VG_(OSetGen_Lookup)(s_clientobj, &addr); } @@ -82,7 +84,7 @@ DrdClientobj* clientobj_get_any(const Addr addr) * and that has object type t. Return 0 if there is no client object in the * set with the specified start address. */ -DrdClientobj* clientobj_get(const Addr addr, const ObjType t) +DrdClientobj* DRD_(clientobj_get)(const Addr addr, const ObjType t) { DrdClientobj* p; p = VG_(OSetGen_Lookup)(s_clientobj, &addr); @@ -94,7 +96,7 @@ DrdClientobj* clientobj_get(const Addr addr, const ObjType t) /** Return true if and only if the address range of any client object overlaps * with the specified address range. */ -Bool clientobj_present(const Addr a1, const Addr a2) +Bool DRD_(clientobj_present)(const Addr a1, const Addr a2) { DrdClientobj *p; @@ -114,12 +116,11 @@ Bool clientobj_present(const Addr a1, const Addr a2) * of type t. Suppress data race reports on the address range [addr,addr+size[. * @pre No other client object is present in the address range [addr,addr+size[. */ -DrdClientobj* -clientobj_add(const Addr a1, const ObjType t) +DrdClientobj* DRD_(clientobj_add)(const Addr a1, const ObjType t) { DrdClientobj* p; - tl_assert(! clientobj_present(a1, a1 + 1)); + tl_assert(! DRD_(clientobj_present)(a1, a1 + 1)); tl_assert(VG_(OSetGen_Lookup)(s_clientobj, &a1) == 0); if (s_trace_clientobj) @@ -138,7 +139,7 @@ clientobj_add(const Addr a1, const ObjType t) return p; } -Bool clientobj_remove(const Addr addr, const ObjType t) +Bool DRD_(clientobj_remove)(const Addr addr, const ObjType t) { DrdClientobj* p; @@ -166,7 +167,7 @@ Bool clientobj_remove(const Addr addr, const ObjType t) return False; } -void clientobj_stop_using_mem(const Addr a1, const Addr a2) +void DRD_(clientobj_stop_using_mem)(const Addr a1, const Addr a2) { Addr removed_at; DrdClientobj* p; @@ -183,7 +184,7 @@ void clientobj_stop_using_mem(const Addr a1, const Addr a2) if (a1 <= p->any.a1 && p->any.a1 < a2) { removed_at = p->any.a1; - clientobj_remove(p->any.a1, p->any.type); + DRD_(clientobj_remove)(p->any.a1, p->any.type); /* The above call removes an element from the oset and hence */ /* invalidates the iterator. Set the iterator back. */ VG_(OSetGen_ResetIter)(s_clientobj); @@ -198,12 +199,12 @@ void clientobj_stop_using_mem(const Addr a1, const Addr a2) } } -void clientobj_resetiter(void) +void DRD_(clientobj_resetiter)(void) { VG_(OSetGen_ResetIter)(s_clientobj); } -DrdClientobj* clientobj_next(const ObjType t) +DrdClientobj* DRD_(clientobj_next)(const ObjType t) { DrdClientobj* p; while ((p = VG_(OSetGen_Next)(s_clientobj)) != 0 && p->any.type != t) @@ -211,7 +212,7 @@ DrdClientobj* clientobj_next(const ObjType t) return p; } -const char* clientobj_type_name(const ObjType t) +const char* DRD_(clientobj_type_name)(const ObjType t) { switch (t) { diff --git a/drd/drd_clientobj.h b/drd/drd_clientobj.h index 1bfdd9337f..4add811938 100644 --- a/drd/drd_clientobj.h +++ b/drd/drd_clientobj.h @@ -27,20 +27,20 @@ #define __DRD_CLIENTOBJ_H +#include "drd_basics.h" /* DrdThreadId */ #include "drd_clientreq.h" /* MutexT */ -#include "drd_thread.h" /* DrdThreadId */ #include "pub_tool_basics.h" #include "pub_tool_execontext.h" /* ExeContext */ #include "pub_tool_oset.h" #include "pub_tool_xarray.h" -// Forward declarations. +/* Forward declarations. */ union drd_clientobj; -// Type definitions. +/* Type definitions. */ typedef enum { ClientMutex = 1, @@ -60,16 +60,16 @@ struct any struct mutex_info { - Addr a1; - ObjType type; - void (*cleanup)(union drd_clientobj*); - ExeContext* first_observed_at; - MutexT mutex_type; // pthread_mutex_t or pthread_spinlock_t. - int recursion_count; // 0 if free, >= 1 if locked. - DrdThreadId owner; // owner if locked, last owner if free. - Segment* last_locked_segment; - ULong acquiry_time_ms; - ExeContext* acquired_at; + Addr a1; + ObjType type; + void (*cleanup)(union drd_clientobj*); + ExeContext* first_observed_at; + MutexT mutex_type; // pthread_mutex_t or pthread_spinlock_t. + int recursion_count; // 0 if free, >= 1 if locked. + DrdThreadId owner; // owner if locked, last owner if free. + struct segment* last_locked_segment; + ULong acquiry_time_ms; + ExeContext* acquired_at; }; struct cond_info @@ -134,20 +134,20 @@ typedef union drd_clientobj } DrdClientobj; -// Function declarations. - -void clientobj_set_trace(const Bool trace); -void clientobj_init(void); -void clientobj_cleanup(void); -DrdClientobj* clientobj_get_any(const Addr addr); -DrdClientobj* clientobj_get(const Addr addr, const ObjType t); -Bool clientobj_present(const Addr a1, const Addr a2); -DrdClientobj* clientobj_add(const Addr a1, const ObjType t); -Bool clientobj_remove(const Addr addr, const ObjType t); -void clientobj_stop_using_mem(const Addr a1, const Addr a2); -void clientobj_resetiter(void); -DrdClientobj* clientobj_next(const ObjType t); -const char* clientobj_type_name(const ObjType t); +/* Function declarations. */ + +void DRD_(clientobj_set_trace)(const Bool trace); +void DRD_(clientobj_init)(void); +void DRD_(clientobj_cleanup)(void); +DrdClientobj* DRD_(clientobj_get_any)(const Addr addr); +DrdClientobj* DRD_(clientobj_get)(const Addr addr, const ObjType t); +Bool DRD_(clientobj_present)(const Addr a1, const Addr a2); +DrdClientobj* DRD_(clientobj_add)(const Addr a1, const ObjType t); +Bool DRD_(clientobj_remove)(const Addr addr, const ObjType t); +void DRD_(clientobj_stop_using_mem)(const Addr a1, const Addr a2); +void DRD_(clientobj_resetiter)(void); +DrdClientobj* DRD_(clientobj_next)(const ObjType t); +const char* DRD_(clientobj_type_name)(const ObjType t); #endif /* __DRD_CLIENTOBJ_H */ diff --git a/drd/drd_cond.c b/drd/drd_cond.c index 219f7b3fb6..06027b2c72 100644 --- a/drd/drd_cond.c +++ b/drd/drd_cond.c @@ -70,8 +70,9 @@ void cond_initialize(struct cond_info* const p, const Addr cond) p->mutex = 0; } -/** Free the memory that was allocated by cond_initialize(). Called by - * clientobj_remove(). +/** + * Free the memory that was allocated by cond_initialize(). Called by + * DRD_(clientobj_remove)(). */ static void cond_cleanup(struct cond_info* p) { @@ -79,7 +80,7 @@ static void cond_cleanup(struct cond_info* p) if (p->mutex) { struct mutex_info* q; - q = &clientobj_get(p->mutex, ClientMutex)->mutex; + q = &(DRD_(clientobj_get)(p->mutex, ClientMutex)->mutex); tl_assert(q); { CondDestrErrInfo cde = { p->a1, q->a1, q->owner }; @@ -98,10 +99,10 @@ static struct cond_info* cond_get_or_allocate(const Addr cond) struct cond_info *p; tl_assert(offsetof(DrdClientobj, cond) == 0); - p = &clientobj_get(cond, ClientCondvar)->cond; + p = &(DRD_(clientobj_get)(cond, ClientCondvar)->cond); if (p == 0) { - p = &clientobj_add(cond, ClientCondvar)->cond; + p = &(DRD_(clientobj_add)(cond, ClientCondvar)->cond); cond_initialize(p, cond); } return p; @@ -110,7 +111,7 @@ static struct cond_info* cond_get_or_allocate(const Addr cond) static struct cond_info* cond_get(const Addr cond) { tl_assert(offsetof(DrdClientobj, cond) == 0); - return &clientobj_get(cond, ClientCondvar)->cond; + return &(DRD_(clientobj_get)(cond, ClientCondvar)->cond); } /** Called before pthread_cond_init(). */ @@ -179,7 +180,7 @@ void cond_post_destroy(const Addr cond) &cei); } - clientobj_remove(p->a1, ClientCondvar); + DRD_(clientobj_remove)(p->a1, ClientCondvar); } /** Called before pthread_cond_wait(). Note: before this function is called, diff --git a/drd/drd_error.c b/drd/drd_error.c index c06dea95e6..870cb2e803 100644 --- a/drd/drd_error.c +++ b/drd/drd_error.c @@ -78,13 +78,13 @@ static void first_observed(const Addr obj) { DrdClientobj* cl; - cl = clientobj_get_any(obj); + cl = DRD_(clientobj_get_any)(obj); if (cl) { tl_assert(cl->any.first_observed_at); VG_(message)(Vg_UserMsg, "%s 0x%lx was first observed at:", - clientobj_type_name(cl->any.type), + DRD_(clientobj_type_name)(cl->any.type), obj); VG_(pp_ExeContext)(cl->any.first_observed_at); } diff --git a/drd/drd_main.c b/drd/drd_main.c index 8e9b8a20cf..ca8b6c35fd 100644 --- a/drd/drd_main.c +++ b/drd/drd_main.c @@ -129,7 +129,7 @@ static Bool DRD_(process_cmd_line_option)(Char* arg) if (trace_barrier != -1) DRD_(barrier_set_trace)(trace_barrier); if (trace_clientobj != -1) - clientobj_set_trace(trace_clientobj); + DRD_(clientobj_set_trace)(trace_clientobj); if (trace_cond != -1) cond_set_trace(trace_cond); if (trace_csw != -1) @@ -296,7 +296,7 @@ void drd_stop_using_mem(const Addr a1, const SizeT len, if (! is_stack_mem || DRD_(get_check_stack_accesses)()) { thread_stop_using_mem(a1, a2); - clientobj_stop_using_mem(a1, a2); + DRD_(clientobj_stop_using_mem)(a1, a2); DRD_(suppression_stop_using_mem)(a1, a2); } } @@ -615,7 +615,7 @@ void drd_pre_clo_init(void) DRD_(suppression_init)(); - clientobj_init(); + DRD_(clientobj_init)(); } diff --git a/drd/drd_mutex.c b/drd/drd_mutex.c index 4860fedfe8..136a644a44 100644 --- a/drd/drd_mutex.c +++ b/drd/drd_mutex.c @@ -129,13 +129,13 @@ mutex_get_or_allocate(const Addr mutex, const MutexT mutex_type) struct mutex_info* p; tl_assert(offsetof(DrdClientobj, mutex) == 0); - p = &clientobj_get(mutex, ClientMutex)->mutex; + p = &(DRD_(clientobj_get)(mutex, ClientMutex)->mutex); if (p) { return p; } - if (clientobj_present(mutex, mutex + 1)) + if (DRD_(clientobj_present)(mutex, mutex + 1)) { not_a_mutex(mutex); return 0; @@ -143,7 +143,7 @@ mutex_get_or_allocate(const Addr mutex, const MutexT mutex_type) tl_assert(mutex_type != mutex_type_unknown); - p = &clientobj_add(mutex, ClientMutex)->mutex; + p = &(DRD_(clientobj_add)(mutex, ClientMutex)->mutex); mutex_initialize(p, mutex, mutex_type); return p; } @@ -151,7 +151,7 @@ mutex_get_or_allocate(const Addr mutex, const MutexT mutex_type) struct mutex_info* mutex_get(const Addr mutex) { tl_assert(offsetof(DrdClientobj, mutex) == 0); - return &clientobj_get(mutex, ClientMutex)->mutex; + return &(DRD_(clientobj_get)(mutex, ClientMutex)->mutex); } /** Called before pthread_mutex_init(). */ @@ -208,7 +208,7 @@ void mutex_post_destroy(const Addr mutex) return; } - clientobj_remove(mutex, ClientMutex); + DRD_(clientobj_remove)(mutex, ClientMutex); } /** Called before pthread_mutex_lock() is invoked. If a data structure for @@ -497,8 +497,8 @@ void mutex_thread_delete(const DrdThreadId tid) { struct mutex_info* p; - clientobj_resetiter(); - for ( ; (p = &clientobj_next(ClientMutex)->mutex) != 0; ) + DRD_(clientobj_resetiter)(); + for ( ; (p = &(DRD_(clientobj_next)(ClientMutex)->mutex)) != 0; ) { if (p->owner == tid && p->recursion_count > 0) { diff --git a/drd/drd_rwlock.c b/drd/drd_rwlock.c index 824e459882..78abbb87ae 100644 --- a/drd/drd_rwlock.c +++ b/drd/drd_rwlock.c @@ -227,13 +227,13 @@ rwlock_get_or_allocate(const Addr rwlock) struct rwlock_info* p; tl_assert(offsetof(DrdClientobj, rwlock) == 0); - p = &clientobj_get(rwlock, ClientRwlock)->rwlock; + p = &(DRD_(clientobj_get)(rwlock, ClientRwlock)->rwlock); if (p) { return p; } - if (clientobj_present(rwlock, rwlock + 1)) + if (DRD_(clientobj_present)(rwlock, rwlock + 1)) { GenericErrInfo GEI; VG_(maybe_record_error)(VG_(get_running_tid)(), @@ -244,7 +244,7 @@ rwlock_get_or_allocate(const Addr rwlock) return 0; } - p = &clientobj_add(rwlock, ClientRwlock)->rwlock; + p = &(DRD_(clientobj_add)(rwlock, ClientRwlock)->rwlock); rwlock_initialize(p, rwlock); return p; } @@ -252,7 +252,7 @@ rwlock_get_or_allocate(const Addr rwlock) static struct rwlock_info* rwlock_get(const Addr rwlock) { tl_assert(offsetof(DrdClientobj, rwlock) == 0); - return &clientobj_get(rwlock, ClientRwlock)->rwlock; + return &(DRD_(clientobj_get)(rwlock, ClientRwlock)->rwlock); } /** Called before pthread_rwlock_init(). */ @@ -306,7 +306,7 @@ void rwlock_post_destroy(const Addr rwlock) return; } - clientobj_remove(rwlock, ClientRwlock); + DRD_(clientobj_remove)(rwlock, ClientRwlock); } /** Called before pthread_rwlock_rdlock() is invoked. If a data structure for @@ -562,8 +562,8 @@ void rwlock_thread_delete(const DrdThreadId tid) { struct rwlock_info* p; - clientobj_resetiter(); - for ( ; (p = &clientobj_next(ClientRwlock)->rwlock) != 0; ) + DRD_(clientobj_resetiter)(); + for ( ; (p = &(DRD_(clientobj_next)(ClientRwlock)->rwlock)) != 0; ) { struct rwlock_thread_info* q; if (rwlock_is_locked_by(p, tid)) diff --git a/drd/drd_semaphore.c b/drd/drd_semaphore.c index bc6b4febcb..c3bad6b305 100644 --- a/drd/drd_semaphore.c +++ b/drd/drd_semaphore.c @@ -102,8 +102,9 @@ void semaphore_initialize(struct semaphore_info* const p, const Addr semaphore) VG_(free), sizeof(Segment*)); } -/** Free the memory that was allocated by semaphore_initialize(). Called by - * clientobj_remove(). +/** + * Free the memory that was allocated by semaphore_initialize(). Called by + * DRD_(clientobj_remove)(). */ static void semaphore_cleanup(struct semaphore_info* p) { @@ -131,11 +132,11 @@ semaphore_get_or_allocate(const Addr semaphore) struct semaphore_info *p; tl_assert(offsetof(DrdClientobj, semaphore) == 0); - p = &clientobj_get(semaphore, ClientSemaphore)->semaphore; + p = &(DRD_(clientobj_get)(semaphore, ClientSemaphore)->semaphore); if (p == 0) { tl_assert(offsetof(DrdClientobj, semaphore) == 0); - p = &clientobj_add(semaphore, ClientSemaphore)->semaphore; + p = &(DRD_(clientobj_add)(semaphore, ClientSemaphore)->semaphore); semaphore_initialize(p, semaphore); } return p; @@ -144,7 +145,7 @@ semaphore_get_or_allocate(const Addr semaphore) static struct semaphore_info* semaphore_get(const Addr semaphore) { tl_assert(offsetof(DrdClientobj, semaphore) == 0); - return &clientobj_get(semaphore, ClientSemaphore)->semaphore; + return &(DRD_(clientobj_get)(semaphore, ClientSemaphore)->semaphore); } /** Called before sem_init(). */ @@ -217,7 +218,7 @@ void semaphore_destroy(const Addr semaphore) return; } - clientobj_remove(semaphore, ClientSemaphore); + DRD_(clientobj_remove)(semaphore, ClientSemaphore); } /** Called before sem_wait(). */