bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 1 | /* |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 2 | This file is part of drd, a thread error detector. |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 3 | |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 4 | Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>. |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 5 | |
| 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 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 28 | |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 29 | #include "drd_bitmap.h" |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 30 | #include "drd_thread.h" /* running_thread_get_segment() */ |
| 31 | #include "pub_drd_bitmap.h" |
| 32 | |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 33 | |
| 34 | static __inline__ |
| 35 | Bool bm_access_load_1_triggers_conflict(const Addr a1) |
| 36 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 37 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static __inline__ |
| 42 | Bool bm_access_load_2_triggers_conflict(const Addr a1) |
| 43 | { |
| 44 | if ((a1 & 1) == 0) |
| 45 | { |
bart | 62a784c | 2009-02-15 13:11:14 +0000 | [diff] [blame] | 46 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 48 | } |
| 49 | else |
| 50 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 51 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | |
| 56 | static __inline__ |
| 57 | Bool bm_access_load_4_triggers_conflict(const Addr a1) |
| 58 | { |
| 59 | if ((a1 & 3) == 0) |
| 60 | { |
bart | 62a784c | 2009-02-15 13:11:14 +0000 | [diff] [blame] | 61 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 63 | } |
| 64 | else |
| 65 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 66 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
| 71 | static __inline__ |
| 72 | Bool bm_access_load_8_triggers_conflict(const Addr a1) |
| 73 | { |
| 74 | if ((a1 & 7) == 0) |
| 75 | { |
bart | 62a784c | 2009-02-15 13:11:14 +0000 | [diff] [blame] | 76 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 78 | } |
| 79 | else if ((a1 & 3) == 0) |
| 80 | { |
bart | 62a784c | 2009-02-15 13:11:14 +0000 | [diff] [blame] | 81 | 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); |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 83 | return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 8, eLoad); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 84 | } |
| 85 | else |
| 86 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 87 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | |
| 92 | static __inline__ |
| 93 | Bool bm_access_load_triggers_conflict(const Addr a1, const Addr a2) |
| 94 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 95 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | static __inline__ |
| 100 | Bool bm_access_store_1_triggers_conflict(const Addr a1) |
| 101 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 102 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | static __inline__ |
| 107 | Bool bm_access_store_2_triggers_conflict(const Addr a1) |
| 108 | { |
| 109 | if ((a1 & 1) == 0) |
| 110 | { |
bart | 62a784c | 2009-02-15 13:11:14 +0000 | [diff] [blame] | 111 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 113 | } |
| 114 | else |
| 115 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 116 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
| 121 | static __inline__ |
| 122 | Bool bm_access_store_4_triggers_conflict(const Addr a1) |
| 123 | { |
| 124 | if ((a1 & 3) == 0) |
| 125 | { |
bart | 62a784c | 2009-02-15 13:11:14 +0000 | [diff] [blame] | 126 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 128 | } |
| 129 | else |
| 130 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 131 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 133 | } |
| 134 | } |
| 135 | |
| 136 | static __inline__ |
| 137 | Bool bm_access_store_8_triggers_conflict(const Addr a1) |
| 138 | { |
| 139 | if ((a1 & 7) == 0) |
| 140 | { |
bart | 62a784c | 2009-02-15 13:11:14 +0000 | [diff] [blame] | 141 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 143 | } |
| 144 | else if ((a1 & 3) == 0) |
| 145 | { |
bart | 62a784c | 2009-02-15 13:11:14 +0000 | [diff] [blame] | 146 | 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); |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 148 | return DRD_(bm_has_conflict_with)(DRD_(thread_get_conflict_set)(), a1, a1 + 8, eStore); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 149 | } |
| 150 | else |
| 151 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 152 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | |
| 157 | static __inline__ |
| 158 | Bool bm_access_store_triggers_conflict(const Addr a1, const Addr a2) |
| 159 | { |
bart | 99edb29 | 2009-02-15 15:59:20 +0000 | [diff] [blame] | 160 | 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); |
bart | d59bb0f | 2008-06-08 08:08:31 +0000 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | #endif // __DRD_THREAD_BITMAP_H |