AMD64).
- Change s_threadinfo[] from an array into an OSet or VgHashTable, in order to
make ThreadId <> DrdThreadId <> pthread_t conversions faster.
-- Write a configure test that figures out sizeof(pthread_mutex_t) etc.
- [AMD64] Find out why removing 'write(1, "", 0)' in drd_preloaded.c triggers
a crash on AMD64. Is this a drd or a VEX bug ?
- Reintroduce the const keyword in the function declarations of the OSet
#include "drd_suppression.h" // drd_start_suppression()
#include "drd_thread.h"
#include "drd_track.h"
-#include "pthread_object_size.h"
+#include "priv_drd_clientreq.h"
#include "pub_core_tooliface.h" // VG_TRACK()
#include "pub_tool_basics.h" // Bool
#include "pub_tool_libcassert.h"
struct mutex_info* mutex_p = mutex_get(spinlock);
if (mutex_p)
{
- mutex_unlock(spinlock);
+ mutex_unlock(spinlock, mutex_type_spinlock);
}
else
{
- mutex_init(spinlock, size);
+ mutex_init(spinlock, size, mutex_type_spinlock);
}
}
-static void drd_pre_cond_wait(const Addr cond, const Addr mutex)
+static void drd_pre_cond_wait(const Addr cond, const SizeT cond_size,
+ const Addr mutex)
{
- mutex_unlock(mutex);
- cond_pre_wait(cond, mutex);
+ mutex_unlock(mutex, mutex_type_mutex);
+ cond_pre_wait(cond, cond_size, mutex);
}
-static void drd_post_cond_wait(const Addr cond, const Addr mutex)
+static void drd_post_cond_wait(const Addr cond, const Addr mutex,
+ const SizeT size)
{
cond_post_wait(cond);
- mutex_lock(mutex, PTHREAD_MUTEX_SIZE);
+ mutex_lock(mutex, size, mutex_type_mutex);
}
static void drd_pre_cond_signal(const Addr cond)
break;
case VG_USERREQ__PRE_MUTEX_INIT:
- drd_pre_mutex_init(arg[1], arg[2]);
+ drd_pre_mutex_init(arg[1], arg[2], arg[3]);
break;
case VG_USERREQ__POST_MUTEX_DESTROY:
break;
case VG_USERREQ__PRE_PTHREAD_MUTEX_LOCK:
- drd_pre_mutex_lock(thread_get_running_tid(), arg[1], arg[2]);
+ drd_pre_mutex_lock(thread_get_running_tid(), arg[1], arg[2], arg[3]);
break;
case VG_USERREQ__POST_PTHREAD_MUTEX_LOCK:
- drd_post_mutex_lock(thread_get_running_tid(), arg[1], arg[2]);
+ drd_post_mutex_lock(thread_get_running_tid(), arg[1], arg[2], arg[3]);
break;
case VG_USERREQ__PRE_PTHREAD_MUTEX_UNLOCK:
- drd_pre_mutex_unlock(thread_get_running_tid(), arg[1]);
+ drd_pre_mutex_unlock(thread_get_running_tid(), arg[1], arg[3]);
break;
case VG_USERREQ__SPIN_INIT_OR_UNLOCK:
break;
case VG_USERREQ__PRE_PTHREAD_COND_DESTROY:
- drd_pre_cond_destroy(arg[1], arg[2]);
+ drd_pre_cond_destroy(arg[1]);
break;
case VG_USERREQ__PRE_PTHREAD_COND_WAIT:
- drd_pre_cond_wait(arg[1], arg[2]);
+ drd_pre_cond_wait(arg[1]/*cond*/, arg[2]/*cond_size*/, arg[3]/*mutex*/);
break;
case VG_USERREQ__POST_PTHREAD_COND_WAIT:
- drd_post_cond_wait(arg[1], arg[2]);
+ drd_post_cond_wait(arg[1]/*cond*/, arg[3]/*mutex*/,
+ arg[4]/*mutex_size*/);
break;
case VG_USERREQ__PRE_PTHREAD_COND_SIGNAL:
/* To notify the core of a pthread_mutex_init call */
VG_USERREQ__PRE_MUTEX_INIT,
- /* args: Addr, SizeT */
+ /* args: Addr, MutexT */
/* To notify the core of a pthread_mutex_destroy call */
VG_USERREQ__POST_MUTEX_DESTROY,
- /* args: Addr, SizeT */
+ /* args: Addr, SizeT, MutexT */
/* To notify the core of pthread_mutex_lock calls */
VG_USERREQ__PRE_PTHREAD_MUTEX_LOCK,
- /* args: Addr, SizeT */
+ /* args: Addr, SizeT, MutexT */
/* To notify the core of pthread_mutex_lock calls */
VG_USERREQ__POST_PTHREAD_MUTEX_LOCK,
- /* args: Addr, SizeT */
+ /* args: Addr, SizeT, MutexT */
/* To notify the core of pthread_mutex_unlock calls */
VG_USERREQ__PRE_PTHREAD_MUTEX_UNLOCK,
/* args: Addr */
/* To notify the core of a pthread_cond_init call */
VG_USERREQ__POST_PTHREAD_COND_INIT,
- /* args: Addr, SizeT */
+ /* args: Addr */
/* To notify the core of a pthread_cond_destroy call */
VG_USERREQ__PRE_PTHREAD_COND_DESTROY,
- /* args: Addr, SizeT */
+ /* args: Addr cond, SizeT cond_size, Addr mutex, SizeT mutex_size */
VG_USERREQ__PRE_PTHREAD_COND_WAIT,
- /* args: Addr cond, Addr mutex */
+ /* args: Addr cond, SizeT cond_size, Addr mutex, SizeT mutex_size */
VG_USERREQ__POST_PTHREAD_COND_WAIT,
- /* args: Addr cond, Addr mutex */
+ /* args: Addr cond, SizeT cond_size, Addr mutex, SizeT mutex_size */
VG_USERREQ__PRE_PTHREAD_COND_SIGNAL,
/* args: Addr cond */
VG_USERREQ__PRE_PTHREAD_COND_BROADCAST,
};
-void drd_clientreq_init(void);
+typedef enum
+{
+ mutex_type_mutex = 1,
+ mutex_type_spinlock = 2,
+} MutexT;
#endif // __DRD_CLIENTREQ_H
#include "drd_error.h"
#include "drd_mutex.h"
#include "drd_suppression.h"
-#include "pthread_object_size.h"
#include "pub_tool_errormgr.h" // VG_(maybe_record_error)()
#include "pub_tool_libcassert.h" // tl_assert()
#include "pub_tool_libcprint.h" // VG_(printf)()
}
static
-void cond_initialize(struct cond_info* const p, const Addr cond)
+void cond_initialize(struct cond_info* const p, const Addr cond,
+ const SizeT size)
{
tl_assert(cond != 0);
p->cond = cond;
+ p->size = size;
p->waiter_count = 0;
p->mutex = 0;
}
-static struct cond_info* cond_get_or_allocate(const Addr cond)
+static struct cond_info*
+cond_get_or_allocate(const Addr cond, const SizeT size)
{
int i;
for (i = 0; i < sizeof(s_cond)/sizeof(s_cond[0]); i++)
+ {
if (s_cond[i].cond == cond)
+ {
+ tl_assert(s_cond[i].size == size);
return &s_cond[i];
+ }
+ }
for (i = 0; i < sizeof(s_cond)/sizeof(s_cond[0]); i++)
{
if (s_cond[i].cond == 0)
{
- cond_initialize(&s_cond[i], cond);
+ cond_initialize(&s_cond[i], cond, size);
/* TO DO: replace the constant below by a symbolic constant referring */
/* to sizeof(pthread_cond_t). */
- drd_start_suppression(cond, cond + PTHREAD_COND_SIZE, "cond");
+ drd_start_suppression(cond, cond + size, "cond");
return &s_cond[i];
}
}
return 0;
}
-void cond_init(const Addr cond)
+void cond_init(const Addr cond, const SizeT size)
{
if (s_trace_cond)
{
VG_(clo_backtrace_size));
}
tl_assert(cond_get(cond) == 0);
- cond_get_or_allocate(cond);
+ tl_assert(size > 0);
+ cond_get_or_allocate(cond, size);
}
void cond_destroy(struct cond_info* const p)
// TO DO: print a proper error message if waiter_count != 0.
tl_assert(p->waiter_count == 0);
- drd_finish_suppression(p->cond, p->cond + PTHREAD_COND_SIZE);
+ drd_finish_suppression(p->cond, p->cond + p->size);
p->cond = 0;
p->waiter_count = 0;
return 0;
}
-int cond_pre_wait(const Addr cond, const Addr mutex)
+int cond_pre_wait(const Addr cond, const SizeT cond_size, const Addr mutex)
{
struct cond_info* p;
- p = cond_get_or_allocate(cond);
+ p = cond_get_or_allocate(cond, cond_size);
if (p->waiter_count == 0)
{
p->mutex = mutex;
{
if (a1 <= s_cond[i].cond && s_cond[i].cond < a2)
{
- tl_assert(s_cond[i].cond + PTHREAD_COND_SIZE <= a2);
+ tl_assert(s_cond[i].cond + s_cond[i].size <= a2);
cond_destroy(&s_cond[i]);
}
}
struct cond_info
{
- Addr cond; // Pointer to client condition variable.
- int waiter_count;
- Addr mutex; // Client mutex specified in pthread_cond_wait() call, and null
+ Addr cond; // Pointer to client condition variable.
+ SizeT size; // sizeof(pthread_cond_t)
+ int waiter_count;
+ Addr mutex; // Client mutex specified in pthread_cond_wait() call, and null
// if no client threads are currently waiting on this cond.var.
};
void cond_set_trace(const Bool trace_cond);
-void cond_init(const Addr cond);
+void cond_init(const Addr cond, const SizeT size);
void cond_destroy(struct cond_info* const p);
struct cond_info* cond_get(Addr const mutex);
-int cond_pre_wait(const Addr cond, const Addr mutex);
+int cond_pre_wait(const Addr cond, const SizeT cond_size, const Addr mutex);
int cond_post_wait(const Addr cond);
void cond_pre_signal(Addr const cond);
void cond_pre_broadcast(Addr const cond);
#include "drd_thread.h"
#include "drd_track.h"
#include "drd_vc.h"
-#include "pthread_object_size.h"
+#include "priv_drd_clientreq.h"
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_tool_vki.h"
thread_finished(drd_tid);
}
-void drd_pre_mutex_init(Addr mutex, SizeT size)
+void drd_pre_mutex_init(Addr mutex, SizeT size, MutexT mutex_type)
{
- mutex_init(mutex, size);
+ mutex_init(mutex, size, mutex_type);
}
-void drd_post_mutex_destroy(Addr mutex, SizeT size)
+void drd_post_mutex_destroy(Addr mutex, MutexT mutex_type)
{
struct mutex_info* p;
void drd_pre_mutex_lock(const DrdThreadId drd_tid,
const Addr mutex,
- const SizeT size)
+ const SizeT size,
+ const MutexT mutex_type)
{
if (mutex_get(mutex) == 0)
{
- mutex_init(mutex, size);
+ mutex_init(mutex, size, mutex_type);
}
}
void drd_post_mutex_lock(const DrdThreadId drd_tid,
const Addr mutex,
- const SizeT size)
+ const SizeT size,
+ const MutexT mutex_type)
{
- mutex_lock(mutex, size);
+ mutex_lock(mutex, size, mutex_type);
}
-void drd_pre_mutex_unlock(const DrdThreadId drd_tid, Addr mutex)
+void drd_pre_mutex_unlock(const DrdThreadId drd_tid,
+ const Addr mutex,
+ const MutexT mutex_type)
{
- mutex_unlock(mutex);
+ mutex_unlock(mutex, mutex_type);
}
void drd_post_cond_init(Addr cond, SizeT s)
{
- tl_assert(s == PTHREAD_COND_SIZE);
if (cond_get(cond))
{
CondErrInfo cei = { .cond = cond };
"initialized twice",
&cei);
}
- cond_init(cond);
+ cond_init(cond, s);
}
-void drd_pre_cond_destroy(Addr cond, SizeT s)
+void drd_pre_cond_destroy(Addr cond)
{
struct cond_info* cond_p;
- tl_assert(s == PTHREAD_COND_SIZE);
cond_p = cond_get(cond);
if (cond_p)
{
#include "drd_error.h"
#include "drd_mutex.h"
#include "drd_suppression.h"
-#include "pthread_object_size.h"
+#include "priv_drd_clientreq.h"
#include "pub_tool_errormgr.h" // VG_(maybe_record_error)()
#include "pub_tool_libcassert.h" // tl_assert()
#include "pub_tool_libcprint.h" // VG_(printf)()
{
Addr mutex; // Pointer to client mutex.
SizeT size; // Size in bytes of client-side object.
+ 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.
VectorClock vc; // vector clock associated with last unlock.
static
void mutex_initialize(struct mutex_info* const p,
const Addr mutex,
- const SizeT size)
+ const SizeT size,
+ const MutexT mutex_type)
{
tl_assert(mutex != 0);
tl_assert(size > 0);
+ tl_assert(mutex_type == mutex_type_mutex
+ || mutex_type == mutex_type_spinlock);
p->mutex = mutex;
p->size = size;
+ p->mutex_type = mutex_type;
p->recursion_count = 0;
p->owner = DRD_INVALID_THREADID;
vc_init(&p->vc, 0, 0);
}
static
-struct mutex_info* mutex_get_or_allocate(const Addr mutex, const SizeT size)
+struct mutex_info*
+mutex_get_or_allocate(const Addr mutex,
+ const SizeT size,
+ const MutexT mutex_type)
{
int i;
+
+ tl_assert(mutex_type == mutex_type_mutex
+ || mutex_type == mutex_type_spinlock);
+
for (i = 0; i < sizeof(s_mutex)/sizeof(s_mutex[0]); i++)
+ {
if (s_mutex[i].mutex == mutex)
+ {
+ tl_assert(s_mutex[i].mutex_type == mutex_type);
+ tl_assert(s_mutex[i].size == size);
return &s_mutex[i];
+ }
+ }
for (i = 0; i < sizeof(s_mutex)/sizeof(s_mutex[0]); i++)
{
if (s_mutex[i].mutex == 0)
{
- mutex_initialize(&s_mutex[i], mutex, size);
+ mutex_initialize(&s_mutex[i], mutex, size, mutex_type);
drd_start_suppression(mutex, mutex + size,
mutex_get_typename(&s_mutex[i]));
return &s_mutex[i];
return 0;
}
-struct mutex_info* mutex_init(const Addr mutex, const SizeT size)
+struct mutex_info*
+mutex_init(const Addr mutex, const SizeT size, const MutexT mutex_type)
{
struct mutex_info* mutex_p;
tl_assert(mutex_get(mutex) == 0);
- mutex_p = mutex_get_or_allocate(mutex, size);
+ tl_assert(mutex_type == mutex_type_mutex
+ || mutex_type == mutex_type_spinlock);
+ mutex_p = mutex_get_or_allocate(mutex, size, mutex_type);
if (s_trace_mutex)
{
* Note: this function must be called after pthread_mutex_lock() has been
* called, or a race condition is triggered !
*/
-int mutex_lock(const Addr mutex, const SizeT size)
+int mutex_lock(const Addr mutex, const SizeT size, MutexT mutex_type)
{
const DrdThreadId drd_tid = VgThreadIdToDrdThreadId(VG_(get_running_tid)());
- struct mutex_info* const p = mutex_get_or_allocate(mutex, size);
+ struct mutex_info* const p = mutex_get_or_allocate(mutex, size, mutex_type);
const DrdThreadId last_owner = p->owner;
if (s_trace_mutex)
p ? p->owner : VG_INVALID_THREADID);
}
- if (p->recursion_count >= 1 && p->size == PTHREAD_SPINLOCK_SIZE)
+ tl_assert(mutex_type == mutex_type_mutex
+ || mutex_type == mutex_type_spinlock);
+ tl_assert(p->mutex_type == mutex_type);
+ tl_assert(p->size == size);
+
+ if (p->recursion_count >= 1 && mutex_type == mutex_type_spinlock)
{
// TO DO: tell the user in a more friendly way that it is not allowed to
// lock spinlocks recursively.
* @param tid ThreadId of the thread calling pthread_mutex_unlock().
* @param vc Pointer to the current vector clock of thread tid.
*/
-int mutex_unlock(const Addr mutex)
+int mutex_unlock(const Addr mutex, const MutexT mutex_type)
{
const DrdThreadId drd_tid = VgThreadIdToDrdThreadId(VG_(get_running_tid)());
const ThreadId vg_tid = DrdThreadIdToVgThreadId(drd_tid);
}
tl_assert(p);
+ tl_assert(p->mutex_type == mutex_type);
tl_assert(p->owner != DRD_INVALID_THREADID);
+ tl_assert(mutex_type == mutex_type_mutex
+ || mutex_type == mutex_type_spinlock);
+
if (p->owner != drd_tid)
{
MutexErrInfo MEI = { p->mutex, p->recursion_count, p->owner };
const char* mutex_get_typename(struct mutex_info* const p)
{
tl_assert(p);
- switch (p->size)
+
+ switch (p->mutex_type)
{
- case PTHREAD_MUTEX_SIZE:
+ case mutex_type_mutex:
return "mutex";
- case PTHREAD_SPINLOCK_SIZE:
+ case mutex_type_spinlock:
return "spinlock";
default:
tl_assert(0);
#define __MUTEX_H
-#include "pub_tool_basics.h" // Addr, SizeT
-#include "drd_vc.h"
+#include "drd_clientreq.h" // MutexT
#include "drd_thread.h" // DrdThreadId
+#include "drd_vc.h"
+#include "pub_tool_basics.h" // Addr, SizeT
struct mutex_info;
void mutex_set_trace(const Bool trace_mutex);
-struct mutex_info* mutex_init(const Addr mutex, const SizeT size);
+struct mutex_info* mutex_init(const Addr mutex, const SizeT size,
+ const MutexT mutex_type);
void mutex_destroy(struct mutex_info* const p);
struct mutex_info* mutex_get(const Addr mutex);
-int mutex_lock(const Addr mutex, const SizeT size);
-int mutex_unlock(const Addr mutex);
+int mutex_lock(const Addr mutex, const SizeT size, const MutexT mutex_type);
+int mutex_unlock(const Addr mutex, const MutexT mutex_type);
const char* mutex_get_typename(struct mutex_info* const p);
Bool mutex_is_locked_by(const Addr mutex, const DrdThreadId tid);
const VectorClock* mutex_get_last_vc(const Addr mutex);
#include "pub_core_debuginfo.h" // Needed for pub_core_redir.h
#include "pub_core_redir.h" // For VG_NOTIFY_ON_LOAD
#include "pub_tool_threadstate.h"// VG_N_THREADS
-#include "pthread_object_size.h" // PTHREAD_MUTEX_SIZE etc.
// Defines.
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK,
0, 0, 0, 0, 0);
- // Sanity checks.
- assert(sizeof(pthread_mutex_t) == PTHREAD_MUTEX_SIZE);
- assert(sizeof(pthread_spinlock_t) == PTHREAD_SPINLOCK_SIZE);
-
// Make sure that DRD knows about the main thread's POSIX thread ID.
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SET_PTHREADID,
pthread_self(), 0, 0, 0, 0);
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_MUTEX_INIT,
- mutex, sizeof(*mutex), 0, 0, 0);
+ mutex, sizeof(*mutex), mutex_type_mutex, 0, 0);
CALL_FN_W_WW(ret, fn, mutex, attr);
return ret;
}
VALGRIND_GET_ORIG_FN(fn);
CALL_FN_W_W(ret, fn, mutex);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_DESTROY,
- mutex, sizeof(*mutex), 0, 0, 0);
+ mutex, mutex_type_mutex, 0, 0, 0);
return ret;
}
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_PTHREAD_MUTEX_LOCK,
- mutex, sizeof(*mutex), 0, 0, 0);
+ mutex, sizeof(*mutex), mutex_type_mutex, 0, 0);
#if 1
// The only purpose of the system call below is to make drd work on AMD64
// systems. Without this system call, clients crash (SIGSEGV) in
CALL_FN_W_W(ret, fn, mutex);
if (ret == 0)
VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__POST_PTHREAD_MUTEX_LOCK,
- mutex, sizeof(*mutex), 0, 0, 0);
+ mutex, sizeof(*mutex), mutex_type_mutex, 0, 0);
return ret;
}
if (ret == 0)
{
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_PTHREAD_MUTEX_LOCK,
- mutex, sizeof(*mutex), 0, 0, 0);
+ mutex, sizeof(*mutex), mutex_type_mutex, 0, 0);
}
return ret;
}
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1,
VG_USERREQ__PRE_PTHREAD_MUTEX_UNLOCK,
- mutex, sizeof(*mutex), 0, 0, 0);
+ mutex, sizeof(*mutex), mutex_type_mutex, 0, 0);
CALL_FN_W_W(ret, fn, mutex);
return ret;
}
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_PTHREAD_COND_DESTROY,
- cond, sizeof(*cond), 0, 0, 0);
+ cond, 0, 0, 0, 0);
CALL_FN_W_W(ret, fn, cond);
return ret;
}
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_PTHREAD_COND_WAIT,
- cond, mutex, 0, 0, 0);
+ cond, sizeof(*cond), mutex, sizeof(*mutex), 0);
CALL_FN_W_WW(ret, fn, cond, mutex);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_PTHREAD_COND_WAIT,
- cond, mutex, 0, 0, 0);
+ cond, sizeof(*cond), mutex, sizeof(*mutex), 0);
return ret;
}
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_PTHREAD_COND_WAIT,
- cond, mutex, 0, 0, 0);
+ cond, sizeof(*cond), mutex, sizeof(*mutex), 0);
CALL_FN_W_WWW(ret, fn, cond, mutex, abstime);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_PTHREAD_COND_WAIT,
- cond, mutex, 0, 0, 0);
+ cond, sizeof(*cond), mutex, sizeof(*mutex), 0);
return ret;
}
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SPIN_INIT_OR_UNLOCK,
- spinlock, sizeof(*spinlock), 0, 0, 0);
+ spinlock, sizeof(*spinlock),
+ mutex_type_spinlock, 0, 0);
CALL_FN_W_WW(ret, fn, spinlock, pshared);
return ret;
}
VALGRIND_GET_ORIG_FN(fn);
CALL_FN_W_W(ret, fn, spinlock);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_DESTROY,
- spinlock, sizeof(*spinlock), 0, 0, 0);
+ spinlock, mutex_type_spinlock, 0, 0, 0);
return ret;
}
if (ret == 0)
{
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_PTHREAD_MUTEX_LOCK,
- spinlock, sizeof(*spinlock), 0, 0, 0);
+ spinlock, sizeof(*spinlock),
+ mutex_type_spinlock, 0, 0);
}
return ret;
}
if (ret == 0)
{
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_PTHREAD_MUTEX_LOCK,
- spinlock, sizeof(*spinlock), 0, 0, 0);
+ spinlock, sizeof(*spinlock),
+ mutex_type_spinlock, 0, 0);
}
return ret;
}
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SPIN_INIT_OR_UNLOCK,
- spinlock, sizeof(*spinlock), 0, 0, 0);
+ spinlock, sizeof(*spinlock),
+ mutex_type_spinlock, 0, 0);
CALL_FN_W_W(ret, fn, spinlock);
return ret;
}
#include "drd_segment.h"
#include "drd_suppression.h"
#include "drd_thread.h"
-#include "pthread_object_size.h"
#include "pub_core_options.h" // VG_(clo_backtrace_size)
#include "pub_tool_basics.h" // Addr, SizeT
#include "pub_tool_errormgr.h" // VG_(unique_error)()
void drd_post_thread_join(DrdThreadId joiner, DrdThreadId joinee);
-void drd_pre_mutex_init(Addr mutex, SizeT size);
-void drd_post_mutex_destroy(Addr mutex, SizeT size);
-void drd_pre_mutex_lock(DrdThreadId tid, Addr mutex, const SizeT size);
-void drd_post_mutex_lock(DrdThreadId tid, Addr mutex, const SizeT size);
-void drd_pre_mutex_unlock(DrdThreadId tid, Addr mutex);
+void drd_pre_mutex_init(Addr mutex, SizeT size, const MutexT mutex_type);
+void drd_post_mutex_destroy(Addr mutex, const MutexT mutex_type);
+void drd_pre_mutex_lock(DrdThreadId tid, Addr mutex, const SizeT size,
+ const MutexT mutex_type);
+void drd_post_mutex_lock(DrdThreadId tid, Addr mutex, const SizeT size,
+ const MutexT mutex_type);
+void drd_pre_mutex_unlock(const DrdThreadId tid, const Addr mutex,
+ const MutexT mutex_type);
void drd_post_cond_init(Addr cond, SizeT s);
-void drd_pre_cond_destroy(Addr cond, SizeT s);
+void drd_pre_cond_destroy(Addr cond);
--- /dev/null
+/*
+ This file is part of drd, a data race detector.
+
+ Copyright (C) 2006-2007 Bart Van Assche
+ bart.vanassche@gmail.com
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PRIV_DRD_CLIENTREQ_H
+#define __PRIV_DRD_CLIENTREQ_H
+
+void drd_clientreq_init(void);
+
+#endif /* __PRIV_DRD_CLIENTREQ_H */
+++ /dev/null
-// TO DO: replace the constants below by macro's #define'd during the configure
-// phase.
-
-#if defined(VGP_x86_linux)
-# define PTHREAD_MUTEX_SIZE 24
-# define PTHREAD_COND_SIZE 48
-#elif defined(VGP_amd64_linux)
-# define PTHREAD_MUTEX_SIZE 40
-# define PTHREAD_COND_SIZE 48
-#else
- /* FIXME: fill these fields in correctly. 32 is arbitrary. */
-# define PTHREAD_MUTEX_SIZE 32
-# define PTHREAD_COND_SIZE 32
-#endif
-#define PTHREAD_SPINLOCK_SIZE 4
pth_detached_LDADD = -lpthread
sigalrm_SOURCES = sigalrm.c
-sigalrm_LDADD = -lpthread -lrt
+sigalrm_LDADD = -lpthread