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