1 /* -*- mode: C; c-basic-offset: 3; indent-tabs-mode: nil; -*- */
3 This file is part of drd, a thread error detector.
5 Copyright (C) 2006-2011 Bart Van Assche <bvanassche@acm.org>.
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.
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.
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
22 The GNU General Public License is contained in the file COPYING.
27 * A bitmap is a data structure that contains information about which
28 * addresses have been accessed for reading or writing within a given
33 #ifndef __PUB_DRD_BITMAP_H
34 #define __PUB_DRD_BITMAP_H
37 #include "drd_basics.h" /* DRD_() */
38 #include "pub_tool_basics.h" /* Addr, SizeT */
39 #include "pub_tool_oset.h" /* struct _OSet */
48 #define HAS_RACE(a) ((((a) & RHS_W) && ((a) & (LHS_R | LHS_W))) \
49 || (((a) & LHS_W) && ((a) & (RHS_R | RHS_W))))
52 /* Forward declarations. */
57 /* Datatype definitions. */
59 typedef enum { eLoad, eStore, eStart, eEnd } BmAccessTypeT;
67 #define DRD_BITMAP_N_CACHE_ELEM 4
69 /* Complete bitmap. */
72 struct bm_cache_elem cache[DRD_BITMAP_N_CACHE_ELEM];
77 /* Function declarations. */
79 struct bitmap* DRD_(bm_new)(void);
80 void DRD_(bm_delete)(struct bitmap* const bm);
81 void DRD_(bm_init)(struct bitmap* const bm);
82 void DRD_(bm_cleanup)(struct bitmap* const bm);
83 void DRD_(bm_access_range)(struct bitmap* const bm,
84 const Addr a1, const Addr a2,
85 const BmAccessTypeT access_type);
86 void DRD_(bm_access_range_load)(struct bitmap* const bm,
87 const Addr a1, const Addr a2);
88 void DRD_(bm_access_load_1)(struct bitmap* const bm, const Addr a1);
89 void DRD_(bm_access_load_2)(struct bitmap* const bm, const Addr a1);
90 void DRD_(bm_access_load_4)(struct bitmap* const bm, const Addr a1);
91 void DRD_(bm_access_load_8)(struct bitmap* const bm, const Addr a1);
92 void DRD_(bm_access_range_store)(struct bitmap* const bm,
93 const Addr a1, const Addr a2);
94 void DRD_(bm_access_store_1)(struct bitmap* const bm, const Addr a1);
95 void DRD_(bm_access_store_2)(struct bitmap* const bm, const Addr a1);
96 void DRD_(bm_access_store_4)(struct bitmap* const bm, const Addr a1);
97 void DRD_(bm_access_store_8)(struct bitmap* const bm, const Addr a1);
98 Bool DRD_(bm_has)(struct bitmap* const bm,
99 const Addr a1, const Addr a2,
100 const BmAccessTypeT access_type);
101 Bool DRD_(bm_has_any_load)(struct bitmap* const bm,
102 const Addr a1, const Addr a2);
103 Bool DRD_(bm_has_any_store)(struct bitmap* const bm,
104 const Addr a1, const Addr a2);
105 Bool DRD_(bm_has_any_access)(struct bitmap* const bm,
106 const Addr a1, const Addr a2);
107 Bool DRD_(bm_has_1)(struct bitmap* const bm,
108 const Addr address, const BmAccessTypeT access_type);
109 void DRD_(bm_clear)(struct bitmap* const bm,
110 const Addr a1, const Addr a2);
111 void DRD_(bm_clear_load)(struct bitmap* const bm,
112 const Addr a1, const Addr a2);
113 void DRD_(bm_clear_store)(struct bitmap* const bm,
114 const Addr a1, const Addr a2);
115 Bool DRD_(bm_test_and_clear)(struct bitmap* const bm,
116 const Addr a1, const Addr a2);
117 Bool DRD_(bm_has_conflict_with)(struct bitmap* const bm,
118 const Addr a1, const Addr a2,
119 const BmAccessTypeT access_type);
120 Bool DRD_(bm_load_1_has_conflict_with)(struct bitmap* const bm, const Addr a1);
121 Bool DRD_(bm_load_2_has_conflict_with)(struct bitmap* const bm, const Addr a1);
122 Bool DRD_(bm_load_4_has_conflict_with)(struct bitmap* const bm, const Addr a1);
123 Bool DRD_(bm_load_8_has_conflict_with)(struct bitmap* const bm, const Addr a1);
124 Bool DRD_(bm_load_has_conflict_with)(struct bitmap* const bm,
125 const Addr a1, const Addr a2);
126 Bool DRD_(bm_store_1_has_conflict_with)(struct bitmap* const bm,const Addr a1);
127 Bool DRD_(bm_store_2_has_conflict_with)(struct bitmap* const bm,const Addr a1);
128 Bool DRD_(bm_store_4_has_conflict_with)(struct bitmap* const bm,const Addr a1);
129 Bool DRD_(bm_store_8_has_conflict_with)(struct bitmap* const bm,const Addr a1);
130 Bool DRD_(bm_store_has_conflict_with)(struct bitmap* const bm,
131 const Addr a1, const Addr a2);
132 Bool DRD_(bm_equal)(struct bitmap* const lhs, struct bitmap* const rhs);
133 void DRD_(bm_swap)(struct bitmap* const bm1, struct bitmap* const bm2);
134 void DRD_(bm_merge2)(struct bitmap* const lhs, struct bitmap* const rhs);
135 void DRD_(bm_unmark)(struct bitmap* bm);
136 Bool DRD_(bm_is_marked)(struct bitmap* bm, const Addr a);
137 void DRD_(bm_mark)(struct bitmap* bm1, struct bitmap* bm2);
138 void DRD_(bm_clear_marked)(struct bitmap* bm);
139 void DRD_(bm_merge2_marked)(struct bitmap* const lhs, struct bitmap* const rhs);
140 void DRD_(bm_remove_cleared_marked)(struct bitmap* bm);
141 int DRD_(bm_has_races)(struct bitmap* const bm1,
142 struct bitmap* const bm2);
143 void DRD_(bm_report_races)(ThreadId const tid1, ThreadId const tid2,
144 struct bitmap* const bm1,
145 struct bitmap* const bm2);
146 void DRD_(bm_print)(struct bitmap* bm);
147 ULong DRD_(bm_get_bitmap_creation_count)(void);
148 ULong DRD_(bm_get_bitmap2_creation_count)(void);
149 ULong DRD_(bm_get_bitmap2_merge_count)(void);
151 void* DRD_(bm2_alloc_node)(HChar* const ec, const SizeT szB);
152 void DRD_(bm2_free_node)(void* const bm2);
154 #endif /* __PUB_DRD_BITMAP_H */