2 ----------------------------------------------------------------
4 Notice that the following BSD-style license applies to this one
5 file (valgrind.h) only. The rest of Valgrind is licensed under the
6 terms of the GNU General Public License, version 2, unless
7 otherwise indicated. See the COPYING file in the source
8 distribution for details.
10 ----------------------------------------------------------------
12 This file is part of Valgrind, a dynamic binary instrumentation
15 Copyright (C) 2000-2010 Julian Seward. All rights reserved.
17 Redistribution and use in source and binary forms, with or without
18 modification, are permitted provided that the following conditions
21 1. Redistributions of source code must retain the above copyright
22 notice, this list of conditions and the following disclaimer.
24 2. The origin of this software must not be misrepresented; you must
25 not claim that you wrote the original software. If you use this
26 software in a product, an acknowledgment in the product
27 documentation would be appreciated but is not required.
29 3. Altered source versions must be plainly marked as such, and must
30 not be misrepresented as being the original software.
32 4. The name of the author may not be used to endorse or promote
33 products derived from this software without specific prior written
36 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
37 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
40 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 ----------------------------------------------------------------
50 Notice that the above BSD-style license applies to this one file
51 (valgrind.h) only. The entire rest of Valgrind is licensed under
52 the terms of the GNU General Public License, version 2. See the
53 COPYING file in the source distribution for details.
55 ----------------------------------------------------------------
59 /* This file is for inclusion into client (your!) code.
61 You can use these macros to manipulate and query Valgrind's
62 execution inside your own programs.
64 The resulting executables will still run without Valgrind, just a
65 little bit more slowly than they otherwise would, but otherwise
66 unchanged. When not running on valgrind, each client request
67 consumes very few (eg. 7) instructions, so the resulting performance
68 loss is negligible unless you plan to execute client requests
69 millions of times per second. Nevertheless, if that is still a
70 problem, you can compile with the NVALGRIND symbol defined (gcc
71 -DNVALGRIND) so that client requests are not even compiled in. */
77 /* ------------------------------------------------------------------ */
78 /* VERSION NUMBER OF VALGRIND */
79 /* ------------------------------------------------------------------ */
81 /* Specify Valgrind's version number, so that user code can
82 conditionally compile based on our version number. Note that these
83 were introduced at version 3.6 and so do not exist in version 3.5
84 or earlier. The recommended way to use them to check for "version
87 #if defined(__VALGRIND_MAJOR__) && defined(__VALGRIND_MINOR__) \
88 && (__VALGRIND_MAJOR__ > 3 \
89 || (__VALGRIND_MAJOR__ == 3 && __VALGRIND_MINOR__ >= 6))
91 #define __VALGRIND_MAJOR__ 3
92 #define __VALGRIND_MINOR__ 6
97 /* Nb: this file might be included in a file compiled with -ansi. So
98 we can't use C++ style "//" comments nor the "asm" keyword (instead
101 /* Derive some tags indicating what the target platform is. Note
102 that in this file we're using the compiler's CPP symbols for
103 identifying architectures, which are different to the ones we use
104 within the rest of Valgrind. Note, __powerpc__ is active for both
105 32 and 64-bit PPC, whereas __powerpc64__ is only active for the
106 latter (on Linux, that is).
108 Misc note: how to find out what's predefined in gcc by default:
109 gcc -Wp,-dM somefile.c
111 #undef PLAT_ppc64_aix5
112 #undef PLAT_ppc32_aix5
113 #undef PLAT_x86_darwin
114 #undef PLAT_amd64_darwin
115 #undef PLAT_x86_win32
116 #undef PLAT_x86_linux
117 #undef PLAT_amd64_linux
118 #undef PLAT_ppc32_linux
119 #undef PLAT_ppc64_linux
120 #undef PLAT_arm_linux
122 #if defined(_AIX) && defined(__64BIT__)
123 # define PLAT_ppc64_aix5 1
124 #elif defined(_AIX) && !defined(__64BIT__)
125 # define PLAT_ppc32_aix5 1
126 #elif defined(__APPLE__) && defined(__i386__)
127 # define PLAT_x86_darwin 1
128 #elif defined(__APPLE__) && defined(__x86_64__)
129 # define PLAT_amd64_darwin 1
130 #elif defined(__MINGW32__) || defined(__CYGWIN32__) || defined(_WIN32) && defined(_M_IX86)
131 # define PLAT_x86_win32 1
132 #elif defined(__linux__) && defined(__i386__)
133 # define PLAT_x86_linux 1
134 #elif defined(__linux__) && defined(__x86_64__)
135 # define PLAT_amd64_linux 1
136 #elif defined(__linux__) && defined(__powerpc__) && !defined(__powerpc64__)
137 # define PLAT_ppc32_linux 1
138 #elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__)
139 # define PLAT_ppc64_linux 1
140 #elif defined(__linux__) && defined(__arm__)
141 # define PLAT_arm_linux 1
143 /* If we're not compiling for our target platform, don't generate
145 # if !defined(NVALGRIND)
151 /* ------------------------------------------------------------------ */
152 /* ARCHITECTURE SPECIFICS for SPECIAL INSTRUCTIONS. There is nothing */
153 /* in here of use to end-users -- skip to the next section. */
154 /* ------------------------------------------------------------------ */
156 #if defined(NVALGRIND)
158 /* Define NVALGRIND to completely remove the Valgrind magic sequence
159 from the compiled code (analogous to NDEBUG's effects on
161 #define VALGRIND_DO_CLIENT_REQUEST( \
162 _zzq_rlval, _zzq_default, _zzq_request, \
163 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
165 (_zzq_rlval) = (_zzq_default); \
168 #else /* ! NVALGRIND */
170 /* The following defines the magic code sequences which the JITter
171 spots and handles magically. Don't look too closely at them as
172 they will rot your brain.
174 The assembly code sequences for all architectures is in this one
175 file. This is because this file must be stand-alone, and we don't
176 want to have multiple files.
178 For VALGRIND_DO_CLIENT_REQUEST, we must ensure that the default
179 value gets put in the return slot, so that everything works when
180 this is executed not under Valgrind. Args are passed in a memory
181 block, and so there's no intrinsic limit to the number that could
182 be passed, but it's currently five.
185 _zzq_rlval result lvalue
186 _zzq_default default value (result returned when running on real CPU)
187 _zzq_request request code
188 _zzq_arg1..5 request params
190 The other two macros are used to support function wrapping, and are
191 a lot simpler. VALGRIND_GET_NR_CONTEXT returns the value of the
192 guest's NRADDR pseudo-register and whatever other information is
193 needed to safely run the call original from the wrapper: on
194 ppc64-linux, the R2 value at the divert point is also needed. This
195 information is abstracted into a user-visible type, OrigFn.
197 VALGRIND_CALL_NOREDIR_* behaves the same as the following on the
198 guest, but guarantees that the branch instruction will not be
199 redirected: x86: call *%eax, amd64: call *%rax, ppc32/ppc64:
200 branch-and-link-to-r11. VALGRIND_CALL_NOREDIR is just text, not a
201 complete inline asm, since it needs to be combined with more magic
202 inline asm stuff to be useful.
205 /* ------------------------- x86-{linux,darwin} ---------------- */
207 #if defined(PLAT_x86_linux) || defined(PLAT_x86_darwin) \
208 || (defined(PLAT_x86_win32) && defined(__GNUC__))
212 unsigned int nraddr
; /* where's the code? */
216 #define __SPECIAL_INSTRUCTION_PREAMBLE \
217 "roll $3, %%edi ; roll $13, %%edi\n\t" \
218 "roll $29, %%edi ; roll $19, %%edi\n\t"
220 #define VALGRIND_DO_CLIENT_REQUEST( \
221 _zzq_rlval, _zzq_default, _zzq_request, \
222 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
223 { volatile unsigned int _zzq_args[6]; \
224 volatile unsigned int _zzq_result; \
225 _zzq_args[0] = (unsigned int)(_zzq_request); \
226 _zzq_args[1] = (unsigned int)(_zzq_arg1); \
227 _zzq_args[2] = (unsigned int)(_zzq_arg2); \
228 _zzq_args[3] = (unsigned int)(_zzq_arg3); \
229 _zzq_args[4] = (unsigned int)(_zzq_arg4); \
230 _zzq_args[5] = (unsigned int)(_zzq_arg5); \
231 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
232 /* %EDX = client_request ( %EAX ) */ \
233 "xchgl %%ebx,%%ebx" \
234 : "=d" (_zzq_result) \
235 : "a" (&_zzq_args[0]), "0" (_zzq_default) \
238 _zzq_rlval = _zzq_result; \
241 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \
242 { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \
243 volatile unsigned int __addr; \
244 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
245 /* %EAX = guest_NRADDR */ \
246 "xchgl %%ecx,%%ecx" \
251 _zzq_orig->nraddr = __addr; \
254 #define VALGRIND_CALL_NOREDIR_EAX \
255 __SPECIAL_INSTRUCTION_PREAMBLE \
256 /* call-noredir *%EAX */ \
257 "xchgl %%edx,%%edx\n\t"
258 #endif /* PLAT_x86_linux || PLAT_x86_darwin || (PLAT_x86_win32 && __GNUC__) */
260 /* ------------------------- x86-Win32 ------------------------- */
262 #if defined(PLAT_x86_win32) && !defined(__GNUC__)
266 unsigned int nraddr
; /* where's the code? */
270 #if defined(_MSC_VER)
272 #define __SPECIAL_INSTRUCTION_PREAMBLE \
273 __asm rol edi, 3 __asm rol edi, 13 \
274 __asm rol edi, 29 __asm rol edi, 19
276 #define VALGRIND_DO_CLIENT_REQUEST( \
277 _zzq_rlval, _zzq_default, _zzq_request, \
278 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
279 { volatile uintptr_t _zzq_args[6]; \
280 volatile unsigned int _zzq_result; \
281 _zzq_args[0] = (uintptr_t)(_zzq_request); \
282 _zzq_args[1] = (uintptr_t)(_zzq_arg1); \
283 _zzq_args[2] = (uintptr_t)(_zzq_arg2); \
284 _zzq_args[3] = (uintptr_t)(_zzq_arg3); \
285 _zzq_args[4] = (uintptr_t)(_zzq_arg4); \
286 _zzq_args[5] = (uintptr_t)(_zzq_arg5); \
287 __asm { __asm lea eax, _zzq_args __asm mov edx, _zzq_default \
288 __SPECIAL_INSTRUCTION_PREAMBLE \
289 /* %EDX = client_request ( %EAX ) */ \
291 __asm mov _zzq_result, edx \
293 _zzq_rlval = _zzq_result; \
296 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \
297 { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \
298 volatile unsigned int __addr; \
299 __asm { __SPECIAL_INSTRUCTION_PREAMBLE \
300 /* %EAX = guest_NRADDR */ \
302 __asm mov __addr, eax \
304 _zzq_orig->nraddr = __addr; \
307 #define VALGRIND_CALL_NOREDIR_EAX ERROR
310 #error Unsupported compiler.
313 #endif /* PLAT_x86_win32 */
315 /* ------------------------ amd64-{linux,darwin} --------------- */
317 #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin)
321 unsigned long long int nraddr
; /* where's the code? */
325 #define __SPECIAL_INSTRUCTION_PREAMBLE \
326 "rolq $3, %%rdi ; rolq $13, %%rdi\n\t" \
327 "rolq $61, %%rdi ; rolq $51, %%rdi\n\t"
329 #define VALGRIND_DO_CLIENT_REQUEST( \
330 _zzq_rlval, _zzq_default, _zzq_request, \
331 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
332 { volatile unsigned long long int _zzq_args[6]; \
333 volatile unsigned long long int _zzq_result; \
334 _zzq_args[0] = (unsigned long long int)(_zzq_request); \
335 _zzq_args[1] = (unsigned long long int)(_zzq_arg1); \
336 _zzq_args[2] = (unsigned long long int)(_zzq_arg2); \
337 _zzq_args[3] = (unsigned long long int)(_zzq_arg3); \
338 _zzq_args[4] = (unsigned long long int)(_zzq_arg4); \
339 _zzq_args[5] = (unsigned long long int)(_zzq_arg5); \
340 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
341 /* %RDX = client_request ( %RAX ) */ \
342 "xchgq %%rbx,%%rbx" \
343 : "=d" (_zzq_result) \
344 : "a" (&_zzq_args[0]), "0" (_zzq_default) \
347 _zzq_rlval = _zzq_result; \
350 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \
351 { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \
352 volatile unsigned long long int __addr; \
353 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
354 /* %RAX = guest_NRADDR */ \
355 "xchgq %%rcx,%%rcx" \
360 _zzq_orig->nraddr = __addr; \
363 #define VALGRIND_CALL_NOREDIR_RAX \
364 __SPECIAL_INSTRUCTION_PREAMBLE \
365 /* call-noredir *%RAX */ \
366 "xchgq %%rdx,%%rdx\n\t"
367 #endif /* PLAT_amd64_linux || PLAT_amd64_darwin */
369 /* ------------------------ ppc32-linux ------------------------ */
371 #if defined(PLAT_ppc32_linux)
375 unsigned int nraddr
; /* where's the code? */
379 #define __SPECIAL_INSTRUCTION_PREAMBLE \
380 "rlwinm 0,0,3,0,0 ; rlwinm 0,0,13,0,0\n\t" \
381 "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t"
383 #define VALGRIND_DO_CLIENT_REQUEST( \
384 _zzq_rlval, _zzq_default, _zzq_request, \
385 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
387 { unsigned int _zzq_args[6]; \
388 unsigned int _zzq_result; \
389 unsigned int* _zzq_ptr; \
390 _zzq_args[0] = (unsigned int)(_zzq_request); \
391 _zzq_args[1] = (unsigned int)(_zzq_arg1); \
392 _zzq_args[2] = (unsigned int)(_zzq_arg2); \
393 _zzq_args[3] = (unsigned int)(_zzq_arg3); \
394 _zzq_args[4] = (unsigned int)(_zzq_arg4); \
395 _zzq_args[5] = (unsigned int)(_zzq_arg5); \
396 _zzq_ptr = _zzq_args; \
397 __asm__ volatile("mr 3,%1\n\t" /*default*/ \
398 "mr 4,%2\n\t" /*ptr*/ \
399 __SPECIAL_INSTRUCTION_PREAMBLE \
400 /* %R3 = client_request ( %R4 ) */ \
402 "mr %0,3" /*result*/ \
403 : "=b" (_zzq_result) \
404 : "b" (_zzq_default), "b" (_zzq_ptr) \
405 : "cc", "memory", "r3", "r4"); \
406 _zzq_rlval = _zzq_result; \
409 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \
410 { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \
411 unsigned int __addr; \
412 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
413 /* %R3 = guest_NRADDR */ \
418 : "cc", "memory", "r3" \
420 _zzq_orig->nraddr = __addr; \
423 #define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
424 __SPECIAL_INSTRUCTION_PREAMBLE \
425 /* branch-and-link-to-noredir *%R11 */ \
427 #endif /* PLAT_ppc32_linux */
429 /* ------------------------ ppc64-linux ------------------------ */
431 #if defined(PLAT_ppc64_linux)
435 unsigned long long int nraddr
; /* where's the code? */
436 unsigned long long int r2
; /* what tocptr do we need? */
440 #define __SPECIAL_INSTRUCTION_PREAMBLE \
441 "rotldi 0,0,3 ; rotldi 0,0,13\n\t" \
442 "rotldi 0,0,61 ; rotldi 0,0,51\n\t"
444 #define VALGRIND_DO_CLIENT_REQUEST( \
445 _zzq_rlval, _zzq_default, _zzq_request, \
446 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
448 { unsigned long long int _zzq_args[6]; \
449 register unsigned long long int _zzq_result __asm__("r3"); \
450 register unsigned long long int* _zzq_ptr __asm__("r4"); \
451 _zzq_args[0] = (unsigned long long int)(_zzq_request); \
452 _zzq_args[1] = (unsigned long long int)(_zzq_arg1); \
453 _zzq_args[2] = (unsigned long long int)(_zzq_arg2); \
454 _zzq_args[3] = (unsigned long long int)(_zzq_arg3); \
455 _zzq_args[4] = (unsigned long long int)(_zzq_arg4); \
456 _zzq_args[5] = (unsigned long long int)(_zzq_arg5); \
457 _zzq_ptr = _zzq_args; \
458 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
459 /* %R3 = client_request ( %R4 ) */ \
461 : "=r" (_zzq_result) \
462 : "0" (_zzq_default), "r" (_zzq_ptr) \
464 _zzq_rlval = _zzq_result; \
467 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \
468 { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \
469 register unsigned long long int __addr __asm__("r3"); \
470 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
471 /* %R3 = guest_NRADDR */ \
477 _zzq_orig->nraddr = __addr; \
478 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
479 /* %R3 = guest_NRADDR_GPR2 */ \
485 _zzq_orig->r2 = __addr; \
488 #define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
489 __SPECIAL_INSTRUCTION_PREAMBLE \
490 /* branch-and-link-to-noredir *%R11 */ \
493 #endif /* PLAT_ppc64_linux */
495 /* ------------------------- arm-linux ------------------------- */
497 #if defined(PLAT_arm_linux)
501 unsigned int nraddr
; /* where's the code? */
505 #define __SPECIAL_INSTRUCTION_PREAMBLE \
506 "mov r12, r12, ror #3 ; mov r12, r12, ror #13 \n\t" \
507 "mov r12, r12, ror #29 ; mov r12, r12, ror #19 \n\t"
509 #define VALGRIND_DO_CLIENT_REQUEST( \
510 _zzq_rlval, _zzq_default, _zzq_request, \
511 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
513 { volatile unsigned int _zzq_args[6]; \
514 volatile unsigned int _zzq_result; \
515 _zzq_args[0] = (unsigned int)(_zzq_request); \
516 _zzq_args[1] = (unsigned int)(_zzq_arg1); \
517 _zzq_args[2] = (unsigned int)(_zzq_arg2); \
518 _zzq_args[3] = (unsigned int)(_zzq_arg3); \
519 _zzq_args[4] = (unsigned int)(_zzq_arg4); \
520 _zzq_args[5] = (unsigned int)(_zzq_arg5); \
521 __asm__ volatile("mov r3, %1\n\t" /*default*/ \
522 "mov r4, %2\n\t" /*ptr*/ \
523 __SPECIAL_INSTRUCTION_PREAMBLE \
524 /* R3 = client_request ( R4 ) */ \
525 "orr r10, r10, r10\n\t" \
526 "mov %0, r3" /*result*/ \
527 : "=r" (_zzq_result) \
528 : "r" (_zzq_default), "r" (&_zzq_args[0]) \
529 : "cc","memory", "r3", "r4"); \
530 _zzq_rlval = _zzq_result; \
533 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \
534 { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \
535 unsigned int __addr; \
536 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
537 /* R3 = guest_NRADDR */ \
538 "orr r11, r11, r11\n\t" \
542 : "cc", "memory", "r3" \
544 _zzq_orig->nraddr = __addr; \
547 #define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
548 __SPECIAL_INSTRUCTION_PREAMBLE \
549 /* branch-and-link-to-noredir *%R4 */ \
550 "orr r12, r12, r12\n\t"
552 #endif /* PLAT_arm_linux */
554 /* ------------------------ ppc32-aix5 ------------------------- */
556 #if defined(PLAT_ppc32_aix5)
560 unsigned int nraddr
; /* where's the code? */
561 unsigned int r2
; /* what tocptr do we need? */
565 #define __SPECIAL_INSTRUCTION_PREAMBLE \
566 "rlwinm 0,0,3,0,0 ; rlwinm 0,0,13,0,0\n\t" \
567 "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t"
569 #define VALGRIND_DO_CLIENT_REQUEST( \
570 _zzq_rlval, _zzq_default, _zzq_request, \
571 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
573 { unsigned int _zzq_args[7]; \
574 register unsigned int _zzq_result; \
575 register unsigned int* _zzq_ptr; \
576 _zzq_args[0] = (unsigned int)(_zzq_request); \
577 _zzq_args[1] = (unsigned int)(_zzq_arg1); \
578 _zzq_args[2] = (unsigned int)(_zzq_arg2); \
579 _zzq_args[3] = (unsigned int)(_zzq_arg3); \
580 _zzq_args[4] = (unsigned int)(_zzq_arg4); \
581 _zzq_args[5] = (unsigned int)(_zzq_arg5); \
582 _zzq_args[6] = (unsigned int)(_zzq_default); \
583 _zzq_ptr = _zzq_args; \
584 __asm__ volatile("mr 4,%1\n\t" \
586 __SPECIAL_INSTRUCTION_PREAMBLE \
587 /* %R3 = client_request ( %R4 ) */ \
590 : "=b" (_zzq_result) \
592 : "r3", "r4", "cc", "memory"); \
593 _zzq_rlval = _zzq_result; \
596 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \
597 { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \
598 register unsigned int __addr; \
599 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
600 /* %R3 = guest_NRADDR */ \
605 : "r3", "cc", "memory" \
607 _zzq_orig->nraddr = __addr; \
608 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
609 /* %R3 = guest_NRADDR_GPR2 */ \
614 : "r3", "cc", "memory" \
616 _zzq_orig->r2 = __addr; \
619 #define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
620 __SPECIAL_INSTRUCTION_PREAMBLE \
621 /* branch-and-link-to-noredir *%R11 */ \
624 #endif /* PLAT_ppc32_aix5 */
626 /* ------------------------ ppc64-aix5 ------------------------- */
628 #if defined(PLAT_ppc64_aix5)
632 unsigned long long int nraddr
; /* where's the code? */
633 unsigned long long int r2
; /* what tocptr do we need? */
637 #define __SPECIAL_INSTRUCTION_PREAMBLE \
638 "rotldi 0,0,3 ; rotldi 0,0,13\n\t" \
639 "rotldi 0,0,61 ; rotldi 0,0,51\n\t"
641 #define VALGRIND_DO_CLIENT_REQUEST( \
642 _zzq_rlval, _zzq_default, _zzq_request, \
643 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
645 { unsigned long long int _zzq_args[7]; \
646 register unsigned long long int _zzq_result; \
647 register unsigned long long int* _zzq_ptr; \
648 _zzq_args[0] = (unsigned int long long)(_zzq_request); \
649 _zzq_args[1] = (unsigned int long long)(_zzq_arg1); \
650 _zzq_args[2] = (unsigned int long long)(_zzq_arg2); \
651 _zzq_args[3] = (unsigned int long long)(_zzq_arg3); \
652 _zzq_args[4] = (unsigned int long long)(_zzq_arg4); \
653 _zzq_args[5] = (unsigned int long long)(_zzq_arg5); \
654 _zzq_args[6] = (unsigned int long long)(_zzq_default); \
655 _zzq_ptr = _zzq_args; \
656 __asm__ volatile("mr 4,%1\n\t" \
658 __SPECIAL_INSTRUCTION_PREAMBLE \
659 /* %R3 = client_request ( %R4 ) */ \
662 : "=b" (_zzq_result) \
664 : "r3", "r4", "cc", "memory"); \
665 _zzq_rlval = _zzq_result; \
668 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \
669 { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \
670 register unsigned long long int __addr; \
671 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
672 /* %R3 = guest_NRADDR */ \
677 : "r3", "cc", "memory" \
679 _zzq_orig->nraddr = __addr; \
680 __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \
681 /* %R3 = guest_NRADDR_GPR2 */ \
686 : "r3", "cc", "memory" \
688 _zzq_orig->r2 = __addr; \
691 #define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
692 __SPECIAL_INSTRUCTION_PREAMBLE \
693 /* branch-and-link-to-noredir *%R11 */ \
696 #endif /* PLAT_ppc64_aix5 */
698 /* Insert assembly code for other platforms here... */
700 #endif /* NVALGRIND */
703 /* ------------------------------------------------------------------ */
704 /* PLATFORM SPECIFICS for FUNCTION WRAPPING. This is all very */
705 /* ugly. It's the least-worst tradeoff I can think of. */
706 /* ------------------------------------------------------------------ */
708 /* This section defines magic (a.k.a appalling-hack) macros for doing
709 guaranteed-no-redirection macros, so as to get from function
710 wrappers to the functions they are wrapping. The whole point is to
711 construct standard call sequences, but to do the call itself with a
712 special no-redirect call pseudo-instruction that the JIT
713 understands and handles specially. This section is long and
714 repetitious, and I can't see a way to make it shorter.
716 The naming scheme is as follows:
718 CALL_FN_{W,v}_{v,W,WW,WWW,WWWW,5W,6W,7W,etc}
720 'W' stands for "word" and 'v' for "void". Hence there are
721 different macros for calling arity 0, 1, 2, 3, 4, etc, functions,
722 and for each, the possibility of returning a word-typed result, or
726 /* Use these to write the name of your wrapper. NOTE: duplicates
727 VG_WRAP_FUNCTION_Z{U,Z} in pub_tool_redir.h. */
729 /* Use an extra level of macroisation so as to ensure the soname/fnname
730 args are fully macro-expanded before pasting them together. */
731 #define VG_CONCAT4(_aa,_bb,_cc,_dd) _aa##_bb##_cc##_dd
733 #define I_WRAP_SONAME_FNNAME_ZU(soname,fnname) \
734 VG_CONCAT4(_vgwZU_,soname,_,fnname)
736 #define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname) \
737 VG_CONCAT4(_vgwZZ_,soname,_,fnname)
739 /* Use this macro from within a wrapper function to collect the
740 context (address and possibly other info) of the original function.
741 Once you have that you can then use it in one of the CALL_FN_
742 macros. The type of the argument _lval is OrigFn. */
743 #define VALGRIND_GET_ORIG_FN(_lval) VALGRIND_GET_NR_CONTEXT(_lval)
745 /* Derivatives of the main macros below, for calling functions
748 #define CALL_FN_v_v(fnptr) \
749 do { volatile unsigned long _junk; \
750 CALL_FN_W_v(_junk,fnptr); } while (0)
752 #define CALL_FN_v_W(fnptr, arg1) \
753 do { volatile unsigned long _junk; \
754 CALL_FN_W_W(_junk,fnptr,arg1); } while (0)
756 #define CALL_FN_v_WW(fnptr, arg1,arg2) \
757 do { volatile unsigned long _junk; \
758 CALL_FN_W_WW(_junk,fnptr,arg1,arg2); } while (0)
760 #define CALL_FN_v_WWW(fnptr, arg1,arg2,arg3) \
761 do { volatile unsigned long _junk; \
762 CALL_FN_W_WWW(_junk,fnptr,arg1,arg2,arg3); } while (0)
764 #define CALL_FN_v_WWWW(fnptr, arg1,arg2,arg3,arg4) \
765 do { volatile unsigned long _junk; \
766 CALL_FN_W_WWWW(_junk,fnptr,arg1,arg2,arg3,arg4); } while (0)
768 #define CALL_FN_v_5W(fnptr, arg1,arg2,arg3,arg4,arg5) \
769 do { volatile unsigned long _junk; \
770 CALL_FN_W_5W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5); } while (0)
772 #define CALL_FN_v_6W(fnptr, arg1,arg2,arg3,arg4,arg5,arg6) \
773 do { volatile unsigned long _junk; \
774 CALL_FN_W_6W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5,arg6); } while (0)
776 #define CALL_FN_v_7W(fnptr, arg1,arg2,arg3,arg4,arg5,arg6,arg7) \
777 do { volatile unsigned long _junk; \
778 CALL_FN_W_7W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5,arg6,arg7); } while (0)
780 /* ------------------------- x86-{linux,darwin} ---------------- */
782 #if defined(PLAT_x86_linux) || defined(PLAT_x86_darwin)
784 /* These regs are trashed by the hidden call. No need to mention eax
785 as gcc can already see that, plus causes gcc to bomb. */
786 #define __CALLER_SAVED_REGS /*"eax"*/ "ecx", "edx"
788 /* These CALL_FN_ macros assume that on x86-linux, sizeof(unsigned
791 #define CALL_FN_W_v(lval, orig) \
793 volatile OrigFn _orig = (orig); \
794 volatile unsigned long _argvec[1]; \
795 volatile unsigned long _res; \
796 _argvec[0] = (unsigned long)_orig.nraddr; \
798 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
799 VALGRIND_CALL_NOREDIR_EAX \
800 : /*out*/ "=a" (_res) \
801 : /*in*/ "a" (&_argvec[0]) \
802 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
804 lval = (__typeof__(lval)) _res; \
807 #define CALL_FN_W_W(lval, orig, arg1) \
809 volatile OrigFn _orig = (orig); \
810 volatile unsigned long _argvec[2]; \
811 volatile unsigned long _res; \
812 _argvec[0] = (unsigned long)_orig.nraddr; \
813 _argvec[1] = (unsigned long)(arg1); \
815 "subl $12, %%esp\n\t" \
816 "pushl 4(%%eax)\n\t" \
817 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
818 VALGRIND_CALL_NOREDIR_EAX \
819 "addl $16, %%esp\n" \
820 : /*out*/ "=a" (_res) \
821 : /*in*/ "a" (&_argvec[0]) \
822 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
824 lval = (__typeof__(lval)) _res; \
827 #define CALL_FN_W_WW(lval, orig, arg1,arg2) \
829 volatile OrigFn _orig = (orig); \
830 volatile unsigned long _argvec[3]; \
831 volatile unsigned long _res; \
832 _argvec[0] = (unsigned long)_orig.nraddr; \
833 _argvec[1] = (unsigned long)(arg1); \
834 _argvec[2] = (unsigned long)(arg2); \
836 "subl $8, %%esp\n\t" \
837 "pushl 8(%%eax)\n\t" \
838 "pushl 4(%%eax)\n\t" \
839 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
840 VALGRIND_CALL_NOREDIR_EAX \
841 "addl $16, %%esp\n" \
842 : /*out*/ "=a" (_res) \
843 : /*in*/ "a" (&_argvec[0]) \
844 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
846 lval = (__typeof__(lval)) _res; \
849 #define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \
851 volatile OrigFn _orig = (orig); \
852 volatile unsigned long _argvec[4]; \
853 volatile unsigned long _res; \
854 _argvec[0] = (unsigned long)_orig.nraddr; \
855 _argvec[1] = (unsigned long)(arg1); \
856 _argvec[2] = (unsigned long)(arg2); \
857 _argvec[3] = (unsigned long)(arg3); \
859 "subl $4, %%esp\n\t" \
860 "pushl 12(%%eax)\n\t" \
861 "pushl 8(%%eax)\n\t" \
862 "pushl 4(%%eax)\n\t" \
863 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
864 VALGRIND_CALL_NOREDIR_EAX \
865 "addl $16, %%esp\n" \
866 : /*out*/ "=a" (_res) \
867 : /*in*/ "a" (&_argvec[0]) \
868 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
870 lval = (__typeof__(lval)) _res; \
873 #define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
875 volatile OrigFn _orig = (orig); \
876 volatile unsigned long _argvec[5]; \
877 volatile unsigned long _res; \
878 _argvec[0] = (unsigned long)_orig.nraddr; \
879 _argvec[1] = (unsigned long)(arg1); \
880 _argvec[2] = (unsigned long)(arg2); \
881 _argvec[3] = (unsigned long)(arg3); \
882 _argvec[4] = (unsigned long)(arg4); \
884 "pushl 16(%%eax)\n\t" \
885 "pushl 12(%%eax)\n\t" \
886 "pushl 8(%%eax)\n\t" \
887 "pushl 4(%%eax)\n\t" \
888 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
889 VALGRIND_CALL_NOREDIR_EAX \
890 "addl $16, %%esp\n" \
891 : /*out*/ "=a" (_res) \
892 : /*in*/ "a" (&_argvec[0]) \
893 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
895 lval = (__typeof__(lval)) _res; \
898 #define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \
900 volatile OrigFn _orig = (orig); \
901 volatile unsigned long _argvec[6]; \
902 volatile unsigned long _res; \
903 _argvec[0] = (unsigned long)_orig.nraddr; \
904 _argvec[1] = (unsigned long)(arg1); \
905 _argvec[2] = (unsigned long)(arg2); \
906 _argvec[3] = (unsigned long)(arg3); \
907 _argvec[4] = (unsigned long)(arg4); \
908 _argvec[5] = (unsigned long)(arg5); \
910 "subl $12, %%esp\n\t" \
911 "pushl 20(%%eax)\n\t" \
912 "pushl 16(%%eax)\n\t" \
913 "pushl 12(%%eax)\n\t" \
914 "pushl 8(%%eax)\n\t" \
915 "pushl 4(%%eax)\n\t" \
916 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
917 VALGRIND_CALL_NOREDIR_EAX \
918 "addl $32, %%esp\n" \
919 : /*out*/ "=a" (_res) \
920 : /*in*/ "a" (&_argvec[0]) \
921 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
923 lval = (__typeof__(lval)) _res; \
926 #define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
928 volatile OrigFn _orig = (orig); \
929 volatile unsigned long _argvec[7]; \
930 volatile unsigned long _res; \
931 _argvec[0] = (unsigned long)_orig.nraddr; \
932 _argvec[1] = (unsigned long)(arg1); \
933 _argvec[2] = (unsigned long)(arg2); \
934 _argvec[3] = (unsigned long)(arg3); \
935 _argvec[4] = (unsigned long)(arg4); \
936 _argvec[5] = (unsigned long)(arg5); \
937 _argvec[6] = (unsigned long)(arg6); \
939 "subl $8, %%esp\n\t" \
940 "pushl 24(%%eax)\n\t" \
941 "pushl 20(%%eax)\n\t" \
942 "pushl 16(%%eax)\n\t" \
943 "pushl 12(%%eax)\n\t" \
944 "pushl 8(%%eax)\n\t" \
945 "pushl 4(%%eax)\n\t" \
946 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
947 VALGRIND_CALL_NOREDIR_EAX \
948 "addl $32, %%esp\n" \
949 : /*out*/ "=a" (_res) \
950 : /*in*/ "a" (&_argvec[0]) \
951 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
953 lval = (__typeof__(lval)) _res; \
956 #define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
959 volatile OrigFn _orig = (orig); \
960 volatile unsigned long _argvec[8]; \
961 volatile unsigned long _res; \
962 _argvec[0] = (unsigned long)_orig.nraddr; \
963 _argvec[1] = (unsigned long)(arg1); \
964 _argvec[2] = (unsigned long)(arg2); \
965 _argvec[3] = (unsigned long)(arg3); \
966 _argvec[4] = (unsigned long)(arg4); \
967 _argvec[5] = (unsigned long)(arg5); \
968 _argvec[6] = (unsigned long)(arg6); \
969 _argvec[7] = (unsigned long)(arg7); \
971 "subl $4, %%esp\n\t" \
972 "pushl 28(%%eax)\n\t" \
973 "pushl 24(%%eax)\n\t" \
974 "pushl 20(%%eax)\n\t" \
975 "pushl 16(%%eax)\n\t" \
976 "pushl 12(%%eax)\n\t" \
977 "pushl 8(%%eax)\n\t" \
978 "pushl 4(%%eax)\n\t" \
979 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
980 VALGRIND_CALL_NOREDIR_EAX \
981 "addl $32, %%esp\n" \
982 : /*out*/ "=a" (_res) \
983 : /*in*/ "a" (&_argvec[0]) \
984 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
986 lval = (__typeof__(lval)) _res; \
989 #define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
992 volatile OrigFn _orig = (orig); \
993 volatile unsigned long _argvec[9]; \
994 volatile unsigned long _res; \
995 _argvec[0] = (unsigned long)_orig.nraddr; \
996 _argvec[1] = (unsigned long)(arg1); \
997 _argvec[2] = (unsigned long)(arg2); \
998 _argvec[3] = (unsigned long)(arg3); \
999 _argvec[4] = (unsigned long)(arg4); \
1000 _argvec[5] = (unsigned long)(arg5); \
1001 _argvec[6] = (unsigned long)(arg6); \
1002 _argvec[7] = (unsigned long)(arg7); \
1003 _argvec[8] = (unsigned long)(arg8); \
1005 "pushl 32(%%eax)\n\t" \
1006 "pushl 28(%%eax)\n\t" \
1007 "pushl 24(%%eax)\n\t" \
1008 "pushl 20(%%eax)\n\t" \
1009 "pushl 16(%%eax)\n\t" \
1010 "pushl 12(%%eax)\n\t" \
1011 "pushl 8(%%eax)\n\t" \
1012 "pushl 4(%%eax)\n\t" \
1013 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
1014 VALGRIND_CALL_NOREDIR_EAX \
1015 "addl $32, %%esp\n" \
1016 : /*out*/ "=a" (_res) \
1017 : /*in*/ "a" (&_argvec[0]) \
1018 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1020 lval = (__typeof__(lval)) _res; \
1023 #define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1026 volatile OrigFn _orig = (orig); \
1027 volatile unsigned long _argvec[10]; \
1028 volatile unsigned long _res; \
1029 _argvec[0] = (unsigned long)_orig.nraddr; \
1030 _argvec[1] = (unsigned long)(arg1); \
1031 _argvec[2] = (unsigned long)(arg2); \
1032 _argvec[3] = (unsigned long)(arg3); \
1033 _argvec[4] = (unsigned long)(arg4); \
1034 _argvec[5] = (unsigned long)(arg5); \
1035 _argvec[6] = (unsigned long)(arg6); \
1036 _argvec[7] = (unsigned long)(arg7); \
1037 _argvec[8] = (unsigned long)(arg8); \
1038 _argvec[9] = (unsigned long)(arg9); \
1040 "subl $12, %%esp\n\t" \
1041 "pushl 36(%%eax)\n\t" \
1042 "pushl 32(%%eax)\n\t" \
1043 "pushl 28(%%eax)\n\t" \
1044 "pushl 24(%%eax)\n\t" \
1045 "pushl 20(%%eax)\n\t" \
1046 "pushl 16(%%eax)\n\t" \
1047 "pushl 12(%%eax)\n\t" \
1048 "pushl 8(%%eax)\n\t" \
1049 "pushl 4(%%eax)\n\t" \
1050 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
1051 VALGRIND_CALL_NOREDIR_EAX \
1052 "addl $48, %%esp\n" \
1053 : /*out*/ "=a" (_res) \
1054 : /*in*/ "a" (&_argvec[0]) \
1055 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1057 lval = (__typeof__(lval)) _res; \
1060 #define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1061 arg7,arg8,arg9,arg10) \
1063 volatile OrigFn _orig = (orig); \
1064 volatile unsigned long _argvec[11]; \
1065 volatile unsigned long _res; \
1066 _argvec[0] = (unsigned long)_orig.nraddr; \
1067 _argvec[1] = (unsigned long)(arg1); \
1068 _argvec[2] = (unsigned long)(arg2); \
1069 _argvec[3] = (unsigned long)(arg3); \
1070 _argvec[4] = (unsigned long)(arg4); \
1071 _argvec[5] = (unsigned long)(arg5); \
1072 _argvec[6] = (unsigned long)(arg6); \
1073 _argvec[7] = (unsigned long)(arg7); \
1074 _argvec[8] = (unsigned long)(arg8); \
1075 _argvec[9] = (unsigned long)(arg9); \
1076 _argvec[10] = (unsigned long)(arg10); \
1078 "subl $8, %%esp\n\t" \
1079 "pushl 40(%%eax)\n\t" \
1080 "pushl 36(%%eax)\n\t" \
1081 "pushl 32(%%eax)\n\t" \
1082 "pushl 28(%%eax)\n\t" \
1083 "pushl 24(%%eax)\n\t" \
1084 "pushl 20(%%eax)\n\t" \
1085 "pushl 16(%%eax)\n\t" \
1086 "pushl 12(%%eax)\n\t" \
1087 "pushl 8(%%eax)\n\t" \
1088 "pushl 4(%%eax)\n\t" \
1089 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
1090 VALGRIND_CALL_NOREDIR_EAX \
1091 "addl $48, %%esp\n" \
1092 : /*out*/ "=a" (_res) \
1093 : /*in*/ "a" (&_argvec[0]) \
1094 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1096 lval = (__typeof__(lval)) _res; \
1099 #define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5, \
1100 arg6,arg7,arg8,arg9,arg10, \
1103 volatile OrigFn _orig = (orig); \
1104 volatile unsigned long _argvec[12]; \
1105 volatile unsigned long _res; \
1106 _argvec[0] = (unsigned long)_orig.nraddr; \
1107 _argvec[1] = (unsigned long)(arg1); \
1108 _argvec[2] = (unsigned long)(arg2); \
1109 _argvec[3] = (unsigned long)(arg3); \
1110 _argvec[4] = (unsigned long)(arg4); \
1111 _argvec[5] = (unsigned long)(arg5); \
1112 _argvec[6] = (unsigned long)(arg6); \
1113 _argvec[7] = (unsigned long)(arg7); \
1114 _argvec[8] = (unsigned long)(arg8); \
1115 _argvec[9] = (unsigned long)(arg9); \
1116 _argvec[10] = (unsigned long)(arg10); \
1117 _argvec[11] = (unsigned long)(arg11); \
1119 "subl $4, %%esp\n\t" \
1120 "pushl 44(%%eax)\n\t" \
1121 "pushl 40(%%eax)\n\t" \
1122 "pushl 36(%%eax)\n\t" \
1123 "pushl 32(%%eax)\n\t" \
1124 "pushl 28(%%eax)\n\t" \
1125 "pushl 24(%%eax)\n\t" \
1126 "pushl 20(%%eax)\n\t" \
1127 "pushl 16(%%eax)\n\t" \
1128 "pushl 12(%%eax)\n\t" \
1129 "pushl 8(%%eax)\n\t" \
1130 "pushl 4(%%eax)\n\t" \
1131 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
1132 VALGRIND_CALL_NOREDIR_EAX \
1133 "addl $48, %%esp\n" \
1134 : /*out*/ "=a" (_res) \
1135 : /*in*/ "a" (&_argvec[0]) \
1136 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1138 lval = (__typeof__(lval)) _res; \
1141 #define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5, \
1142 arg6,arg7,arg8,arg9,arg10, \
1145 volatile OrigFn _orig = (orig); \
1146 volatile unsigned long _argvec[13]; \
1147 volatile unsigned long _res; \
1148 _argvec[0] = (unsigned long)_orig.nraddr; \
1149 _argvec[1] = (unsigned long)(arg1); \
1150 _argvec[2] = (unsigned long)(arg2); \
1151 _argvec[3] = (unsigned long)(arg3); \
1152 _argvec[4] = (unsigned long)(arg4); \
1153 _argvec[5] = (unsigned long)(arg5); \
1154 _argvec[6] = (unsigned long)(arg6); \
1155 _argvec[7] = (unsigned long)(arg7); \
1156 _argvec[8] = (unsigned long)(arg8); \
1157 _argvec[9] = (unsigned long)(arg9); \
1158 _argvec[10] = (unsigned long)(arg10); \
1159 _argvec[11] = (unsigned long)(arg11); \
1160 _argvec[12] = (unsigned long)(arg12); \
1162 "pushl 48(%%eax)\n\t" \
1163 "pushl 44(%%eax)\n\t" \
1164 "pushl 40(%%eax)\n\t" \
1165 "pushl 36(%%eax)\n\t" \
1166 "pushl 32(%%eax)\n\t" \
1167 "pushl 28(%%eax)\n\t" \
1168 "pushl 24(%%eax)\n\t" \
1169 "pushl 20(%%eax)\n\t" \
1170 "pushl 16(%%eax)\n\t" \
1171 "pushl 12(%%eax)\n\t" \
1172 "pushl 8(%%eax)\n\t" \
1173 "pushl 4(%%eax)\n\t" \
1174 "movl (%%eax), %%eax\n\t" /* target->%eax */ \
1175 VALGRIND_CALL_NOREDIR_EAX \
1176 "addl $48, %%esp\n" \
1177 : /*out*/ "=a" (_res) \
1178 : /*in*/ "a" (&_argvec[0]) \
1179 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1181 lval = (__typeof__(lval)) _res; \
1184 #endif /* PLAT_x86_linux || PLAT_x86_darwin */
1186 /* ------------------------ amd64-{linux,darwin} --------------- */
1188 #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin)
1190 /* ARGREGS: rdi rsi rdx rcx r8 r9 (the rest on stack in R-to-L order) */
1192 /* These regs are trashed by the hidden call. */
1193 #define __CALLER_SAVED_REGS /*"rax",*/ "rcx", "rdx", "rsi", \
1194 "rdi", "r8", "r9", "r10", "r11"
1196 /* This is all pretty complex. It's so as to make stack unwinding
1197 work reliably. See bug 243270. The basic problem is the sub and
1198 add of 128 of %rsp in all of the following macros. If gcc believes
1199 the CFA is in %rsp, then unwinding may fail, because what's at the
1200 CFA is not what gcc "expected" when it constructs the CFIs for the
1201 places where the macros are instantiated.
1203 But we can't just add a CFI annotation to increase the CFA offset
1204 by 128, to match the sub of 128 from %rsp, because we don't know
1205 whether gcc has chosen %rsp as the CFA at that point, or whether it
1206 has chosen some other register (eg, %rbp). In the latter case,
1207 adding a CFI annotation to change the CFA offset is simply wrong.
1209 So the solution is to get hold of the CFA using
1210 __builtin_dwarf_cfa(), put it in a known register, and add a
1211 CFI annotation to say what the register is. We choose %rbp for
1212 this (perhaps perversely), because:
1214 (1) %rbp is already subject to unwinding. If a new register was
1215 chosen then the unwinder would have to unwind it in all stack
1216 traces, which is expensive, and
1218 (2) %rbp is already subject to precise exception updates in the
1219 JIT. If a new register was chosen, we'd have to have precise
1220 exceptions for it too, which reduces performance of the
1223 However .. one extra complication. We can't just whack the result
1224 of __builtin_dwarf_cfa() into %rbp and then add %rbp to the
1225 list of trashed registers at the end of the inline assembly
1226 fragments; gcc won't allow %rbp to appear in that list. Hence
1227 instead we need to stash %rbp in %r15 for the duration of the asm,
1228 and say that %r15 is trashed instead. gcc seems happy to go with
1231 Oh .. and this all needs to be conditionalised so that it is
1232 unchanged from before this commit, when compiled with older gccs
1233 that don't support __builtin_dwarf_cfa. Furthermore, since
1234 this header file is freestanding, it has to be independent of
1235 config.h, and so the following conditionalisation cannot depend on
1236 configure time checks.
1238 Although it's not clear from
1239 'defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)',
1240 this expression excludes Darwin.
1241 .cfi directives in Darwin assembly appear to be completely
1242 different and I haven't investigated how they work.
1244 For even more entertainment value, note we have to use the
1245 completely undocumented __builtin_dwarf_cfa(), which appears to
1246 really compute the CFA, whereas __builtin_frame_address(0) claims
1247 to but actually doesn't. See
1248 https://bugs.kde.org/show_bug.cgi?id=243270#c47
1250 #if defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)
1251 # define __FRAME_POINTER \
1252 ,"r"(__builtin_dwarf_cfa())
1253 # define VALGRIND_CFI_PROLOGUE \
1254 "movq %%rbp, %%r15\n\t" \
1255 "movq %2, %%rbp\n\t" \
1256 ".cfi_remember_state\n\t" \
1257 ".cfi_def_cfa rbp, 0\n\t"
1258 # define VALGRIND_CFI_EPILOGUE \
1259 "movq %%r15, %%rbp\n\t" \
1260 ".cfi_restore_state\n\t"
1262 # define __FRAME_POINTER
1263 # define VALGRIND_CFI_PROLOGUE
1264 # define VALGRIND_CFI_EPILOGUE
1268 /* These CALL_FN_ macros assume that on amd64-linux, sizeof(unsigned
1271 /* NB 9 Sept 07. There is a nasty kludge here in all these CALL_FN_
1272 macros. In order not to trash the stack redzone, we need to drop
1273 %rsp by 128 before the hidden call, and restore afterwards. The
1274 nastyness is that it is only by luck that the stack still appears
1275 to be unwindable during the hidden call - since then the behaviour
1276 of any routine using this macro does not match what the CFI data
1279 Why is this important? Imagine that a wrapper has a stack
1280 allocated local, and passes to the hidden call, a pointer to it.
1281 Because gcc does not know about the hidden call, it may allocate
1282 that local in the redzone. Unfortunately the hidden call may then
1283 trash it before it comes to use it. So we must step clear of the
1284 redzone, for the duration of the hidden call, to make it safe.
1286 Probably the same problem afflicts the other redzone-style ABIs too
1287 (ppc64-linux, ppc32-aix5, ppc64-aix5); but for those, the stack is
1288 self describing (none of this CFI nonsense) so at least messing
1289 with the stack pointer doesn't give a danger of non-unwindable
1292 #define CALL_FN_W_v(lval, orig) \
1294 volatile OrigFn _orig = (orig); \
1295 volatile unsigned long _argvec[1]; \
1296 volatile unsigned long _res; \
1297 _argvec[0] = (unsigned long)_orig.nraddr; \
1299 VALGRIND_CFI_PROLOGUE \
1300 "subq $128,%%rsp\n\t" \
1301 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1302 VALGRIND_CALL_NOREDIR_RAX \
1303 "addq $128,%%rsp\n\t" \
1304 VALGRIND_CFI_EPILOGUE \
1305 : /*out*/ "=a" (_res) \
1306 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1307 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1309 lval = (__typeof__(lval)) _res; \
1312 #define CALL_FN_W_W(lval, orig, arg1) \
1314 volatile OrigFn _orig = (orig); \
1315 volatile unsigned long _argvec[2]; \
1316 volatile unsigned long _res; \
1317 _argvec[0] = (unsigned long)_orig.nraddr; \
1318 _argvec[1] = (unsigned long)(arg1); \
1320 VALGRIND_CFI_PROLOGUE \
1321 "subq $128,%%rsp\n\t" \
1322 "movq 8(%%rax), %%rdi\n\t" \
1323 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1324 VALGRIND_CALL_NOREDIR_RAX \
1325 "addq $128,%%rsp\n\t" \
1326 VALGRIND_CFI_EPILOGUE \
1327 : /*out*/ "=a" (_res) \
1328 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1329 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1331 lval = (__typeof__(lval)) _res; \
1334 #define CALL_FN_W_WW(lval, orig, arg1,arg2) \
1336 volatile OrigFn _orig = (orig); \
1337 volatile unsigned long _argvec[3]; \
1338 volatile unsigned long _res; \
1339 _argvec[0] = (unsigned long)_orig.nraddr; \
1340 _argvec[1] = (unsigned long)(arg1); \
1341 _argvec[2] = (unsigned long)(arg2); \
1343 VALGRIND_CFI_PROLOGUE \
1344 "subq $128,%%rsp\n\t" \
1345 "movq 16(%%rax), %%rsi\n\t" \
1346 "movq 8(%%rax), %%rdi\n\t" \
1347 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1348 VALGRIND_CALL_NOREDIR_RAX \
1349 "addq $128,%%rsp\n\t" \
1350 VALGRIND_CFI_EPILOGUE \
1351 : /*out*/ "=a" (_res) \
1352 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1353 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1355 lval = (__typeof__(lval)) _res; \
1358 #define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \
1360 volatile OrigFn _orig = (orig); \
1361 volatile unsigned long _argvec[4]; \
1362 volatile unsigned long _res; \
1363 _argvec[0] = (unsigned long)_orig.nraddr; \
1364 _argvec[1] = (unsigned long)(arg1); \
1365 _argvec[2] = (unsigned long)(arg2); \
1366 _argvec[3] = (unsigned long)(arg3); \
1368 VALGRIND_CFI_PROLOGUE \
1369 "subq $128,%%rsp\n\t" \
1370 "movq 24(%%rax), %%rdx\n\t" \
1371 "movq 16(%%rax), %%rsi\n\t" \
1372 "movq 8(%%rax), %%rdi\n\t" \
1373 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1374 VALGRIND_CALL_NOREDIR_RAX \
1375 "addq $128,%%rsp\n\t" \
1376 VALGRIND_CFI_EPILOGUE \
1377 : /*out*/ "=a" (_res) \
1378 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1379 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1381 lval = (__typeof__(lval)) _res; \
1384 #define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
1386 volatile OrigFn _orig = (orig); \
1387 volatile unsigned long _argvec[5]; \
1388 volatile unsigned long _res; \
1389 _argvec[0] = (unsigned long)_orig.nraddr; \
1390 _argvec[1] = (unsigned long)(arg1); \
1391 _argvec[2] = (unsigned long)(arg2); \
1392 _argvec[3] = (unsigned long)(arg3); \
1393 _argvec[4] = (unsigned long)(arg4); \
1395 VALGRIND_CFI_PROLOGUE \
1396 "subq $128,%%rsp\n\t" \
1397 "movq 32(%%rax), %%rcx\n\t" \
1398 "movq 24(%%rax), %%rdx\n\t" \
1399 "movq 16(%%rax), %%rsi\n\t" \
1400 "movq 8(%%rax), %%rdi\n\t" \
1401 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1402 VALGRIND_CALL_NOREDIR_RAX \
1403 "addq $128,%%rsp\n\t" \
1404 VALGRIND_CFI_EPILOGUE \
1405 : /*out*/ "=a" (_res) \
1406 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1407 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1409 lval = (__typeof__(lval)) _res; \
1412 #define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \
1414 volatile OrigFn _orig = (orig); \
1415 volatile unsigned long _argvec[6]; \
1416 volatile unsigned long _res; \
1417 _argvec[0] = (unsigned long)_orig.nraddr; \
1418 _argvec[1] = (unsigned long)(arg1); \
1419 _argvec[2] = (unsigned long)(arg2); \
1420 _argvec[3] = (unsigned long)(arg3); \
1421 _argvec[4] = (unsigned long)(arg4); \
1422 _argvec[5] = (unsigned long)(arg5); \
1424 VALGRIND_CFI_PROLOGUE \
1425 "subq $128,%%rsp\n\t" \
1426 "movq 40(%%rax), %%r8\n\t" \
1427 "movq 32(%%rax), %%rcx\n\t" \
1428 "movq 24(%%rax), %%rdx\n\t" \
1429 "movq 16(%%rax), %%rsi\n\t" \
1430 "movq 8(%%rax), %%rdi\n\t" \
1431 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1432 VALGRIND_CALL_NOREDIR_RAX \
1433 "addq $128,%%rsp\n\t" \
1434 VALGRIND_CFI_EPILOGUE \
1435 : /*out*/ "=a" (_res) \
1436 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1437 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1439 lval = (__typeof__(lval)) _res; \
1442 #define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
1444 volatile OrigFn _orig = (orig); \
1445 volatile unsigned long _argvec[7]; \
1446 volatile unsigned long _res; \
1447 _argvec[0] = (unsigned long)_orig.nraddr; \
1448 _argvec[1] = (unsigned long)(arg1); \
1449 _argvec[2] = (unsigned long)(arg2); \
1450 _argvec[3] = (unsigned long)(arg3); \
1451 _argvec[4] = (unsigned long)(arg4); \
1452 _argvec[5] = (unsigned long)(arg5); \
1453 _argvec[6] = (unsigned long)(arg6); \
1455 VALGRIND_CFI_PROLOGUE \
1456 "subq $128,%%rsp\n\t" \
1457 "movq 48(%%rax), %%r9\n\t" \
1458 "movq 40(%%rax), %%r8\n\t" \
1459 "movq 32(%%rax), %%rcx\n\t" \
1460 "movq 24(%%rax), %%rdx\n\t" \
1461 "movq 16(%%rax), %%rsi\n\t" \
1462 "movq 8(%%rax), %%rdi\n\t" \
1463 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1464 VALGRIND_CALL_NOREDIR_RAX \
1465 "addq $128,%%rsp\n\t" \
1466 VALGRIND_CFI_EPILOGUE \
1467 : /*out*/ "=a" (_res) \
1468 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1469 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1471 lval = (__typeof__(lval)) _res; \
1474 #define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1477 volatile OrigFn _orig = (orig); \
1478 volatile unsigned long _argvec[8]; \
1479 volatile unsigned long _res; \
1480 _argvec[0] = (unsigned long)_orig.nraddr; \
1481 _argvec[1] = (unsigned long)(arg1); \
1482 _argvec[2] = (unsigned long)(arg2); \
1483 _argvec[3] = (unsigned long)(arg3); \
1484 _argvec[4] = (unsigned long)(arg4); \
1485 _argvec[5] = (unsigned long)(arg5); \
1486 _argvec[6] = (unsigned long)(arg6); \
1487 _argvec[7] = (unsigned long)(arg7); \
1489 VALGRIND_CFI_PROLOGUE \
1490 "subq $136,%%rsp\n\t" \
1491 "pushq 56(%%rax)\n\t" \
1492 "movq 48(%%rax), %%r9\n\t" \
1493 "movq 40(%%rax), %%r8\n\t" \
1494 "movq 32(%%rax), %%rcx\n\t" \
1495 "movq 24(%%rax), %%rdx\n\t" \
1496 "movq 16(%%rax), %%rsi\n\t" \
1497 "movq 8(%%rax), %%rdi\n\t" \
1498 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1499 VALGRIND_CALL_NOREDIR_RAX \
1500 "addq $8, %%rsp\n" \
1501 "addq $136,%%rsp\n\t" \
1502 VALGRIND_CFI_EPILOGUE \
1503 : /*out*/ "=a" (_res) \
1504 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1505 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1507 lval = (__typeof__(lval)) _res; \
1510 #define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1513 volatile OrigFn _orig = (orig); \
1514 volatile unsigned long _argvec[9]; \
1515 volatile unsigned long _res; \
1516 _argvec[0] = (unsigned long)_orig.nraddr; \
1517 _argvec[1] = (unsigned long)(arg1); \
1518 _argvec[2] = (unsigned long)(arg2); \
1519 _argvec[3] = (unsigned long)(arg3); \
1520 _argvec[4] = (unsigned long)(arg4); \
1521 _argvec[5] = (unsigned long)(arg5); \
1522 _argvec[6] = (unsigned long)(arg6); \
1523 _argvec[7] = (unsigned long)(arg7); \
1524 _argvec[8] = (unsigned long)(arg8); \
1526 VALGRIND_CFI_PROLOGUE \
1527 "subq $128,%%rsp\n\t" \
1528 "pushq 64(%%rax)\n\t" \
1529 "pushq 56(%%rax)\n\t" \
1530 "movq 48(%%rax), %%r9\n\t" \
1531 "movq 40(%%rax), %%r8\n\t" \
1532 "movq 32(%%rax), %%rcx\n\t" \
1533 "movq 24(%%rax), %%rdx\n\t" \
1534 "movq 16(%%rax), %%rsi\n\t" \
1535 "movq 8(%%rax), %%rdi\n\t" \
1536 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1537 VALGRIND_CALL_NOREDIR_RAX \
1538 "addq $16, %%rsp\n" \
1539 "addq $128,%%rsp\n\t" \
1540 VALGRIND_CFI_EPILOGUE \
1541 : /*out*/ "=a" (_res) \
1542 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1543 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1545 lval = (__typeof__(lval)) _res; \
1548 #define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1551 volatile OrigFn _orig = (orig); \
1552 volatile unsigned long _argvec[10]; \
1553 volatile unsigned long _res; \
1554 _argvec[0] = (unsigned long)_orig.nraddr; \
1555 _argvec[1] = (unsigned long)(arg1); \
1556 _argvec[2] = (unsigned long)(arg2); \
1557 _argvec[3] = (unsigned long)(arg3); \
1558 _argvec[4] = (unsigned long)(arg4); \
1559 _argvec[5] = (unsigned long)(arg5); \
1560 _argvec[6] = (unsigned long)(arg6); \
1561 _argvec[7] = (unsigned long)(arg7); \
1562 _argvec[8] = (unsigned long)(arg8); \
1563 _argvec[9] = (unsigned long)(arg9); \
1565 VALGRIND_CFI_PROLOGUE \
1566 "subq $136,%%rsp\n\t" \
1567 "pushq 72(%%rax)\n\t" \
1568 "pushq 64(%%rax)\n\t" \
1569 "pushq 56(%%rax)\n\t" \
1570 "movq 48(%%rax), %%r9\n\t" \
1571 "movq 40(%%rax), %%r8\n\t" \
1572 "movq 32(%%rax), %%rcx\n\t" \
1573 "movq 24(%%rax), %%rdx\n\t" \
1574 "movq 16(%%rax), %%rsi\n\t" \
1575 "movq 8(%%rax), %%rdi\n\t" \
1576 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1577 VALGRIND_CALL_NOREDIR_RAX \
1578 "addq $24, %%rsp\n" \
1579 "addq $136,%%rsp\n\t" \
1580 VALGRIND_CFI_EPILOGUE \
1581 : /*out*/ "=a" (_res) \
1582 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1583 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1585 lval = (__typeof__(lval)) _res; \
1588 #define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1589 arg7,arg8,arg9,arg10) \
1591 volatile OrigFn _orig = (orig); \
1592 volatile unsigned long _argvec[11]; \
1593 volatile unsigned long _res; \
1594 _argvec[0] = (unsigned long)_orig.nraddr; \
1595 _argvec[1] = (unsigned long)(arg1); \
1596 _argvec[2] = (unsigned long)(arg2); \
1597 _argvec[3] = (unsigned long)(arg3); \
1598 _argvec[4] = (unsigned long)(arg4); \
1599 _argvec[5] = (unsigned long)(arg5); \
1600 _argvec[6] = (unsigned long)(arg6); \
1601 _argvec[7] = (unsigned long)(arg7); \
1602 _argvec[8] = (unsigned long)(arg8); \
1603 _argvec[9] = (unsigned long)(arg9); \
1604 _argvec[10] = (unsigned long)(arg10); \
1606 VALGRIND_CFI_PROLOGUE \
1607 "subq $128,%%rsp\n\t" \
1608 "pushq 80(%%rax)\n\t" \
1609 "pushq 72(%%rax)\n\t" \
1610 "pushq 64(%%rax)\n\t" \
1611 "pushq 56(%%rax)\n\t" \
1612 "movq 48(%%rax), %%r9\n\t" \
1613 "movq 40(%%rax), %%r8\n\t" \
1614 "movq 32(%%rax), %%rcx\n\t" \
1615 "movq 24(%%rax), %%rdx\n\t" \
1616 "movq 16(%%rax), %%rsi\n\t" \
1617 "movq 8(%%rax), %%rdi\n\t" \
1618 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1619 VALGRIND_CALL_NOREDIR_RAX \
1620 "addq $32, %%rsp\n" \
1621 "addq $128,%%rsp\n\t" \
1622 VALGRIND_CFI_EPILOGUE \
1623 : /*out*/ "=a" (_res) \
1624 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1625 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1627 lval = (__typeof__(lval)) _res; \
1630 #define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1631 arg7,arg8,arg9,arg10,arg11) \
1633 volatile OrigFn _orig = (orig); \
1634 volatile unsigned long _argvec[12]; \
1635 volatile unsigned long _res; \
1636 _argvec[0] = (unsigned long)_orig.nraddr; \
1637 _argvec[1] = (unsigned long)(arg1); \
1638 _argvec[2] = (unsigned long)(arg2); \
1639 _argvec[3] = (unsigned long)(arg3); \
1640 _argvec[4] = (unsigned long)(arg4); \
1641 _argvec[5] = (unsigned long)(arg5); \
1642 _argvec[6] = (unsigned long)(arg6); \
1643 _argvec[7] = (unsigned long)(arg7); \
1644 _argvec[8] = (unsigned long)(arg8); \
1645 _argvec[9] = (unsigned long)(arg9); \
1646 _argvec[10] = (unsigned long)(arg10); \
1647 _argvec[11] = (unsigned long)(arg11); \
1649 VALGRIND_CFI_PROLOGUE \
1650 "subq $136,%%rsp\n\t" \
1651 "pushq 88(%%rax)\n\t" \
1652 "pushq 80(%%rax)\n\t" \
1653 "pushq 72(%%rax)\n\t" \
1654 "pushq 64(%%rax)\n\t" \
1655 "pushq 56(%%rax)\n\t" \
1656 "movq 48(%%rax), %%r9\n\t" \
1657 "movq 40(%%rax), %%r8\n\t" \
1658 "movq 32(%%rax), %%rcx\n\t" \
1659 "movq 24(%%rax), %%rdx\n\t" \
1660 "movq 16(%%rax), %%rsi\n\t" \
1661 "movq 8(%%rax), %%rdi\n\t" \
1662 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1663 VALGRIND_CALL_NOREDIR_RAX \
1664 "addq $40, %%rsp\n" \
1665 "addq $136,%%rsp\n\t" \
1666 VALGRIND_CFI_EPILOGUE \
1667 : /*out*/ "=a" (_res) \
1668 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1669 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1671 lval = (__typeof__(lval)) _res; \
1674 #define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1675 arg7,arg8,arg9,arg10,arg11,arg12) \
1677 volatile OrigFn _orig = (orig); \
1678 volatile unsigned long _argvec[13]; \
1679 volatile unsigned long _res; \
1680 _argvec[0] = (unsigned long)_orig.nraddr; \
1681 _argvec[1] = (unsigned long)(arg1); \
1682 _argvec[2] = (unsigned long)(arg2); \
1683 _argvec[3] = (unsigned long)(arg3); \
1684 _argvec[4] = (unsigned long)(arg4); \
1685 _argvec[5] = (unsigned long)(arg5); \
1686 _argvec[6] = (unsigned long)(arg6); \
1687 _argvec[7] = (unsigned long)(arg7); \
1688 _argvec[8] = (unsigned long)(arg8); \
1689 _argvec[9] = (unsigned long)(arg9); \
1690 _argvec[10] = (unsigned long)(arg10); \
1691 _argvec[11] = (unsigned long)(arg11); \
1692 _argvec[12] = (unsigned long)(arg12); \
1694 VALGRIND_CFI_PROLOGUE \
1695 "subq $128,%%rsp\n\t" \
1696 "pushq 96(%%rax)\n\t" \
1697 "pushq 88(%%rax)\n\t" \
1698 "pushq 80(%%rax)\n\t" \
1699 "pushq 72(%%rax)\n\t" \
1700 "pushq 64(%%rax)\n\t" \
1701 "pushq 56(%%rax)\n\t" \
1702 "movq 48(%%rax), %%r9\n\t" \
1703 "movq 40(%%rax), %%r8\n\t" \
1704 "movq 32(%%rax), %%rcx\n\t" \
1705 "movq 24(%%rax), %%rdx\n\t" \
1706 "movq 16(%%rax), %%rsi\n\t" \
1707 "movq 8(%%rax), %%rdi\n\t" \
1708 "movq (%%rax), %%rax\n\t" /* target->%rax */ \
1709 VALGRIND_CALL_NOREDIR_RAX \
1710 "addq $48, %%rsp\n" \
1711 "addq $128,%%rsp\n\t" \
1712 VALGRIND_CFI_EPILOGUE \
1713 : /*out*/ "=a" (_res) \
1714 : /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
1715 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r15" \
1717 lval = (__typeof__(lval)) _res; \
1720 #endif /* PLAT_amd64_linux || PLAT_amd64_darwin */
1722 /* ------------------------ ppc32-linux ------------------------ */
1724 #if defined(PLAT_ppc32_linux)
1726 /* This is useful for finding out about the on-stack stuff:
1728 extern int f9 ( int,int,int,int,int,int,int,int,int );
1729 extern int f10 ( int,int,int,int,int,int,int,int,int,int );
1730 extern int f11 ( int,int,int,int,int,int,int,int,int,int,int );
1731 extern int f12 ( int,int,int,int,int,int,int,int,int,int,int,int );
1734 return f9(11,22,33,44,55,66,77,88,99);
1737 return f10(11,22,33,44,55,66,77,88,99,110);
1740 return f11(11,22,33,44,55,66,77,88,99,110,121);
1743 return f12(11,22,33,44,55,66,77,88,99,110,121,132);
1747 /* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
1749 /* These regs are trashed by the hidden call. */
1750 #define __CALLER_SAVED_REGS \
1751 "lr", "ctr", "xer", \
1752 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \
1753 "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \
1756 /* These CALL_FN_ macros assume that on ppc32-linux,
1757 sizeof(unsigned long) == 4. */
1759 #define CALL_FN_W_v(lval, orig) \
1761 volatile OrigFn _orig = (orig); \
1762 volatile unsigned long _argvec[1]; \
1763 volatile unsigned long _res; \
1764 _argvec[0] = (unsigned long)_orig.nraddr; \
1767 "lwz 11,0(11)\n\t" /* target->r11 */ \
1768 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1770 : /*out*/ "=r" (_res) \
1771 : /*in*/ "r" (&_argvec[0]) \
1772 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1774 lval = (__typeof__(lval)) _res; \
1777 #define CALL_FN_W_W(lval, orig, arg1) \
1779 volatile OrigFn _orig = (orig); \
1780 volatile unsigned long _argvec[2]; \
1781 volatile unsigned long _res; \
1782 _argvec[0] = (unsigned long)_orig.nraddr; \
1783 _argvec[1] = (unsigned long)arg1; \
1786 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
1787 "lwz 11,0(11)\n\t" /* target->r11 */ \
1788 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1790 : /*out*/ "=r" (_res) \
1791 : /*in*/ "r" (&_argvec[0]) \
1792 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1794 lval = (__typeof__(lval)) _res; \
1797 #define CALL_FN_W_WW(lval, orig, arg1,arg2) \
1799 volatile OrigFn _orig = (orig); \
1800 volatile unsigned long _argvec[3]; \
1801 volatile unsigned long _res; \
1802 _argvec[0] = (unsigned long)_orig.nraddr; \
1803 _argvec[1] = (unsigned long)arg1; \
1804 _argvec[2] = (unsigned long)arg2; \
1807 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
1809 "lwz 11,0(11)\n\t" /* target->r11 */ \
1810 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1812 : /*out*/ "=r" (_res) \
1813 : /*in*/ "r" (&_argvec[0]) \
1814 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1816 lval = (__typeof__(lval)) _res; \
1819 #define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \
1821 volatile OrigFn _orig = (orig); \
1822 volatile unsigned long _argvec[4]; \
1823 volatile unsigned long _res; \
1824 _argvec[0] = (unsigned long)_orig.nraddr; \
1825 _argvec[1] = (unsigned long)arg1; \
1826 _argvec[2] = (unsigned long)arg2; \
1827 _argvec[3] = (unsigned long)arg3; \
1830 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
1832 "lwz 5,12(11)\n\t" \
1833 "lwz 11,0(11)\n\t" /* target->r11 */ \
1834 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1836 : /*out*/ "=r" (_res) \
1837 : /*in*/ "r" (&_argvec[0]) \
1838 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1840 lval = (__typeof__(lval)) _res; \
1843 #define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
1845 volatile OrigFn _orig = (orig); \
1846 volatile unsigned long _argvec[5]; \
1847 volatile unsigned long _res; \
1848 _argvec[0] = (unsigned long)_orig.nraddr; \
1849 _argvec[1] = (unsigned long)arg1; \
1850 _argvec[2] = (unsigned long)arg2; \
1851 _argvec[3] = (unsigned long)arg3; \
1852 _argvec[4] = (unsigned long)arg4; \
1855 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
1857 "lwz 5,12(11)\n\t" \
1858 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
1859 "lwz 11,0(11)\n\t" /* target->r11 */ \
1860 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1862 : /*out*/ "=r" (_res) \
1863 : /*in*/ "r" (&_argvec[0]) \
1864 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1866 lval = (__typeof__(lval)) _res; \
1869 #define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \
1871 volatile OrigFn _orig = (orig); \
1872 volatile unsigned long _argvec[6]; \
1873 volatile unsigned long _res; \
1874 _argvec[0] = (unsigned long)_orig.nraddr; \
1875 _argvec[1] = (unsigned long)arg1; \
1876 _argvec[2] = (unsigned long)arg2; \
1877 _argvec[3] = (unsigned long)arg3; \
1878 _argvec[4] = (unsigned long)arg4; \
1879 _argvec[5] = (unsigned long)arg5; \
1882 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
1884 "lwz 5,12(11)\n\t" \
1885 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
1886 "lwz 7,20(11)\n\t" \
1887 "lwz 11,0(11)\n\t" /* target->r11 */ \
1888 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1890 : /*out*/ "=r" (_res) \
1891 : /*in*/ "r" (&_argvec[0]) \
1892 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1894 lval = (__typeof__(lval)) _res; \
1897 #define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
1899 volatile OrigFn _orig = (orig); \
1900 volatile unsigned long _argvec[7]; \
1901 volatile unsigned long _res; \
1902 _argvec[0] = (unsigned long)_orig.nraddr; \
1903 _argvec[1] = (unsigned long)arg1; \
1904 _argvec[2] = (unsigned long)arg2; \
1905 _argvec[3] = (unsigned long)arg3; \
1906 _argvec[4] = (unsigned long)arg4; \
1907 _argvec[5] = (unsigned long)arg5; \
1908 _argvec[6] = (unsigned long)arg6; \
1911 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
1913 "lwz 5,12(11)\n\t" \
1914 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
1915 "lwz 7,20(11)\n\t" \
1916 "lwz 8,24(11)\n\t" \
1917 "lwz 11,0(11)\n\t" /* target->r11 */ \
1918 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1920 : /*out*/ "=r" (_res) \
1921 : /*in*/ "r" (&_argvec[0]) \
1922 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1924 lval = (__typeof__(lval)) _res; \
1927 #define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1930 volatile OrigFn _orig = (orig); \
1931 volatile unsigned long _argvec[8]; \
1932 volatile unsigned long _res; \
1933 _argvec[0] = (unsigned long)_orig.nraddr; \
1934 _argvec[1] = (unsigned long)arg1; \
1935 _argvec[2] = (unsigned long)arg2; \
1936 _argvec[3] = (unsigned long)arg3; \
1937 _argvec[4] = (unsigned long)arg4; \
1938 _argvec[5] = (unsigned long)arg5; \
1939 _argvec[6] = (unsigned long)arg6; \
1940 _argvec[7] = (unsigned long)arg7; \
1943 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
1945 "lwz 5,12(11)\n\t" \
1946 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
1947 "lwz 7,20(11)\n\t" \
1948 "lwz 8,24(11)\n\t" \
1949 "lwz 9,28(11)\n\t" \
1950 "lwz 11,0(11)\n\t" /* target->r11 */ \
1951 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1953 : /*out*/ "=r" (_res) \
1954 : /*in*/ "r" (&_argvec[0]) \
1955 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1957 lval = (__typeof__(lval)) _res; \
1960 #define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1963 volatile OrigFn _orig = (orig); \
1964 volatile unsigned long _argvec[9]; \
1965 volatile unsigned long _res; \
1966 _argvec[0] = (unsigned long)_orig.nraddr; \
1967 _argvec[1] = (unsigned long)arg1; \
1968 _argvec[2] = (unsigned long)arg2; \
1969 _argvec[3] = (unsigned long)arg3; \
1970 _argvec[4] = (unsigned long)arg4; \
1971 _argvec[5] = (unsigned long)arg5; \
1972 _argvec[6] = (unsigned long)arg6; \
1973 _argvec[7] = (unsigned long)arg7; \
1974 _argvec[8] = (unsigned long)arg8; \
1977 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
1979 "lwz 5,12(11)\n\t" \
1980 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
1981 "lwz 7,20(11)\n\t" \
1982 "lwz 8,24(11)\n\t" \
1983 "lwz 9,28(11)\n\t" \
1984 "lwz 10,32(11)\n\t" /* arg8->r10 */ \
1985 "lwz 11,0(11)\n\t" /* target->r11 */ \
1986 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
1988 : /*out*/ "=r" (_res) \
1989 : /*in*/ "r" (&_argvec[0]) \
1990 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
1992 lval = (__typeof__(lval)) _res; \
1995 #define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
1998 volatile OrigFn _orig = (orig); \
1999 volatile unsigned long _argvec[10]; \
2000 volatile unsigned long _res; \
2001 _argvec[0] = (unsigned long)_orig.nraddr; \
2002 _argvec[1] = (unsigned long)arg1; \
2003 _argvec[2] = (unsigned long)arg2; \
2004 _argvec[3] = (unsigned long)arg3; \
2005 _argvec[4] = (unsigned long)arg4; \
2006 _argvec[5] = (unsigned long)arg5; \
2007 _argvec[6] = (unsigned long)arg6; \
2008 _argvec[7] = (unsigned long)arg7; \
2009 _argvec[8] = (unsigned long)arg8; \
2010 _argvec[9] = (unsigned long)arg9; \
2013 "addi 1,1,-16\n\t" \
2015 "lwz 3,36(11)\n\t" \
2018 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
2020 "lwz 5,12(11)\n\t" \
2021 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
2022 "lwz 7,20(11)\n\t" \
2023 "lwz 8,24(11)\n\t" \
2024 "lwz 9,28(11)\n\t" \
2025 "lwz 10,32(11)\n\t" /* arg8->r10 */ \
2026 "lwz 11,0(11)\n\t" /* target->r11 */ \
2027 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2030 : /*out*/ "=r" (_res) \
2031 : /*in*/ "r" (&_argvec[0]) \
2032 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2034 lval = (__typeof__(lval)) _res; \
2037 #define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2038 arg7,arg8,arg9,arg10) \
2040 volatile OrigFn _orig = (orig); \
2041 volatile unsigned long _argvec[11]; \
2042 volatile unsigned long _res; \
2043 _argvec[0] = (unsigned long)_orig.nraddr; \
2044 _argvec[1] = (unsigned long)arg1; \
2045 _argvec[2] = (unsigned long)arg2; \
2046 _argvec[3] = (unsigned long)arg3; \
2047 _argvec[4] = (unsigned long)arg4; \
2048 _argvec[5] = (unsigned long)arg5; \
2049 _argvec[6] = (unsigned long)arg6; \
2050 _argvec[7] = (unsigned long)arg7; \
2051 _argvec[8] = (unsigned long)arg8; \
2052 _argvec[9] = (unsigned long)arg9; \
2053 _argvec[10] = (unsigned long)arg10; \
2056 "addi 1,1,-16\n\t" \
2058 "lwz 3,40(11)\n\t" \
2061 "lwz 3,36(11)\n\t" \
2064 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
2066 "lwz 5,12(11)\n\t" \
2067 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
2068 "lwz 7,20(11)\n\t" \
2069 "lwz 8,24(11)\n\t" \
2070 "lwz 9,28(11)\n\t" \
2071 "lwz 10,32(11)\n\t" /* arg8->r10 */ \
2072 "lwz 11,0(11)\n\t" /* target->r11 */ \
2073 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2076 : /*out*/ "=r" (_res) \
2077 : /*in*/ "r" (&_argvec[0]) \
2078 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2080 lval = (__typeof__(lval)) _res; \
2083 #define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2084 arg7,arg8,arg9,arg10,arg11) \
2086 volatile OrigFn _orig = (orig); \
2087 volatile unsigned long _argvec[12]; \
2088 volatile unsigned long _res; \
2089 _argvec[0] = (unsigned long)_orig.nraddr; \
2090 _argvec[1] = (unsigned long)arg1; \
2091 _argvec[2] = (unsigned long)arg2; \
2092 _argvec[3] = (unsigned long)arg3; \
2093 _argvec[4] = (unsigned long)arg4; \
2094 _argvec[5] = (unsigned long)arg5; \
2095 _argvec[6] = (unsigned long)arg6; \
2096 _argvec[7] = (unsigned long)arg7; \
2097 _argvec[8] = (unsigned long)arg8; \
2098 _argvec[9] = (unsigned long)arg9; \
2099 _argvec[10] = (unsigned long)arg10; \
2100 _argvec[11] = (unsigned long)arg11; \
2103 "addi 1,1,-32\n\t" \
2105 "lwz 3,44(11)\n\t" \
2108 "lwz 3,40(11)\n\t" \
2111 "lwz 3,36(11)\n\t" \
2114 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
2116 "lwz 5,12(11)\n\t" \
2117 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
2118 "lwz 7,20(11)\n\t" \
2119 "lwz 8,24(11)\n\t" \
2120 "lwz 9,28(11)\n\t" \
2121 "lwz 10,32(11)\n\t" /* arg8->r10 */ \
2122 "lwz 11,0(11)\n\t" /* target->r11 */ \
2123 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2126 : /*out*/ "=r" (_res) \
2127 : /*in*/ "r" (&_argvec[0]) \
2128 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2130 lval = (__typeof__(lval)) _res; \
2133 #define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2134 arg7,arg8,arg9,arg10,arg11,arg12) \
2136 volatile OrigFn _orig = (orig); \
2137 volatile unsigned long _argvec[13]; \
2138 volatile unsigned long _res; \
2139 _argvec[0] = (unsigned long)_orig.nraddr; \
2140 _argvec[1] = (unsigned long)arg1; \
2141 _argvec[2] = (unsigned long)arg2; \
2142 _argvec[3] = (unsigned long)arg3; \
2143 _argvec[4] = (unsigned long)arg4; \
2144 _argvec[5] = (unsigned long)arg5; \
2145 _argvec[6] = (unsigned long)arg6; \
2146 _argvec[7] = (unsigned long)arg7; \
2147 _argvec[8] = (unsigned long)arg8; \
2148 _argvec[9] = (unsigned long)arg9; \
2149 _argvec[10] = (unsigned long)arg10; \
2150 _argvec[11] = (unsigned long)arg11; \
2151 _argvec[12] = (unsigned long)arg12; \
2154 "addi 1,1,-32\n\t" \
2156 "lwz 3,48(11)\n\t" \
2159 "lwz 3,44(11)\n\t" \
2162 "lwz 3,40(11)\n\t" \
2165 "lwz 3,36(11)\n\t" \
2168 "lwz 3,4(11)\n\t" /* arg1->r3 */ \
2170 "lwz 5,12(11)\n\t" \
2171 "lwz 6,16(11)\n\t" /* arg4->r6 */ \
2172 "lwz 7,20(11)\n\t" \
2173 "lwz 8,24(11)\n\t" \
2174 "lwz 9,28(11)\n\t" \
2175 "lwz 10,32(11)\n\t" /* arg8->r10 */ \
2176 "lwz 11,0(11)\n\t" /* target->r11 */ \
2177 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2180 : /*out*/ "=r" (_res) \
2181 : /*in*/ "r" (&_argvec[0]) \
2182 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2184 lval = (__typeof__(lval)) _res; \
2187 #endif /* PLAT_ppc32_linux */
2189 /* ------------------------ ppc64-linux ------------------------ */
2191 #if defined(PLAT_ppc64_linux)
2193 /* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
2195 /* These regs are trashed by the hidden call. */
2196 #define __CALLER_SAVED_REGS \
2197 "lr", "ctr", "xer", \
2198 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \
2199 "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \
2202 /* These CALL_FN_ macros assume that on ppc64-linux, sizeof(unsigned
2205 #define CALL_FN_W_v(lval, orig) \
2207 volatile OrigFn _orig = (orig); \
2208 volatile unsigned long _argvec[3+0]; \
2209 volatile unsigned long _res; \
2210 /* _argvec[0] holds current r2 across the call */ \
2211 _argvec[1] = (unsigned long)_orig.r2; \
2212 _argvec[2] = (unsigned long)_orig.nraddr; \
2215 "std 2,-16(11)\n\t" /* save tocptr */ \
2216 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2217 "ld 11, 0(11)\n\t" /* target->r11 */ \
2218 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2221 "ld 2,-16(11)" /* restore tocptr */ \
2222 : /*out*/ "=r" (_res) \
2223 : /*in*/ "r" (&_argvec[2]) \
2224 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2226 lval = (__typeof__(lval)) _res; \
2229 #define CALL_FN_W_W(lval, orig, arg1) \
2231 volatile OrigFn _orig = (orig); \
2232 volatile unsigned long _argvec[3+1]; \
2233 volatile unsigned long _res; \
2234 /* _argvec[0] holds current r2 across the call */ \
2235 _argvec[1] = (unsigned long)_orig.r2; \
2236 _argvec[2] = (unsigned long)_orig.nraddr; \
2237 _argvec[2+1] = (unsigned long)arg1; \
2240 "std 2,-16(11)\n\t" /* save tocptr */ \
2241 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2242 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2243 "ld 11, 0(11)\n\t" /* target->r11 */ \
2244 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2247 "ld 2,-16(11)" /* restore tocptr */ \
2248 : /*out*/ "=r" (_res) \
2249 : /*in*/ "r" (&_argvec[2]) \
2250 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2252 lval = (__typeof__(lval)) _res; \
2255 #define CALL_FN_W_WW(lval, orig, arg1,arg2) \
2257 volatile OrigFn _orig = (orig); \
2258 volatile unsigned long _argvec[3+2]; \
2259 volatile unsigned long _res; \
2260 /* _argvec[0] holds current r2 across the call */ \
2261 _argvec[1] = (unsigned long)_orig.r2; \
2262 _argvec[2] = (unsigned long)_orig.nraddr; \
2263 _argvec[2+1] = (unsigned long)arg1; \
2264 _argvec[2+2] = (unsigned long)arg2; \
2267 "std 2,-16(11)\n\t" /* save tocptr */ \
2268 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2269 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2270 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2271 "ld 11, 0(11)\n\t" /* target->r11 */ \
2272 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2275 "ld 2,-16(11)" /* restore tocptr */ \
2276 : /*out*/ "=r" (_res) \
2277 : /*in*/ "r" (&_argvec[2]) \
2278 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2280 lval = (__typeof__(lval)) _res; \
2283 #define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \
2285 volatile OrigFn _orig = (orig); \
2286 volatile unsigned long _argvec[3+3]; \
2287 volatile unsigned long _res; \
2288 /* _argvec[0] holds current r2 across the call */ \
2289 _argvec[1] = (unsigned long)_orig.r2; \
2290 _argvec[2] = (unsigned long)_orig.nraddr; \
2291 _argvec[2+1] = (unsigned long)arg1; \
2292 _argvec[2+2] = (unsigned long)arg2; \
2293 _argvec[2+3] = (unsigned long)arg3; \
2296 "std 2,-16(11)\n\t" /* save tocptr */ \
2297 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2298 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2299 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2300 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2301 "ld 11, 0(11)\n\t" /* target->r11 */ \
2302 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2305 "ld 2,-16(11)" /* restore tocptr */ \
2306 : /*out*/ "=r" (_res) \
2307 : /*in*/ "r" (&_argvec[2]) \
2308 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2310 lval = (__typeof__(lval)) _res; \
2313 #define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
2315 volatile OrigFn _orig = (orig); \
2316 volatile unsigned long _argvec[3+4]; \
2317 volatile unsigned long _res; \
2318 /* _argvec[0] holds current r2 across the call */ \
2319 _argvec[1] = (unsigned long)_orig.r2; \
2320 _argvec[2] = (unsigned long)_orig.nraddr; \
2321 _argvec[2+1] = (unsigned long)arg1; \
2322 _argvec[2+2] = (unsigned long)arg2; \
2323 _argvec[2+3] = (unsigned long)arg3; \
2324 _argvec[2+4] = (unsigned long)arg4; \
2327 "std 2,-16(11)\n\t" /* save tocptr */ \
2328 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2329 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2330 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2331 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2332 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2333 "ld 11, 0(11)\n\t" /* target->r11 */ \
2334 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2337 "ld 2,-16(11)" /* restore tocptr */ \
2338 : /*out*/ "=r" (_res) \
2339 : /*in*/ "r" (&_argvec[2]) \
2340 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2342 lval = (__typeof__(lval)) _res; \
2345 #define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \
2347 volatile OrigFn _orig = (orig); \
2348 volatile unsigned long _argvec[3+5]; \
2349 volatile unsigned long _res; \
2350 /* _argvec[0] holds current r2 across the call */ \
2351 _argvec[1] = (unsigned long)_orig.r2; \
2352 _argvec[2] = (unsigned long)_orig.nraddr; \
2353 _argvec[2+1] = (unsigned long)arg1; \
2354 _argvec[2+2] = (unsigned long)arg2; \
2355 _argvec[2+3] = (unsigned long)arg3; \
2356 _argvec[2+4] = (unsigned long)arg4; \
2357 _argvec[2+5] = (unsigned long)arg5; \
2360 "std 2,-16(11)\n\t" /* save tocptr */ \
2361 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2362 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2363 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2364 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2365 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2366 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
2367 "ld 11, 0(11)\n\t" /* target->r11 */ \
2368 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2371 "ld 2,-16(11)" /* restore tocptr */ \
2372 : /*out*/ "=r" (_res) \
2373 : /*in*/ "r" (&_argvec[2]) \
2374 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2376 lval = (__typeof__(lval)) _res; \
2379 #define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
2381 volatile OrigFn _orig = (orig); \
2382 volatile unsigned long _argvec[3+6]; \
2383 volatile unsigned long _res; \
2384 /* _argvec[0] holds current r2 across the call */ \
2385 _argvec[1] = (unsigned long)_orig.r2; \
2386 _argvec[2] = (unsigned long)_orig.nraddr; \
2387 _argvec[2+1] = (unsigned long)arg1; \
2388 _argvec[2+2] = (unsigned long)arg2; \
2389 _argvec[2+3] = (unsigned long)arg3; \
2390 _argvec[2+4] = (unsigned long)arg4; \
2391 _argvec[2+5] = (unsigned long)arg5; \
2392 _argvec[2+6] = (unsigned long)arg6; \
2395 "std 2,-16(11)\n\t" /* save tocptr */ \
2396 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2397 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2398 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2399 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2400 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2401 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
2402 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
2403 "ld 11, 0(11)\n\t" /* target->r11 */ \
2404 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2407 "ld 2,-16(11)" /* restore tocptr */ \
2408 : /*out*/ "=r" (_res) \
2409 : /*in*/ "r" (&_argvec[2]) \
2410 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2412 lval = (__typeof__(lval)) _res; \
2415 #define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2418 volatile OrigFn _orig = (orig); \
2419 volatile unsigned long _argvec[3+7]; \
2420 volatile unsigned long _res; \
2421 /* _argvec[0] holds current r2 across the call */ \
2422 _argvec[1] = (unsigned long)_orig.r2; \
2423 _argvec[2] = (unsigned long)_orig.nraddr; \
2424 _argvec[2+1] = (unsigned long)arg1; \
2425 _argvec[2+2] = (unsigned long)arg2; \
2426 _argvec[2+3] = (unsigned long)arg3; \
2427 _argvec[2+4] = (unsigned long)arg4; \
2428 _argvec[2+5] = (unsigned long)arg5; \
2429 _argvec[2+6] = (unsigned long)arg6; \
2430 _argvec[2+7] = (unsigned long)arg7; \
2433 "std 2,-16(11)\n\t" /* save tocptr */ \
2434 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2435 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2436 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2437 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2438 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2439 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
2440 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
2441 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
2442 "ld 11, 0(11)\n\t" /* target->r11 */ \
2443 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2446 "ld 2,-16(11)" /* restore tocptr */ \
2447 : /*out*/ "=r" (_res) \
2448 : /*in*/ "r" (&_argvec[2]) \
2449 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2451 lval = (__typeof__(lval)) _res; \
2454 #define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2457 volatile OrigFn _orig = (orig); \
2458 volatile unsigned long _argvec[3+8]; \
2459 volatile unsigned long _res; \
2460 /* _argvec[0] holds current r2 across the call */ \
2461 _argvec[1] = (unsigned long)_orig.r2; \
2462 _argvec[2] = (unsigned long)_orig.nraddr; \
2463 _argvec[2+1] = (unsigned long)arg1; \
2464 _argvec[2+2] = (unsigned long)arg2; \
2465 _argvec[2+3] = (unsigned long)arg3; \
2466 _argvec[2+4] = (unsigned long)arg4; \
2467 _argvec[2+5] = (unsigned long)arg5; \
2468 _argvec[2+6] = (unsigned long)arg6; \
2469 _argvec[2+7] = (unsigned long)arg7; \
2470 _argvec[2+8] = (unsigned long)arg8; \
2473 "std 2,-16(11)\n\t" /* save tocptr */ \
2474 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2475 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2476 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2477 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2478 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2479 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
2480 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
2481 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
2482 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
2483 "ld 11, 0(11)\n\t" /* target->r11 */ \
2484 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2487 "ld 2,-16(11)" /* restore tocptr */ \
2488 : /*out*/ "=r" (_res) \
2489 : /*in*/ "r" (&_argvec[2]) \
2490 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2492 lval = (__typeof__(lval)) _res; \
2495 #define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2498 volatile OrigFn _orig = (orig); \
2499 volatile unsigned long _argvec[3+9]; \
2500 volatile unsigned long _res; \
2501 /* _argvec[0] holds current r2 across the call */ \
2502 _argvec[1] = (unsigned long)_orig.r2; \
2503 _argvec[2] = (unsigned long)_orig.nraddr; \
2504 _argvec[2+1] = (unsigned long)arg1; \
2505 _argvec[2+2] = (unsigned long)arg2; \
2506 _argvec[2+3] = (unsigned long)arg3; \
2507 _argvec[2+4] = (unsigned long)arg4; \
2508 _argvec[2+5] = (unsigned long)arg5; \
2509 _argvec[2+6] = (unsigned long)arg6; \
2510 _argvec[2+7] = (unsigned long)arg7; \
2511 _argvec[2+8] = (unsigned long)arg8; \
2512 _argvec[2+9] = (unsigned long)arg9; \
2515 "std 2,-16(11)\n\t" /* save tocptr */ \
2516 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2517 "addi 1,1,-128\n\t" /* expand stack frame */ \
2520 "std 3,112(1)\n\t" \
2522 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2523 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2524 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2525 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2526 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
2527 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
2528 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
2529 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
2530 "ld 11, 0(11)\n\t" /* target->r11 */ \
2531 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2534 "ld 2,-16(11)\n\t" /* restore tocptr */ \
2535 "addi 1,1,128" /* restore frame */ \
2536 : /*out*/ "=r" (_res) \
2537 : /*in*/ "r" (&_argvec[2]) \
2538 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2540 lval = (__typeof__(lval)) _res; \
2543 #define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2544 arg7,arg8,arg9,arg10) \
2546 volatile OrigFn _orig = (orig); \
2547 volatile unsigned long _argvec[3+10]; \
2548 volatile unsigned long _res; \
2549 /* _argvec[0] holds current r2 across the call */ \
2550 _argvec[1] = (unsigned long)_orig.r2; \
2551 _argvec[2] = (unsigned long)_orig.nraddr; \
2552 _argvec[2+1] = (unsigned long)arg1; \
2553 _argvec[2+2] = (unsigned long)arg2; \
2554 _argvec[2+3] = (unsigned long)arg3; \
2555 _argvec[2+4] = (unsigned long)arg4; \
2556 _argvec[2+5] = (unsigned long)arg5; \
2557 _argvec[2+6] = (unsigned long)arg6; \
2558 _argvec[2+7] = (unsigned long)arg7; \
2559 _argvec[2+8] = (unsigned long)arg8; \
2560 _argvec[2+9] = (unsigned long)arg9; \
2561 _argvec[2+10] = (unsigned long)arg10; \
2564 "std 2,-16(11)\n\t" /* save tocptr */ \
2565 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2566 "addi 1,1,-128\n\t" /* expand stack frame */ \
2569 "std 3,120(1)\n\t" \
2572 "std 3,112(1)\n\t" \
2574 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2575 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2576 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2577 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2578 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
2579 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
2580 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
2581 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
2582 "ld 11, 0(11)\n\t" /* target->r11 */ \
2583 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2586 "ld 2,-16(11)\n\t" /* restore tocptr */ \
2587 "addi 1,1,128" /* restore frame */ \
2588 : /*out*/ "=r" (_res) \
2589 : /*in*/ "r" (&_argvec[2]) \
2590 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2592 lval = (__typeof__(lval)) _res; \
2595 #define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2596 arg7,arg8,arg9,arg10,arg11) \
2598 volatile OrigFn _orig = (orig); \
2599 volatile unsigned long _argvec[3+11]; \
2600 volatile unsigned long _res; \
2601 /* _argvec[0] holds current r2 across the call */ \
2602 _argvec[1] = (unsigned long)_orig.r2; \
2603 _argvec[2] = (unsigned long)_orig.nraddr; \
2604 _argvec[2+1] = (unsigned long)arg1; \
2605 _argvec[2+2] = (unsigned long)arg2; \
2606 _argvec[2+3] = (unsigned long)arg3; \
2607 _argvec[2+4] = (unsigned long)arg4; \
2608 _argvec[2+5] = (unsigned long)arg5; \
2609 _argvec[2+6] = (unsigned long)arg6; \
2610 _argvec[2+7] = (unsigned long)arg7; \
2611 _argvec[2+8] = (unsigned long)arg8; \
2612 _argvec[2+9] = (unsigned long)arg9; \
2613 _argvec[2+10] = (unsigned long)arg10; \
2614 _argvec[2+11] = (unsigned long)arg11; \
2617 "std 2,-16(11)\n\t" /* save tocptr */ \
2618 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2619 "addi 1,1,-144\n\t" /* expand stack frame */ \
2622 "std 3,128(1)\n\t" \
2625 "std 3,120(1)\n\t" \
2628 "std 3,112(1)\n\t" \
2630 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2631 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2632 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2633 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2634 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
2635 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
2636 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
2637 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
2638 "ld 11, 0(11)\n\t" /* target->r11 */ \
2639 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2642 "ld 2,-16(11)\n\t" /* restore tocptr */ \
2643 "addi 1,1,144" /* restore frame */ \
2644 : /*out*/ "=r" (_res) \
2645 : /*in*/ "r" (&_argvec[2]) \
2646 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2648 lval = (__typeof__(lval)) _res; \
2651 #define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2652 arg7,arg8,arg9,arg10,arg11,arg12) \
2654 volatile OrigFn _orig = (orig); \
2655 volatile unsigned long _argvec[3+12]; \
2656 volatile unsigned long _res; \
2657 /* _argvec[0] holds current r2 across the call */ \
2658 _argvec[1] = (unsigned long)_orig.r2; \
2659 _argvec[2] = (unsigned long)_orig.nraddr; \
2660 _argvec[2+1] = (unsigned long)arg1; \
2661 _argvec[2+2] = (unsigned long)arg2; \
2662 _argvec[2+3] = (unsigned long)arg3; \
2663 _argvec[2+4] = (unsigned long)arg4; \
2664 _argvec[2+5] = (unsigned long)arg5; \
2665 _argvec[2+6] = (unsigned long)arg6; \
2666 _argvec[2+7] = (unsigned long)arg7; \
2667 _argvec[2+8] = (unsigned long)arg8; \
2668 _argvec[2+9] = (unsigned long)arg9; \
2669 _argvec[2+10] = (unsigned long)arg10; \
2670 _argvec[2+11] = (unsigned long)arg11; \
2671 _argvec[2+12] = (unsigned long)arg12; \
2674 "std 2,-16(11)\n\t" /* save tocptr */ \
2675 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
2676 "addi 1,1,-144\n\t" /* expand stack frame */ \
2679 "std 3,136(1)\n\t" \
2682 "std 3,128(1)\n\t" \
2685 "std 3,120(1)\n\t" \
2688 "std 3,112(1)\n\t" \
2690 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
2691 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
2692 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
2693 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
2694 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
2695 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
2696 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
2697 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
2698 "ld 11, 0(11)\n\t" /* target->r11 */ \
2699 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
2702 "ld 2,-16(11)\n\t" /* restore tocptr */ \
2703 "addi 1,1,144" /* restore frame */ \
2704 : /*out*/ "=r" (_res) \
2705 : /*in*/ "r" (&_argvec[2]) \
2706 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2708 lval = (__typeof__(lval)) _res; \
2711 #endif /* PLAT_ppc64_linux */
2713 /* ------------------------- arm-linux ------------------------- */
2715 #if defined(PLAT_arm_linux)
2717 /* These regs are trashed by the hidden call. */
2718 #define __CALLER_SAVED_REGS "r0", "r1", "r2", "r3","r4","r14"
2720 /* These CALL_FN_ macros assume that on arm-linux, sizeof(unsigned
2723 #define CALL_FN_W_v(lval, orig) \
2725 volatile OrigFn _orig = (orig); \
2726 volatile unsigned long _argvec[1]; \
2727 volatile unsigned long _res; \
2728 _argvec[0] = (unsigned long)_orig.nraddr; \
2730 "ldr r4, [%1] \n\t" /* target->r4 */ \
2731 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2733 : /*out*/ "=r" (_res) \
2734 : /*in*/ "0" (&_argvec[0]) \
2735 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2737 lval = (__typeof__(lval)) _res; \
2740 #define CALL_FN_W_W(lval, orig, arg1) \
2742 volatile OrigFn _orig = (orig); \
2743 volatile unsigned long _argvec[2]; \
2744 volatile unsigned long _res; \
2745 _argvec[0] = (unsigned long)_orig.nraddr; \
2746 _argvec[1] = (unsigned long)(arg1); \
2748 "ldr r0, [%1, #4] \n\t" \
2749 "ldr r4, [%1] \n\t" /* target->r4 */ \
2750 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2752 : /*out*/ "=r" (_res) \
2753 : /*in*/ "0" (&_argvec[0]) \
2754 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2756 lval = (__typeof__(lval)) _res; \
2759 #define CALL_FN_W_WW(lval, orig, arg1,arg2) \
2761 volatile OrigFn _orig = (orig); \
2762 volatile unsigned long _argvec[3]; \
2763 volatile unsigned long _res; \
2764 _argvec[0] = (unsigned long)_orig.nraddr; \
2765 _argvec[1] = (unsigned long)(arg1); \
2766 _argvec[2] = (unsigned long)(arg2); \
2768 "ldr r0, [%1, #4] \n\t" \
2769 "ldr r1, [%1, #8] \n\t" \
2770 "ldr r4, [%1] \n\t" /* target->r4 */ \
2771 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2773 : /*out*/ "=r" (_res) \
2774 : /*in*/ "0" (&_argvec[0]) \
2775 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2777 lval = (__typeof__(lval)) _res; \
2780 #define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \
2782 volatile OrigFn _orig = (orig); \
2783 volatile unsigned long _argvec[4]; \
2784 volatile unsigned long _res; \
2785 _argvec[0] = (unsigned long)_orig.nraddr; \
2786 _argvec[1] = (unsigned long)(arg1); \
2787 _argvec[2] = (unsigned long)(arg2); \
2788 _argvec[3] = (unsigned long)(arg3); \
2790 "ldr r0, [%1, #4] \n\t" \
2791 "ldr r1, [%1, #8] \n\t" \
2792 "ldr r2, [%1, #12] \n\t" \
2793 "ldr r4, [%1] \n\t" /* target->r4 */ \
2794 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2796 : /*out*/ "=r" (_res) \
2797 : /*in*/ "0" (&_argvec[0]) \
2798 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2800 lval = (__typeof__(lval)) _res; \
2803 #define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
2805 volatile OrigFn _orig = (orig); \
2806 volatile unsigned long _argvec[5]; \
2807 volatile unsigned long _res; \
2808 _argvec[0] = (unsigned long)_orig.nraddr; \
2809 _argvec[1] = (unsigned long)(arg1); \
2810 _argvec[2] = (unsigned long)(arg2); \
2811 _argvec[3] = (unsigned long)(arg3); \
2812 _argvec[4] = (unsigned long)(arg4); \
2814 "ldr r0, [%1, #4] \n\t" \
2815 "ldr r1, [%1, #8] \n\t" \
2816 "ldr r2, [%1, #12] \n\t" \
2817 "ldr r3, [%1, #16] \n\t" \
2818 "ldr r4, [%1] \n\t" /* target->r4 */ \
2819 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2821 : /*out*/ "=r" (_res) \
2822 : /*in*/ "0" (&_argvec[0]) \
2823 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2825 lval = (__typeof__(lval)) _res; \
2828 #define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \
2830 volatile OrigFn _orig = (orig); \
2831 volatile unsigned long _argvec[6]; \
2832 volatile unsigned long _res; \
2833 _argvec[0] = (unsigned long)_orig.nraddr; \
2834 _argvec[1] = (unsigned long)(arg1); \
2835 _argvec[2] = (unsigned long)(arg2); \
2836 _argvec[3] = (unsigned long)(arg3); \
2837 _argvec[4] = (unsigned long)(arg4); \
2838 _argvec[5] = (unsigned long)(arg5); \
2840 "ldr r0, [%1, #20] \n\t" \
2842 "ldr r0, [%1, #4] \n\t" \
2843 "ldr r1, [%1, #8] \n\t" \
2844 "ldr r2, [%1, #12] \n\t" \
2845 "ldr r3, [%1, #16] \n\t" \
2846 "ldr r4, [%1] \n\t" /* target->r4 */ \
2847 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2848 "add sp, sp, #4 \n\t" \
2850 : /*out*/ "=r" (_res) \
2851 : /*in*/ "0" (&_argvec[0]) \
2852 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2854 lval = (__typeof__(lval)) _res; \
2857 #define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
2859 volatile OrigFn _orig = (orig); \
2860 volatile unsigned long _argvec[7]; \
2861 volatile unsigned long _res; \
2862 _argvec[0] = (unsigned long)_orig.nraddr; \
2863 _argvec[1] = (unsigned long)(arg1); \
2864 _argvec[2] = (unsigned long)(arg2); \
2865 _argvec[3] = (unsigned long)(arg3); \
2866 _argvec[4] = (unsigned long)(arg4); \
2867 _argvec[5] = (unsigned long)(arg5); \
2868 _argvec[6] = (unsigned long)(arg6); \
2870 "ldr r0, [%1, #20] \n\t" \
2871 "ldr r1, [%1, #24] \n\t" \
2872 "push {r0, r1} \n\t" \
2873 "ldr r0, [%1, #4] \n\t" \
2874 "ldr r1, [%1, #8] \n\t" \
2875 "ldr r2, [%1, #12] \n\t" \
2876 "ldr r3, [%1, #16] \n\t" \
2877 "ldr r4, [%1] \n\t" /* target->r4 */ \
2878 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2879 "add sp, sp, #8 \n\t" \
2881 : /*out*/ "=r" (_res) \
2882 : /*in*/ "0" (&_argvec[0]) \
2883 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2885 lval = (__typeof__(lval)) _res; \
2888 #define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2891 volatile OrigFn _orig = (orig); \
2892 volatile unsigned long _argvec[8]; \
2893 volatile unsigned long _res; \
2894 _argvec[0] = (unsigned long)_orig.nraddr; \
2895 _argvec[1] = (unsigned long)(arg1); \
2896 _argvec[2] = (unsigned long)(arg2); \
2897 _argvec[3] = (unsigned long)(arg3); \
2898 _argvec[4] = (unsigned long)(arg4); \
2899 _argvec[5] = (unsigned long)(arg5); \
2900 _argvec[6] = (unsigned long)(arg6); \
2901 _argvec[7] = (unsigned long)(arg7); \
2903 "ldr r0, [%1, #20] \n\t" \
2904 "ldr r1, [%1, #24] \n\t" \
2905 "ldr r2, [%1, #28] \n\t" \
2906 "push {r0, r1, r2} \n\t" \
2907 "ldr r0, [%1, #4] \n\t" \
2908 "ldr r1, [%1, #8] \n\t" \
2909 "ldr r2, [%1, #12] \n\t" \
2910 "ldr r3, [%1, #16] \n\t" \
2911 "ldr r4, [%1] \n\t" /* target->r4 */ \
2912 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2913 "add sp, sp, #12 \n\t" \
2915 : /*out*/ "=r" (_res) \
2916 : /*in*/ "0" (&_argvec[0]) \
2917 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2919 lval = (__typeof__(lval)) _res; \
2922 #define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2925 volatile OrigFn _orig = (orig); \
2926 volatile unsigned long _argvec[9]; \
2927 volatile unsigned long _res; \
2928 _argvec[0] = (unsigned long)_orig.nraddr; \
2929 _argvec[1] = (unsigned long)(arg1); \
2930 _argvec[2] = (unsigned long)(arg2); \
2931 _argvec[3] = (unsigned long)(arg3); \
2932 _argvec[4] = (unsigned long)(arg4); \
2933 _argvec[5] = (unsigned long)(arg5); \
2934 _argvec[6] = (unsigned long)(arg6); \
2935 _argvec[7] = (unsigned long)(arg7); \
2936 _argvec[8] = (unsigned long)(arg8); \
2938 "ldr r0, [%1, #20] \n\t" \
2939 "ldr r1, [%1, #24] \n\t" \
2940 "ldr r2, [%1, #28] \n\t" \
2941 "ldr r3, [%1, #32] \n\t" \
2942 "push {r0, r1, r2, r3} \n\t" \
2943 "ldr r0, [%1, #4] \n\t" \
2944 "ldr r1, [%1, #8] \n\t" \
2945 "ldr r2, [%1, #12] \n\t" \
2946 "ldr r3, [%1, #16] \n\t" \
2947 "ldr r4, [%1] \n\t" /* target->r4 */ \
2948 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2949 "add sp, sp, #16 \n\t" \
2951 : /*out*/ "=r" (_res) \
2952 : /*in*/ "0" (&_argvec[0]) \
2953 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2955 lval = (__typeof__(lval)) _res; \
2958 #define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2961 volatile OrigFn _orig = (orig); \
2962 volatile unsigned long _argvec[10]; \
2963 volatile unsigned long _res; \
2964 _argvec[0] = (unsigned long)_orig.nraddr; \
2965 _argvec[1] = (unsigned long)(arg1); \
2966 _argvec[2] = (unsigned long)(arg2); \
2967 _argvec[3] = (unsigned long)(arg3); \
2968 _argvec[4] = (unsigned long)(arg4); \
2969 _argvec[5] = (unsigned long)(arg5); \
2970 _argvec[6] = (unsigned long)(arg6); \
2971 _argvec[7] = (unsigned long)(arg7); \
2972 _argvec[8] = (unsigned long)(arg8); \
2973 _argvec[9] = (unsigned long)(arg9); \
2975 "ldr r0, [%1, #20] \n\t" \
2976 "ldr r1, [%1, #24] \n\t" \
2977 "ldr r2, [%1, #28] \n\t" \
2978 "ldr r3, [%1, #32] \n\t" \
2979 "ldr r4, [%1, #36] \n\t" \
2980 "push {r0, r1, r2, r3, r4} \n\t" \
2981 "ldr r0, [%1, #4] \n\t" \
2982 "ldr r1, [%1, #8] \n\t" \
2983 "ldr r2, [%1, #12] \n\t" \
2984 "ldr r3, [%1, #16] \n\t" \
2985 "ldr r4, [%1] \n\t" /* target->r4 */ \
2986 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
2987 "add sp, sp, #20 \n\t" \
2989 : /*out*/ "=r" (_res) \
2990 : /*in*/ "0" (&_argvec[0]) \
2991 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
2993 lval = (__typeof__(lval)) _res; \
2996 #define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
2997 arg7,arg8,arg9,arg10) \
2999 volatile OrigFn _orig = (orig); \
3000 volatile unsigned long _argvec[11]; \
3001 volatile unsigned long _res; \
3002 _argvec[0] = (unsigned long)_orig.nraddr; \
3003 _argvec[1] = (unsigned long)(arg1); \
3004 _argvec[2] = (unsigned long)(arg2); \
3005 _argvec[3] = (unsigned long)(arg3); \
3006 _argvec[4] = (unsigned long)(arg4); \
3007 _argvec[5] = (unsigned long)(arg5); \
3008 _argvec[6] = (unsigned long)(arg6); \
3009 _argvec[7] = (unsigned long)(arg7); \
3010 _argvec[8] = (unsigned long)(arg8); \
3011 _argvec[9] = (unsigned long)(arg9); \
3012 _argvec[10] = (unsigned long)(arg10); \
3014 "ldr r0, [%1, #40] \n\t" \
3016 "ldr r0, [%1, #20] \n\t" \
3017 "ldr r1, [%1, #24] \n\t" \
3018 "ldr r2, [%1, #28] \n\t" \
3019 "ldr r3, [%1, #32] \n\t" \
3020 "ldr r4, [%1, #36] \n\t" \
3021 "push {r0, r1, r2, r3, r4} \n\t" \
3022 "ldr r0, [%1, #4] \n\t" \
3023 "ldr r1, [%1, #8] \n\t" \
3024 "ldr r2, [%1, #12] \n\t" \
3025 "ldr r3, [%1, #16] \n\t" \
3026 "ldr r4, [%1] \n\t" /* target->r4 */ \
3027 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
3028 "add sp, sp, #24 \n\t" \
3030 : /*out*/ "=r" (_res) \
3031 : /*in*/ "0" (&_argvec[0]) \
3032 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3034 lval = (__typeof__(lval)) _res; \
3037 #define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5, \
3038 arg6,arg7,arg8,arg9,arg10, \
3041 volatile OrigFn _orig = (orig); \
3042 volatile unsigned long _argvec[12]; \
3043 volatile unsigned long _res; \
3044 _argvec[0] = (unsigned long)_orig.nraddr; \
3045 _argvec[1] = (unsigned long)(arg1); \
3046 _argvec[2] = (unsigned long)(arg2); \
3047 _argvec[3] = (unsigned long)(arg3); \
3048 _argvec[4] = (unsigned long)(arg4); \
3049 _argvec[5] = (unsigned long)(arg5); \
3050 _argvec[6] = (unsigned long)(arg6); \
3051 _argvec[7] = (unsigned long)(arg7); \
3052 _argvec[8] = (unsigned long)(arg8); \
3053 _argvec[9] = (unsigned long)(arg9); \
3054 _argvec[10] = (unsigned long)(arg10); \
3055 _argvec[11] = (unsigned long)(arg11); \
3057 "ldr r0, [%1, #40] \n\t" \
3058 "ldr r1, [%1, #44] \n\t" \
3059 "push {r0, r1} \n\t" \
3060 "ldr r0, [%1, #20] \n\t" \
3061 "ldr r1, [%1, #24] \n\t" \
3062 "ldr r2, [%1, #28] \n\t" \
3063 "ldr r3, [%1, #32] \n\t" \
3064 "ldr r4, [%1, #36] \n\t" \
3065 "push {r0, r1, r2, r3, r4} \n\t" \
3066 "ldr r0, [%1, #4] \n\t" \
3067 "ldr r1, [%1, #8] \n\t" \
3068 "ldr r2, [%1, #12] \n\t" \
3069 "ldr r3, [%1, #16] \n\t" \
3070 "ldr r4, [%1] \n\t" /* target->r4 */ \
3071 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
3072 "add sp, sp, #28 \n\t" \
3074 : /*out*/ "=r" (_res) \
3075 : /*in*/ "0" (&_argvec[0]) \
3076 : /*trash*/ "cc", "memory",__CALLER_SAVED_REGS \
3078 lval = (__typeof__(lval)) _res; \
3081 #define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5, \
3082 arg6,arg7,arg8,arg9,arg10, \
3085 volatile OrigFn _orig = (orig); \
3086 volatile unsigned long _argvec[13]; \
3087 volatile unsigned long _res; \
3088 _argvec[0] = (unsigned long)_orig.nraddr; \
3089 _argvec[1] = (unsigned long)(arg1); \
3090 _argvec[2] = (unsigned long)(arg2); \
3091 _argvec[3] = (unsigned long)(arg3); \
3092 _argvec[4] = (unsigned long)(arg4); \
3093 _argvec[5] = (unsigned long)(arg5); \
3094 _argvec[6] = (unsigned long)(arg6); \
3095 _argvec[7] = (unsigned long)(arg7); \
3096 _argvec[8] = (unsigned long)(arg8); \
3097 _argvec[9] = (unsigned long)(arg9); \
3098 _argvec[10] = (unsigned long)(arg10); \
3099 _argvec[11] = (unsigned long)(arg11); \
3100 _argvec[12] = (unsigned long)(arg12); \
3102 "ldr r0, [%1, #40] \n\t" \
3103 "ldr r1, [%1, #44] \n\t" \
3104 "ldr r2, [%1, #48] \n\t" \
3105 "push {r0, r1, r2} \n\t" \
3106 "ldr r0, [%1, #20] \n\t" \
3107 "ldr r1, [%1, #24] \n\t" \
3108 "ldr r2, [%1, #28] \n\t" \
3109 "ldr r3, [%1, #32] \n\t" \
3110 "ldr r4, [%1, #36] \n\t" \
3111 "push {r0, r1, r2, r3, r4} \n\t" \
3112 "ldr r0, [%1, #4] \n\t" \
3113 "ldr r1, [%1, #8] \n\t" \
3114 "ldr r2, [%1, #12] \n\t" \
3115 "ldr r3, [%1, #16] \n\t" \
3116 "ldr r4, [%1] \n\t" /* target->r4 */ \
3117 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4 \
3118 "add sp, sp, #32 \n\t" \
3120 : /*out*/ "=r" (_res) \
3121 : /*in*/ "0" (&_argvec[0]) \
3122 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3124 lval = (__typeof__(lval)) _res; \
3127 #endif /* PLAT_arm_linux */
3129 /* ------------------------ ppc32-aix5 ------------------------- */
3131 #if defined(PLAT_ppc32_aix5)
3133 /* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
3135 /* These regs are trashed by the hidden call. */
3136 #define __CALLER_SAVED_REGS \
3137 "lr", "ctr", "xer", \
3138 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \
3139 "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \
3142 /* Expand the stack frame, copying enough info that unwinding
3143 still works. Trashes r3. */
3145 #define VG_EXPAND_FRAME_BY_trashes_r3(_n_fr) \
3146 "addi 1,1,-" #_n_fr "\n\t" \
3147 "lwz 3," #_n_fr "(1)\n\t" \
3150 #define VG_CONTRACT_FRAME_BY(_n_fr) \
3151 "addi 1,1," #_n_fr "\n\t"
3153 /* These CALL_FN_ macros assume that on ppc32-aix5, sizeof(unsigned
3156 #define CALL_FN_W_v(lval, orig) \
3158 volatile OrigFn _orig = (orig); \
3159 volatile unsigned long _argvec[3+0]; \
3160 volatile unsigned long _res; \
3161 /* _argvec[0] holds current r2 across the call */ \
3162 _argvec[1] = (unsigned long)_orig.r2; \
3163 _argvec[2] = (unsigned long)_orig.nraddr; \
3166 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3167 "stw 2,-8(11)\n\t" /* save tocptr */ \
3168 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3169 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3170 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3173 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3174 VG_CONTRACT_FRAME_BY(512) \
3175 : /*out*/ "=r" (_res) \
3176 : /*in*/ "r" (&_argvec[2]) \
3177 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3179 lval = (__typeof__(lval)) _res; \
3182 #define CALL_FN_W_W(lval, orig, arg1) \
3184 volatile OrigFn _orig = (orig); \
3185 volatile unsigned long _argvec[3+1]; \
3186 volatile unsigned long _res; \
3187 /* _argvec[0] holds current r2 across the call */ \
3188 _argvec[1] = (unsigned long)_orig.r2; \
3189 _argvec[2] = (unsigned long)_orig.nraddr; \
3190 _argvec[2+1] = (unsigned long)arg1; \
3193 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3194 "stw 2,-8(11)\n\t" /* save tocptr */ \
3195 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3196 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3197 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3198 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3201 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3202 VG_CONTRACT_FRAME_BY(512) \
3203 : /*out*/ "=r" (_res) \
3204 : /*in*/ "r" (&_argvec[2]) \
3205 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3207 lval = (__typeof__(lval)) _res; \
3210 #define CALL_FN_W_WW(lval, orig, arg1,arg2) \
3212 volatile OrigFn _orig = (orig); \
3213 volatile unsigned long _argvec[3+2]; \
3214 volatile unsigned long _res; \
3215 /* _argvec[0] holds current r2 across the call */ \
3216 _argvec[1] = (unsigned long)_orig.r2; \
3217 _argvec[2] = (unsigned long)_orig.nraddr; \
3218 _argvec[2+1] = (unsigned long)arg1; \
3219 _argvec[2+2] = (unsigned long)arg2; \
3222 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3223 "stw 2,-8(11)\n\t" /* save tocptr */ \
3224 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3225 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3226 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3227 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3228 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3231 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3232 VG_CONTRACT_FRAME_BY(512) \
3233 : /*out*/ "=r" (_res) \
3234 : /*in*/ "r" (&_argvec[2]) \
3235 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3237 lval = (__typeof__(lval)) _res; \
3240 #define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \
3242 volatile OrigFn _orig = (orig); \
3243 volatile unsigned long _argvec[3+3]; \
3244 volatile unsigned long _res; \
3245 /* _argvec[0] holds current r2 across the call */ \
3246 _argvec[1] = (unsigned long)_orig.r2; \
3247 _argvec[2] = (unsigned long)_orig.nraddr; \
3248 _argvec[2+1] = (unsigned long)arg1; \
3249 _argvec[2+2] = (unsigned long)arg2; \
3250 _argvec[2+3] = (unsigned long)arg3; \
3253 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3254 "stw 2,-8(11)\n\t" /* save tocptr */ \
3255 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3256 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3257 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3258 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3259 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3260 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3263 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3264 VG_CONTRACT_FRAME_BY(512) \
3265 : /*out*/ "=r" (_res) \
3266 : /*in*/ "r" (&_argvec[2]) \
3267 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3269 lval = (__typeof__(lval)) _res; \
3272 #define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
3274 volatile OrigFn _orig = (orig); \
3275 volatile unsigned long _argvec[3+4]; \
3276 volatile unsigned long _res; \
3277 /* _argvec[0] holds current r2 across the call */ \
3278 _argvec[1] = (unsigned long)_orig.r2; \
3279 _argvec[2] = (unsigned long)_orig.nraddr; \
3280 _argvec[2+1] = (unsigned long)arg1; \
3281 _argvec[2+2] = (unsigned long)arg2; \
3282 _argvec[2+3] = (unsigned long)arg3; \
3283 _argvec[2+4] = (unsigned long)arg4; \
3286 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3287 "stw 2,-8(11)\n\t" /* save tocptr */ \
3288 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3289 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3290 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3291 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3292 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3293 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3294 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3297 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3298 VG_CONTRACT_FRAME_BY(512) \
3299 : /*out*/ "=r" (_res) \
3300 : /*in*/ "r" (&_argvec[2]) \
3301 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3303 lval = (__typeof__(lval)) _res; \
3306 #define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \
3308 volatile OrigFn _orig = (orig); \
3309 volatile unsigned long _argvec[3+5]; \
3310 volatile unsigned long _res; \
3311 /* _argvec[0] holds current r2 across the call */ \
3312 _argvec[1] = (unsigned long)_orig.r2; \
3313 _argvec[2] = (unsigned long)_orig.nraddr; \
3314 _argvec[2+1] = (unsigned long)arg1; \
3315 _argvec[2+2] = (unsigned long)arg2; \
3316 _argvec[2+3] = (unsigned long)arg3; \
3317 _argvec[2+4] = (unsigned long)arg4; \
3318 _argvec[2+5] = (unsigned long)arg5; \
3321 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3322 "stw 2,-8(11)\n\t" /* save tocptr */ \
3323 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3324 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3325 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3326 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3327 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3328 "lwz 7, 20(11)\n\t" /* arg5->r7 */ \
3329 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3330 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3333 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3334 VG_CONTRACT_FRAME_BY(512) \
3335 : /*out*/ "=r" (_res) \
3336 : /*in*/ "r" (&_argvec[2]) \
3337 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3339 lval = (__typeof__(lval)) _res; \
3342 #define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
3344 volatile OrigFn _orig = (orig); \
3345 volatile unsigned long _argvec[3+6]; \
3346 volatile unsigned long _res; \
3347 /* _argvec[0] holds current r2 across the call */ \
3348 _argvec[1] = (unsigned long)_orig.r2; \
3349 _argvec[2] = (unsigned long)_orig.nraddr; \
3350 _argvec[2+1] = (unsigned long)arg1; \
3351 _argvec[2+2] = (unsigned long)arg2; \
3352 _argvec[2+3] = (unsigned long)arg3; \
3353 _argvec[2+4] = (unsigned long)arg4; \
3354 _argvec[2+5] = (unsigned long)arg5; \
3355 _argvec[2+6] = (unsigned long)arg6; \
3358 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3359 "stw 2,-8(11)\n\t" /* save tocptr */ \
3360 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3361 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3362 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3363 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3364 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3365 "lwz 7, 20(11)\n\t" /* arg5->r7 */ \
3366 "lwz 8, 24(11)\n\t" /* arg6->r8 */ \
3367 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3368 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3371 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3372 VG_CONTRACT_FRAME_BY(512) \
3373 : /*out*/ "=r" (_res) \
3374 : /*in*/ "r" (&_argvec[2]) \
3375 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3377 lval = (__typeof__(lval)) _res; \
3380 #define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
3383 volatile OrigFn _orig = (orig); \
3384 volatile unsigned long _argvec[3+7]; \
3385 volatile unsigned long _res; \
3386 /* _argvec[0] holds current r2 across the call */ \
3387 _argvec[1] = (unsigned long)_orig.r2; \
3388 _argvec[2] = (unsigned long)_orig.nraddr; \
3389 _argvec[2+1] = (unsigned long)arg1; \
3390 _argvec[2+2] = (unsigned long)arg2; \
3391 _argvec[2+3] = (unsigned long)arg3; \
3392 _argvec[2+4] = (unsigned long)arg4; \
3393 _argvec[2+5] = (unsigned long)arg5; \
3394 _argvec[2+6] = (unsigned long)arg6; \
3395 _argvec[2+7] = (unsigned long)arg7; \
3398 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3399 "stw 2,-8(11)\n\t" /* save tocptr */ \
3400 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3401 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3402 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3403 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3404 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3405 "lwz 7, 20(11)\n\t" /* arg5->r7 */ \
3406 "lwz 8, 24(11)\n\t" /* arg6->r8 */ \
3407 "lwz 9, 28(11)\n\t" /* arg7->r9 */ \
3408 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3409 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3412 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3413 VG_CONTRACT_FRAME_BY(512) \
3414 : /*out*/ "=r" (_res) \
3415 : /*in*/ "r" (&_argvec[2]) \
3416 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3418 lval = (__typeof__(lval)) _res; \
3421 #define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
3424 volatile OrigFn _orig = (orig); \
3425 volatile unsigned long _argvec[3+8]; \
3426 volatile unsigned long _res; \
3427 /* _argvec[0] holds current r2 across the call */ \
3428 _argvec[1] = (unsigned long)_orig.r2; \
3429 _argvec[2] = (unsigned long)_orig.nraddr; \
3430 _argvec[2+1] = (unsigned long)arg1; \
3431 _argvec[2+2] = (unsigned long)arg2; \
3432 _argvec[2+3] = (unsigned long)arg3; \
3433 _argvec[2+4] = (unsigned long)arg4; \
3434 _argvec[2+5] = (unsigned long)arg5; \
3435 _argvec[2+6] = (unsigned long)arg6; \
3436 _argvec[2+7] = (unsigned long)arg7; \
3437 _argvec[2+8] = (unsigned long)arg8; \
3440 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3441 "stw 2,-8(11)\n\t" /* save tocptr */ \
3442 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3443 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3444 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3445 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3446 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3447 "lwz 7, 20(11)\n\t" /* arg5->r7 */ \
3448 "lwz 8, 24(11)\n\t" /* arg6->r8 */ \
3449 "lwz 9, 28(11)\n\t" /* arg7->r9 */ \
3450 "lwz 10, 32(11)\n\t" /* arg8->r10 */ \
3451 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3452 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3455 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3456 VG_CONTRACT_FRAME_BY(512) \
3457 : /*out*/ "=r" (_res) \
3458 : /*in*/ "r" (&_argvec[2]) \
3459 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3461 lval = (__typeof__(lval)) _res; \
3464 #define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
3467 volatile OrigFn _orig = (orig); \
3468 volatile unsigned long _argvec[3+9]; \
3469 volatile unsigned long _res; \
3470 /* _argvec[0] holds current r2 across the call */ \
3471 _argvec[1] = (unsigned long)_orig.r2; \
3472 _argvec[2] = (unsigned long)_orig.nraddr; \
3473 _argvec[2+1] = (unsigned long)arg1; \
3474 _argvec[2+2] = (unsigned long)arg2; \
3475 _argvec[2+3] = (unsigned long)arg3; \
3476 _argvec[2+4] = (unsigned long)arg4; \
3477 _argvec[2+5] = (unsigned long)arg5; \
3478 _argvec[2+6] = (unsigned long)arg6; \
3479 _argvec[2+7] = (unsigned long)arg7; \
3480 _argvec[2+8] = (unsigned long)arg8; \
3481 _argvec[2+9] = (unsigned long)arg9; \
3484 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3485 "stw 2,-8(11)\n\t" /* save tocptr */ \
3486 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3487 VG_EXPAND_FRAME_BY_trashes_r3(64) \
3489 "lwz 3,36(11)\n\t" \
3492 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3493 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3494 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3495 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3496 "lwz 7, 20(11)\n\t" /* arg5->r7 */ \
3497 "lwz 8, 24(11)\n\t" /* arg6->r8 */ \
3498 "lwz 9, 28(11)\n\t" /* arg7->r9 */ \
3499 "lwz 10, 32(11)\n\t" /* arg8->r10 */ \
3500 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3501 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3504 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3505 VG_CONTRACT_FRAME_BY(64) \
3506 VG_CONTRACT_FRAME_BY(512) \
3507 : /*out*/ "=r" (_res) \
3508 : /*in*/ "r" (&_argvec[2]) \
3509 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3511 lval = (__typeof__(lval)) _res; \
3514 #define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
3515 arg7,arg8,arg9,arg10) \
3517 volatile OrigFn _orig = (orig); \
3518 volatile unsigned long _argvec[3+10]; \
3519 volatile unsigned long _res; \
3520 /* _argvec[0] holds current r2 across the call */ \
3521 _argvec[1] = (unsigned long)_orig.r2; \
3522 _argvec[2] = (unsigned long)_orig.nraddr; \
3523 _argvec[2+1] = (unsigned long)arg1; \
3524 _argvec[2+2] = (unsigned long)arg2; \
3525 _argvec[2+3] = (unsigned long)arg3; \
3526 _argvec[2+4] = (unsigned long)arg4; \
3527 _argvec[2+5] = (unsigned long)arg5; \
3528 _argvec[2+6] = (unsigned long)arg6; \
3529 _argvec[2+7] = (unsigned long)arg7; \
3530 _argvec[2+8] = (unsigned long)arg8; \
3531 _argvec[2+9] = (unsigned long)arg9; \
3532 _argvec[2+10] = (unsigned long)arg10; \
3535 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3536 "stw 2,-8(11)\n\t" /* save tocptr */ \
3537 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3538 VG_EXPAND_FRAME_BY_trashes_r3(64) \
3540 "lwz 3,40(11)\n\t" \
3543 "lwz 3,36(11)\n\t" \
3546 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3547 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3548 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3549 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3550 "lwz 7, 20(11)\n\t" /* arg5->r7 */ \
3551 "lwz 8, 24(11)\n\t" /* arg6->r8 */ \
3552 "lwz 9, 28(11)\n\t" /* arg7->r9 */ \
3553 "lwz 10, 32(11)\n\t" /* arg8->r10 */ \
3554 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3555 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3558 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3559 VG_CONTRACT_FRAME_BY(64) \
3560 VG_CONTRACT_FRAME_BY(512) \
3561 : /*out*/ "=r" (_res) \
3562 : /*in*/ "r" (&_argvec[2]) \
3563 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3565 lval = (__typeof__(lval)) _res; \
3568 #define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
3569 arg7,arg8,arg9,arg10,arg11) \
3571 volatile OrigFn _orig = (orig); \
3572 volatile unsigned long _argvec[3+11]; \
3573 volatile unsigned long _res; \
3574 /* _argvec[0] holds current r2 across the call */ \
3575 _argvec[1] = (unsigned long)_orig.r2; \
3576 _argvec[2] = (unsigned long)_orig.nraddr; \
3577 _argvec[2+1] = (unsigned long)arg1; \
3578 _argvec[2+2] = (unsigned long)arg2; \
3579 _argvec[2+3] = (unsigned long)arg3; \
3580 _argvec[2+4] = (unsigned long)arg4; \
3581 _argvec[2+5] = (unsigned long)arg5; \
3582 _argvec[2+6] = (unsigned long)arg6; \
3583 _argvec[2+7] = (unsigned long)arg7; \
3584 _argvec[2+8] = (unsigned long)arg8; \
3585 _argvec[2+9] = (unsigned long)arg9; \
3586 _argvec[2+10] = (unsigned long)arg10; \
3587 _argvec[2+11] = (unsigned long)arg11; \
3590 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3591 "stw 2,-8(11)\n\t" /* save tocptr */ \
3592 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3593 VG_EXPAND_FRAME_BY_trashes_r3(72) \
3595 "lwz 3,44(11)\n\t" \
3598 "lwz 3,40(11)\n\t" \
3601 "lwz 3,36(11)\n\t" \
3604 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3605 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3606 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3607 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3608 "lwz 7, 20(11)\n\t" /* arg5->r7 */ \
3609 "lwz 8, 24(11)\n\t" /* arg6->r8 */ \
3610 "lwz 9, 28(11)\n\t" /* arg7->r9 */ \
3611 "lwz 10, 32(11)\n\t" /* arg8->r10 */ \
3612 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3613 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3616 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3617 VG_CONTRACT_FRAME_BY(72) \
3618 VG_CONTRACT_FRAME_BY(512) \
3619 : /*out*/ "=r" (_res) \
3620 : /*in*/ "r" (&_argvec[2]) \
3621 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3623 lval = (__typeof__(lval)) _res; \
3626 #define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
3627 arg7,arg8,arg9,arg10,arg11,arg12) \
3629 volatile OrigFn _orig = (orig); \
3630 volatile unsigned long _argvec[3+12]; \
3631 volatile unsigned long _res; \
3632 /* _argvec[0] holds current r2 across the call */ \
3633 _argvec[1] = (unsigned long)_orig.r2; \
3634 _argvec[2] = (unsigned long)_orig.nraddr; \
3635 _argvec[2+1] = (unsigned long)arg1; \
3636 _argvec[2+2] = (unsigned long)arg2; \
3637 _argvec[2+3] = (unsigned long)arg3; \
3638 _argvec[2+4] = (unsigned long)arg4; \
3639 _argvec[2+5] = (unsigned long)arg5; \
3640 _argvec[2+6] = (unsigned long)arg6; \
3641 _argvec[2+7] = (unsigned long)arg7; \
3642 _argvec[2+8] = (unsigned long)arg8; \
3643 _argvec[2+9] = (unsigned long)arg9; \
3644 _argvec[2+10] = (unsigned long)arg10; \
3645 _argvec[2+11] = (unsigned long)arg11; \
3646 _argvec[2+12] = (unsigned long)arg12; \
3649 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3650 "stw 2,-8(11)\n\t" /* save tocptr */ \
3651 "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \
3652 VG_EXPAND_FRAME_BY_trashes_r3(72) \
3654 "lwz 3,48(11)\n\t" \
3657 "lwz 3,44(11)\n\t" \
3660 "lwz 3,40(11)\n\t" \
3663 "lwz 3,36(11)\n\t" \
3666 "lwz 3, 4(11)\n\t" /* arg1->r3 */ \
3667 "lwz 4, 8(11)\n\t" /* arg2->r4 */ \
3668 "lwz 5, 12(11)\n\t" /* arg3->r5 */ \
3669 "lwz 6, 16(11)\n\t" /* arg4->r6 */ \
3670 "lwz 7, 20(11)\n\t" /* arg5->r7 */ \
3671 "lwz 8, 24(11)\n\t" /* arg6->r8 */ \
3672 "lwz 9, 28(11)\n\t" /* arg7->r9 */ \
3673 "lwz 10, 32(11)\n\t" /* arg8->r10 */ \
3674 "lwz 11, 0(11)\n\t" /* target->r11 */ \
3675 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3678 "lwz 2,-8(11)\n\t" /* restore tocptr */ \
3679 VG_CONTRACT_FRAME_BY(72) \
3680 VG_CONTRACT_FRAME_BY(512) \
3681 : /*out*/ "=r" (_res) \
3682 : /*in*/ "r" (&_argvec[2]) \
3683 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3685 lval = (__typeof__(lval)) _res; \
3688 #endif /* PLAT_ppc32_aix5 */
3690 /* ------------------------ ppc64-aix5 ------------------------- */
3692 #if defined(PLAT_ppc64_aix5)
3694 /* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
3696 /* These regs are trashed by the hidden call. */
3697 #define __CALLER_SAVED_REGS \
3698 "lr", "ctr", "xer", \
3699 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \
3700 "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \
3703 /* Expand the stack frame, copying enough info that unwinding
3704 still works. Trashes r3. */
3706 #define VG_EXPAND_FRAME_BY_trashes_r3(_n_fr) \
3707 "addi 1,1,-" #_n_fr "\n\t" \
3708 "ld 3," #_n_fr "(1)\n\t" \
3711 #define VG_CONTRACT_FRAME_BY(_n_fr) \
3712 "addi 1,1," #_n_fr "\n\t"
3714 /* These CALL_FN_ macros assume that on ppc64-aix5, sizeof(unsigned
3717 #define CALL_FN_W_v(lval, orig) \
3719 volatile OrigFn _orig = (orig); \
3720 volatile unsigned long _argvec[3+0]; \
3721 volatile unsigned long _res; \
3722 /* _argvec[0] holds current r2 across the call */ \
3723 _argvec[1] = (unsigned long)_orig.r2; \
3724 _argvec[2] = (unsigned long)_orig.nraddr; \
3727 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3728 "std 2,-16(11)\n\t" /* save tocptr */ \
3729 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
3730 "ld 11, 0(11)\n\t" /* target->r11 */ \
3731 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3734 "ld 2,-16(11)\n\t" /* restore tocptr */ \
3735 VG_CONTRACT_FRAME_BY(512) \
3736 : /*out*/ "=r" (_res) \
3737 : /*in*/ "r" (&_argvec[2]) \
3738 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3740 lval = (__typeof__(lval)) _res; \
3743 #define CALL_FN_W_W(lval, orig, arg1) \
3745 volatile OrigFn _orig = (orig); \
3746 volatile unsigned long _argvec[3+1]; \
3747 volatile unsigned long _res; \
3748 /* _argvec[0] holds current r2 across the call */ \
3749 _argvec[1] = (unsigned long)_orig.r2; \
3750 _argvec[2] = (unsigned long)_orig.nraddr; \
3751 _argvec[2+1] = (unsigned long)arg1; \
3754 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3755 "std 2,-16(11)\n\t" /* save tocptr */ \
3756 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
3757 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
3758 "ld 11, 0(11)\n\t" /* target->r11 */ \
3759 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3762 "ld 2,-16(11)\n\t" /* restore tocptr */ \
3763 VG_CONTRACT_FRAME_BY(512) \
3764 : /*out*/ "=r" (_res) \
3765 : /*in*/ "r" (&_argvec[2]) \
3766 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3768 lval = (__typeof__(lval)) _res; \
3771 #define CALL_FN_W_WW(lval, orig, arg1,arg2) \
3773 volatile OrigFn _orig = (orig); \
3774 volatile unsigned long _argvec[3+2]; \
3775 volatile unsigned long _res; \
3776 /* _argvec[0] holds current r2 across the call */ \
3777 _argvec[1] = (unsigned long)_orig.r2; \
3778 _argvec[2] = (unsigned long)_orig.nraddr; \
3779 _argvec[2+1] = (unsigned long)arg1; \
3780 _argvec[2+2] = (unsigned long)arg2; \
3783 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3784 "std 2,-16(11)\n\t" /* save tocptr */ \
3785 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
3786 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
3787 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
3788 "ld 11, 0(11)\n\t" /* target->r11 */ \
3789 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3792 "ld 2,-16(11)\n\t" /* restore tocptr */ \
3793 VG_CONTRACT_FRAME_BY(512) \
3794 : /*out*/ "=r" (_res) \
3795 : /*in*/ "r" (&_argvec[2]) \
3796 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3798 lval = (__typeof__(lval)) _res; \
3801 #define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \
3803 volatile OrigFn _orig = (orig); \
3804 volatile unsigned long _argvec[3+3]; \
3805 volatile unsigned long _res; \
3806 /* _argvec[0] holds current r2 across the call */ \
3807 _argvec[1] = (unsigned long)_orig.r2; \
3808 _argvec[2] = (unsigned long)_orig.nraddr; \
3809 _argvec[2+1] = (unsigned long)arg1; \
3810 _argvec[2+2] = (unsigned long)arg2; \
3811 _argvec[2+3] = (unsigned long)arg3; \
3814 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3815 "std 2,-16(11)\n\t" /* save tocptr */ \
3816 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
3817 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
3818 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
3819 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
3820 "ld 11, 0(11)\n\t" /* target->r11 */ \
3821 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3824 "ld 2,-16(11)\n\t" /* restore tocptr */ \
3825 VG_CONTRACT_FRAME_BY(512) \
3826 : /*out*/ "=r" (_res) \
3827 : /*in*/ "r" (&_argvec[2]) \
3828 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3830 lval = (__typeof__(lval)) _res; \
3833 #define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
3835 volatile OrigFn _orig = (orig); \
3836 volatile unsigned long _argvec[3+4]; \
3837 volatile unsigned long _res; \
3838 /* _argvec[0] holds current r2 across the call */ \
3839 _argvec[1] = (unsigned long)_orig.r2; \
3840 _argvec[2] = (unsigned long)_orig.nraddr; \
3841 _argvec[2+1] = (unsigned long)arg1; \
3842 _argvec[2+2] = (unsigned long)arg2; \
3843 _argvec[2+3] = (unsigned long)arg3; \
3844 _argvec[2+4] = (unsigned long)arg4; \
3847 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3848 "std 2,-16(11)\n\t" /* save tocptr */ \
3849 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
3850 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
3851 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
3852 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
3853 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
3854 "ld 11, 0(11)\n\t" /* target->r11 */ \
3855 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3858 "ld 2,-16(11)\n\t" /* restore tocptr */ \
3859 VG_CONTRACT_FRAME_BY(512) \
3860 : /*out*/ "=r" (_res) \
3861 : /*in*/ "r" (&_argvec[2]) \
3862 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3864 lval = (__typeof__(lval)) _res; \
3867 #define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \
3869 volatile OrigFn _orig = (orig); \
3870 volatile unsigned long _argvec[3+5]; \
3871 volatile unsigned long _res; \
3872 /* _argvec[0] holds current r2 across the call */ \
3873 _argvec[1] = (unsigned long)_orig.r2; \
3874 _argvec[2] = (unsigned long)_orig.nraddr; \
3875 _argvec[2+1] = (unsigned long)arg1; \
3876 _argvec[2+2] = (unsigned long)arg2; \
3877 _argvec[2+3] = (unsigned long)arg3; \
3878 _argvec[2+4] = (unsigned long)arg4; \
3879 _argvec[2+5] = (unsigned long)arg5; \
3882 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3883 "std 2,-16(11)\n\t" /* save tocptr */ \
3884 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
3885 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
3886 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
3887 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
3888 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
3889 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
3890 "ld 11, 0(11)\n\t" /* target->r11 */ \
3891 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3894 "ld 2,-16(11)\n\t" /* restore tocptr */ \
3895 VG_CONTRACT_FRAME_BY(512) \
3896 : /*out*/ "=r" (_res) \
3897 : /*in*/ "r" (&_argvec[2]) \
3898 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3900 lval = (__typeof__(lval)) _res; \
3903 #define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
3905 volatile OrigFn _orig = (orig); \
3906 volatile unsigned long _argvec[3+6]; \
3907 volatile unsigned long _res; \
3908 /* _argvec[0] holds current r2 across the call */ \
3909 _argvec[1] = (unsigned long)_orig.r2; \
3910 _argvec[2] = (unsigned long)_orig.nraddr; \
3911 _argvec[2+1] = (unsigned long)arg1; \
3912 _argvec[2+2] = (unsigned long)arg2; \
3913 _argvec[2+3] = (unsigned long)arg3; \
3914 _argvec[2+4] = (unsigned long)arg4; \
3915 _argvec[2+5] = (unsigned long)arg5; \
3916 _argvec[2+6] = (unsigned long)arg6; \
3919 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3920 "std 2,-16(11)\n\t" /* save tocptr */ \
3921 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
3922 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
3923 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
3924 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
3925 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
3926 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
3927 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
3928 "ld 11, 0(11)\n\t" /* target->r11 */ \
3929 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3932 "ld 2,-16(11)\n\t" /* restore tocptr */ \
3933 VG_CONTRACT_FRAME_BY(512) \
3934 : /*out*/ "=r" (_res) \
3935 : /*in*/ "r" (&_argvec[2]) \
3936 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3938 lval = (__typeof__(lval)) _res; \
3941 #define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
3944 volatile OrigFn _orig = (orig); \
3945 volatile unsigned long _argvec[3+7]; \
3946 volatile unsigned long _res; \
3947 /* _argvec[0] holds current r2 across the call */ \
3948 _argvec[1] = (unsigned long)_orig.r2; \
3949 _argvec[2] = (unsigned long)_orig.nraddr; \
3950 _argvec[2+1] = (unsigned long)arg1; \
3951 _argvec[2+2] = (unsigned long)arg2; \
3952 _argvec[2+3] = (unsigned long)arg3; \
3953 _argvec[2+4] = (unsigned long)arg4; \
3954 _argvec[2+5] = (unsigned long)arg5; \
3955 _argvec[2+6] = (unsigned long)arg6; \
3956 _argvec[2+7] = (unsigned long)arg7; \
3959 VG_EXPAND_FRAME_BY_trashes_r3(512) \
3960 "std 2,-16(11)\n\t" /* save tocptr */ \
3961 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
3962 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
3963 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
3964 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
3965 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
3966 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
3967 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
3968 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
3969 "ld 11, 0(11)\n\t" /* target->r11 */ \
3970 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
3973 "ld 2,-16(11)\n\t" /* restore tocptr */ \
3974 VG_CONTRACT_FRAME_BY(512) \
3975 : /*out*/ "=r" (_res) \
3976 : /*in*/ "r" (&_argvec[2]) \
3977 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
3979 lval = (__typeof__(lval)) _res; \
3982 #define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
3985 volatile OrigFn _orig = (orig); \
3986 volatile unsigned long _argvec[3+8]; \
3987 volatile unsigned long _res; \
3988 /* _argvec[0] holds current r2 across the call */ \
3989 _argvec[1] = (unsigned long)_orig.r2; \
3990 _argvec[2] = (unsigned long)_orig.nraddr; \
3991 _argvec[2+1] = (unsigned long)arg1; \
3992 _argvec[2+2] = (unsigned long)arg2; \
3993 _argvec[2+3] = (unsigned long)arg3; \
3994 _argvec[2+4] = (unsigned long)arg4; \
3995 _argvec[2+5] = (unsigned long)arg5; \
3996 _argvec[2+6] = (unsigned long)arg6; \
3997 _argvec[2+7] = (unsigned long)arg7; \
3998 _argvec[2+8] = (unsigned long)arg8; \
4001 VG_EXPAND_FRAME_BY_trashes_r3(512) \
4002 "std 2,-16(11)\n\t" /* save tocptr */ \
4003 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
4004 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
4005 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
4006 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
4007 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
4008 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
4009 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
4010 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
4011 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
4012 "ld 11, 0(11)\n\t" /* target->r11 */ \
4013 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
4016 "ld 2,-16(11)\n\t" /* restore tocptr */ \
4017 VG_CONTRACT_FRAME_BY(512) \
4018 : /*out*/ "=r" (_res) \
4019 : /*in*/ "r" (&_argvec[2]) \
4020 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
4022 lval = (__typeof__(lval)) _res; \
4025 #define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
4028 volatile OrigFn _orig = (orig); \
4029 volatile unsigned long _argvec[3+9]; \
4030 volatile unsigned long _res; \
4031 /* _argvec[0] holds current r2 across the call */ \
4032 _argvec[1] = (unsigned long)_orig.r2; \
4033 _argvec[2] = (unsigned long)_orig.nraddr; \
4034 _argvec[2+1] = (unsigned long)arg1; \
4035 _argvec[2+2] = (unsigned long)arg2; \
4036 _argvec[2+3] = (unsigned long)arg3; \
4037 _argvec[2+4] = (unsigned long)arg4; \
4038 _argvec[2+5] = (unsigned long)arg5; \
4039 _argvec[2+6] = (unsigned long)arg6; \
4040 _argvec[2+7] = (unsigned long)arg7; \
4041 _argvec[2+8] = (unsigned long)arg8; \
4042 _argvec[2+9] = (unsigned long)arg9; \
4045 VG_EXPAND_FRAME_BY_trashes_r3(512) \
4046 "std 2,-16(11)\n\t" /* save tocptr */ \
4047 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
4048 VG_EXPAND_FRAME_BY_trashes_r3(128) \
4051 "std 3,112(1)\n\t" \
4053 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
4054 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
4055 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
4056 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
4057 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
4058 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
4059 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
4060 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
4061 "ld 11, 0(11)\n\t" /* target->r11 */ \
4062 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
4065 "ld 2,-16(11)\n\t" /* restore tocptr */ \
4066 VG_CONTRACT_FRAME_BY(128) \
4067 VG_CONTRACT_FRAME_BY(512) \
4068 : /*out*/ "=r" (_res) \
4069 : /*in*/ "r" (&_argvec[2]) \
4070 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
4072 lval = (__typeof__(lval)) _res; \
4075 #define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
4076 arg7,arg8,arg9,arg10) \
4078 volatile OrigFn _orig = (orig); \
4079 volatile unsigned long _argvec[3+10]; \
4080 volatile unsigned long _res; \
4081 /* _argvec[0] holds current r2 across the call */ \
4082 _argvec[1] = (unsigned long)_orig.r2; \
4083 _argvec[2] = (unsigned long)_orig.nraddr; \
4084 _argvec[2+1] = (unsigned long)arg1; \
4085 _argvec[2+2] = (unsigned long)arg2; \
4086 _argvec[2+3] = (unsigned long)arg3; \
4087 _argvec[2+4] = (unsigned long)arg4; \
4088 _argvec[2+5] = (unsigned long)arg5; \
4089 _argvec[2+6] = (unsigned long)arg6; \
4090 _argvec[2+7] = (unsigned long)arg7; \
4091 _argvec[2+8] = (unsigned long)arg8; \
4092 _argvec[2+9] = (unsigned long)arg9; \
4093 _argvec[2+10] = (unsigned long)arg10; \
4096 VG_EXPAND_FRAME_BY_trashes_r3(512) \
4097 "std 2,-16(11)\n\t" /* save tocptr */ \
4098 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
4099 VG_EXPAND_FRAME_BY_trashes_r3(128) \
4102 "std 3,120(1)\n\t" \
4105 "std 3,112(1)\n\t" \
4107 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
4108 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
4109 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
4110 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
4111 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
4112 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
4113 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
4114 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
4115 "ld 11, 0(11)\n\t" /* target->r11 */ \
4116 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
4119 "ld 2,-16(11)\n\t" /* restore tocptr */ \
4120 VG_CONTRACT_FRAME_BY(128) \
4121 VG_CONTRACT_FRAME_BY(512) \
4122 : /*out*/ "=r" (_res) \
4123 : /*in*/ "r" (&_argvec[2]) \
4124 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
4126 lval = (__typeof__(lval)) _res; \
4129 #define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
4130 arg7,arg8,arg9,arg10,arg11) \
4132 volatile OrigFn _orig = (orig); \
4133 volatile unsigned long _argvec[3+11]; \
4134 volatile unsigned long _res; \
4135 /* _argvec[0] holds current r2 across the call */ \
4136 _argvec[1] = (unsigned long)_orig.r2; \
4137 _argvec[2] = (unsigned long)_orig.nraddr; \
4138 _argvec[2+1] = (unsigned long)arg1; \
4139 _argvec[2+2] = (unsigned long)arg2; \
4140 _argvec[2+3] = (unsigned long)arg3; \
4141 _argvec[2+4] = (unsigned long)arg4; \
4142 _argvec[2+5] = (unsigned long)arg5; \
4143 _argvec[2+6] = (unsigned long)arg6; \
4144 _argvec[2+7] = (unsigned long)arg7; \
4145 _argvec[2+8] = (unsigned long)arg8; \
4146 _argvec[2+9] = (unsigned long)arg9; \
4147 _argvec[2+10] = (unsigned long)arg10; \
4148 _argvec[2+11] = (unsigned long)arg11; \
4151 VG_EXPAND_FRAME_BY_trashes_r3(512) \
4152 "std 2,-16(11)\n\t" /* save tocptr */ \
4153 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
4154 VG_EXPAND_FRAME_BY_trashes_r3(144) \
4157 "std 3,128(1)\n\t" \
4160 "std 3,120(1)\n\t" \
4163 "std 3,112(1)\n\t" \
4165 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
4166 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
4167 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
4168 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
4169 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
4170 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
4171 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
4172 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
4173 "ld 11, 0(11)\n\t" /* target->r11 */ \
4174 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
4177 "ld 2,-16(11)\n\t" /* restore tocptr */ \
4178 VG_CONTRACT_FRAME_BY(144) \
4179 VG_CONTRACT_FRAME_BY(512) \
4180 : /*out*/ "=r" (_res) \
4181 : /*in*/ "r" (&_argvec[2]) \
4182 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
4184 lval = (__typeof__(lval)) _res; \
4187 #define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
4188 arg7,arg8,arg9,arg10,arg11,arg12) \
4190 volatile OrigFn _orig = (orig); \
4191 volatile unsigned long _argvec[3+12]; \
4192 volatile unsigned long _res; \
4193 /* _argvec[0] holds current r2 across the call */ \
4194 _argvec[1] = (unsigned long)_orig.r2; \
4195 _argvec[2] = (unsigned long)_orig.nraddr; \
4196 _argvec[2+1] = (unsigned long)arg1; \
4197 _argvec[2+2] = (unsigned long)arg2; \
4198 _argvec[2+3] = (unsigned long)arg3; \
4199 _argvec[2+4] = (unsigned long)arg4; \
4200 _argvec[2+5] = (unsigned long)arg5; \
4201 _argvec[2+6] = (unsigned long)arg6; \
4202 _argvec[2+7] = (unsigned long)arg7; \
4203 _argvec[2+8] = (unsigned long)arg8; \
4204 _argvec[2+9] = (unsigned long)arg9; \
4205 _argvec[2+10] = (unsigned long)arg10; \
4206 _argvec[2+11] = (unsigned long)arg11; \
4207 _argvec[2+12] = (unsigned long)arg12; \
4210 VG_EXPAND_FRAME_BY_trashes_r3(512) \
4211 "std 2,-16(11)\n\t" /* save tocptr */ \
4212 "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \
4213 VG_EXPAND_FRAME_BY_trashes_r3(144) \
4216 "std 3,136(1)\n\t" \
4219 "std 3,128(1)\n\t" \
4222 "std 3,120(1)\n\t" \
4225 "std 3,112(1)\n\t" \
4227 "ld 3, 8(11)\n\t" /* arg1->r3 */ \
4228 "ld 4, 16(11)\n\t" /* arg2->r4 */ \
4229 "ld 5, 24(11)\n\t" /* arg3->r5 */ \
4230 "ld 6, 32(11)\n\t" /* arg4->r6 */ \
4231 "ld 7, 40(11)\n\t" /* arg5->r7 */ \
4232 "ld 8, 48(11)\n\t" /* arg6->r8 */ \
4233 "ld 9, 56(11)\n\t" /* arg7->r9 */ \
4234 "ld 10, 64(11)\n\t" /* arg8->r10 */ \
4235 "ld 11, 0(11)\n\t" /* target->r11 */ \
4236 VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \
4239 "ld 2,-16(11)\n\t" /* restore tocptr */ \
4240 VG_CONTRACT_FRAME_BY(144) \
4241 VG_CONTRACT_FRAME_BY(512) \
4242 : /*out*/ "=r" (_res) \
4243 : /*in*/ "r" (&_argvec[2]) \
4244 : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \
4246 lval = (__typeof__(lval)) _res; \
4249 #endif /* PLAT_ppc64_aix5 */
4252 /* ------------------------------------------------------------------ */
4253 /* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS. */
4255 /* ------------------------------------------------------------------ */
4257 /* Some request codes. There are many more of these, but most are not
4258 exposed to end-user view. These are the public ones, all of the
4259 form 0x1000 + small_number.
4261 Core ones are in the range 0x00000000--0x0000ffff. The non-public
4262 ones start at 0x2000.
4265 /* These macros are used by tools -- they must be public, but don't
4266 embed them into other programs. */
4267 #define VG_USERREQ_TOOL_BASE(a,b) \
4268 ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16))
4269 #define VG_IS_TOOL_USERREQ(a, b, v) \
4270 (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000))
4272 /* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !!
4273 This enum comprises an ABI exported by Valgrind to programs
4274 which use client requests. DO NOT CHANGE THE ORDER OF THESE
4275 ENTRIES, NOR DELETE ANY -- add new ones at the end. */
4277 enum { VG_USERREQ__RUNNING_ON_VALGRIND
= 0x1001,
4278 VG_USERREQ__DISCARD_TRANSLATIONS
= 0x1002,
4280 /* These allow any function to be called from the simulated
4281 CPU but run on the real CPU. Nb: the first arg passed to
4282 the function is always the ThreadId of the running
4283 thread! So CLIENT_CALL0 actually requires a 1 arg
4285 VG_USERREQ__CLIENT_CALL0
= 0x1101,
4286 VG_USERREQ__CLIENT_CALL1
= 0x1102,
4287 VG_USERREQ__CLIENT_CALL2
= 0x1103,
4288 VG_USERREQ__CLIENT_CALL3
= 0x1104,
4290 /* Can be useful in regression testing suites -- eg. can
4291 send Valgrind's output to /dev/null and still count
4293 VG_USERREQ__COUNT_ERRORS
= 0x1201,
4295 /* These are useful and can be interpreted by any tool that
4296 tracks malloc() et al, by using vg_replace_malloc.c. */
4297 VG_USERREQ__MALLOCLIKE_BLOCK
= 0x1301,
4298 VG_USERREQ__FREELIKE_BLOCK
= 0x1302,
4299 /* Memory pool support. */
4300 VG_USERREQ__CREATE_MEMPOOL
= 0x1303,
4301 VG_USERREQ__DESTROY_MEMPOOL
= 0x1304,
4302 VG_USERREQ__MEMPOOL_ALLOC
= 0x1305,
4303 VG_USERREQ__MEMPOOL_FREE
= 0x1306,
4304 VG_USERREQ__MEMPOOL_TRIM
= 0x1307,
4305 VG_USERREQ__MOVE_MEMPOOL
= 0x1308,
4306 VG_USERREQ__MEMPOOL_CHANGE
= 0x1309,
4307 VG_USERREQ__MEMPOOL_EXISTS
= 0x130a,
4309 /* Allow printfs to valgrind log. */
4310 /* The first two pass the va_list argument by value, which
4311 assumes it is the same size as or smaller than a UWord,
4312 which generally isn't the case. Hence are deprecated.
4313 The second two pass the vargs by reference and so are
4314 immune to this problem. */
4315 /* both :: char* fmt, va_list vargs (DEPRECATED) */
4316 VG_USERREQ__PRINTF
= 0x1401,
4317 VG_USERREQ__PRINTF_BACKTRACE
= 0x1402,
4318 /* both :: char* fmt, va_list* vargs */
4319 VG_USERREQ__PRINTF_VALIST_BY_REF
= 0x1403,
4320 VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF
= 0x1404,
4322 /* Stack support. */
4323 VG_USERREQ__STACK_REGISTER
= 0x1501,
4324 VG_USERREQ__STACK_DEREGISTER
= 0x1502,
4325 VG_USERREQ__STACK_CHANGE
= 0x1503,
4328 VG_USERREQ__LOAD_PDB_DEBUGINFO
= 0x1601,
4330 /* Querying of debug info. */
4331 VG_USERREQ__MAP_IP_TO_SRCLOC
= 0x1701
4334 #if !defined(__GNUC__)
4335 # define __extension__ /* */
4340 * VALGRIND_DO_CLIENT_REQUEST_EXPR(): a C expression that invokes a Valgrind
4341 * client request and whose value equals the client request result.
4344 #if defined(NVALGRIND)
4346 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \
4347 _zzq_default, _zzq_request, \
4348 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
4351 #else /*defined(NVALGRIND)*/
4353 #if defined(_MSC_VER)
4355 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \
4356 _zzq_default, _zzq_request, \
4357 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
4358 (vg_VALGRIND_DO_CLIENT_REQUEST_EXPR((uintptr_t)(_zzq_default), \
4359 (_zzq_request), (uintptr_t)(_zzq_arg1), (uintptr_t)(_zzq_arg2), \
4360 (uintptr_t)(_zzq_arg3), (uintptr_t)(_zzq_arg4), \
4361 (uintptr_t)(_zzq_arg5)))
4363 static __inline
unsigned
4364 vg_VALGRIND_DO_CLIENT_REQUEST_EXPR(uintptr_t _zzq_default
,
4365 unsigned _zzq_request
, uintptr_t _zzq_arg1
,
4366 uintptr_t _zzq_arg2
, uintptr_t _zzq_arg3
,
4367 uintptr_t _zzq_arg4
, uintptr_t _zzq_arg5
)
4369 unsigned _zzq_rlval
;
4370 VALGRIND_DO_CLIENT_REQUEST(_zzq_rlval
, _zzq_default
, _zzq_request
,
4371 _zzq_arg1
, _zzq_arg2
, _zzq_arg3
, _zzq_arg4
, _zzq_arg5
);
4375 #else /*defined(_MSC_VER)*/
4377 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \
4378 _zzq_default, _zzq_request, \
4379 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
4380 (__extension__({unsigned int _zzq_rlval; \
4381 VALGRIND_DO_CLIENT_REQUEST(_zzq_rlval, _zzq_default, _zzq_request, \
4382 _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \
4386 #endif /*defined(_MSC_VER)*/
4388 #endif /*defined(NVALGRIND)*/
4391 /* Returns the number of Valgrinds this code is running under. That
4392 is, 0 if running natively, 1 if running under Valgrind, 2 if
4393 running under Valgrind which is running under another Valgrind,
4395 #define RUNNING_ON_VALGRIND \
4396 VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* if not */, \
4397 VG_USERREQ__RUNNING_ON_VALGRIND, \
4401 /* Discard translation of code in the range [_qzz_addr .. _qzz_addr +
4402 _qzz_len - 1]. Useful if you are debugging a JITter or some such,
4403 since it provides a way to make sure valgrind will retranslate the
4404 invalidated area. Returns no value. */
4405 #define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len) \
4406 {unsigned int _qzz_res; \
4407 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4408 VG_USERREQ__DISCARD_TRANSLATIONS, \
4409 _qzz_addr, _qzz_len, 0, 0, 0); \
4413 /* These requests are for getting Valgrind itself to print something.
4414 Possibly with a backtrace. This is a really ugly hack. The return value
4415 is the number of characters printed, excluding the "**<pid>** " part at the
4416 start and the backtrace (if present). */
4418 #if defined(NVALGRIND)
4420 # define VALGRIND_PRINTF(...)
4421 # define VALGRIND_PRINTF_BACKTRACE(...)
4423 #else /* NVALGRIND */
4425 #if !defined(_MSC_VER)
4426 /* Modern GCC will optimize the static routine out if unused,
4427 and unused attribute will shut down warnings about it. */
4428 static int VALGRIND_PRINTF(const char *format
, ...)
4429 __attribute__((format(__printf__
, 1, 2), __unused__
));
4432 #if defined(_MSC_VER)
4435 VALGRIND_PRINTF(const char *format
, ...)
4437 unsigned long _qzz_res
;
4439 va_start(vargs
, format
);
4440 #if defined(_MSC_VER)
4441 VALGRIND_DO_CLIENT_REQUEST(_qzz_res
, 0,
4442 VG_USERREQ__PRINTF_VALIST_BY_REF
,
4447 VALGRIND_DO_CLIENT_REQUEST(_qzz_res
, 0,
4448 VG_USERREQ__PRINTF_VALIST_BY_REF
,
4449 (unsigned long)format
,
4450 (unsigned long)&vargs
,
4454 return (int)_qzz_res
;
4457 #if !defined(_MSC_VER)
4458 static int VALGRIND_PRINTF_BACKTRACE(const char *format
, ...)
4459 __attribute__((format(__printf__
, 1, 2), __unused__
));
4462 #if defined(_MSC_VER)
4465 VALGRIND_PRINTF_BACKTRACE(const char *format
, ...)
4467 unsigned long _qzz_res
;
4469 va_start(vargs
, format
);
4470 #if defined(_MSC_VER)
4471 VALGRIND_DO_CLIENT_REQUEST(_qzz_res
, 0,
4472 VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF
,
4477 VALGRIND_DO_CLIENT_REQUEST(_qzz_res
, 0,
4478 VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF
,
4479 (unsigned long)format
,
4480 (unsigned long)&vargs
,
4484 return (int)_qzz_res
;
4487 #endif /* NVALGRIND */
4490 /* These requests allow control to move from the simulated CPU to the
4491 real CPU, calling an arbitary function.
4493 Note that the current ThreadId is inserted as the first argument.
4496 VALGRIND_NON_SIMD_CALL2(f, arg1, arg2)
4498 requires f to have this signature:
4500 Word f(Word tid, Word arg1, Word arg2)
4502 where "Word" is a word-sized type.
4504 Note that these client requests are not entirely reliable. For example,
4505 if you call a function with them that subsequently calls printf(),
4506 there's a high chance Valgrind will crash. Generally, your prospects of
4507 these working are made higher if the called function does not refer to
4508 any global variables, and does not refer to any libc or other functions
4509 (printf et al). Any kind of entanglement with libc or dynamic linking is
4510 likely to have a bad outcome, for tricky reasons which we've grappled
4511 with a lot in the past.
4513 #define VALGRIND_NON_SIMD_CALL0(_qyy_fn) \
4515 ({unsigned long _qyy_res; \
4516 VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \
4517 VG_USERREQ__CLIENT_CALL0, \
4523 #define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1) \
4525 ({unsigned long _qyy_res; \
4526 VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \
4527 VG_USERREQ__CLIENT_CALL1, \
4529 _qyy_arg1, 0, 0, 0); \
4533 #define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2) \
4535 ({unsigned long _qyy_res; \
4536 VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \
4537 VG_USERREQ__CLIENT_CALL2, \
4539 _qyy_arg1, _qyy_arg2, 0, 0); \
4543 #define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \
4545 ({unsigned long _qyy_res; \
4546 VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \
4547 VG_USERREQ__CLIENT_CALL3, \
4549 _qyy_arg1, _qyy_arg2, \
4555 /* Counts the number of errors that have been recorded by a tool. Nb:
4556 the tool must record the errors with VG_(maybe_record_error)() or
4557 VG_(unique_error)() for them to be counted. */
4558 #define VALGRIND_COUNT_ERRORS \
4560 ({unsigned int _qyy_res; \
4561 VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \
4562 VG_USERREQ__COUNT_ERRORS, \
4567 /* Several Valgrind tools (Memcheck, Massif, Helgrind, DRD) rely on knowing
4568 when heap blocks are allocated in order to give accurate results. This
4569 happens automatically for the standard allocator functions such as
4570 malloc(), calloc(), realloc(), memalign(), new, new[], free(), delete,
4573 But if your program uses a custom allocator, this doesn't automatically
4574 happen, and Valgrind will not do as well. For example, if you allocate
4575 superblocks with mmap() and then allocates chunks of the superblocks, all
4576 Valgrind's observations will be at the mmap() level and it won't know that
4577 the chunks should be considered separate entities. In Memcheck's case,
4578 that means you probably won't get heap block overrun detection (because
4579 there won't be redzones marked as unaddressable) and you definitely won't
4580 get any leak detection.
4582 The following client requests allow a custom allocator to be annotated so
4583 that it can be handled accurately by Valgrind.
4585 VALGRIND_MALLOCLIKE_BLOCK marks a region of memory as having been allocated
4586 by a malloc()-like function. For Memcheck (an illustrative case), this
4589 - It records that the block has been allocated. This means any addresses
4590 within the block mentioned in error messages will be
4591 identified as belonging to the block. It also means that if the block
4592 isn't freed it will be detected by the leak checker.
4594 - It marks the block as being addressable and undefined (if 'is_zeroed' is
4595 not set), or addressable and defined (if 'is_zeroed' is set). This
4596 controls how accesses to the block by the program are handled.
4598 'addr' is the start of the usable block (ie. after any
4599 redzone), 'sizeB' is its size. 'rzB' is the redzone size if the allocator
4600 can apply redzones -- these are blocks of padding at the start and end of
4601 each block. Adding redzones is recommended as it makes it much more likely
4602 Valgrind will spot block overruns. `is_zeroed' indicates if the memory is
4603 zeroed (or filled with another predictable value), as is the case for
4606 VALGRIND_MALLOCLIKE_BLOCK should be put immediately after the point where a
4607 heap block -- that will be used by the client program -- is allocated.
4608 It's best to put it at the outermost level of the allocator if possible;
4609 for example, if you have a function my_alloc() which calls
4610 internal_alloc(), and the client request is put inside internal_alloc(),
4611 stack traces relating to the heap block will contain entries for both
4612 my_alloc() and internal_alloc(), which is probably not what you want.
4614 For Memcheck users: if you use VALGRIND_MALLOCLIKE_BLOCK to carve out
4615 custom blocks from within a heap block, B, that has been allocated with
4616 malloc/calloc/new/etc, then block B will be *ignored* during leak-checking
4617 -- the custom blocks will take precedence.
4619 VALGRIND_FREELIKE_BLOCK is the partner to VALGRIND_MALLOCLIKE_BLOCK. For
4620 Memcheck, it does two things:
4622 - It records that the block has been deallocated. This assumes that the
4623 block was annotated as having been allocated via
4624 VALGRIND_MALLOCLIKE_BLOCK. Otherwise, an error will be issued.
4626 - It marks the block as being unaddressable.
4628 VALGRIND_FREELIKE_BLOCK should be put immediately after the point where a
4629 heap block is deallocated.
4631 In many cases, these two client requests will not be enough to get your
4632 allocator working well with Memcheck. More specifically, if your allocator
4633 writes to freed blocks in any way then a VALGRIND_MAKE_MEM_UNDEFINED call
4634 will be necessary to mark the memory as addressable just before the zeroing
4635 occurs, otherwise you'll get a lot of invalid write errors. For example,
4636 you'll need to do this if your allocator recycles freed blocks, but it
4637 zeroes them before handing them back out (via VALGRIND_MALLOCLIKE_BLOCK).
4638 Alternatively, if your allocator reuses freed blocks for allocator-internal
4639 data structures, VALGRIND_MAKE_MEM_UNDEFINED calls will also be necessary.
4641 Really, what's happening is a blurring of the lines between the client
4642 program and the allocator... after VALGRIND_FREELIKE_BLOCK is called, the
4643 memory should be considered unaddressable to the client program, but the
4644 allocator knows more than the rest of the client program and so may be able
4645 to safely access it. Extra client requests are necessary for Valgrind to
4646 understand the distinction between the allocator and the rest of the
4649 Note: there is currently no VALGRIND_REALLOCLIKE_BLOCK client request; it
4650 has to be emulated with MALLOCLIKE/FREELIKE and memory copying.
4652 Ignored if addr == 0.
4654 #define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) \
4655 {unsigned int _qzz_res; \
4656 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4657 VG_USERREQ__MALLOCLIKE_BLOCK, \
4658 addr, sizeB, rzB, is_zeroed, 0); \
4661 /* See the comment for VALGRIND_MALLOCLIKE_BLOCK for details.
4662 Ignored if addr == 0.
4664 #define VALGRIND_FREELIKE_BLOCK(addr, rzB) \
4665 {unsigned int _qzz_res; \
4666 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4667 VG_USERREQ__FREELIKE_BLOCK, \
4668 addr, rzB, 0, 0, 0); \
4671 /* Create a memory pool. */
4672 #define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) \
4673 {unsigned int _qzz_res; \
4674 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4675 VG_USERREQ__CREATE_MEMPOOL, \
4676 pool, rzB, is_zeroed, 0, 0); \
4679 /* Destroy a memory pool. */
4680 #define VALGRIND_DESTROY_MEMPOOL(pool) \
4681 {unsigned int _qzz_res; \
4682 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4683 VG_USERREQ__DESTROY_MEMPOOL, \
4684 pool, 0, 0, 0, 0); \
4687 /* Associate a piece of memory with a memory pool. */
4688 #define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) \
4689 {unsigned int _qzz_res; \
4690 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4691 VG_USERREQ__MEMPOOL_ALLOC, \
4692 pool, addr, size, 0, 0); \
4695 /* Disassociate a piece of memory from a memory pool. */
4696 #define VALGRIND_MEMPOOL_FREE(pool, addr) \
4697 {unsigned int _qzz_res; \
4698 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4699 VG_USERREQ__MEMPOOL_FREE, \
4700 pool, addr, 0, 0, 0); \
4703 /* Disassociate any pieces outside a particular range. */
4704 #define VALGRIND_MEMPOOL_TRIM(pool, addr, size) \
4705 {unsigned int _qzz_res; \
4706 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4707 VG_USERREQ__MEMPOOL_TRIM, \
4708 pool, addr, size, 0, 0); \
4711 /* Resize and/or move a piece associated with a memory pool. */
4712 #define VALGRIND_MOVE_MEMPOOL(poolA, poolB) \
4713 {unsigned int _qzz_res; \
4714 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4715 VG_USERREQ__MOVE_MEMPOOL, \
4716 poolA, poolB, 0, 0, 0); \
4719 /* Resize and/or move a piece associated with a memory pool. */
4720 #define VALGRIND_MEMPOOL_CHANGE(pool, addrA, addrB, size) \
4721 {unsigned int _qzz_res; \
4722 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4723 VG_USERREQ__MEMPOOL_CHANGE, \
4724 pool, addrA, addrB, size, 0); \
4727 /* Return 1 if a mempool exists, else 0. */
4728 #define VALGRIND_MEMPOOL_EXISTS(pool) \
4730 ({unsigned int _qzz_res; \
4731 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4732 VG_USERREQ__MEMPOOL_EXISTS, \
4733 pool, 0, 0, 0, 0); \
4737 /* Mark a piece of memory as being a stack. Returns a stack id. */
4738 #define VALGRIND_STACK_REGISTER(start, end) \
4740 ({unsigned int _qzz_res; \
4741 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4742 VG_USERREQ__STACK_REGISTER, \
4743 start, end, 0, 0, 0); \
4747 /* Unmark the piece of memory associated with a stack id as being a
4749 #define VALGRIND_STACK_DEREGISTER(id) \
4750 {unsigned int _qzz_res; \
4751 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4752 VG_USERREQ__STACK_DEREGISTER, \
4756 /* Change the start and end address of the stack id. */
4757 #define VALGRIND_STACK_CHANGE(id, start, end) \
4758 {unsigned int _qzz_res; \
4759 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4760 VG_USERREQ__STACK_CHANGE, \
4761 id, start, end, 0, 0); \
4764 /* Load PDB debug info for Wine PE image_map. */
4765 #define VALGRIND_LOAD_PDB_DEBUGINFO(fd, ptr, total_size, delta) \
4766 {unsigned int _qzz_res; \
4767 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4768 VG_USERREQ__LOAD_PDB_DEBUGINFO, \
4769 fd, ptr, total_size, delta, 0); \
4772 /* Map a code address to a source file name and line number. buf64
4773 must point to a 64-byte buffer in the caller's address space. The
4774 result will be dumped in there and is guaranteed to be zero
4775 terminated. If no info is found, the first byte is set to zero. */
4776 #define VALGRIND_MAP_IP_TO_SRCLOC(addr, buf64) \
4777 {unsigned int _qzz_res; \
4778 VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
4779 VG_USERREQ__MAP_IP_TO_SRCLOC, \
4780 addr, buf64, 0, 0, 0); \
4784 #undef PLAT_x86_linux
4785 #undef PLAT_amd64_linux
4786 #undef PLAT_ppc32_linux
4787 #undef PLAT_ppc64_linux
4788 #undef PLAT_arm_linux
4789 #undef PLAT_ppc32_aix5
4790 #undef PLAT_ppc64_aix5
4792 #endif /* __VALGRIND_H */