blob: 27cc5d0aadbc9252afbe749d5d646b3abd0ee584 [file] [log] [blame]
sewardjaf44c822007-11-25 14:01:38 +00001/*
2 This file is part of drd, a data race detector.
3
sewardj85642922008-01-14 11:54:56 +00004 Copyright (C) 2006-2008 Bart Van Assche
sewardjaf44c822007-11-25 14:01:38 +00005 bart.vanassche@gmail.com
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307, USA.
21
22 The GNU General Public License is contained in the file COPYING.
23*/
24
25
26// Mutex state information: owner thread and recursion count.
27
28
bart777f7fe2008-03-02 17:43:18 +000029#ifndef __DRD_MUTEX_H
30#define __DRD_MUTEX_H
sewardjaf44c822007-11-25 14:01:38 +000031
32
sewardj721ad7b2007-11-30 08:30:29 +000033#include "drd_clientreq.h" // MutexT
sewardjaf44c822007-11-25 14:01:38 +000034#include "drd_thread.h" // DrdThreadId
sewardj721ad7b2007-11-30 08:30:29 +000035#include "drd_vc.h"
36#include "pub_tool_basics.h" // Addr, SizeT
sewardjaf44c822007-11-25 14:01:38 +000037
38
39struct mutex_info;
40
41
42void mutex_set_trace(const Bool trace_mutex);
sewardj721ad7b2007-11-30 08:30:29 +000043struct mutex_info* mutex_init(const Addr mutex, const SizeT size,
44 const MutexT mutex_type);
sewardj347eeba2008-01-21 14:19:07 +000045void mutex_post_destroy(const Addr mutex);
sewardjaf44c822007-11-25 14:01:38 +000046struct mutex_info* mutex_get(const Addr mutex);
bart3b1ee452008-02-29 19:28:15 +000047void mutex_pre_lock(const Addr mutex, const SizeT size,
48 const MutexT mutex_type);
bart777f7fe2008-03-02 17:43:18 +000049void mutex_post_lock(const Addr mutex, const Bool took_lock);
50void mutex_unlock(const Addr mutex, const MutexT mutex_type);
sewardjaf44c822007-11-25 14:01:38 +000051const char* mutex_get_typename(struct mutex_info* const p);
sewardj347eeba2008-01-21 14:19:07 +000052const char* mutex_type_name(const MutexT mt);
sewardjaf44c822007-11-25 14:01:38 +000053Bool mutex_is_locked_by(const Addr mutex, const DrdThreadId tid);
54const VectorClock* mutex_get_last_vc(const Addr mutex);
55int mutex_get_recursion_count(const Addr mutex);
bart291b3692008-02-24 18:27:11 +000056void mutex_thread_delete(const DrdThreadId tid);
sewardjaf44c822007-11-25 14:01:38 +000057ULong get_mutex_lock_count(void);
58
59
bart777f7fe2008-03-02 17:43:18 +000060#endif /* __DRD_MUTEX_H */