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