blob: 64adfe99b5e31f6461630de6f9ca9ffba987de7b [file] [log] [blame]
bartbedfd232009-03-26 19:07:15 +00001/* -*- mode: C; c-basic-offset: 3; -*- */
bart3c1e9d82008-06-30 17:10:29 +00002
3/*
bartbedfd232009-03-26 19:07:15 +00004 ----------------------------------------------------------------
bart3c1e9d82008-06-30 17:10:29 +00005
bartbedfd232009-03-26 19:07:15 +00006 Notice that the following BSD-style license applies to this one
7 file (drd.h) only. The rest of Valgrind is licensed under the
8 terms of the GNU General Public License, version 2, unless
9 otherwise indicated. See the COPYING file in the source
10 distribution for details.
bart3c1e9d82008-06-30 17:10:29 +000011
bartbedfd232009-03-26 19:07:15 +000012 ----------------------------------------------------------------
bart3c1e9d82008-06-30 17:10:29 +000013
bartd45d9952009-05-31 18:53:54 +000014 This file is part of DRD, a Valgrind tool for verification of
bartbedfd232009-03-26 19:07:15 +000015 multithreaded programs.
bart3c1e9d82008-06-30 17:10:29 +000016
bartbedfd232009-03-26 19:07:15 +000017 Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>.
18 All rights reserved.
bart3c1e9d82008-06-30 17:10:29 +000019
bartbedfd232009-03-26 19:07:15 +000020 Redistribution and use in source and binary forms, with or without
21 modification, are permitted provided that the following conditions
22 are met:
bart3c1e9d82008-06-30 17:10:29 +000023
bartbedfd232009-03-26 19:07:15 +000024 1. Redistributions of source code must retain the above copyright
25 notice, this list of conditions and the following disclaimer.
bart3c1e9d82008-06-30 17:10:29 +000026
bartbedfd232009-03-26 19:07:15 +000027 2. The origin of this software must not be misrepresented; you must
28 not claim that you wrote the original software. If you use this
29 software in a product, an acknowledgment in the product
30 documentation would be appreciated but is not required.
bart3c1e9d82008-06-30 17:10:29 +000031
bartbedfd232009-03-26 19:07:15 +000032 3. Altered source versions must be plainly marked as such, and must
33 not be misrepresented as being the original software.
bart3c1e9d82008-06-30 17:10:29 +000034
bartbedfd232009-03-26 19:07:15 +000035 4. The name of the author may not be used to endorse or promote
36 products derived from this software without specific prior written
37 permission.
bart3c1e9d82008-06-30 17:10:29 +000038
bartbedfd232009-03-26 19:07:15 +000039 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
40 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
41 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
43 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
45 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
47 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
48 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bart3c1e9d82008-06-30 17:10:29 +000050
bartbedfd232009-03-26 19:07:15 +000051 ----------------------------------------------------------------
bart3c1e9d82008-06-30 17:10:29 +000052
bartbedfd232009-03-26 19:07:15 +000053 Notice that the above BSD-style license applies to this one file
54 (drd.h) only. The entire rest of Valgrind is licensed under
55 the terms of the GNU General Public License, version 2. See the
56 COPYING file in the source distribution for details.
bart3c1e9d82008-06-30 17:10:29 +000057
bartbedfd232009-03-26 19:07:15 +000058 ----------------------------------------------------------------
bart3c1e9d82008-06-30 17:10:29 +000059*/
60
61#ifndef __VALGRIND_DRD_H
62#define __VALGRIND_DRD_H
63
64
65#include "valgrind.h"
66
67
bartd45d9952009-05-31 18:53:54 +000068/** Prefix for the (inline) functions defined in this header file. */
69#define DRDCL_(str) vgDrdCl_##str
70
71
72/** Obtain the thread ID assigned by Valgrind's core. */
73#define DRD_GET_VALGRIND_THREADID (DRDCL_(get_valgrind_threadid)())
74
75/** Obtain the thread ID assigned by DRD. */
76#define DRD_GET_DRD_THREADID (DRDCL_(get_drd_threadid)())
77
78/** Tell DRD not to complain about data races for the specified variable. */
79#define DRD_IGNORE_VAR(x) DRDCL_(ignore_range)(&(x), sizeof(x))
80
bartd9b8eb72009-07-26 15:46:47 +000081/** Tell DRD to no longer ignore data races for the specified variable. */
82#define DRD_STOP_IGNORING_VAR(x) DRDCL_(ignore_range)(&(x), sizeof(x))
83
bartd45d9952009-05-31 18:53:54 +000084/**
bart31b983d2010-02-21 14:52:59 +000085 * Tell DRD to trace all memory accesses on the specified variable.
bartd45d9952009-05-31 18:53:54 +000086 * until the memory that was allocated for the variable is freed.
87 */
88#define DRD_TRACE_VAR(x) DRDCL_(trace_range)(&(x), sizeof(x))
89
bart1c8cc402009-07-01 18:45:45 +000090/**
91 * @defgroup RaceDetectionAnnotations Data race detection annotations.
92 *
bart733db9e2010-03-07 10:44:46 +000093 * @see See also the source file <a href="http://code.google.com/p/data-race-test/source/browse/trunk/dynamic_annotations/dynamic_annotations.h</a>
94
bart1c8cc402009-07-01 18:45:45 +000095 * in the ThreadSanitizer project.
96 */
97/*@{*/
bart44afe932009-06-01 10:49:38 +000098
bartd45d9952009-05-31 18:53:54 +000099/**
bart733db9e2010-03-07 10:44:46 +0000100 * Tell DRD to insert a happens-before mark. addr is the address of an object
101 * that is not a pthread synchronization object.
bartd45d9952009-05-31 18:53:54 +0000102 */
103#define ANNOTATE_HAPPENS_BEFORE(addr) DRDCL_(annotate_happens_before)(addr)
104
105/**
bart733db9e2010-03-07 10:44:46 +0000106 * Tell DRD that the memory accesses executed after this annotation will
107 * happen after all memory accesses performed before all preceding
bartdf5a1e22009-06-03 08:11:02 +0000108 * ANNOTATE_HAPPENS_BEFORE(addr). addr is the address of an object that is not
bart733db9e2010-03-07 10:44:46 +0000109 * a pthread synchronization object. Inserting a happens-after annotation
110 * before any other thread has passed by a happens-before annotation for the
bartdf5a1e22009-06-03 08:11:02 +0000111 * same address is an error.
bartd45d9952009-05-31 18:53:54 +0000112 */
113#define ANNOTATE_HAPPENS_AFTER(addr) DRDCL_(annotate_happens_after)(addr)
114
115/**
bart733db9e2010-03-07 10:44:46 +0000116 * Tell DRD that no more happens-after annotations will follow.
117 */
118#define ANNOTATE_HAPPENS_DONE(addr) DRDCL_(annotate_happens_done)(addr)
119
120/**
bartd45d9952009-05-31 18:53:54 +0000121 * Tell DRD that waiting on the condition variable at address cv has succeeded
122 * and a lock on the mutex at address mtx is now held. Since DRD always inserts
123 * a happens before relation between the pthread_cond_signal() or
124 * pthread_cond_broadcast() call that wakes up a pthread_cond_wait() or
125 * pthread_cond_timedwait() call and the woken up thread, this macro has been
bartdf5a1e22009-06-03 08:11:02 +0000126 * defined such that it has no effect.
bartd45d9952009-05-31 18:53:54 +0000127 */
bartdf5a1e22009-06-03 08:11:02 +0000128#define ANNOTATE_CONDVAR_LOCK_WAIT(cv, mtx) do { } while(0)
bartd45d9952009-05-31 18:53:54 +0000129
130/**
131 * Tell DRD that the condition variable at address cv is about to be signaled.
bartd45d9952009-05-31 18:53:54 +0000132 */
bartdf5a1e22009-06-03 08:11:02 +0000133#define ANNOTATE_CONDVAR_SIGNAL(cv) do { } while(0)
bartd45d9952009-05-31 18:53:54 +0000134
135/**
bartdf5a1e22009-06-03 08:11:02 +0000136 * Tell DRD that waiting on condition variable at address cv succeeded and that
137 * the memory operations performed after this annotation should be considered
138 * to happen after the matching ANNOTATE_CONDVAR_SIGNAL(cv). Since this is the
139 * default behavior of DRD, this macro and the macro above have been defined
140 * such that they have no effect.
bartd45d9952009-05-31 18:53:54 +0000141 */
bartdf5a1e22009-06-03 08:11:02 +0000142#define ANNOTATE_CONDVAR_WAIT(cv) do { } while(0)
bartd45d9952009-05-31 18:53:54 +0000143
144/**
145 * Tell DRD to consider the memory operations that happened before a mutex
146 * unlock event and after the subsequent mutex lock event on the same mutex as
bartdf5a1e22009-06-03 08:11:02 +0000147 * ordered. This is how DRD always behaves, so this macro has been defined
148 * such that it has no effect.
bartd45d9952009-05-31 18:53:54 +0000149 */
bartdf5a1e22009-06-03 08:11:02 +0000150#define ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mtx) do { } while(0)
151
152/**
153 * Tell DRD to handle the specified memory range like a pure happens-before
154 * detector would do. Since this is how DRD always behaves, this annotation
155 * has been defined such that it has no effect.
156 */
157#define ANNOTATE_PUBLISH_MEMORY_RANGE(addr, size) do { } while(0)
158
159/**
160 * Tell DRD to undo the effect of ANNOTATE_PUBLISH_MEMORY_RANGE().
161 */
162#define ANNOTATE_UNPUBLISH_MEMORY_RANGE(addr, size) do { } while(0)
bartd45d9952009-05-31 18:53:54 +0000163
164/** Tell DRD that a reader-writer lock object has been initialized. */
165#define ANNOTATE_RWLOCK_CREATE(rwlock) \
bart66f196d2009-08-15 10:50:35 +0000166 DRDCL_(annotate_rwlock_create)(rwlock)
bartd45d9952009-05-31 18:53:54 +0000167
168/** Tell DRD that a reader-writer lock object has been destroyed. */
169#define ANNOTATE_RWLOCK_DESTROY(rwlock) \
bart66f196d2009-08-15 10:50:35 +0000170 DRDCL_(annotate_rwlock_destroy)(rwlock)
bartd45d9952009-05-31 18:53:54 +0000171
172/**
173 * Tell DRD that a reader-writer lock has been acquired. is_w == 1 means that
174 * a write lock has been obtained, is_w == 0 means that a read lock has been
175 * obtained.
176 */
177#define ANNOTATE_RWLOCK_ACQUIRED(rwlock, is_w) \
bart66f196d2009-08-15 10:50:35 +0000178 DRDCL_(annotate_rwlock_acquired)(rwlock, is_w)
bartd45d9952009-05-31 18:53:54 +0000179
180/**
bart1c8cc402009-07-01 18:45:45 +0000181 * Tell DRD that a reader lock has been acquired on a reader-writer
182 * synchronization object.
183 */
184#define ANNOTATE_READERLOCK_ACQUIRED(rwlock) ANNOTATE_RWLOCK_ACQUIRED(rwlock, 0)
185
186/**
187 * Tell DRD that a writer lock has been acquired on a reader-writer
188 * synchronization object.
189 */
190#define ANNOTATE_WRITERLOCK_ACQUIRED(rwlock) ANNOTATE_RWLOCK_ACQUIRED(rwlock, 1)
191
192/**
bartd45d9952009-05-31 18:53:54 +0000193 * Tell DRD that a reader-writer lock is about to be released. is_w == 1 means
194 * that a write lock is about to be released, is_w == 0 means that a read lock
195 * is about to be released.
196 */
197#define ANNOTATE_RWLOCK_RELEASED(rwlock, is_w) \
bart66f196d2009-08-15 10:50:35 +0000198 DRDCL_(annotate_rwlock_released)(rwlock, is_w)
bartd45d9952009-05-31 18:53:54 +0000199
bart82c54c42009-06-03 20:01:44 +0000200/**
bart1c8cc402009-07-01 18:45:45 +0000201 * Tell DRD that a reader lock is about to be released.
202 */
203#define ANNOTATE_READERLOCK_RELEASED(rwlock) ANNOTATE_RWLOCK_RELEASED(rwlock, 0)
204
205/**
206 * Tell DRD that a writer lock is about to be released.
207 */
208#define ANNOTATE_WRITERLOCK_RELEASED(rwlock) ANNOTATE_RWLOCK_RELEASED(rwlock, 1)
209
210/**
bart82c54c42009-06-03 20:01:44 +0000211 * Tell DRD that a FIFO queue has been created. The abbreviation PCQ stands for
212 * <em>producer-consumer</em>.
213 */
bartdf5a1e22009-06-03 08:11:02 +0000214#define ANNOTATE_PCQ_CREATE(pcq) do { } while(0)
215
bart82c54c42009-06-03 20:01:44 +0000216/** Tell DRD that a FIFO queue has been destroyed. */
bartdf5a1e22009-06-03 08:11:02 +0000217#define ANNOTATE_PCQ_DESTROY(pcq) do { } while(0)
218
bart82c54c42009-06-03 20:01:44 +0000219/**
220 * Tell DRD that an element has been added to the FIFO queue at address pcq.
221 */
bartdf5a1e22009-06-03 08:11:02 +0000222#define ANNOTATE_PCQ_PUT(pcq) do { } while(0)
223
bart82c54c42009-06-03 20:01:44 +0000224/**
225 * Tell DRD that an element has been removed from the FIFO queue at address pcq,
226 * and that DRD should insert a happens-before relationship between the memory
227 * accesses that occurred before the corresponding ANNOTATE_PCQ_PUT(pcq)
228 * annotation and the memory accesses after this annotation. Correspondence
229 * between PUT and GET annotations happens in FIFO order. Since locking
230 * of the queue is needed anyway to add elements to or to remove elements from
231 * the queue, for DRD all four FIFO annotations are defined as no-ops.
232 */
bartdf5a1e22009-06-03 08:11:02 +0000233#define ANNOTATE_PCQ_GET(pcq) do { } while(0)
234
bartd45d9952009-05-31 18:53:54 +0000235/**
barte08eb5f2010-02-28 09:51:00 +0000236 * Tell DRD that data races at the specified address are expected and must not
237 * be reported.
bartd45d9952009-05-31 18:53:54 +0000238 */
barte08eb5f2010-02-28 09:51:00 +0000239#define ANNOTATE_BENIGN_RACE(addr, descr) \
240 DRDCL_(ignore_range)(addr, sizeof(*addr))
bartd45d9952009-05-31 18:53:54 +0000241
242/** Tell DRD to ignore all reads performed by the current thread. */
243#define ANNOTATE_IGNORE_READS_BEGIN() DRDCL_(set_record_loads)(0)
244
245/** Tell DRD to no longer ignore the reads performed by the current thread. */
246#define ANNOTATE_IGNORE_READS_END() DRDCL_(set_record_loads)(1)
247
248/** Tell DRD to ignore all writes performed by the current thread. */
249#define ANNOTATE_IGNORE_WRITES_BEGIN() DRDCL_(set_record_stores)(0)
250
251/** Tell DRD to no longer ignore the writes performed by the current thread. */
252#define ANNOTATE_IGNORE_WRITES_END() DRDCL_(set_record_stores)(1)
253
254/** Tell DRD to ignore all memory accesses performed by the current thread. */
255#define ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \
bart7fd1f772009-07-23 19:01:35 +0000256 do { DRDCL_(set_record_loads)(0); DRDCL_(set_record_stores)(0); } while(0)
bartd45d9952009-05-31 18:53:54 +0000257
258/**
259 * Tell DRD to no longer ignore the memory accesses performed by the current
260 * thread.
261 */
262#define ANNOTATE_IGNORE_READS_AND_WRITES_END() \
bart7fd1f772009-07-23 19:01:35 +0000263 do { DRDCL_(set_record_loads)(1); DRDCL_(set_record_stores)(1); } while(0)
bartd45d9952009-05-31 18:53:54 +0000264
265/**
266 * Tell DRD that size bytes starting at addr has been allocated by a custom
267 * memory allocator.
268 */
269#define ANNOTATE_NEW_MEMORY(addr, size) DRDCL_(clean_memory)(addr, size)
270
271/** Ask DRD to report every access to the specified address range. */
272#define ANNOTATE_TRACE_MEMORY(addr) DRDCL_(trace_range)(addr, 1)
273
274/**
275 * Tell DRD to assign the specified name to the current thread. This name will
276 * be used in error messages printed by DRD.
277 */
278#define ANNOTATE_THREAD_NAME(name) DRDCL_(set_thread_name)(name)
279
bart1c8cc402009-07-01 18:45:45 +0000280/*@}*/
bart44afe932009-06-01 10:49:38 +0000281
bartd45d9952009-05-31 18:53:54 +0000282
bart3c1e9d82008-06-30 17:10:29 +0000283/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !!
284 This enum comprises an ABI exported by Valgrind to programs
285 which use client requests. DO NOT CHANGE THE ORDER OF THESE
286 ENTRIES, NOR DELETE ANY -- add new ones at the end.
bartbedfd232009-03-26 19:07:15 +0000287*/
bartd45d9952009-05-31 18:53:54 +0000288enum {
289 /* Ask the DRD tool to discard all information about memory accesses */
290 /* and client objects for the specified range. This client request is */
291 /* binary compatible with the similarly named Helgrind client request. */
292 VG_USERREQ__DRD_CLEAN_MEMORY = VG_USERREQ_TOOL_BASE('H','G'),
293 /* args: Addr, SizeT. */
bart3c1e9d82008-06-30 17:10:29 +0000294
bartd45d9952009-05-31 18:53:54 +0000295 /* Ask the DRD tool the thread ID assigned by Valgrind. */
296 VG_USERREQ__DRD_GET_VALGRIND_THREAD_ID = VG_USERREQ_TOOL_BASE('D','R'),
297 /* args: none. */
298 /* Ask the DRD tool the thread ID assigned by DRD. */
299 VG_USERREQ__DRD_GET_DRD_THREAD_ID,
300 /* args: none. */
bart3c1e9d82008-06-30 17:10:29 +0000301
bartd45d9952009-05-31 18:53:54 +0000302 /* To tell the DRD tool to suppress data race detection on the */
303 /* specified address range. */
304 VG_USERREQ__DRD_START_SUPPRESSION,
305 /* args: start address, size in bytes */
306 /* To tell the DRD tool no longer to suppress data race detection on */
307 /* the specified address range. */
308 VG_USERREQ__DRD_FINISH_SUPPRESSION,
309 /* args: start address, size in bytes */
barte7471762009-03-11 18:51:22 +0000310
bartd45d9952009-05-31 18:53:54 +0000311 /* To ask the DRD tool to trace all accesses to the specified range. */
312 VG_USERREQ__DRD_START_TRACE_ADDR,
313 /* args: Addr, SizeT. */
314 /* To ask the DRD tool to stop tracing accesses to the specified range. */
315 VG_USERREQ__DRD_STOP_TRACE_ADDR,
316 /* args: Addr, SizeT. */
317
318 /* Tell DRD whether or not to record memory loads in the calling thread. */
319 VG_USERREQ__DRD_RECORD_LOADS,
320 /* args: Bool. */
321 /* Tell DRD whether or not to record memory stores in the calling thread. */
322 VG_USERREQ__DRD_RECORD_STORES,
323 /* args: Bool. */
324
325 /* Set the name of the thread that performs this client request. */
326 VG_USERREQ__DRD_SET_THREAD_NAME,
327 /* args: null-terminated character string. */
328
bart66f196d2009-08-15 10:50:35 +0000329 /* Tell DRD that a user-defined reader-writer synchronization object
330 * has been created. */
331 VG_USERREQ__DRD_ANNOTATE_RWLOCK_CREATE
332 = VG_USERREQ_TOOL_BASE('H','G') + 256 + 14,
333 /* args: Addr. */
334 /* Tell DRD that a user-defined reader-writer synchronization object
335 * is about to be destroyed. */
336 VG_USERREQ__DRD_ANNOTATE_RWLOCK_DESTROY
337 = VG_USERREQ_TOOL_BASE('H','G') + 256 + 15,
338 /* args: Addr. */
339 /* Tell DRD that a lock on a user-defined reader-writer synchronization
340 * object has been acquired. */
341 VG_USERREQ__DRD_ANNOTATE_RWLOCK_ACQUIRED
342 = VG_USERREQ_TOOL_BASE('H','G') + 256 + 17,
343 /* args: Addr, Int is_rw. */
344 /* Tell DRD that a lock on a user-defined reader-writer synchronization
345 * object is about to be released. */
346 VG_USERREQ__DRD_ANNOTATE_RWLOCK_RELEASED
347 = VG_USERREQ_TOOL_BASE('H','G') + 256 + 18,
348 /* args: Addr, Int is_rw. */
349
350 /* Tell DRD that an annotation has not yet been implemented. */
351 VG_USERREQ__DRD_ANNOTATION_UNIMP
352 = VG_USERREQ_TOOL_BASE('H','G') + 256 + 32,
353 /* args: Char*. */
354
bart733db9e2010-03-07 10:44:46 +0000355 /* Tell DRD to insert a happens-before annotation. */
bartf64a8aa2009-08-14 13:25:38 +0000356 VG_USERREQ__DRD_ANNOTATE_HAPPENS_BEFORE
357 = VG_USERREQ_TOOL_BASE('H','G') + 256 + 33,
bartd45d9952009-05-31 18:53:54 +0000358 /* args: Addr. */
bart733db9e2010-03-07 10:44:46 +0000359 /* Tell DRD to insert a happens-after annotation. */
bartf64a8aa2009-08-14 13:25:38 +0000360 VG_USERREQ__DRD_ANNOTATE_HAPPENS_AFTER
361 = VG_USERREQ_TOOL_BASE('H','G') + 256 + 34,
bartd45d9952009-05-31 18:53:54 +0000362 /* args: Addr. */
bart733db9e2010-03-07 10:44:46 +0000363 /* Tell DRD to insert a happens-done annotation. */
364 VG_USERREQ__DRD_ANNOTATE_HAPPENS_DONE,
365 /* args: Addr. */
bartd45d9952009-05-31 18:53:54 +0000366
bartd45d9952009-05-31 18:53:54 +0000367};
bart3c1e9d82008-06-30 17:10:29 +0000368
369
bartd45d9952009-05-31 18:53:54 +0000370/*
371 * Do not call the inline functions below directly but use the macro's defined
372 * above. The names of these inline functions may change from one release to
373 * another.
bart8e1033f2008-12-25 09:31:40 +0000374 */
bart8e1033f2008-12-25 09:31:40 +0000375
bart3c1e9d82008-06-30 17:10:29 +0000376static __inline__
bartd45d9952009-05-31 18:53:54 +0000377void DRDCL_(clean_memory)(const void* const addr, const int size)
378{
379 int res;
380 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_CLEAN_MEMORY,
381 addr, size, 0, 0, 0);
382}
383
384static __inline__
385int DRDCL_(get_valgrind_threadid)(void)
bart5f57be92008-07-01 08:48:56 +0000386{
bartbedfd232009-03-26 19:07:15 +0000387 int res;
388 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_GET_VALGRIND_THREAD_ID,
389 0, 0, 0, 0, 0);
390 return res;
bart5f57be92008-07-01 08:48:56 +0000391}
392
393static __inline__
bartd45d9952009-05-31 18:53:54 +0000394int DRDCL_(get_drd_threadid)(void)
bart3c1e9d82008-06-30 17:10:29 +0000395{
bartbedfd232009-03-26 19:07:15 +0000396 int res;
397 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_GET_DRD_THREAD_ID,
398 0, 0, 0, 0, 0);
399 return res;
bart3c1e9d82008-06-30 17:10:29 +0000400}
401
402static __inline__
bartd45d9952009-05-31 18:53:54 +0000403void DRDCL_(ignore_range)(const void* const addr, const int size)
bart3c1e9d82008-06-30 17:10:29 +0000404{
bartbedfd232009-03-26 19:07:15 +0000405 int res;
406 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_START_SUPPRESSION,
bartd45d9952009-05-31 18:53:54 +0000407 addr, size, 0, 0, 0);
bart3c1e9d82008-06-30 17:10:29 +0000408}
409
410static __inline__
bartd9b8eb72009-07-26 15:46:47 +0000411void DRDCL_(stop_ignoring_range)(const void* const addr, const int size)
412{
413 int res;
414 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_FINISH_SUPPRESSION,
415 addr, size, 0, 0, 0);
416}
417
418static __inline__
bartd45d9952009-05-31 18:53:54 +0000419void DRDCL_(trace_range)(const void* const addr, const int size)
bart3c1e9d82008-06-30 17:10:29 +0000420{
bartbedfd232009-03-26 19:07:15 +0000421 int res;
422 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_START_TRACE_ADDR,
bartd45d9952009-05-31 18:53:54 +0000423 addr, size, 0, 0, 0);
bart3c1e9d82008-06-30 17:10:29 +0000424}
425
bartd45d9952009-05-31 18:53:54 +0000426static __inline__
427void DRDCL_(set_record_loads)(const int enabled)
428{
429 int res;
430 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_RECORD_LOADS,
431 enabled, 0, 0, 0, 0);
432}
433
434static __inline__
435void DRDCL_(set_record_stores)(const int enabled)
436{
437 int res;
438 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_RECORD_STORES,
439 enabled, 0, 0, 0, 0);
440}
441
442static __inline__
443void DRDCL_(set_thread_name)(const char* const name)
444{
445 int res;
446 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_SET_THREAD_NAME,
447 name, 0, 0, 0, 0);
448}
449
450static __inline__
451void DRDCL_(annotate_happens_before)(const void* const addr)
452{
453 int res;
454 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_ANNOTATE_HAPPENS_BEFORE,
455 addr, 0, 0, 0, 0);
456}
457
458static __inline__
459void DRDCL_(annotate_happens_after)(const void* const addr)
460{
461 int res;
462 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_ANNOTATE_HAPPENS_AFTER,
463 addr, 0, 0, 0, 0);
464}
465
466static __inline__
bart733db9e2010-03-07 10:44:46 +0000467void DRDCL_(annotate_happens_done)(const void* const addr)
468{
469 int res;
470 VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_ANNOTATE_HAPPENS_DONE,
471 addr, 0, 0, 0, 0);
472}
473
474static __inline__
bart66f196d2009-08-15 10:50:35 +0000475void DRDCL_(annotate_rwlock_create)(const void* const rwlock)
bartd45d9952009-05-31 18:53:54 +0000476{
477 int res;
478 VALGRIND_DO_CLIENT_REQUEST(res, 0,
bart66f196d2009-08-15 10:50:35 +0000479 VG_USERREQ__DRD_ANNOTATE_RWLOCK_CREATE,
480 rwlock, 0, 0, 0, 0);
481}
482
483static __inline__
484void DRDCL_(annotate_rwlock_destroy)(const void* const rwlock)
485{
486 int res;
487 VALGRIND_DO_CLIENT_REQUEST(res, 0,
488 VG_USERREQ__DRD_ANNOTATE_RWLOCK_DESTROY,
489 rwlock, 0, 0, 0, 0);
490}
491
492static __inline__
493void DRDCL_(annotate_rwlock_acquired)(const void* const rwlock, const int is_w)
494{
495 int res;
496 VALGRIND_DO_CLIENT_REQUEST(res, 0,
497 VG_USERREQ__DRD_ANNOTATE_RWLOCK_ACQUIRED,
498 rwlock, is_w, 0, 0, 0);
499}
500
501static __inline__
502void DRDCL_(annotate_rwlock_released)(const void* const rwlock, const int is_w)
503{
504 int res;
505 VALGRIND_DO_CLIENT_REQUEST(res, 0,
506 VG_USERREQ__DRD_ANNOTATE_RWLOCK_RELEASED,
507 rwlock, is_w, 0, 0, 0);
bartd45d9952009-05-31 18:53:54 +0000508}
bart3c1e9d82008-06-30 17:10:29 +0000509
510#endif /* __VALGRIND_DRD_H */