blob: 00f9605456fbe50a0ff6c4049f52d3836676a326 [file] [log] [blame]
sewardjb5f6f512005-03-10 23:59:00 +00001/* -*- c -*-
njn25e49d8e72002-09-23 09:36:25 +00002 ----------------------------------------------------------------
3
4 Notice that the following BSD-style license applies to this one
5 file (valgrind.h) only. The entire rest of Valgrind is licensed
6 under the terms of the GNU General Public License, version 2. See
7 the COPYING file in the source distribution for details.
8
9 ----------------------------------------------------------------
10
njnb9c427c2004-12-01 14:14:42 +000011 This file is part of Valgrind, a dynamic binary instrumentation
12 framework.
sewardjde4a1d02002-03-22 01:27:54 +000013
nethercotebb1c9912004-01-04 16:43:23 +000014 Copyright (C) 2000-2004 Julian Seward. All rights reserved.
sewardjde4a1d02002-03-22 01:27:54 +000015
njn25e49d8e72002-09-23 09:36:25 +000016 Redistribution and use in source and binary forms, with or without
17 modification, are permitted provided that the following conditions
18 are met:
sewardjde4a1d02002-03-22 01:27:54 +000019
njn25e49d8e72002-09-23 09:36:25 +000020 1. Redistributions of source code must retain the above copyright
21 notice, this list of conditions and the following disclaimer.
sewardjde4a1d02002-03-22 01:27:54 +000022
njn25e49d8e72002-09-23 09:36:25 +000023 2. The origin of this software must not be misrepresented; you must
24 not claim that you wrote the original software. If you use this
25 software in a product, an acknowledgment in the product
26 documentation would be appreciated but is not required.
sewardjde4a1d02002-03-22 01:27:54 +000027
njn25e49d8e72002-09-23 09:36:25 +000028 3. Altered source versions must be plainly marked as such, and must
29 not be misrepresented as being the original software.
30
31 4. The name of the author may not be used to endorse or promote
32 products derived from this software without specific prior written
33 permission.
34
35 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
36 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
39 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
43 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
47 ----------------------------------------------------------------
48
49 Notice that the above BSD-style license applies to this one file
50 (valgrind.h) only. The entire rest of Valgrind is licensed under
51 the terms of the GNU General Public License, version 2. See the
52 COPYING file in the source distribution for details.
53
54 ----------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +000055*/
56
57
58#ifndef __VALGRIND_H
59#define __VALGRIND_H
60
fitzhardinge39de4b42003-10-31 07:12:21 +000061#include <stdarg.h>
62
nethercoteb2decc32004-10-25 19:33:26 +000063#undef __@VG_ARCH@__
64#define __@VG_ARCH@__ 1 // Architecture we're installed on
sewardjde4a1d02002-03-22 01:27:54 +000065
sewardjb5f6f512005-03-10 23:59:00 +000066
67/* If we're not compiling for our target architecture, don't generate
68 any inline asms. This would be a bit neater if we used the same
69 CPP symbols as the compiler for identifying architectures. */
70#if !(__x86__ && __i386__)
71# ifndef NVALGRIND
72# define NVALGRIND 1
73# endif /* NVALGRIND */
74#endif
75
76
sewardjde4a1d02002-03-22 01:27:54 +000077/* This file is for inclusion into client (your!) code.
78
njn25e49d8e72002-09-23 09:36:25 +000079 You can use these macros to manipulate and query Valgrind's
80 execution inside your own programs.
sewardjde4a1d02002-03-22 01:27:54 +000081
82 The resulting executables will still run without Valgrind, just a
83 little bit more slowly than they otherwise would, but otherwise
sewardj285f77f2003-03-15 23:39:11 +000084 unchanged. When not running on valgrind, each client request
nethercotee90c6832004-10-18 18:07:49 +000085 consumes very few (eg. < 10) instructions, so the resulting performance
sewardj285f77f2003-03-15 23:39:11 +000086 loss is negligible unless you plan to execute client requests
87 millions of times per second. Nevertheless, if that is still a
88 problem, you can compile with the NVALGRIND symbol defined (gcc
89 -DNVALGRIND) so that client requests are not even compiled in. */
sewardjde4a1d02002-03-22 01:27:54 +000090
sewardj37091fb2002-11-16 11:06:50 +000091#ifndef NVALGRIND
nethercotee90c6832004-10-18 18:07:49 +000092
nethercote54265442004-10-26 12:56:58 +000093/* The following defines the magic code sequences which the JITter spots and
94 handles magically. Don't look too closely at them; they will rot
nethercotee90c6832004-10-18 18:07:49 +000095 your brain. We must ensure that the default value gets put in the return
96 slot, so that everything works when this is executed not under Valgrind.
97 Args are passed in a memory block, and so there's no intrinsic limit to
98 the number that could be passed, but it's currently four.
99
nethercote54265442004-10-26 12:56:58 +0000100 The macro args are:
101 _zzq_rlval result lvalue
102 _zzq_default default value (result returned when running on real CPU)
103 _zzq_request request code
104 _zzq_arg1..4 request params
105
nethercotee90c6832004-10-18 18:07:49 +0000106 Nb: we put the assembly code sequences for all architectures in this one
107 file. This is because this file must be stand-alone, so we can't rely on
108 eg. x86/ subdirectories like we do within the rest of Valgrind.
109*/
110
njnc6168192004-11-29 13:54:10 +0000111#ifdef __arm__
112// XXX: termporary, until MAGIC_SEQUENCE is written properly
113extern int printf (__const char *__restrict __format, ...);
114extern void exit (int __status);
115#define VALGRIND_MAGIC_SEQUENCE( \
116 _zzq_rlval, _zzq_default, _zzq_request, \
117 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
118 \
119 { volatile unsigned int _zzq_args[5]; \
120 _zzq_args[0] = (volatile unsigned int)(_zzq_request); \
121 _zzq_args[1] = (volatile unsigned int)(_zzq_arg1); \
122 _zzq_args[2] = (volatile unsigned int)(_zzq_arg2); \
123 _zzq_args[3] = (volatile unsigned int)(_zzq_arg3); \
124 _zzq_args[4] = (volatile unsigned int)(_zzq_arg4); \
125 (_zzq_rlval) = (_zzq_default);/* temporary only */ \
126 printf("argh: MAGIC_SEQUENCE"); exit(1); \
127 asm volatile(""); \
128 }
129// XXX: make sure that the register holding the args and the register taking
130// the return value match ARCH_CLREQ_ARGS and ARCH_CLREQ_RET in
131// arm/core_arch.h!
132#endif // __arm__
133#ifdef __amd64__
134// XXX: termporary, until MAGIC_SEQUENCE is written properly
135extern int printf (__const char *__restrict __format, ...);
136extern void exit (int __status);
137#define VALGRIND_MAGIC_SEQUENCE( \
138 _zzq_rlval, _zzq_default, _zzq_request, \
139 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
140 \
141 { volatile unsigned long _zzq_args[5]; \
142 _zzq_args[0] = (volatile unsigned long)(_zzq_request); \
143 _zzq_args[1] = (volatile unsigned long)(_zzq_arg1); \
144 _zzq_args[2] = (volatile unsigned long)(_zzq_arg2); \
145 _zzq_args[3] = (volatile unsigned long)(_zzq_arg3); \
146 _zzq_args[4] = (volatile unsigned long)(_zzq_arg4); \
147 (_zzq_rlval) = (_zzq_default);/* temporary only */ \
148 printf("argh: MAGIC_SEQUENCE"); exit(1); \
149 asm volatile(""); \
150 }
151// XXX: make sure that the register holding the args and the register taking
152// the return value match ARCH_CLREQ_ARGS and ARCH_CLREQ_RET in
153// amd64/core_arch.h!
154#endif // __amd64__
nethercotee90c6832004-10-18 18:07:49 +0000155#ifdef __x86__
sewardjb5f6f512005-03-10 23:59:00 +0000156#define VALGRIND_MAGIC_SEQUENCE( \
157 _zzq_rlval, _zzq_default, _zzq_request, \
158 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
159 \
160 { unsigned int _zzq_args[5]; \
161 _zzq_args[0] = (unsigned int)(_zzq_request); \
162 _zzq_args[1] = (unsigned int)(_zzq_arg1); \
163 _zzq_args[2] = (unsigned int)(_zzq_arg2); \
164 _zzq_args[3] = (unsigned int)(_zzq_arg3); \
165 _zzq_args[4] = (unsigned int)(_zzq_arg4); \
166 asm volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
167 "rorl $27, %%eax ; rorl $5, %%eax\n\t" \
168 "roll $13, %%eax ; roll $19, %%eax" \
169 : "=d" (_zzq_rlval) \
170 : "a" (&_zzq_args[0]), "0" (_zzq_default) \
171 : "cc", "memory" \
172 ); \
sewardj2e93c502002-04-12 11:12:52 +0000173 }
njnca0518d2004-11-26 19:34:36 +0000174#endif // __x86__
nethercotee90c6832004-10-18 18:07:49 +0000175// Insert assembly code for other architectures here...
176
sewardj37091fb2002-11-16 11:06:50 +0000177#else /* NVALGRIND */
178/* Define NVALGRIND to completely remove the Valgrind magic sequence
179 from the compiled code (analogous to NDEBUG's effects on
180 assert()) */
181#define VALGRIND_MAGIC_SEQUENCE( \
nethercote69d9c462004-10-26 13:00:12 +0000182 _zzq_rlval, _zzq_default, _zzq_request, \
183 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
sewardj37091fb2002-11-16 11:06:50 +0000184 { \
185 (_zzq_rlval) = (_zzq_default); \
186 }
187#endif /* NVALGRIND */
sewardj2e93c502002-04-12 11:12:52 +0000188
nethercote69d9c462004-10-26 13:00:12 +0000189
sewardj2e93c502002-04-12 11:12:52 +0000190/* Some request codes. There are many more of these, but most are not
191 exposed to end-user view. These are the public ones, all of the
njn25e49d8e72002-09-23 09:36:25 +0000192 form 0x1000 + small_number.
njnd7994182003-10-02 13:44:04 +0000193
194 Core ones are in the range 0x00000000--0x0000ffff. The non-public ones
195 start at 0x2000.
sewardj2e93c502002-04-12 11:12:52 +0000196*/
197
njnfc26ff92004-11-22 19:12:49 +0000198// These macros are used by tools -- they must be public, but don't embed them
199// into other programs.
200#define VG_USERREQ_TOOL_BASE(a,b) \
njn4c791212003-05-02 17:53:54 +0000201 ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16))
njnfc26ff92004-11-22 19:12:49 +0000202#define VG_IS_TOOL_USERREQ(a, b, v) \
203 (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000))
sewardj34042512002-10-22 04:14:35 +0000204
njn25e49d8e72002-09-23 09:36:25 +0000205typedef
njn4c791212003-05-02 17:53:54 +0000206 enum { VG_USERREQ__RUNNING_ON_VALGRIND = 0x1001,
207 VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002,
njn3e884182003-04-15 13:03:23 +0000208
njnd4795be2004-11-24 11:57:51 +0000209 /* These allow any function to be called from the
210 simulated CPU but run on the real CPU.
211 Nb: the first arg passed to the function is always the ThreadId of
212 the running thread! So CLIENT_CALL0 actually requires a 1 arg
213 function, etc. */
njn4c791212003-05-02 17:53:54 +0000214 VG_USERREQ__CLIENT_CALL0 = 0x1101,
215 VG_USERREQ__CLIENT_CALL1 = 0x1102,
216 VG_USERREQ__CLIENT_CALL2 = 0x1103,
217 VG_USERREQ__CLIENT_CALL3 = 0x1104,
njn3e884182003-04-15 13:03:23 +0000218
njn47363ab2003-04-21 13:24:40 +0000219 /* Can be useful in regression testing suites -- eg. can send
220 Valgrind's output to /dev/null and still count errors. */
njn4c791212003-05-02 17:53:54 +0000221 VG_USERREQ__COUNT_ERRORS = 0x1201,
njn47363ab2003-04-21 13:24:40 +0000222
nethercote7cc9c232004-01-21 15:08:04 +0000223 /* These are useful and can be interpreted by any tool that tracks
njnd7994182003-10-02 13:44:04 +0000224 malloc() et al, by using vg_replace_malloc.c. */
225 VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
226 VG_USERREQ__FREELIKE_BLOCK = 0x1302,
rjwalshbc0bb832004-06-19 18:12:36 +0000227 /* Memory pool support. */
228 VG_USERREQ__CREATE_MEMPOOL = 0x1303,
229 VG_USERREQ__DESTROY_MEMPOOL = 0x1304,
230 VG_USERREQ__MEMPOOL_ALLOC = 0x1305,
231 VG_USERREQ__MEMPOOL_FREE = 0x1306,
njnd7994182003-10-02 13:44:04 +0000232
fitzhardinge39de4b42003-10-31 07:12:21 +0000233 /* Allow printfs to valgrind log. */
234 VG_USERREQ__PRINTF = 0x1401,
thughes85c8a502004-08-25 13:25:30 +0000235 VG_USERREQ__PRINTF_BACKTRACE = 0x1402
njn25e49d8e72002-09-23 09:36:25 +0000236 } Vg_ClientRequest;
sewardj2e93c502002-04-12 11:12:52 +0000237
muellerc9b36552003-12-31 14:32:23 +0000238#ifndef __GNUC__
239#define __extension__
240#endif
sewardj2e93c502002-04-12 11:12:52 +0000241
242/* Returns 1 if running on Valgrind, 0 if running on the real CPU.
243 Currently implemented but untested. */
muellerc9b36552003-12-31 14:32:23 +0000244#define RUNNING_ON_VALGRIND __extension__ \
sewardj2e93c502002-04-12 11:12:52 +0000245 ({unsigned int _qzz_res; \
246 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0 /* returned if not */, \
247 VG_USERREQ__RUNNING_ON_VALGRIND, \
248 0, 0, 0, 0); \
249 _qzz_res; \
sewardjde4a1d02002-03-22 01:27:54 +0000250 })
251
252
sewardj18d75132002-05-16 11:06:21 +0000253/* Discard translation of code in the range [_qzz_addr .. _qzz_addr +
254 _qzz_len - 1]. Useful if you are debugging a JITter or some such,
255 since it provides a way to make sure valgrind will retranslate the
256 invalidated area. Returns no value. */
257#define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len) \
258 {unsigned int _qzz_res; \
259 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
260 VG_USERREQ__DISCARD_TRANSLATIONS, \
261 _qzz_addr, _qzz_len, 0, 0); \
262 }
263
fitzhardinge39de4b42003-10-31 07:12:21 +0000264#ifndef NVALGRIND
265
fitzhardingea09a1b52003-11-07 23:09:48 +0000266int VALGRIND_PRINTF(const char *format, ...)
267 __attribute__((format(__printf__, 1, 2)));
fitzhardinge39de4b42003-10-31 07:12:21 +0000268__attribute__((weak))
269int
fitzhardingea09a1b52003-11-07 23:09:48 +0000270VALGRIND_PRINTF(const char *format, ...)
fitzhardinge39de4b42003-10-31 07:12:21 +0000271{
njnc6168192004-11-29 13:54:10 +0000272 unsigned long _qzz_res;
fitzhardinge39de4b42003-10-31 07:12:21 +0000273 va_list vargs;
274 va_start(vargs, format);
275 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__PRINTF,
njnc6168192004-11-29 13:54:10 +0000276 (unsigned long)format, (unsigned long)vargs, 0, 0);
fitzhardinge39de4b42003-10-31 07:12:21 +0000277 va_end(vargs);
njnc6168192004-11-29 13:54:10 +0000278 return (int)_qzz_res;
fitzhardinge39de4b42003-10-31 07:12:21 +0000279}
280
fitzhardingea09a1b52003-11-07 23:09:48 +0000281int VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
282 __attribute__((format(__printf__, 1, 2)));
fitzhardinge39de4b42003-10-31 07:12:21 +0000283__attribute__((weak))
284int
fitzhardingea09a1b52003-11-07 23:09:48 +0000285VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
fitzhardinge39de4b42003-10-31 07:12:21 +0000286{
njnc6168192004-11-29 13:54:10 +0000287 unsigned long _qzz_res;
fitzhardinge39de4b42003-10-31 07:12:21 +0000288 va_list vargs;
289 va_start(vargs, format);
290 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__PRINTF_BACKTRACE,
njnc6168192004-11-29 13:54:10 +0000291 (unsigned long)format, (unsigned long)vargs, 0, 0);
fitzhardinge39de4b42003-10-31 07:12:21 +0000292 va_end(vargs);
njnc6168192004-11-29 13:54:10 +0000293 return (int)_qzz_res;
fitzhardinge39de4b42003-10-31 07:12:21 +0000294}
295
296#else /* NVALGRIND */
297
298#define VALGRIND_PRINTF(...)
299#define VALGRIND_PRINTF_BACKTRACE(...)
300
301#endif /* NVALGRIND */
sewardj18d75132002-05-16 11:06:21 +0000302
njn3e884182003-04-15 13:03:23 +0000303/* These requests allow control to move from the simulated CPU to the
304 real CPU, calling an arbitary function */
njn057c65f2003-04-21 13:30:55 +0000305#define VALGRIND_NON_SIMD_CALL0(_qyy_fn) \
njnc6168192004-11-29 13:54:10 +0000306 ({unsigned long _qyy_res; \
njn3e884182003-04-15 13:03:23 +0000307 VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
308 VG_USERREQ__CLIENT_CALL0, \
309 _qyy_fn, \
310 0, 0, 0); \
311 _qyy_res; \
312 })
313
njn057c65f2003-04-21 13:30:55 +0000314#define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1) \
njnc6168192004-11-29 13:54:10 +0000315 ({unsigned long _qyy_res; \
njn3e884182003-04-15 13:03:23 +0000316 VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
317 VG_USERREQ__CLIENT_CALL1, \
318 _qyy_fn, \
319 _qyy_arg1, 0, 0); \
320 _qyy_res; \
321 })
322
njn057c65f2003-04-21 13:30:55 +0000323#define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2) \
njnc6168192004-11-29 13:54:10 +0000324 ({unsigned long _qyy_res; \
njn3e884182003-04-15 13:03:23 +0000325 VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
326 VG_USERREQ__CLIENT_CALL2, \
327 _qyy_fn, \
328 _qyy_arg1, _qyy_arg2, 0); \
329 _qyy_res; \
330 })
331
njn057c65f2003-04-21 13:30:55 +0000332#define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \
njnc6168192004-11-29 13:54:10 +0000333 ({unsigned long _qyy_res; \
njn3e884182003-04-15 13:03:23 +0000334 VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
335 VG_USERREQ__CLIENT_CALL3, \
336 _qyy_fn, \
337 _qyy_arg1, _qyy_arg2, _qyy_arg3); \
338 _qyy_res; \
339 })
340
341
nethercote7cc9c232004-01-21 15:08:04 +0000342/* Counts the number of errors that have been recorded by a tool. Nb:
343 the tool must record the errors with VG_(maybe_record_error)() or
njn47363ab2003-04-21 13:24:40 +0000344 VG_(unique_error)() for them to be counted. */
345#define VALGRIND_COUNT_ERRORS \
346 ({unsigned int _qyy_res; \
347 VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
348 VG_USERREQ__COUNT_ERRORS, \
349 0, 0, 0, 0); \
350 _qyy_res; \
351 })
352
njnd7994182003-10-02 13:44:04 +0000353/* Mark a block of memory as having been allocated by a malloc()-like
354 function. `addr' is the start of the usable block (ie. after any
355 redzone) `rzB' is redzone size if the allocator can apply redzones;
356 use '0' if not. Adding redzones makes it more likely Valgrind will spot
357 block overruns. `is_zeroed' indicates if the memory is zeroed, as it is
358 for calloc(). Put it immediately after the point where a block is
359 allocated.
360
361 If you're allocating memory via superblocks, and then handing out small
362 chunks of each superblock, if you don't have redzones on your small
363 blocks, it's worth marking the superblock with VALGRIND_MAKE_NOACCESS
364 when it's created, so that block overruns are detected. But if you can
365 put redzones on, it's probably better to not do this, so that messages
366 for small overruns are described in terms of the small block rather than
367 the superblock (but if you have a big overrun that skips over a redzone,
368 you could miss an error this way). See memcheck/tests/custom_alloc.c
369 for an example.
370
371 Nb: block must be freed via a free()-like function specified
372 with VALGRIND_FREELIKE_BLOCK or mismatch errors will occur. */
373#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) \
374 {unsigned int _qzz_res; \
375 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
376 VG_USERREQ__MALLOCLIKE_BLOCK, \
377 addr, sizeB, rzB, is_zeroed); \
378 }
379
380/* Mark a block of memory as having been freed by a free()-like function.
381 `rzB' is redzone size; it must match that given to
382 VALGRIND_MALLOCLIKE_BLOCK. Memory not freed will be detected by the leak
383 checker. Put it immediately after the point where the block is freed. */
384#define VALGRIND_FREELIKE_BLOCK(addr, rzB) \
385 {unsigned int _qzz_res; \
386 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
387 VG_USERREQ__FREELIKE_BLOCK, \
388 addr, rzB, 0, 0); \
389 }
390
rjwalshbc0bb832004-06-19 18:12:36 +0000391/* Create a memory pool. */
392#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) \
393 {unsigned int _qzz_res; \
394 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
395 VG_USERREQ__CREATE_MEMPOOL, \
396 pool, rzB, is_zeroed, 0); \
397 }
398
399/* Destroy a memory pool. */
400#define VALGRIND_DESTROY_MEMPOOL(pool) \
401 {unsigned int _qzz_res; \
402 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
403 VG_USERREQ__DESTROY_MEMPOOL, \
404 pool, 0, 0, 0); \
405 }
406
407/* Associate a piece of memory with a memory pool. */
408#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) \
409 {unsigned int _qzz_res; \
410 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
411 VG_USERREQ__MEMPOOL_ALLOC, \
412 pool, addr, size, 0); \
413 }
414
415/* Disassociate a piece of memory from a memory pool. */
416#define VALGRIND_MEMPOOL_FREE(pool, addr) \
417 {unsigned int _qzz_res; \
418 VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
419 VG_USERREQ__MEMPOOL_FREE, \
420 pool, addr, 0, 0); \
421 }
422
njn3e884182003-04-15 13:03:23 +0000423#endif /* __VALGRIND_H */