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