sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 26 | #include "drd_clientreq.h" |
| 27 | #include "drd_cond.h" |
| 28 | #include "drd_mutex.h" |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 29 | #include "drd_semaphore.h" |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 30 | #include "drd_suppression.h" // drd_start_suppression() |
| 31 | #include "drd_thread.h" |
| 32 | #include "drd_track.h" |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 33 | #include "drd_rwlock.h" |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 34 | #include "priv_drd_clientreq.h" |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 35 | #include "pub_tool_basics.h" // Bool |
| 36 | #include "pub_tool_libcassert.h" |
| 37 | #include "pub_tool_libcassert.h" // tl_assert() |
| 38 | #include "pub_tool_libcprint.h" // VG_(message)() |
| 39 | #include "pub_tool_machine.h" // VG_(get_SP)() |
| 40 | #include "pub_tool_threadstate.h" |
| 41 | #include "pub_tool_tooliface.h" // VG_(needs_...)() |
| 42 | |
| 43 | |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 44 | static void drd_spin_init_or_unlock(const Addr spinlock) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 45 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 46 | struct mutex_info* mutex_p = mutex_get(spinlock); |
| 47 | if (mutex_p) |
| 48 | { |
| 49 | mutex_unlock(spinlock, mutex_type_spinlock); |
| 50 | } |
| 51 | else |
| 52 | { |
| 53 | mutex_init(spinlock, mutex_type_spinlock); |
| 54 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 55 | } |
| 56 | |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 57 | static void drd_pre_cond_wait(const Addr cond, |
bart | 5357fcb | 2008-02-27 15:46:00 +0000 | [diff] [blame] | 58 | const Addr mutex, const MutexT mutex_type) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 59 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 60 | mutex_unlock(mutex, mutex_type); |
| 61 | cond_pre_wait(cond, mutex); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 62 | } |
| 63 | |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 64 | static void drd_post_cond_wait(const Addr cond, |
| 65 | const Addr mutex, |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 66 | const Bool took_lock) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 67 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 68 | cond_post_wait(cond); |
bart | 4a975e1 | 2008-03-30 13:28:33 +0000 | [diff] [blame] | 69 | mutex_post_lock(mutex, took_lock, True); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | static void drd_pre_cond_signal(const Addr cond) |
| 73 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 74 | cond_pre_signal(cond); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | static void drd_pre_cond_broadcast(const Addr cond) |
| 78 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 79 | cond_pre_broadcast(cond); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 80 | } |
| 81 | |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 82 | static Bool drd_handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 83 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 84 | UWord result = 0; |
| 85 | const DrdThreadId drd_tid = thread_get_running_tid(); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 86 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 87 | tl_assert(vg_tid == VG_(get_running_tid())); |
| 88 | tl_assert(VgThreadIdToDrdThreadId(vg_tid) == drd_tid); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 89 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 90 | switch (arg[0]) |
| 91 | { |
| 92 | case VG_USERREQ__GET_THREAD_SELF: |
| 93 | result = vg_tid; |
| 94 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 95 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 96 | case VG_USERREQ__DRD_START_SUPPRESSION: |
bart | f5bb46a | 2008-03-29 13:18:02 +0000 | [diff] [blame] | 97 | drd_start_suppression(arg[1], arg[1] + arg[2], "client"); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 98 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 99 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 100 | case VG_USERREQ__DRD_FINISH_SUPPRESSION: |
bart | f5bb46a | 2008-03-29 13:18:02 +0000 | [diff] [blame] | 101 | drd_finish_suppression(arg[1], arg[1] + arg[2]); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 102 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 103 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 104 | case VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK: |
| 105 | thread_set_stack_startup(drd_tid, VG_(get_SP)(vg_tid)); |
| 106 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 107 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 108 | case VG_USERREQ__DRD_START_NEW_SEGMENT: |
| 109 | thread_new_segment(PtThreadIdToDrdThreadId(arg[1])); |
| 110 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 111 | |
bart | 005dc97 | 2008-03-29 14:42:59 +0000 | [diff] [blame] | 112 | case VG_USERREQ__DRD_START_TRACE_ADDR: |
| 113 | drd_start_tracing_address_range(arg[1], arg[1] + arg[2]); |
| 114 | break; |
| 115 | |
| 116 | case VG_USERREQ__DRD_STOP_TRACE_ADDR: |
| 117 | drd_stop_tracing_address_range(arg[1], arg[1] + arg[2]); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 118 | break; |
bart | 5bd9f2d | 2008-03-03 20:31:58 +0000 | [diff] [blame] | 119 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 120 | case VG_USERREQ__SET_PTHREADID: |
| 121 | thread_set_pthreadid(drd_tid, arg[1]); |
| 122 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 123 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 124 | case VG_USERREQ__SET_JOINABLE: |
| 125 | thread_set_joinable(PtThreadIdToDrdThreadId(arg[1]), (Bool)arg[2]); |
| 126 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 127 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 128 | case VG_USERREQ__POST_THREAD_JOIN: |
| 129 | tl_assert(arg[1]); |
| 130 | drd_post_thread_join(drd_tid, |
| 131 | PtThreadIdToDrdThreadId(arg[1])); |
| 132 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 133 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 134 | case VG_USERREQ__PRE_MUTEX_INIT: |
| 135 | if (thread_enter_synchr(drd_tid) == 0) |
| 136 | drd_pre_mutex_init(arg[1], arg[2]); |
| 137 | break; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 138 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 139 | case VG_USERREQ__POST_MUTEX_INIT: |
| 140 | thread_leave_synchr(drd_tid); |
| 141 | break; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 142 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 143 | case VG_USERREQ__PRE_MUTEX_DESTROY: |
| 144 | thread_enter_synchr(drd_tid); |
| 145 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 146 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 147 | case VG_USERREQ__POST_MUTEX_DESTROY: |
| 148 | if (thread_leave_synchr(drd_tid) == 0) |
| 149 | drd_post_mutex_destroy(arg[1], arg[2]); |
| 150 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 151 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 152 | case VG_USERREQ__PRE_MUTEX_LOCK: |
| 153 | if (thread_enter_synchr(drd_tid) == 0) |
bart | 2e3a3c1 | 2008-03-24 08:33:47 +0000 | [diff] [blame] | 154 | drd_pre_mutex_lock(arg[1], arg[2], arg[3]); |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 155 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 156 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 157 | case VG_USERREQ__POST_MUTEX_LOCK: |
| 158 | if (thread_leave_synchr(drd_tid) == 0) |
| 159 | drd_post_mutex_lock(arg[1], arg[2]); |
| 160 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 161 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 162 | case VG_USERREQ__PRE_MUTEX_UNLOCK: |
| 163 | if (thread_enter_synchr(drd_tid) == 0) |
| 164 | drd_pre_mutex_unlock(arg[1], arg[2]); |
| 165 | break; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 166 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 167 | case VG_USERREQ__POST_MUTEX_UNLOCK: |
| 168 | thread_leave_synchr(drd_tid); |
| 169 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 170 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 171 | case VG_USERREQ__SPIN_INIT_OR_UNLOCK: |
| 172 | tl_assert(thread_get_synchr_nesting_count(drd_tid) == 0); |
| 173 | drd_spin_init_or_unlock(arg[1]); |
| 174 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 175 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 176 | case VG_USERREQ__PRE_COND_INIT: |
| 177 | tl_assert(thread_get_synchr_nesting_count(drd_tid) == 0); |
| 178 | drd_pre_cond_init(arg[1]); |
| 179 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 180 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 181 | case VG_USERREQ__POST_COND_DESTROY: |
| 182 | tl_assert(thread_get_synchr_nesting_count(drd_tid) == 0); |
| 183 | drd_post_cond_destroy(arg[1]); |
| 184 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 185 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 186 | case VG_USERREQ__PRE_COND_WAIT: |
| 187 | if (thread_enter_synchr(drd_tid) == 0) |
| 188 | drd_pre_cond_wait(arg[1], arg[2], arg[3]); |
| 189 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 190 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 191 | case VG_USERREQ__POST_COND_WAIT: |
| 192 | if (thread_leave_synchr(drd_tid) == 0) |
| 193 | drd_post_cond_wait(arg[1], arg[2], arg[3]); |
| 194 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 195 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 196 | case VG_USERREQ__PRE_COND_SIGNAL: |
| 197 | tl_assert(thread_get_synchr_nesting_count(drd_tid) == 0); |
| 198 | drd_pre_cond_signal(arg[1]); |
| 199 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 200 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 201 | case VG_USERREQ__PRE_COND_BROADCAST: |
| 202 | tl_assert(thread_get_synchr_nesting_count(drd_tid) == 0); |
| 203 | drd_pre_cond_broadcast(arg[1]); |
| 204 | break; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 205 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 206 | case VG_USERREQ__PRE_SEM_INIT: |
| 207 | if (thread_enter_synchr(drd_tid) == 0) |
| 208 | drd_semaphore_init(arg[1], arg[2], arg[3]); |
| 209 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 210 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 211 | case VG_USERREQ__POST_SEM_INIT: |
| 212 | thread_leave_synchr(drd_tid); |
| 213 | break; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 214 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 215 | case VG_USERREQ__PRE_SEM_DESTROY: |
| 216 | thread_enter_synchr(drd_tid); |
| 217 | break; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 218 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 219 | case VG_USERREQ__POST_SEM_DESTROY: |
| 220 | if (thread_leave_synchr(drd_tid) == 0) |
| 221 | drd_semaphore_destroy(arg[1]); |
| 222 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 223 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 224 | case VG_USERREQ__PRE_SEM_WAIT: |
| 225 | if (thread_enter_synchr(drd_tid) == 0) |
| 226 | drd_semaphore_pre_wait(drd_tid, arg[1]); |
| 227 | break; |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 228 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 229 | case VG_USERREQ__POST_SEM_WAIT: |
| 230 | if (thread_leave_synchr(drd_tid) == 0) |
| 231 | drd_semaphore_post_wait(drd_tid, arg[1], arg[2]); |
| 232 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 233 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 234 | case VG_USERREQ__PRE_SEM_POST: |
| 235 | if (thread_enter_synchr(drd_tid) == 0) |
| 236 | drd_semaphore_pre_post(drd_tid, arg[1]); |
| 237 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 238 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 239 | case VG_USERREQ__POST_SEM_POST: |
| 240 | if (thread_leave_synchr(drd_tid) == 0) |
| 241 | drd_semaphore_post_post(drd_tid, arg[1], arg[2]); |
| 242 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 243 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 244 | case VG_USERREQ__PRE_BARRIER_INIT: |
| 245 | if (thread_enter_synchr(drd_tid) == 0) |
| 246 | drd_barrier_init(arg[1], arg[2], arg[3], arg[4]); |
| 247 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 248 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 249 | case VG_USERREQ__POST_BARRIER_INIT: |
| 250 | thread_leave_synchr(drd_tid); |
| 251 | break; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 252 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 253 | case VG_USERREQ__PRE_BARRIER_DESTROY: |
| 254 | thread_enter_synchr(drd_tid); |
| 255 | break; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 256 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 257 | case VG_USERREQ__POST_BARRIER_DESTROY: |
| 258 | if (thread_leave_synchr(drd_tid) == 0) |
| 259 | drd_barrier_destroy(arg[1], arg[2]); |
| 260 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 261 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 262 | case VG_USERREQ__PRE_BARRIER_WAIT: |
| 263 | if (thread_enter_synchr(drd_tid) == 0) |
| 264 | drd_barrier_pre_wait(drd_tid, arg[1], arg[2]); |
| 265 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 266 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 267 | case VG_USERREQ__POST_BARRIER_WAIT: |
| 268 | if (thread_leave_synchr(drd_tid) == 0) |
| 269 | drd_barrier_post_wait(drd_tid, arg[1], arg[2], arg[3]); |
| 270 | break; |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 271 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 272 | case VG_USERREQ__PRE_RWLOCK_INIT: |
| 273 | rwlock_pre_init(arg[1]); |
| 274 | break; |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 275 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 276 | case VG_USERREQ__POST_RWLOCK_DESTROY: |
| 277 | rwlock_post_destroy(arg[1]); |
| 278 | break; |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 279 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 280 | case VG_USERREQ__PRE_RWLOCK_RDLOCK: |
| 281 | if (thread_enter_synchr(drd_tid) == 0) |
| 282 | rwlock_pre_rdlock(arg[1]); |
| 283 | break; |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 284 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 285 | case VG_USERREQ__POST_RWLOCK_RDLOCK: |
| 286 | if (thread_leave_synchr(drd_tid) == 0) |
| 287 | rwlock_post_rdlock(arg[1], arg[2]); |
| 288 | break; |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 289 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 290 | case VG_USERREQ__PRE_RWLOCK_WRLOCK: |
| 291 | if (thread_enter_synchr(drd_tid) == 0) |
| 292 | rwlock_pre_wrlock(arg[1]); |
| 293 | break; |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 294 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 295 | case VG_USERREQ__POST_RWLOCK_WRLOCK: |
| 296 | if (thread_leave_synchr(drd_tid) == 0) |
| 297 | rwlock_post_wrlock(arg[1], arg[2]); |
| 298 | break; |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 299 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 300 | case VG_USERREQ__PRE_RWLOCK_UNLOCK: |
| 301 | if (thread_enter_synchr(drd_tid) == 0) |
| 302 | rwlock_pre_unlock(arg[1]); |
| 303 | break; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 304 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 305 | case VG_USERREQ__POST_RWLOCK_UNLOCK: |
| 306 | thread_leave_synchr(drd_tid); |
| 307 | break; |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 308 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 309 | default: |
| 310 | VG_(message)(Vg_DebugMsg, "Unrecognized client request 0x%lx 0x%lx", |
| 311 | arg[0], arg[1]); |
| 312 | tl_assert(0); |
| 313 | return False; |
| 314 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 315 | |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 316 | *ret = result; |
| 317 | return True; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | void drd_clientreq_init(void) |
| 321 | { |
bart | 3772a98 | 2008-03-15 08:11:03 +0000 | [diff] [blame] | 322 | VG_(needs_client_requests)(drd_handle_client_request); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 323 | } |