sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 3 | /*--- Client-space code for drd. drd_intercepts.c ---*/ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of drd, a data race detector. |
| 8 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 9 | Copyright (C) 2006-2008 Bart Van Assche |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 10 | bart.vanassche@gmail.com |
| 11 | |
| 12 | This program is free software; you can redistribute it and/or |
| 13 | modify it under the terms of the GNU General Public License as |
| 14 | published by the Free Software Foundation; either version 2 of the |
| 15 | License, or (at your option) any later version. |
| 16 | |
| 17 | This program is distributed in the hope that it will be useful, but |
| 18 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License |
| 23 | along with this program; if not, write to the Free Software |
| 24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 25 | 02111-1307, USA. |
| 26 | |
| 27 | The GNU General Public License is contained in the file COPYING. |
| 28 | */ |
| 29 | |
| 30 | /* --------------------------------------------------------------------- |
| 31 | ALL THE CODE IN THIS FILE RUNS ON THE SIMULATED CPU. |
| 32 | |
| 33 | These functions are not called directly - they're the targets of code |
| 34 | redirection or load notifications (see pub_core_redir.h for info). |
| 35 | They're named weirdly so that the intercept code can find them when the |
| 36 | shared object is initially loaded. |
| 37 | |
| 38 | Note that this filename has the "drd_" prefix because it can appear |
| 39 | in stack traces, and the "drd_" makes it a little clearer that it |
| 40 | originates from Valgrind. |
| 41 | ------------------------------------------------------------------ */ |
| 42 | |
bart | 5e85d26 | 2008-03-01 10:49:37 +0000 | [diff] [blame] | 43 | // Make sure pthread_spinlock_t is available when compiling with older glibc |
| 44 | // versions (2.3 or before). |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 45 | #ifndef _GNU_SOURCE |
| 46 | #define _GNU_SOURCE |
| 47 | #endif |
| 48 | |
| 49 | #include <assert.h> |
bart | 4501d5c | 2008-03-04 18:36:23 +0000 | [diff] [blame] | 50 | #include <inttypes.h> // uintptr_t |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 51 | #include <pthread.h> |
| 52 | #include <semaphore.h> |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 53 | #include <stdio.h> |
bart | 0d06300 | 2008-03-01 07:25:13 +0000 | [diff] [blame] | 54 | #include <stdlib.h> |
bart | 4501d5c | 2008-03-04 18:36:23 +0000 | [diff] [blame] | 55 | #include <unistd.h> // confstr() |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 56 | #include "drd_clientreq.h" |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 57 | #include "pub_tool_redir.h" |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 58 | |
| 59 | |
| 60 | // Defines. |
| 61 | |
| 62 | #define PTH_FUNC(ret_ty, f, args...) \ |
| 63 | ret_ty VG_WRAP_FUNCTION_ZZ(libpthreadZdsoZd0,f)(args); \ |
| 64 | ret_ty VG_WRAP_FUNCTION_ZZ(libpthreadZdsoZd0,f)(args) |
| 65 | |
| 66 | |
| 67 | // Local data structures. |
| 68 | |
| 69 | typedef struct |
| 70 | { |
| 71 | void* (*start)(void*); |
| 72 | void* arg; |
| 73 | int detachstate; |
| 74 | #if 0 |
| 75 | pthread_mutex_t mutex; |
| 76 | pthread_cond_t cond; |
| 77 | #else |
| 78 | int wrapper_started; |
| 79 | #endif |
| 80 | } VgPosixThreadArgs; |
| 81 | |
| 82 | |
| 83 | // Local variables. |
| 84 | |
| 85 | static int vg_main_thread_state_is_set = 0; |
| 86 | |
| 87 | |
| 88 | // Function definitions. |
| 89 | |
bart | 5357fcb | 2008-02-27 15:46:00 +0000 | [diff] [blame] | 90 | static MutexT pthread_to_drd_mutex_type(const int kind) |
| 91 | { |
| 92 | switch (kind) |
| 93 | { |
| 94 | /* PTHREAD_MUTEX_RECURSIVE_NP */ |
| 95 | case PTHREAD_MUTEX_RECURSIVE: |
| 96 | return mutex_type_recursive_mutex; |
| 97 | /* PTHREAD_MUTEX_ERRORCHECK_NP */ |
| 98 | case PTHREAD_MUTEX_ERRORCHECK: |
| 99 | return mutex_type_errorcheck_mutex; |
| 100 | /* PTHREAD_MUTEX_TIMED_NP */ |
| 101 | /* PTHREAD_MUTEX_NORMAL */ |
| 102 | case PTHREAD_MUTEX_DEFAULT: |
| 103 | case PTHREAD_MUTEX_ADAPTIVE_NP: |
| 104 | return mutex_type_default_mutex; |
bart | 5357fcb | 2008-02-27 15:46:00 +0000 | [diff] [blame] | 105 | } |
bart | 635cb16 | 2008-02-28 08:30:43 +0000 | [diff] [blame] | 106 | return mutex_type_invalid_mutex; |
bart | 5357fcb | 2008-02-27 15:46:00 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | static MutexT mutex_type(pthread_mutex_t* mutex) |
| 110 | { |
bart | c9463c4 | 2008-02-28 07:36:04 +0000 | [diff] [blame] | 111 | #if defined(_PTHREAD_DESCR_DEFINED) |
| 112 | // Linuxthreads. |
| 113 | const int kind = mutex->__m_kind; |
| 114 | #elif defined(__SIZEOF_PTHREAD_MUTEX_T) |
| 115 | // NPTL. |
| 116 | const int kind = mutex->__data.__kind; |
| 117 | #else |
| 118 | // Another POSIX threads implementation. Regression tests will fail. |
| 119 | const int kind = PTHREAD_MUTEX_DEFAULT; |
| 120 | #endif |
| 121 | return pthread_to_drd_mutex_type(kind); |
bart | 5357fcb | 2008-02-27 15:46:00 +0000 | [diff] [blame] | 122 | } |
| 123 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 124 | static void vg_start_suppression(const void* const p, size_t const size) |
| 125 | { |
| 126 | int res; |
| 127 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_START_SUPPRESSION, |
bart | 5e85d26 | 2008-03-01 10:49:37 +0000 | [diff] [blame] | 128 | p, (char*)p + size, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | static void vg_set_joinable(const pthread_t tid, const int joinable) |
| 132 | { |
| 133 | int res; |
| 134 | assert(joinable == 0 || joinable == 1); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 135 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__SET_JOINABLE, |
| 136 | tid, joinable, 0, 0, 0); |
| 137 | } |
| 138 | |
| 139 | static void* vg_thread_wrapper(void* arg) |
| 140 | { |
| 141 | int res; |
bart | 0d06300 | 2008-03-01 07:25:13 +0000 | [diff] [blame] | 142 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 143 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK, |
| 144 | 0, 0, 0, 0, 0); |
| 145 | |
| 146 | { |
| 147 | VgPosixThreadArgs* const arg_ptr = (VgPosixThreadArgs*)arg; |
| 148 | VgPosixThreadArgs const arg_copy = *arg_ptr; |
| 149 | void* result; |
| 150 | |
| 151 | #if 0 |
| 152 | pthread_mutex_lock(arg_ptr->mutex); |
| 153 | pthread_cond_signal(arg_ptr->cond); |
| 154 | pthread_mutex_unlock(arg_ptr->mutex); |
| 155 | #else |
| 156 | arg_ptr->wrapper_started = 1; |
| 157 | #endif |
| 158 | |
| 159 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SET_PTHREADID, |
| 160 | pthread_self(), 0, 0, 0, 0); |
| 161 | vg_set_joinable(pthread_self(), |
| 162 | arg_copy.detachstate == PTHREAD_CREATE_JOINABLE); |
| 163 | result = (arg_copy.start)(arg_copy.arg); |
| 164 | return result; |
| 165 | } |
| 166 | } |
| 167 | |
bart | 4501d5c | 2008-03-04 18:36:23 +0000 | [diff] [blame] | 168 | static int detected_linuxthreads(void) |
| 169 | { |
| 170 | #if defined(linux) |
| 171 | #if defined(_CS_GNU_LIBPTHREAD_VERSION) |
| 172 | /* Linux with a recent glibc. */ |
| 173 | char buffer[256]; |
bart | d218a58 | 2008-03-09 13:39:35 +0000 | [diff] [blame] | 174 | unsigned len; |
bart | 4501d5c | 2008-03-04 18:36:23 +0000 | [diff] [blame] | 175 | len = confstr(_CS_GNU_LIBPTHREAD_VERSION, buffer, sizeof(buffer)); |
| 176 | assert(len <= sizeof(buffer)); |
| 177 | return len > 0 && buffer[0] == 'l'; |
| 178 | #else |
| 179 | /* Linux without _CS_GNU_LIBPTHREAD_VERSION: most likely LinuxThreads. */ |
| 180 | return 1; |
| 181 | #endif |
| 182 | #else |
| 183 | /* Another OS than Linux, hence no LinuxThreads. */ |
| 184 | return 0; |
| 185 | #endif |
| 186 | } |
| 187 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 188 | static void vg_set_main_thread_state(void) |
| 189 | { |
| 190 | int res; |
| 191 | |
bart | 4501d5c | 2008-03-04 18:36:23 +0000 | [diff] [blame] | 192 | if (detected_linuxthreads()) |
| 193 | { |
| 194 | if (getenv("LD_ASSUME_KERNEL")) |
| 195 | { |
| 196 | fprintf(stderr, |
| 197 | "Detected the LinuxThreads threading library. Sorry, but DRD only supports\n" |
| 198 | "the newer NPTL (Native POSIX Threads Library). Please try to rerun DRD\n" |
| 199 | "after having unset the environment variable LD_ASSUME_KERNEL. Giving up.\n" |
| 200 | ); |
| 201 | } |
| 202 | else |
| 203 | { |
| 204 | fprintf(stderr, |
| 205 | "Detected the LinuxThreads threading library. Sorry, but DRD only supports\n" |
| 206 | "the newer NPTL (Native POSIX Threads Library). Please try to rerun DRD\n" |
| 207 | "after having upgraded to a newer version of your Linux distribution.\n" |
| 208 | "Giving up.\n" |
| 209 | ); |
| 210 | } |
| 211 | abort(); |
| 212 | } |
bart | 0d06300 | 2008-03-01 07:25:13 +0000 | [diff] [blame] | 213 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 214 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK, |
| 215 | 0, 0, 0, 0, 0); |
| 216 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 217 | // Make sure that DRD knows about the main thread's POSIX thread ID. |
| 218 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SET_PTHREADID, |
| 219 | pthread_self(), 0, 0, 0, 0); |
| 220 | |
| 221 | } |
| 222 | |
| 223 | // pthread_create |
sewardj | 347eeba | 2008-01-21 14:19:07 +0000 | [diff] [blame] | 224 | PTH_FUNC(int, pthreadZucreateZa, // pthread_create* |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 225 | pthread_t *thread, const pthread_attr_t *attr, |
| 226 | void *(*start) (void *), void *arg) |
| 227 | { |
| 228 | int ret; |
| 229 | OrigFn fn; |
| 230 | VgPosixThreadArgs vgargs; |
| 231 | |
| 232 | VALGRIND_GET_ORIG_FN(fn); |
| 233 | |
| 234 | if (vg_main_thread_state_is_set == 0) |
| 235 | { |
| 236 | vg_set_main_thread_state(); |
| 237 | vg_main_thread_state_is_set = 1; |
| 238 | } |
| 239 | vg_start_suppression(&vgargs.wrapper_started, |
| 240 | sizeof(vgargs.wrapper_started)); |
| 241 | vgargs.start = start; |
| 242 | vgargs.arg = arg; |
| 243 | vgargs.wrapper_started = 0; |
| 244 | vgargs.detachstate = PTHREAD_CREATE_JOINABLE; |
| 245 | if (attr) |
| 246 | { |
| 247 | if (pthread_attr_getdetachstate(attr, &vgargs.detachstate) != 0) |
| 248 | { |
| 249 | assert(0); |
| 250 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 251 | } |
| 252 | assert(vgargs.detachstate == PTHREAD_CREATE_JOINABLE |
| 253 | || vgargs.detachstate == PTHREAD_CREATE_DETACHED); |
| 254 | #if 0 |
| 255 | pthread_mutex_init(&vgargs.mutex, 0); |
| 256 | pthread_cond_init(&vgargs.cond, 0); |
| 257 | pthread_mutex_lock(&vgargs.mutex); |
| 258 | #endif |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 259 | CALL_FN_W_WWWW(ret, fn, thread, attr, vg_thread_wrapper, &vgargs); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 260 | #if 0 |
| 261 | pthread_cond_wait(&vgargs.cond, &vgargs.mutex); |
| 262 | pthread_mutex_unlock(&vgargs.mutex); |
| 263 | pthread_cond_destroy(&vgargs.cond); |
| 264 | pthread_mutex_destroy(&vgargs.mutex); |
| 265 | #else |
| 266 | // Yes, you see it correctly, busy waiting ... The problem is that |
| 267 | // POSIX threads functions cannot be called here -- the functions defined |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 268 | // in this file (drd_intercepts.c) would be called instead of those in |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 269 | // libpthread.so. This loop is necessary because vgargs is allocated on the |
| 270 | // stack, and the created thread reads it. |
sewardj | e0744f0 | 2007-12-01 02:09:50 +0000 | [diff] [blame] | 271 | if (ret == 0) |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 272 | { |
sewardj | e0744f0 | 2007-12-01 02:09:50 +0000 | [diff] [blame] | 273 | while (! vgargs.wrapper_started) |
| 274 | { |
| 275 | sched_yield(); |
| 276 | } |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 277 | } |
| 278 | #endif |
| 279 | return ret; |
| 280 | } |
| 281 | |
| 282 | // pthread_join |
| 283 | PTH_FUNC(int, pthreadZujoin, // pthread_join |
| 284 | pthread_t pt_joinee, void **thread_return) |
| 285 | { |
| 286 | int ret; |
| 287 | int res; |
| 288 | OrigFn fn; |
| 289 | |
| 290 | VALGRIND_GET_ORIG_FN(fn); |
| 291 | CALL_FN_W_WW(ret, fn, pt_joinee, thread_return); |
| 292 | if (ret == 0) |
| 293 | { |
| 294 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_THREAD_JOIN, |
| 295 | pt_joinee, 0, 0, 0, 0); |
| 296 | } |
| 297 | return ret; |
| 298 | } |
| 299 | |
| 300 | // pthread_detach |
| 301 | PTH_FUNC(int, pthreadZudetach, pthread_t pt_thread) |
| 302 | { |
| 303 | int ret; |
| 304 | OrigFn fn; |
| 305 | VALGRIND_GET_ORIG_FN(fn); |
| 306 | { |
| 307 | CALL_FN_W_W(ret, fn, pt_thread); |
| 308 | if (ret == 0) |
| 309 | { |
| 310 | vg_set_joinable(pt_thread, 0); |
| 311 | } |
| 312 | } |
| 313 | return ret; |
| 314 | } |
| 315 | |
| 316 | // pthread_mutex_init |
| 317 | PTH_FUNC(int, pthreadZumutexZuinit, |
| 318 | pthread_mutex_t *mutex, |
| 319 | const pthread_mutexattr_t* attr) |
| 320 | { |
| 321 | int ret; |
| 322 | int res; |
| 323 | OrigFn fn; |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 324 | int mt; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 325 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 326 | mt = PTHREAD_MUTEX_DEFAULT; |
bart | 5357fcb | 2008-02-27 15:46:00 +0000 | [diff] [blame] | 327 | if (attr) |
| 328 | pthread_mutexattr_gettype(attr, &mt); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 329 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_MUTEX_INIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 330 | mutex, pthread_to_drd_mutex_type(mt), 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 331 | CALL_FN_W_WW(ret, fn, mutex, attr); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 332 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_INIT, |
| 333 | mutex, 0, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 334 | return ret; |
| 335 | } |
| 336 | |
| 337 | // pthread_mutex_destroy |
| 338 | PTH_FUNC(int, pthreadZumutexZudestroy, |
| 339 | pthread_mutex_t *mutex) |
| 340 | { |
| 341 | int ret; |
| 342 | int res; |
| 343 | OrigFn fn; |
| 344 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 345 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_MUTEX_DESTROY, |
| 346 | mutex, 0, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 347 | CALL_FN_W_W(ret, fn, mutex); |
| 348 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_DESTROY, |
bart | 5357fcb | 2008-02-27 15:46:00 +0000 | [diff] [blame] | 349 | mutex, mutex_type(mutex), 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 350 | return ret; |
| 351 | } |
| 352 | |
| 353 | // pthread_mutex_lock |
| 354 | PTH_FUNC(int, pthreadZumutexZulock, // pthread_mutex_lock |
| 355 | pthread_mutex_t *mutex) |
| 356 | { |
| 357 | int ret; |
| 358 | int res; |
| 359 | OrigFn fn; |
| 360 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 361 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_MUTEX_LOCK, |
| 362 | mutex, mutex_type(mutex), 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 363 | CALL_FN_W_W(ret, fn, mutex); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 364 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__POST_MUTEX_LOCK, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 365 | mutex, ret == 0, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 366 | return ret; |
| 367 | } |
| 368 | |
| 369 | // pthread_mutex_trylock |
| 370 | PTH_FUNC(int, pthreadZumutexZutrylock, // pthread_mutex_trylock |
| 371 | pthread_mutex_t *mutex) |
| 372 | { |
| 373 | int ret; |
| 374 | int res; |
| 375 | OrigFn fn; |
| 376 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 377 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_MUTEX_LOCK, |
| 378 | mutex, mutex_type(mutex), 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 379 | CALL_FN_W_W(ret, fn, mutex); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 380 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_LOCK, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 381 | mutex, ret == 0, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 382 | return ret; |
| 383 | } |
| 384 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 385 | // pthread_mutex_timedlock |
| 386 | PTH_FUNC(int, pthreadZumutexZutimedlock, // pthread_mutex_timedlock |
| 387 | pthread_mutex_t *mutex, |
| 388 | const struct timespec *abs_timeout) |
| 389 | { |
| 390 | int ret; |
| 391 | int res; |
| 392 | OrigFn fn; |
| 393 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 394 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_MUTEX_LOCK, |
| 395 | mutex, mutex_type(mutex), 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 396 | CALL_FN_W_WW(ret, fn, mutex, abs_timeout); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 397 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_LOCK, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 398 | mutex, ret == 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 399 | return ret; |
| 400 | } |
| 401 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 402 | // pthread_mutex_unlock |
| 403 | PTH_FUNC(int, pthreadZumutexZuunlock, // pthread_mutex_unlock |
| 404 | pthread_mutex_t *mutex) |
| 405 | { |
| 406 | int ret; |
| 407 | int res; |
| 408 | OrigFn fn; |
| 409 | VALGRIND_GET_ORIG_FN(fn); |
| 410 | VALGRIND_DO_CLIENT_REQUEST(res, -1, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 411 | VG_USERREQ__PRE_MUTEX_UNLOCK, |
| 412 | mutex, mutex_type(mutex), 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 413 | CALL_FN_W_W(ret, fn, mutex); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 414 | VALGRIND_DO_CLIENT_REQUEST(res, -1, |
| 415 | VG_USERREQ__POST_MUTEX_UNLOCK, |
| 416 | mutex, 0, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 417 | return ret; |
| 418 | } |
| 419 | |
| 420 | // pthread_cond_init |
sewardj | 347eeba | 2008-01-21 14:19:07 +0000 | [diff] [blame] | 421 | PTH_FUNC(int, pthreadZucondZuinitZa, // pthread_cond_init* |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 422 | pthread_cond_t* cond, |
| 423 | const pthread_condattr_t* attr) |
| 424 | { |
| 425 | int ret; |
| 426 | int res; |
| 427 | OrigFn fn; |
| 428 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 429 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_COND_INIT, |
| 430 | cond, 0, 0, 0, 0); |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 431 | CALL_FN_W_WW(ret, fn, cond, attr); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 432 | return ret; |
| 433 | } |
| 434 | |
| 435 | // pthread_cond_destroy |
sewardj | 347eeba | 2008-01-21 14:19:07 +0000 | [diff] [blame] | 436 | PTH_FUNC(int, pthreadZucondZudestroyZa, // pthread_cond_destroy* |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 437 | pthread_cond_t* cond) |
| 438 | { |
| 439 | int ret; |
| 440 | int res; |
| 441 | OrigFn fn; |
| 442 | VALGRIND_GET_ORIG_FN(fn); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 443 | CALL_FN_W_W(ret, fn, cond); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 444 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_COND_DESTROY, |
bart | 72b751c | 2008-03-01 13:44:24 +0000 | [diff] [blame] | 445 | cond, 0, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 446 | return ret; |
| 447 | } |
| 448 | |
| 449 | // pthread_cond_wait |
sewardj | 347eeba | 2008-01-21 14:19:07 +0000 | [diff] [blame] | 450 | PTH_FUNC(int, pthreadZucondZuwaitZa, // pthread_cond_wait* |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 451 | pthread_cond_t *cond, |
| 452 | pthread_mutex_t *mutex) |
| 453 | { |
| 454 | int ret; |
| 455 | int res; |
| 456 | OrigFn fn; |
| 457 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 458 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_COND_WAIT, |
| 459 | cond, mutex, mutex_type(mutex), 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 460 | CALL_FN_W_WW(ret, fn, cond, mutex); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 461 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_COND_WAIT, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 462 | cond, mutex, ret == 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 463 | return ret; |
| 464 | } |
| 465 | |
| 466 | // pthread_cond_timedwait |
sewardj | 347eeba | 2008-01-21 14:19:07 +0000 | [diff] [blame] | 467 | PTH_FUNC(int, pthreadZucondZutimedwaitZa, // pthread_cond_timedwait* |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 468 | pthread_cond_t *cond, |
| 469 | pthread_mutex_t *mutex, |
| 470 | const struct timespec* abstime) |
| 471 | { |
| 472 | int ret; |
| 473 | int res; |
| 474 | OrigFn fn; |
| 475 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 476 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_COND_WAIT, |
| 477 | cond, mutex, mutex_type(mutex), 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 478 | CALL_FN_W_WWW(ret, fn, cond, mutex, abstime); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 479 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_COND_WAIT, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 480 | cond, mutex, ret == 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 481 | return ret; |
| 482 | } |
| 483 | |
| 484 | // pthread_cond_signal |
sewardj | 347eeba | 2008-01-21 14:19:07 +0000 | [diff] [blame] | 485 | PTH_FUNC(int, pthreadZucondZusignalZa, // pthread_cond_signal* |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 486 | pthread_cond_t* cond) |
| 487 | { |
| 488 | int ret; |
| 489 | int res; |
| 490 | OrigFn fn; |
| 491 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 492 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_COND_SIGNAL, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 493 | cond, 0, 0, 0, 0); |
| 494 | CALL_FN_W_W(ret, fn, cond); |
| 495 | return ret; |
| 496 | } |
| 497 | |
| 498 | // pthread_cond_broadcast |
sewardj | 347eeba | 2008-01-21 14:19:07 +0000 | [diff] [blame] | 499 | PTH_FUNC(int, pthreadZucondZubroadcastZa, // pthread_cond_broadcast* |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 500 | pthread_cond_t* cond) |
| 501 | { |
| 502 | int ret; |
| 503 | int res; |
| 504 | OrigFn fn; |
| 505 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 506 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_COND_BROADCAST, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 507 | cond, 0, 0, 0, 0); |
| 508 | CALL_FN_W_W(ret, fn, cond); |
| 509 | return ret; |
| 510 | } |
| 511 | |
| 512 | |
| 513 | // pthread_spin_init |
| 514 | PTH_FUNC(int, pthreadZuspinZuinit, // pthread_spin_init |
| 515 | pthread_spinlock_t *spinlock, |
| 516 | int pshared) |
| 517 | { |
| 518 | int ret; |
| 519 | int res; |
| 520 | OrigFn fn; |
| 521 | VALGRIND_GET_ORIG_FN(fn); |
| 522 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SPIN_INIT_OR_UNLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 523 | spinlock, mutex_type_spinlock, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 524 | CALL_FN_W_WW(ret, fn, spinlock, pshared); |
| 525 | return ret; |
| 526 | } |
| 527 | |
| 528 | // pthread_spin_destroy |
| 529 | PTH_FUNC(int, pthreadZuspinZudestroy, // pthread_spin_destroy |
| 530 | pthread_spinlock_t *spinlock) |
| 531 | { |
| 532 | int ret; |
| 533 | int res; |
| 534 | OrigFn fn; |
| 535 | VALGRIND_GET_ORIG_FN(fn); |
| 536 | CALL_FN_W_W(ret, fn, spinlock); |
| 537 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_DESTROY, |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 538 | spinlock, mutex_type_spinlock, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 539 | return ret; |
| 540 | } |
| 541 | |
| 542 | // pthread_spin_lock |
| 543 | PTH_FUNC(int, pthreadZuspinZulock, // pthread_spin_lock |
| 544 | pthread_spinlock_t *spinlock) |
| 545 | { |
| 546 | int ret; |
| 547 | int res; |
| 548 | OrigFn fn; |
| 549 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 550 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_MUTEX_LOCK, |
| 551 | spinlock, mutex_type_spinlock, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 552 | CALL_FN_W_W(ret, fn, spinlock); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 553 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_LOCK, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 554 | spinlock, ret == 0, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 555 | return ret; |
| 556 | } |
| 557 | |
| 558 | // pthread_spin_trylock |
| 559 | PTH_FUNC(int, pthreadZuspinZutrylock, // pthread_spin_trylock |
| 560 | pthread_spinlock_t *spinlock) |
| 561 | { |
| 562 | int ret; |
| 563 | int res; |
| 564 | OrigFn fn; |
| 565 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 566 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__PRE_MUTEX_LOCK, |
| 567 | spinlock, mutex_type_spinlock, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 568 | CALL_FN_W_W(ret, fn, spinlock); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 569 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_MUTEX_LOCK, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 570 | spinlock, ret == 0, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 571 | return ret; |
| 572 | } |
| 573 | |
| 574 | // pthread_spin_unlock |
| 575 | PTH_FUNC(int, pthreadZuspinZuunlock, // pthread_spin_unlock |
| 576 | pthread_spinlock_t *spinlock) |
| 577 | { |
| 578 | int ret; |
| 579 | int res; |
| 580 | OrigFn fn; |
| 581 | VALGRIND_GET_ORIG_FN(fn); |
| 582 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__SPIN_INIT_OR_UNLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 583 | spinlock, mutex_type_spinlock, 0, 0, 0); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 584 | CALL_FN_W_W(ret, fn, spinlock); |
| 585 | return ret; |
| 586 | } |
| 587 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 588 | // pthread_barrier_init |
| 589 | PTH_FUNC(int, pthreadZubarrierZuinit, // pthread_barrier_init |
| 590 | pthread_barrier_t* barrier, |
| 591 | const pthread_barrierattr_t* attr, |
| 592 | unsigned count) |
| 593 | { |
| 594 | int ret; |
| 595 | int res; |
| 596 | OrigFn fn; |
| 597 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 598 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_BARRIER_INIT, |
| 599 | barrier, pthread_barrier, count, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 600 | CALL_FN_W_WWW(ret, fn, barrier, attr, count); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 601 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_BARRIER_INIT, |
| 602 | barrier, pthread_barrier, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 603 | return ret; |
| 604 | } |
| 605 | |
| 606 | // pthread_barrier_destroy |
| 607 | PTH_FUNC(int, pthreadZubarrierZudestroy, // pthread_barrier_destroy |
| 608 | pthread_barrier_t* barrier) |
| 609 | { |
| 610 | int ret; |
| 611 | int res; |
| 612 | OrigFn fn; |
| 613 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 614 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_BARRIER_DESTROY, |
| 615 | barrier, pthread_barrier, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 616 | CALL_FN_W_W(ret, fn, barrier); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 617 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_BARRIER_DESTROY, |
| 618 | barrier, pthread_barrier, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 619 | return ret; |
| 620 | } |
| 621 | |
| 622 | // pthread_barrier_wait |
| 623 | PTH_FUNC(int, pthreadZubarrierZuwait, // pthread_barrier_wait |
| 624 | pthread_barrier_t* barrier) |
| 625 | { |
| 626 | int ret; |
| 627 | int res; |
| 628 | OrigFn fn; |
| 629 | VALGRIND_GET_ORIG_FN(fn); |
| 630 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_BARRIER_WAIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 631 | barrier, pthread_barrier, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 632 | CALL_FN_W_W(ret, fn, barrier); |
| 633 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_BARRIER_WAIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 634 | barrier, pthread_barrier, |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 635 | ret == 0 || ret == PTHREAD_BARRIER_SERIAL_THREAD, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 636 | 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 637 | return ret; |
| 638 | } |
| 639 | |
| 640 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 641 | // sem_init |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 642 | PTH_FUNC(int, semZuinitZAGLIBCZu2Zd0, // sem_init@GLIBC_2.0 |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 643 | sem_t *sem, |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 644 | int pshared, |
| 645 | unsigned int value) |
| 646 | { |
| 647 | int ret; |
| 648 | int res; |
| 649 | OrigFn fn; |
| 650 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 651 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_INIT, |
| 652 | sem, pshared, value, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 653 | CALL_FN_W_WWW(ret, fn, sem, pshared, value); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 654 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_INIT, |
| 655 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 656 | return ret; |
| 657 | } |
| 658 | |
bart | 368ec98 | 2008-03-11 20:39:01 +0000 | [diff] [blame] | 659 | PTH_FUNC(int, semZuinitZa, // sem_init* |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 660 | sem_t *sem, |
| 661 | int pshared, |
| 662 | unsigned int value) |
| 663 | { |
| 664 | int ret; |
| 665 | int res; |
| 666 | OrigFn fn; |
| 667 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 668 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_INIT, |
| 669 | sem, pshared, value, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 670 | CALL_FN_W_WWW(ret, fn, sem, pshared, value); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 671 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_INIT, |
| 672 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 673 | return ret; |
| 674 | } |
| 675 | |
| 676 | // sem_destroy |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 677 | PTH_FUNC(int, semZudestroyZAGLIBCZu2Zd0, // sem_destroy@GLIBC_2.0 |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 678 | sem_t *sem) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 679 | { |
| 680 | int ret; |
| 681 | int res; |
| 682 | OrigFn fn; |
| 683 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 684 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_DESTROY, |
| 685 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 686 | CALL_FN_W_W(ret, fn, sem); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 687 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_DESTROY, |
| 688 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 689 | return ret; |
| 690 | } |
| 691 | |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 692 | PTH_FUNC(int, semZudestroyZa, // sem_destroy* |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 693 | sem_t *sem) |
| 694 | { |
| 695 | int ret; |
| 696 | int res; |
| 697 | OrigFn fn; |
| 698 | VALGRIND_GET_ORIG_FN(fn); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 699 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_DESTROY, |
| 700 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 701 | CALL_FN_W_W(ret, fn, sem); |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 702 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_DESTROY, |
| 703 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 704 | return ret; |
| 705 | } |
| 706 | |
| 707 | // sem_wait |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 708 | PTH_FUNC(int, semZuwaitZAGLIBCZu2Zd0, // sem_wait@GLIBC_2.0 |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 709 | sem_t *sem) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 710 | { |
| 711 | int ret; |
| 712 | int res; |
| 713 | OrigFn fn; |
| 714 | VALGRIND_GET_ORIG_FN(fn); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 715 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_WAIT, |
| 716 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 717 | CALL_FN_W_W(ret, fn, sem); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 718 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_WAIT, |
| 719 | sem, ret == 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 720 | return ret; |
| 721 | } |
| 722 | |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 723 | // sem_wait |
bart | 368ec98 | 2008-03-11 20:39:01 +0000 | [diff] [blame] | 724 | PTH_FUNC(int, semZuwaitZa, // sem_wait* |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 725 | sem_t *sem) |
| 726 | { |
| 727 | int ret; |
| 728 | int res; |
| 729 | OrigFn fn; |
| 730 | VALGRIND_GET_ORIG_FN(fn); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 731 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_WAIT, |
| 732 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 733 | CALL_FN_W_W(ret, fn, sem); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 734 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_WAIT, |
| 735 | sem, ret == 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 736 | return ret; |
| 737 | } |
| 738 | |
| 739 | // sem_trywait |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 740 | PTH_FUNC(int, semZutrywaitZAGLIBCZu2Zd0, // sem_trywait@GLIBC_2.0 |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 741 | sem_t *sem) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 742 | { |
| 743 | int ret; |
| 744 | int res; |
| 745 | OrigFn fn; |
| 746 | VALGRIND_GET_ORIG_FN(fn); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 747 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_WAIT, |
| 748 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 749 | CALL_FN_W_W(ret, fn, sem); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 750 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_WAIT, |
| 751 | sem, ret == 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 752 | return ret; |
| 753 | } |
| 754 | |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 755 | PTH_FUNC(int, semZutrywaitZa, // sem_trywait* |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 756 | sem_t *sem) |
| 757 | { |
| 758 | int ret; |
| 759 | int res; |
| 760 | OrigFn fn; |
| 761 | VALGRIND_GET_ORIG_FN(fn); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 762 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_WAIT, |
| 763 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 764 | CALL_FN_W_W(ret, fn, sem); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 765 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_WAIT, |
| 766 | sem, ret == 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 767 | return ret; |
| 768 | } |
| 769 | |
| 770 | // sem_timedwait |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 771 | PTH_FUNC(int, semZutimedwait, // sem_timedwait |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 772 | sem_t *sem, const struct timespec *abs_timeout) |
| 773 | { |
| 774 | int ret; |
| 775 | int res; |
| 776 | OrigFn fn; |
| 777 | VALGRIND_GET_ORIG_FN(fn); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 778 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_WAIT, |
| 779 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 780 | CALL_FN_W_WW(ret, fn, sem, abs_timeout); |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 781 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_WAIT, |
| 782 | sem, ret == 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 783 | return ret; |
| 784 | } |
| 785 | |
| 786 | // sem_post |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 787 | PTH_FUNC(int, semZupostZAGLIBCZu2Zd0, // sem_post@GLIBC_2.0 |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 788 | sem_t *sem) |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 789 | { |
| 790 | int ret; |
| 791 | int res; |
| 792 | OrigFn fn; |
| 793 | VALGRIND_GET_ORIG_FN(fn); |
| 794 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_POST, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 795 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 796 | CALL_FN_W_W(ret, fn, sem); |
sewardj | c0be925 | 2008-02-11 11:00:51 +0000 | [diff] [blame] | 797 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_POST, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 798 | sem, ret == 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 799 | return ret; |
| 800 | } |
| 801 | |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 802 | // sem_post |
bart | 368ec98 | 2008-03-11 20:39:01 +0000 | [diff] [blame] | 803 | PTH_FUNC(int, semZupostZa, // sem_post* |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 804 | sem_t *sem) |
| 805 | { |
| 806 | int ret; |
| 807 | int res; |
| 808 | OrigFn fn; |
| 809 | VALGRIND_GET_ORIG_FN(fn); |
| 810 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_SEM_POST, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 811 | sem, 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 812 | CALL_FN_W_W(ret, fn, sem); |
sewardj | e3b57aa | 2008-01-18 07:42:01 +0000 | [diff] [blame] | 813 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_SEM_POST, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 814 | sem, ret == 0, 0, 0, 0); |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 815 | return ret; |
| 816 | } |
| 817 | |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 818 | // pthread_rwlock_init |
| 819 | PTH_FUNC(int, |
| 820 | pthreadZurwlockZuinitZa, // pthread_rwlock_init* |
| 821 | pthread_rwlock_t* rwlock, |
| 822 | const pthread_rwlockattr_t* attr) |
| 823 | { |
| 824 | int ret; |
| 825 | int res; |
| 826 | OrigFn fn; |
| 827 | VALGRIND_GET_ORIG_FN(fn); |
| 828 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_RWLOCK_INIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 829 | rwlock, 0, 0, 0, 0); |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 830 | CALL_FN_W_WW(ret, fn, rwlock, attr); |
| 831 | return ret; |
| 832 | } |
| 833 | |
| 834 | // pthread_rwlock_destroy |
| 835 | PTH_FUNC(int, |
| 836 | pthreadZurwlockZudestroyZa, // pthread_rwlock_destroy* |
| 837 | pthread_rwlock_t* rwlock) |
| 838 | { |
| 839 | int ret; |
| 840 | int res; |
| 841 | OrigFn fn; |
| 842 | VALGRIND_GET_ORIG_FN(fn); |
| 843 | CALL_FN_W_W(ret, fn, rwlock); |
| 844 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_RWLOCK_DESTROY, |
| 845 | rwlock, 0, 0, 0, 0); |
| 846 | return ret; |
| 847 | } |
| 848 | |
| 849 | // pthread_rwlock_rdlock |
| 850 | PTH_FUNC(int, |
| 851 | pthreadZurwlockZurdlockZa, // pthread_rwlock_rdlock* |
| 852 | pthread_rwlock_t* rwlock) |
| 853 | { |
| 854 | int ret; |
| 855 | int res; |
| 856 | OrigFn fn; |
| 857 | VALGRIND_GET_ORIG_FN(fn); |
| 858 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_RWLOCK_RDLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 859 | rwlock, 0, 0, 0, 0); |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 860 | CALL_FN_W_W(ret, fn, rwlock); |
| 861 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_RWLOCK_RDLOCK, |
| 862 | rwlock, ret == 0, 0, 0, 0); |
| 863 | return ret; |
| 864 | } |
| 865 | |
| 866 | // pthread_rwlock_wrlock |
| 867 | PTH_FUNC(int, |
| 868 | pthreadZurwlockZuwrlockZa, // pthread_rwlock_wrlock* |
| 869 | pthread_rwlock_t* rwlock) |
| 870 | { |
| 871 | int ret; |
| 872 | int res; |
| 873 | OrigFn fn; |
| 874 | VALGRIND_GET_ORIG_FN(fn); |
| 875 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_RWLOCK_WRLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 876 | rwlock, 0, 0, 0, 0); |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 877 | CALL_FN_W_W(ret, fn, rwlock); |
| 878 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_RWLOCK_WRLOCK, |
| 879 | rwlock, ret == 0, 0, 0, 0); |
| 880 | return ret; |
| 881 | } |
| 882 | |
| 883 | // pthread_rwlock_timedrdlock |
| 884 | PTH_FUNC(int, |
| 885 | pthreadZurwlockZutimedrdlockZa, // pthread_rwlock_timedrdlock* |
| 886 | pthread_rwlock_t* rwlock) |
| 887 | { |
| 888 | int ret; |
| 889 | int res; |
| 890 | OrigFn fn; |
| 891 | VALGRIND_GET_ORIG_FN(fn); |
| 892 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_RWLOCK_RDLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 893 | rwlock, 0, 0, 0, 0); |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 894 | CALL_FN_W_W(ret, fn, rwlock); |
| 895 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_RWLOCK_RDLOCK, |
| 896 | rwlock, ret == 0, 0, 0, 0); |
| 897 | return ret; |
| 898 | } |
| 899 | |
| 900 | // pthread_rwlock_timedwrlock |
| 901 | PTH_FUNC(int, |
| 902 | pthreadZurwlockZutimedwrlockZa, // pthread_rwlock_timedwrlock* |
| 903 | pthread_rwlock_t* rwlock) |
| 904 | { |
| 905 | int ret; |
| 906 | int res; |
| 907 | OrigFn fn; |
| 908 | VALGRIND_GET_ORIG_FN(fn); |
| 909 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_RWLOCK_WRLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 910 | rwlock, 0, 0, 0, 0); |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 911 | CALL_FN_W_W(ret, fn, rwlock); |
| 912 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_RWLOCK_WRLOCK, |
| 913 | rwlock, ret == 0, 0, 0, 0); |
| 914 | return ret; |
| 915 | } |
| 916 | |
| 917 | // pthread_rwlock_tryrdlock |
| 918 | PTH_FUNC(int, |
| 919 | pthreadZurwlockZutryrdlockZa, // pthread_rwlock_tryrdlock* |
| 920 | pthread_rwlock_t* rwlock) |
| 921 | { |
| 922 | int ret; |
| 923 | int res; |
| 924 | OrigFn fn; |
| 925 | VALGRIND_GET_ORIG_FN(fn); |
| 926 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_RWLOCK_RDLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 927 | rwlock, 0, 0, 0, 0); |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 928 | CALL_FN_W_W(ret, fn, rwlock); |
| 929 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_RWLOCK_RDLOCK, |
| 930 | rwlock, ret == 0, 0, 0, 0); |
| 931 | return ret; |
| 932 | } |
| 933 | |
| 934 | // pthread_rwlock_trywrlock |
| 935 | PTH_FUNC(int, |
| 936 | pthreadZurwlockZutrywrlockZa, // pthread_rwlock_trywrlock* |
| 937 | pthread_rwlock_t* rwlock) |
| 938 | { |
| 939 | int ret; |
| 940 | int res; |
| 941 | OrigFn fn; |
| 942 | VALGRIND_GET_ORIG_FN(fn); |
| 943 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_RWLOCK_WRLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 944 | rwlock, 0, 0, 0, 0); |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 945 | CALL_FN_W_W(ret, fn, rwlock); |
| 946 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_RWLOCK_WRLOCK, |
| 947 | rwlock, ret == 0, 0, 0, 0); |
| 948 | return ret; |
| 949 | } |
| 950 | |
| 951 | // pthread_rwlock_unlock |
| 952 | PTH_FUNC(int, |
| 953 | pthreadZurwlockZuunlockZa, // pthread_rwlock_unlock* |
| 954 | pthread_rwlock_t* rwlock) |
| 955 | { |
| 956 | int ret; |
| 957 | int res; |
| 958 | OrigFn fn; |
| 959 | VALGRIND_GET_ORIG_FN(fn); |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 960 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__PRE_RWLOCK_UNLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 961 | rwlock, 0, 0, 0, 0); |
| 962 | CALL_FN_W_W(ret, fn, rwlock); |
| 963 | VALGRIND_DO_CLIENT_REQUEST(res, -1, VG_USERREQ__POST_RWLOCK_UNLOCK, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 964 | rwlock, ret == 0, 0, 0, 0); |
| 965 | return ret; |
| 966 | } |
| 967 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 968 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 969 | /* |
| 970 | * Local variables: |
| 971 | * c-basic-offset: 3 |
| 972 | * End: |
| 973 | */ |