]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added DRD_(spinlock_init_or_unlock)().
authorBart Van Assche <bvanassche@acm.org>
Sat, 14 Feb 2009 12:14:50 +0000 (12:14 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 14 Feb 2009 12:14:50 +0000 (12:14 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9150

drd/drd_mutex.c
drd/drd_mutex.h

index fe0888ca06e609dcccba301d7e3b94d51aaf58d5..e4ae3b1543f1a43775b1318d55f25c3991935664 100644 (file)
@@ -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 <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
@@ -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);
index 956bb44852f6b7bde45bbdcd6132a5f6ba1e3cb4..289c1ea4c20e445a6fedd083f8b3235717ee184a 100644 (file)
@@ -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);