blob: e310398c3a026b5bfea370d41ce2678eff14063b [file] [log] [blame]
bartd59bb0f2008-06-08 08:08:31 +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_THREAD_BITMAP_H
27#define __DRD_THREAD_BITMAP_H
28
29#include "drd_bitmap.h"
30
31static __inline__
32Bool bm_access_load_1_triggers_conflict(const Addr a1)
33{
34 bm_access_load_1(running_thread_get_segment()->bm, a1);
35 return bm_load_1_has_conflict_with(thread_get_danger_set(), a1);
36}
37
38static __inline__
39Bool bm_access_load_2_triggers_conflict(const Addr a1)
40{
41 if ((a1 & 1) == 0)
42 {
43 bm_access_aligned_load(running_thread_get_segment()->bm, a1, 2);
44 return bm_aligned_load_has_conflict_with(thread_get_danger_set(), a1, 2);
45 }
46 else
47 {
48 bm_access_range(running_thread_get_segment()->bm, a1, a1 + 2, eLoad);
49 return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 2, eLoad);
50 }
51}
52
53static __inline__
54Bool bm_access_load_4_triggers_conflict(const Addr a1)
55{
56 if ((a1 & 3) == 0)
57 {
58 bm_access_aligned_load(running_thread_get_segment()->bm, a1, 4);
59 return bm_aligned_load_has_conflict_with(thread_get_danger_set(), a1, 4);
60 }
61 else
62 {
63 bm_access_range(running_thread_get_segment()->bm, a1, a1 + 4, eLoad);
64 return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 4, eLoad);
65 }
66}
67
68static __inline__
69Bool bm_access_load_8_triggers_conflict(const Addr a1)
70{
71 if ((a1 & 7) == 0)
72 {
73 bm_access_aligned_load(running_thread_get_segment()->bm, a1, 8);
74 return bm_aligned_load_has_conflict_with(thread_get_danger_set(), a1, 8);
75 }
76 else if ((a1 & 3) == 0)
77 {
78 bm_access_aligned_load(running_thread_get_segment()->bm, a1 + 0, 4);
79 bm_access_aligned_load(running_thread_get_segment()->bm, a1 + 4, 4);
80 return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 8, eLoad);
81 }
82 else
83 {
84 bm_access_range(running_thread_get_segment()->bm, a1, a1 + 8, eLoad);
85 return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 8, eLoad);
86 }
87}
88
89static __inline__
90Bool bm_access_load_triggers_conflict(const Addr a1, const Addr a2)
91{
92 bm_access_range_load(running_thread_get_segment()->bm, a1, a2);
93 return bm_load_has_conflict_with(thread_get_danger_set(), a1, a2);
94}
95
96static __inline__
97Bool bm_access_store_1_triggers_conflict(const Addr a1)
98{
99 bm_access_store_1(running_thread_get_segment()->bm, a1);
100 return bm_store_1_has_conflict_with(thread_get_danger_set(), a1);
101}
102
103static __inline__
104Bool bm_access_store_2_triggers_conflict(const Addr a1)
105{
106 if ((a1 & 1) == 0)
107 {
108 bm_access_aligned_store(running_thread_get_segment()->bm, a1, 2);
109 return bm_aligned_store_has_conflict_with(thread_get_danger_set(), a1, 2);
110 }
111 else
112 {
113 bm_access_range(running_thread_get_segment()->bm, a1, a1 + 2, eStore);
114 return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 2, eStore);
115 }
116}
117
118static __inline__
119Bool bm_access_store_4_triggers_conflict(const Addr a1)
120{
121 if ((a1 & 3) == 0)
122 {
123 bm_access_aligned_store(running_thread_get_segment()->bm, a1, 4);
124 return bm_aligned_store_has_conflict_with(thread_get_danger_set(), a1, 4);
125 }
126 else
127 {
128 bm_access_range(running_thread_get_segment()->bm, a1, a1 + 4, eStore);
129 return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 4, eStore);
130 }
131}
132
133static __inline__
134Bool bm_access_store_8_triggers_conflict(const Addr a1)
135{
136 if ((a1 & 7) == 0)
137 {
138 bm_access_aligned_store(running_thread_get_segment()->bm, a1, 8);
139 return bm_aligned_store_has_conflict_with(thread_get_danger_set(), a1, 8);
140 }
141 else if ((a1 & 3) == 0)
142 {
143 bm_access_aligned_store(running_thread_get_segment()->bm, a1 + 0, 4);
144 bm_access_aligned_store(running_thread_get_segment()->bm, a1 + 4, 4);
145 return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 8, eStore);
146 }
147 else
148 {
149 bm_access_range(running_thread_get_segment()->bm, a1, a1 + 8, eStore);
150 return bm_has_conflict_with(thread_get_danger_set(), a1, a1 + 8, eStore);
151 }
152}
153
154static __inline__
155Bool bm_access_store_triggers_conflict(const Addr a1, const Addr a2)
156{
157 bm_access_range_store(running_thread_get_segment()->bm, a1, a2);
158 return bm_store_has_conflict_with(thread_get_danger_set(), a1, a2);
159}
160
161#endif // __DRD_THREAD_BITMAP_H