blob: 102fd982b74cbd2835fd7ee8a861773e01220388 [file] [log] [blame]
bartd59bb0f2008-06-08 08:08:31 +00001/*
bart86562bd2009-02-16 19:43:56 +00002 This file is part of drd, a thread error detector.
bartd59bb0f2008-06-08 08:08:31 +00003
bart86562bd2009-02-16 19:43:56 +00004 Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>.
bartd59bb0f2008-06-08 08:08:31 +00005
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307, USA.
20
21 The GNU General Public License is contained in the file COPYING.
22*/
23
24
25#ifndef __DRD_THREAD_BITMAP_H
26#define __DRD_THREAD_BITMAP_H
27
bart09dc13f2009-02-14 15:13:31 +000028
bartd59bb0f2008-06-08 08:08:31 +000029#include "drd_bitmap.h"
bart09dc13f2009-02-14 15:13:31 +000030#include "drd_thread.h" /* running_thread_get_segment() */
31#include "pub_drd_bitmap.h"
32
bartd59bb0f2008-06-08 08:08:31 +000033
34static __inline__
35Bool bm_access_load_1_triggers_conflict(const Addr a1)
36{
bart99edb292009-02-15 15:59:20 +000037 DRD_(bm_access_load_1)(DRD_(running_thread_get_segment)()->bm, a1);
38 return DRD_(bm_load_1_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1);
bartd59bb0f2008-06-08 08:08:31 +000039}
40
41static __inline__
42Bool bm_access_load_2_triggers_conflict(const Addr a1)
43{
44 if ((a1 & 1) == 0)
45 {
bart62a784c2009-02-15 13:11:14 +000046 bm_access_aligned_load(DRD_(running_thread_get_segment)()->bm, a1, 2);
47 return bm_aligned_load_has_conflict_with(DRD_(thread_get_conflict_set)(), a1, 2);
bartd59bb0f2008-06-08 08:08:31 +000048 }
49 else
50 {
bart99edb292009-02-15 15:59:20 +000051 DRD_(bm_access_range)(DRD_(running_thread_get_segment)()->bm, a1, a1 + 2, eLoad);
52 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 2, eLoad);
bartd59bb0f2008-06-08 08:08:31 +000053 }
54}
55
56static __inline__
57Bool bm_access_load_4_triggers_conflict(const Addr a1)
58{
59 if ((a1 & 3) == 0)
60 {
bart62a784c2009-02-15 13:11:14 +000061 bm_access_aligned_load(DRD_(running_thread_get_segment)()->bm, a1, 4);
62 return bm_aligned_load_has_conflict_with(DRD_(thread_get_conflict_set)(), a1, 4);
bartd59bb0f2008-06-08 08:08:31 +000063 }
64 else
65 {
bart99edb292009-02-15 15:59:20 +000066 DRD_(bm_access_range)(DRD_(running_thread_get_segment)()->bm, a1, a1 + 4, eLoad);
67 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 4, eLoad);
bartd59bb0f2008-06-08 08:08:31 +000068 }
69}
70
71static __inline__
72Bool bm_access_load_8_triggers_conflict(const Addr a1)
73{
74 if ((a1 & 7) == 0)
75 {
bart62a784c2009-02-15 13:11:14 +000076 bm_access_aligned_load(DRD_(running_thread_get_segment)()->bm, a1, 8);
77 return bm_aligned_load_has_conflict_with(DRD_(thread_get_conflict_set)(), a1, 8);
bartd59bb0f2008-06-08 08:08:31 +000078 }
79 else if ((a1 & 3) == 0)
80 {
bart62a784c2009-02-15 13:11:14 +000081 bm_access_aligned_load(DRD_(running_thread_get_segment)()->bm, a1 + 0, 4);
82 bm_access_aligned_load(DRD_(running_thread_get_segment)()->bm, a1 + 4, 4);
bart99edb292009-02-15 15:59:20 +000083 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 8, eLoad);
bartd59bb0f2008-06-08 08:08:31 +000084 }
85 else
86 {
bart99edb292009-02-15 15:59:20 +000087 DRD_(bm_access_range)(DRD_(running_thread_get_segment)()->bm, a1, a1 + 8, eLoad);
88 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 8, eLoad);
bartd59bb0f2008-06-08 08:08:31 +000089 }
90}
91
92static __inline__
93Bool bm_access_load_triggers_conflict(const Addr a1, const Addr a2)
94{
bart99edb292009-02-15 15:59:20 +000095 DRD_(bm_access_range_load)(DRD_(running_thread_get_segment)()->bm, a1, a2);
96 return DRD_(bm_load_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a2);
bartd59bb0f2008-06-08 08:08:31 +000097}
98
99static __inline__
100Bool bm_access_store_1_triggers_conflict(const Addr a1)
101{
bart99edb292009-02-15 15:59:20 +0000102 DRD_(bm_access_store_1)(DRD_(running_thread_get_segment)()->bm, a1);
103 return DRD_(bm_store_1_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1);
bartd59bb0f2008-06-08 08:08:31 +0000104}
105
106static __inline__
107Bool bm_access_store_2_triggers_conflict(const Addr a1)
108{
109 if ((a1 & 1) == 0)
110 {
bart62a784c2009-02-15 13:11:14 +0000111 bm_access_aligned_store(DRD_(running_thread_get_segment)()->bm, a1, 2);
112 return bm_aligned_store_has_conflict_with(DRD_(thread_get_conflict_set)(), a1, 2);
bartd59bb0f2008-06-08 08:08:31 +0000113 }
114 else
115 {
bart99edb292009-02-15 15:59:20 +0000116 DRD_(bm_access_range)(DRD_(running_thread_get_segment)()->bm, a1, a1 + 2, eStore);
117 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 2, eStore);
bartd59bb0f2008-06-08 08:08:31 +0000118 }
119}
120
121static __inline__
122Bool bm_access_store_4_triggers_conflict(const Addr a1)
123{
124 if ((a1 & 3) == 0)
125 {
bart62a784c2009-02-15 13:11:14 +0000126 bm_access_aligned_store(DRD_(running_thread_get_segment)()->bm, a1, 4);
127 return bm_aligned_store_has_conflict_with(DRD_(thread_get_conflict_set)(), a1, 4);
bartd59bb0f2008-06-08 08:08:31 +0000128 }
129 else
130 {
bart99edb292009-02-15 15:59:20 +0000131 DRD_(bm_access_range)(DRD_(running_thread_get_segment)()->bm, a1, a1 + 4, eStore);
132 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 4, eStore);
bartd59bb0f2008-06-08 08:08:31 +0000133 }
134}
135
136static __inline__
137Bool bm_access_store_8_triggers_conflict(const Addr a1)
138{
139 if ((a1 & 7) == 0)
140 {
bart62a784c2009-02-15 13:11:14 +0000141 bm_access_aligned_store(DRD_(running_thread_get_segment)()->bm, a1, 8);
142 return bm_aligned_store_has_conflict_with(DRD_(thread_get_conflict_set)(), a1, 8);
bartd59bb0f2008-06-08 08:08:31 +0000143 }
144 else if ((a1 & 3) == 0)
145 {
bart62a784c2009-02-15 13:11:14 +0000146 bm_access_aligned_store(DRD_(running_thread_get_segment)()->bm, a1 + 0, 4);
147 bm_access_aligned_store(DRD_(running_thread_get_segment)()->bm, a1 + 4, 4);
bart99edb292009-02-15 15:59:20 +0000148 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 8, eStore);
bartd59bb0f2008-06-08 08:08:31 +0000149 }
150 else
151 {
bart99edb292009-02-15 15:59:20 +0000152 DRD_(bm_access_range)(DRD_(running_thread_get_segment)()->bm, a1, a1 + 8, eStore);
153 return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 8, eStore);
bartd59bb0f2008-06-08 08:08:31 +0000154 }
155}
156
157static __inline__
158Bool bm_access_store_triggers_conflict(const Addr a1, const Addr a2)
159{
bart99edb292009-02-15 15:59:20 +0000160 DRD_(bm_access_range_store)(DRD_(running_thread_get_segment)()->bm, a1, a2);
161 return DRD_(bm_store_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a2);
bartd59bb0f2008-06-08 08:08:31 +0000162}
163
164#endif // __DRD_THREAD_BITMAP_H