blob: 972495a36c1d650c4713ea9fa454b6a7bac652c5 [file] [log] [blame]
barte7d58722008-02-28 19:08:04 +00001/*
2 This file is part of drd, a data race detector.
3
4 Copyright (C) 2006-2008 Bart Van Assche
5 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#ifndef __DRD_CLIENTOBJ_H
27#define __DRD_CLIENTOBJ_H
28
29
30#include "drd_clientreq.h" /* MutexT */
31#include "drd_thread.h" /* DrdThreadId */
32#include "pub_tool_basics.h"
33
34
35// Forward declarations.
36
37union drd_clientobj;
38
39
40// Type definitions.
41
42typedef enum { ClientMutex, } ObjType;
43
44struct any
45{
46 Addr a1;
47 Addr a2;
48 ObjType type;
49 void (*cleanup)(union drd_clientobj*);
50};
51
52struct mutex_info
53{
54 Addr a1;
55 Addr a2;
56 ObjType type;
57 void (*cleanup)(union drd_clientobj*);
58 MutexT mutex_type; // pthread_mutex_t or pthread_spinlock_t.
59 int recursion_count; // 0 if free, >= 1 if locked.
60 DrdThreadId owner; // owner if locked, last owner if free.
61 VectorClock vc; // vector clock associated with last unlock.
62};
63
64typedef union drd_clientobj
65{
66 struct any any;
67 struct mutex_info mutex;
68} DrdClientobj;
69
70
71// Function declarations.
72
73void drd_clientobj_init(void);
74void drd_clientobj_cleanup(void);
75DrdClientobj* drd_clientobj_get(const Addr addr, const ObjType t);
76Bool drd_clientobj_present(const Addr a1, const Addr a2);
77DrdClientobj* drd_clientobj_add(const Addr a1, const Addr a2, const ObjType t);
78Bool drd_clientobj_remove(const Addr addr);
79void drd_clientobj_stop_using_mem(const Addr a1, const Addr a2);
80void drd_clientobj_resetiter(void);
81DrdClientobj* drd_clientobj_next(const ObjType t);
82
83#endif /* __DRD_CLIENTOBJ_H */