From: Bart Van Assche Date: Sat, 14 Feb 2009 12:14:50 +0000 (+0000) Subject: Added DRD_(spinlock_init_or_unlock)(). X-Git-Tag: svn/VALGRIND_3_5_0~996 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=233320f6142f161f9b583725cc14103aeb4a0f61;p=thirdparty%2Fvalgrind.git Added DRD_(spinlock_init_or_unlock)(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9150 --- diff --git a/drd/drd_mutex.c b/drd/drd_mutex.c index fe0888ca06..e4ae3b1543 100644 --- a/drd/drd_mutex.c +++ b/drd/drd_mutex.c @@ -1,8 +1,7 @@ /* This file is part of drd, a data race detector. - Copyright (C) 2006-2008 Bart Van Assche - bart.vanassche@gmail.com + Copyright (C) 2006-2009 Bart Van Assche . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -23,6 +22,7 @@ */ +#include "drd_basics.h" #include "drd_clientobj.h" #include "drd_error.h" #include "drd_mutex.h" @@ -425,6 +425,19 @@ void mutex_unlock(const Addr mutex, MutexT mutex_type) } } +void DRD_(spinlock_init_or_unlock)(const Addr spinlock) +{ + struct mutex_info* mutex_p = mutex_get(spinlock); + if (mutex_p) + { + mutex_unlock(spinlock, mutex_type_spinlock); + } + else + { + mutex_init(spinlock, mutex_type_spinlock); + } +} + const char* mutex_get_typename(struct mutex_info* const p) { tl_assert(p); diff --git a/drd/drd_mutex.h b/drd/drd_mutex.h index 956bb44852..289c1ea4c2 100644 --- a/drd/drd_mutex.h +++ b/drd/drd_mutex.h @@ -48,6 +48,7 @@ void mutex_pre_lock(const Addr mutex, const MutexT mutex_type, void mutex_post_lock(const Addr mutex, const Bool took_lock, const Bool post_cond_wait); void mutex_unlock(const Addr mutex, const MutexT mutex_type); +void DRD_(spinlock_init_or_unlock)(const Addr spinlock); const char* mutex_get_typename(struct mutex_info* const p); const char* mutex_type_name(const MutexT mt); Bool mutex_is_locked_by(const Addr mutex, const DrdThreadId tid);