valgrind.h revision 112711afefcfcd43680c7c4aa8d38ef180e8811e
1b5f6f51ebcac183818061bf53427a3e7808ef10dsewardj/* -*- c -*-
2e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   ----------------------------------------------------------------
3e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn
4e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   Notice that the following BSD-style license applies to this one
57fd15d674f18757167305947732057099e175914njn   file (valgrind.h) only.  The rest of Valgrind is licensed under the
67fd15d674f18757167305947732057099e175914njn   terms of the GNU General Public License, version 2, unless
77fd15d674f18757167305947732057099e175914njn   otherwise indicated.  See the COPYING file in the source
87fd15d674f18757167305947732057099e175914njn   distribution for details.
9e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn
10e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   ----------------------------------------------------------------
11e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn
12b9c427c63a278cc612ae0ec573be7bb1abaa447fnjn   This file is part of Valgrind, a dynamic binary instrumentation
13b9c427c63a278cc612ae0ec573be7bb1abaa447fnjn   framework.
14de4a1d01951937632098a6cda45859afa587a06fsewardj
150f157ddb404bcde7815a1c5bf2d7e41c114f3d73sewardj   Copyright (C) 2000-2013 Julian Seward.  All rights reserved.
16e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn
17e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   Redistribution and use in source and binary forms, with or without
18e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   modification, are permitted provided that the following conditions
19e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   are met:
20e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn
21e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   1. Redistributions of source code must retain the above copyright
22e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn      notice, this list of conditions and the following disclaimer.
23e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn
24e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   2. The origin of this software must not be misrepresented; you must
25e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn      not claim that you wrote the original software.  If you use this
26e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn      software in a product, an acknowledgment in the product
27e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn      documentation would be appreciated but is not required.
28de4a1d01951937632098a6cda45859afa587a06fsewardj
29e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   3. Altered source versions must be plainly marked as such, and must
30e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn      not be misrepresented as being the original software.
31de4a1d01951937632098a6cda45859afa587a06fsewardj
32e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   4. The name of the author may not be used to endorse or promote
33e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn      products derived from this software without specific prior written
34e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn      permission.
35de4a1d01951937632098a6cda45859afa587a06fsewardj
36e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
37e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
40e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47de4a1d01951937632098a6cda45859afa587a06fsewardj
48e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   ----------------------------------------------------------------
49e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn
50e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   Notice that the above BSD-style license applies to this one file
51e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   (valgrind.h) only.  The entire rest of Valgrind is licensed under
52e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   the terms of the GNU General Public License, version 2.  See the
53e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   COPYING file in the source distribution for details.
54e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn
55e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   ----------------------------------------------------------------
56de4a1d01951937632098a6cda45859afa587a06fsewardj*/
57de4a1d01951937632098a6cda45859afa587a06fsewardj
58de4a1d01951937632098a6cda45859afa587a06fsewardj
5930d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* This file is for inclusion into client (your!) code.
6030d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn
6130d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   You can use these macros to manipulate and query Valgrind's
6230d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   execution inside your own programs.
6330d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn
6430d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   The resulting executables will still run without Valgrind, just a
6530d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   little bit more slowly than they otherwise would, but otherwise
6630d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   unchanged.  When not running on valgrind, each client request
670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   consumes very few (eg. 7) instructions, so the resulting performance
6830d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   loss is negligible unless you plan to execute client requests
6930d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   millions of times per second.  Nevertheless, if that is still a
7030d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   problem, you can compile with the NVALGRIND symbol defined (gcc
7130d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn   -DNVALGRIND) so that client requests are not even compiled in.  */
7230d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn
73de4a1d01951937632098a6cda45859afa587a06fsewardj#ifndef __VALGRIND_H
74de4a1d01951937632098a6cda45859afa587a06fsewardj#define __VALGRIND_H
75de4a1d01951937632098a6cda45859afa587a06fsewardj
767104416748e90239b97560f5d727da107e3e08a9sewardj
777104416748e90239b97560f5d727da107e3e08a9sewardj/* ------------------------------------------------------------------ */
787104416748e90239b97560f5d727da107e3e08a9sewardj/* VERSION NUMBER OF VALGRIND                                         */
797104416748e90239b97560f5d727da107e3e08a9sewardj/* ------------------------------------------------------------------ */
807104416748e90239b97560f5d727da107e3e08a9sewardj
817104416748e90239b97560f5d727da107e3e08a9sewardj/* Specify Valgrind's version number, so that user code can
820fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj   conditionally compile based on our version number.  Note that these
830fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj   were introduced at version 3.6 and so do not exist in version 3.5
840fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj   or earlier.  The recommended way to use them to check for "version
850fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj   X.Y or later" is (eg)
860fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj
870fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj#if defined(__VALGRIND_MAJOR__) && defined(__VALGRIND_MINOR__)   \
880fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj    && (__VALGRIND_MAJOR__ > 3                                   \
890fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj        || (__VALGRIND_MAJOR__ == 3 && __VALGRIND_MINOR__ >= 6))
900fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj*/
910fe1d4c134ba889ff5e0a3b1b4dc8f36e610ca97sewardj#define __VALGRIND_MAJOR__    3
92bd830b45bf40e077fb5c0ea6333a416971c253cdsewardj#define __VALGRIND_MINOR__    10
937104416748e90239b97560f5d727da107e3e08a9sewardj
947104416748e90239b97560f5d727da107e3e08a9sewardj
9539de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge#include <stdarg.h>
9639de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge
973dd0a912e48a4884ee51ab3afe41856c165185canjn/* Nb: this file might be included in a file compiled with -ansi.  So
983dd0a912e48a4884ee51ab3afe41856c165185canjn   we can't use C++ style "//" comments nor the "asm" keyword (instead
993dd0a912e48a4884ee51ab3afe41856c165185canjn   use "__asm__"). */
1003dd0a912e48a4884ee51ab3afe41856c165185canjn
101f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* Derive some tags indicating what the target platform is.  Note
1020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   that in this file we're using the compiler's CPP symbols for
1030ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   identifying architectures, which are different to the ones we use
1040ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   within the rest of Valgrind.  Note, __powerpc__ is active for both
1050ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   32 and 64-bit PPC, whereas __powerpc64__ is only active for the
10659570ffbe31930ab4d678754daaeec0715117a3dsewardj   latter (on Linux, that is).
10759570ffbe31930ab4d678754daaeec0715117a3dsewardj
10859570ffbe31930ab4d678754daaeec0715117a3dsewardj   Misc note: how to find out what's predefined in gcc by default:
10959570ffbe31930ab4d678754daaeec0715117a3dsewardj   gcc -Wp,-dM somefile.c
11059570ffbe31930ab4d678754daaeec0715117a3dsewardj*/
1117af3230a91de23a737946c1b4649b2f826672bf6sewardj#undef PLAT_x86_darwin
1127af3230a91de23a737946c1b4649b2f826672bf6sewardj#undef PLAT_amd64_darwin
1137f489813d200fb614a0856fca05e2f9ebf66dd48bart#undef PLAT_x86_win32
114aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#undef PLAT_amd64_win64
115f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_x86_linux
116f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_amd64_linux
117f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_ppc32_linux
118cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#undef PLAT_ppc64be_linux
119582d58245637ab05272d89fb94b12fd0f18fa0f8carll#undef PLAT_ppc64le_linux
12059570ffbe31930ab4d678754daaeec0715117a3dsewardj#undef PLAT_arm_linux
121f0c1250e324f6684757c6a15545366447ef1d64fsewardj#undef PLAT_arm64_linux
122b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#undef PLAT_s390x_linux
1235db15403e889d4db339b342bc2a824ef0bfaa654sewardj#undef PLAT_mips32_linux
1244df0bfc0614379192c780c944415dc420d9cfe8epetarj#undef PLAT_mips64_linux
125112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#undef PLAT_tilegx_linux
126b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
127f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj
1286e9de463ef677f093e9f24f126e1b11c28cf59fdsewardj#if defined(__APPLE__) && defined(__i386__)
129f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#  define PLAT_x86_darwin 1
130f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#elif defined(__APPLE__) && defined(__x86_64__)
131f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#  define PLAT_amd64_darwin 1
132c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#elif (defined(__MINGW32__) && !defined(__MINGW64__)) \
133c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj      || defined(__CYGWIN32__) \
1346e9de463ef677f093e9f24f126e1b11c28cf59fdsewardj      || (defined(_WIN32) && defined(_M_IX86))
1357f489813d200fb614a0856fca05e2f9ebf66dd48bart#  define PLAT_x86_win32 1
136c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#elif defined(__MINGW64__) \
137c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj      || (defined(_WIN64) && defined(_M_X64))
138aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#  define PLAT_amd64_win64 1
13959570ffbe31930ab4d678754daaeec0715117a3dsewardj#elif defined(__linux__) && defined(__i386__)
140f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#  define PLAT_x86_linux 1
14159570ffbe31930ab4d678754daaeec0715117a3dsewardj#elif defined(__linux__) && defined(__x86_64__)
142f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#  define PLAT_amd64_linux 1
14359570ffbe31930ab4d678754daaeec0715117a3dsewardj#elif defined(__linux__) && defined(__powerpc__) && !defined(__powerpc64__)
144f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#  define PLAT_ppc32_linux 1
145cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__) && _CALL_ELF != 2
146cae0cc22b83ffb260ee8379e92099c5a701944cbcarll/* Big Endian uses ELF version 1 */
147cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#  define PLAT_ppc64be_linux 1
148582d58245637ab05272d89fb94b12fd0f18fa0f8carll#elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__) && _CALL_ELF == 2
149582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* Little Endian uses ELF version 2 */
150582d58245637ab05272d89fb94b12fd0f18fa0f8carll#  define PLAT_ppc64le_linux 1
151f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(__linux__) && defined(__arm__) && !defined(__aarch64__)
15259570ffbe31930ab4d678754daaeec0715117a3dsewardj#  define PLAT_arm_linux 1
153f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(__linux__) && defined(__aarch64__) && !defined(__arm__)
154f0c1250e324f6684757c6a15545366447ef1d64fsewardj#  define PLAT_arm64_linux 1
155b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#elif defined(__linux__) && defined(__s390__) && defined(__s390x__)
156b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define PLAT_s390x_linux 1
157f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(__linux__) && defined(__mips__) && (__mips==64)
1584df0bfc0614379192c780c944415dc420d9cfe8epetarj#  define PLAT_mips64_linux 1
159f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(__linux__) && defined(__mips__) && (__mips!=64)
1605db15403e889d4db339b342bc2a824ef0bfaa654sewardj#  define PLAT_mips32_linux 1
161112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#elif defined(__linux__) && defined(__tilegx__)
162112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#  define PLAT_tilegx_linux 1
163f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#else
164f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* If we're not compiling for our target platform, don't generate
1650ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   any inline asms.  */
1660ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#  if !defined(NVALGRIND)
1670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#    define NVALGRIND 1
1680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#  endif
169b5f6f51ebcac183818061bf53427a3e7808ef10dsewardj#endif
170b5f6f51ebcac183818061bf53427a3e7808ef10dsewardj
1710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
17230d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* ------------------------------------------------------------------ */
1730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ARCHITECTURE SPECIFICS for SPECIAL INSTRUCTIONS.  There is nothing */
1740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* in here of use to end-users -- skip to the next section.           */
17530d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* ------------------------------------------------------------------ */
176de4a1d01951937632098a6cda45859afa587a06fsewardj
177575ce8ef8fa86a502dabe152293320676922dcfebart/*
178575ce8ef8fa86a502dabe152293320676922dcfebart * VALGRIND_DO_CLIENT_REQUEST(): a statement that invokes a Valgrind client
179575ce8ef8fa86a502dabe152293320676922dcfebart * request. Accepts both pointers and integers as arguments.
180575ce8ef8fa86a502dabe152293320676922dcfebart *
1814b3a74204894e943c43cb8e8aae39d813040702csewardj * VALGRIND_DO_CLIENT_REQUEST_STMT(): a statement that invokes a Valgrind
1824b3a74204894e943c43cb8e8aae39d813040702csewardj * client request that does not return a value.
1834b3a74204894e943c43cb8e8aae39d813040702csewardj
184575ce8ef8fa86a502dabe152293320676922dcfebart * VALGRIND_DO_CLIENT_REQUEST_EXPR(): a C expression that invokes a Valgrind
1854b3a74204894e943c43cb8e8aae39d813040702csewardj * client request and whose value equals the client request result.  Accepts
1864b3a74204894e943c43cb8e8aae39d813040702csewardj * both pointers and integers as arguments.  Note that such calls are not
1874b3a74204894e943c43cb8e8aae39d813040702csewardj * necessarily pure functions -- they may have side effects.
188575ce8ef8fa86a502dabe152293320676922dcfebart */
189575ce8ef8fa86a502dabe152293320676922dcfebart
190575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST(_zzq_rlval, _zzq_default,            \
191575ce8ef8fa86a502dabe152293320676922dcfebart                                   _zzq_request, _zzq_arg1, _zzq_arg2,  \
192575ce8ef8fa86a502dabe152293320676922dcfebart                                   _zzq_arg3, _zzq_arg4, _zzq_arg5)     \
19317dfe1addc98de357b9e24ddbe4ad7df4454873aflorian  do { (_zzq_rlval) = VALGRIND_DO_CLIENT_REQUEST_EXPR((_zzq_default),   \
194575ce8ef8fa86a502dabe152293320676922dcfebart                        (_zzq_request), (_zzq_arg1), (_zzq_arg2),       \
19517dfe1addc98de357b9e24ddbe4ad7df4454873aflorian                        (_zzq_arg3), (_zzq_arg4), (_zzq_arg5)); } while (0)
196575ce8ef8fa86a502dabe152293320676922dcfebart
1974b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_DO_CLIENT_REQUEST_STMT(_zzq_request, _zzq_arg1,        \
1984b3a74204894e943c43cb8e8aae39d813040702csewardj                           _zzq_arg2,  _zzq_arg3, _zzq_arg4, _zzq_arg5) \
1994b3a74204894e943c43cb8e8aae39d813040702csewardj  do { (void) VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                        \
2004b3a74204894e943c43cb8e8aae39d813040702csewardj                    (_zzq_request), (_zzq_arg1), (_zzq_arg2),           \
2014b3a74204894e943c43cb8e8aae39d813040702csewardj                    (_zzq_arg3), (_zzq_arg4), (_zzq_arg5)); } while (0)
2024b3a74204894e943c43cb8e8aae39d813040702csewardj
2030ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#if defined(NVALGRIND)
20426aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn
20526aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn/* Define NVALGRIND to completely remove the Valgrind magic sequence
2060ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   from the compiled code (analogous to NDEBUG's effects on
2070ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   assert()) */
208575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
209575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
2109af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
211575ce8ef8fa86a502dabe152293320676922dcfebart      (_zzq_default)
21226aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn
2130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#else  /* ! NVALGRIND */
2140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* The following defines the magic code sequences which the JITter
2160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   spots and handles magically.  Don't look too closely at them as
2170ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   they will rot your brain.
218de4a1d01951937632098a6cda45859afa587a06fsewardj
2190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   The assembly code sequences for all architectures is in this one
2200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   file.  This is because this file must be stand-alone, and we don't
2210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   want to have multiple files.
2220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   For VALGRIND_DO_CLIENT_REQUEST, we must ensure that the default
2240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   value gets put in the return slot, so that everything works when
2250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   this is executed not under Valgrind.  Args are passed in a memory
2260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   block, and so there's no intrinsic limit to the number that could
2279af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj   be passed, but it's currently five.
228e90c6836fd430124799e52896c99ea27b1c88541nethercote
2295426544c9c3fc835ead99fae9e2054625110ef3enethercote   The macro args are:
2305426544c9c3fc835ead99fae9e2054625110ef3enethercote      _zzq_rlval    result lvalue
2315426544c9c3fc835ead99fae9e2054625110ef3enethercote      _zzq_default  default value (result returned when running on real CPU)
2325426544c9c3fc835ead99fae9e2054625110ef3enethercote      _zzq_request  request code
2339af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj      _zzq_arg1..5  request params
2345426544c9c3fc835ead99fae9e2054625110ef3enethercote
2350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   The other two macros are used to support function wrapping, and are
236d68ac3e974d25f88492774f6baa491999afde9f9sewardj   a lot simpler.  VALGRIND_GET_NR_CONTEXT returns the value of the
237d68ac3e974d25f88492774f6baa491999afde9f9sewardj   guest's NRADDR pseudo-register and whatever other information is
238d68ac3e974d25f88492774f6baa491999afde9f9sewardj   needed to safely run the call original from the wrapper: on
239d68ac3e974d25f88492774f6baa491999afde9f9sewardj   ppc64-linux, the R2 value at the divert point is also needed.  This
240d68ac3e974d25f88492774f6baa491999afde9f9sewardj   information is abstracted into a user-visible type, OrigFn.
241d68ac3e974d25f88492774f6baa491999afde9f9sewardj
242d68ac3e974d25f88492774f6baa491999afde9f9sewardj   VALGRIND_CALL_NOREDIR_* behaves the same as the following on the
243d68ac3e974d25f88492774f6baa491999afde9f9sewardj   guest, but guarantees that the branch instruction will not be
244d68ac3e974d25f88492774f6baa491999afde9f9sewardj   redirected: x86: call *%eax, amd64: call *%rax, ppc32/ppc64:
245d68ac3e974d25f88492774f6baa491999afde9f9sewardj   branch-and-link-to-r11.  VALGRIND_CALL_NOREDIR is just text, not a
246d68ac3e974d25f88492774f6baa491999afde9f9sewardj   complete inline asm, since it needs to be combined with more magic
247d68ac3e974d25f88492774f6baa491999afde9f9sewardj   inline asm stuff to be useful.
248e90c6836fd430124799e52896c99ea27b1c88541nethercote*/
249de4a1d01951937632098a6cda45859afa587a06fsewardj
250f76d27a697a7b0bf3b84490baf60623fc96a23afnjn/* ------------------------- x86-{linux,darwin} ---------------- */
2510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
252520a03a4c59703908bae4cc437814abf0a24cdcdsewardj#if defined(PLAT_x86_linux)  ||  defined(PLAT_x86_darwin)  \
253602278444fa6b4135a44d19ae833ed42a9898e48sewardj    ||  (defined(PLAT_x86_win32) && defined(__GNUC__))
254c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj
255c885844f7484a13bcf1c7f9b14cf5bc527462963sewardjtypedef
256c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   struct {
257c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj      unsigned int nraddr; /* where's the code? */
258c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   }
259c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   OrigFn;
260c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj
2610ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
2620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "roll $3,  %%edi ; roll $13, %%edi\n\t"      \
2631a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "roll $29, %%edi ; roll $19, %%edi\n\t"
2640ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
265575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
266575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
2679af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
268575ce8ef8fa86a502dabe152293320676922dcfebart  __extension__                                                   \
269575ce8ef8fa86a502dabe152293320676922dcfebart  ({volatile unsigned int _zzq_args[6];                           \
2700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    volatile unsigned int _zzq_result;                            \
2710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
2720ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
2730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
2740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
2750ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
2769af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
2770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
2780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %EDX = client_request ( %EAX ) */         \
2790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgl %%ebx,%%ebx"                          \
2800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "=d" (_zzq_result)                         \
2810ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
2820ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "cc", "memory"                             \
2830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
284575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
285575ce8ef8fa86a502dabe152293320676922dcfebart  })
2860ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
287c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
288c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
289c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj    volatile unsigned int __addr;                                 \
2900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
2910ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %EAX = guest_NRADDR */                    \
2920ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgl %%ecx,%%ecx"                          \
2930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "=a" (__addr)                              \
2940ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     :                                            \
2950ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "cc", "memory"                             \
2960ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
297c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj    _zzq_orig->nraddr = __addr;                                   \
298ca0518df66f8c3375a860f1a55a51f18e2a16c44njn  }
2990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
3000ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_CALL_NOREDIR_EAX                                 \
3010ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
3020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* call-noredir *%EAX */                     \
3030ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgl %%edx,%%edx\n\t"
304bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
305bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
306bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
307bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
308bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "xchgl %%edi,%%edi\n\t"                     \
309bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     : : : "cc", "memory"                        \
310bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
311bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
312bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
313602278444fa6b4135a44d19ae833ed42a9898e48sewardj#endif /* PLAT_x86_linux || PLAT_x86_darwin || (PLAT_x86_win32 && __GNUC__) */
3147f489813d200fb614a0856fca05e2f9ebf66dd48bart
3157f489813d200fb614a0856fca05e2f9ebf66dd48bart/* ------------------------- x86-Win32 ------------------------- */
3167f489813d200fb614a0856fca05e2f9ebf66dd48bart
3177f489813d200fb614a0856fca05e2f9ebf66dd48bart#if defined(PLAT_x86_win32) && !defined(__GNUC__)
3187f489813d200fb614a0856fca05e2f9ebf66dd48bart
3197f489813d200fb614a0856fca05e2f9ebf66dd48barttypedef
3207f489813d200fb614a0856fca05e2f9ebf66dd48bart   struct {
3217f489813d200fb614a0856fca05e2f9ebf66dd48bart      unsigned int nraddr; /* where's the code? */
3227f489813d200fb614a0856fca05e2f9ebf66dd48bart   }
3237f489813d200fb614a0856fca05e2f9ebf66dd48bart   OrigFn;
3247f489813d200fb614a0856fca05e2f9ebf66dd48bart
3257f489813d200fb614a0856fca05e2f9ebf66dd48bart#if defined(_MSC_VER)
3267f489813d200fb614a0856fca05e2f9ebf66dd48bart
3277f489813d200fb614a0856fca05e2f9ebf66dd48bart#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
3287f489813d200fb614a0856fca05e2f9ebf66dd48bart                     __asm rol edi, 3  __asm rol edi, 13          \
3297f489813d200fb614a0856fca05e2f9ebf66dd48bart                     __asm rol edi, 29 __asm rol edi, 19
3307f489813d200fb614a0856fca05e2f9ebf66dd48bart
331575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
332575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
3337f489813d200fb614a0856fca05e2f9ebf66dd48bart        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
334575ce8ef8fa86a502dabe152293320676922dcfebart    valgrind_do_client_request_expr((uintptr_t)(_zzq_default),    \
335575ce8ef8fa86a502dabe152293320676922dcfebart        (uintptr_t)(_zzq_request), (uintptr_t)(_zzq_arg1),        \
336575ce8ef8fa86a502dabe152293320676922dcfebart        (uintptr_t)(_zzq_arg2), (uintptr_t)(_zzq_arg3),           \
337575ce8ef8fa86a502dabe152293320676922dcfebart        (uintptr_t)(_zzq_arg4), (uintptr_t)(_zzq_arg5))
338575ce8ef8fa86a502dabe152293320676922dcfebart
339575ce8ef8fa86a502dabe152293320676922dcfebartstatic __inline uintptr_t
340575ce8ef8fa86a502dabe152293320676922dcfebartvalgrind_do_client_request_expr(uintptr_t _zzq_default, uintptr_t _zzq_request,
341575ce8ef8fa86a502dabe152293320676922dcfebart                                uintptr_t _zzq_arg1, uintptr_t _zzq_arg2,
342575ce8ef8fa86a502dabe152293320676922dcfebart                                uintptr_t _zzq_arg3, uintptr_t _zzq_arg4,
343575ce8ef8fa86a502dabe152293320676922dcfebart                                uintptr_t _zzq_arg5)
344575ce8ef8fa86a502dabe152293320676922dcfebart{
345575ce8ef8fa86a502dabe152293320676922dcfebart    volatile uintptr_t _zzq_args[6];
346575ce8ef8fa86a502dabe152293320676922dcfebart    volatile unsigned int _zzq_result;
347575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[0] = (uintptr_t)(_zzq_request);
348575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[1] = (uintptr_t)(_zzq_arg1);
349575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[2] = (uintptr_t)(_zzq_arg2);
350575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[3] = (uintptr_t)(_zzq_arg3);
351575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[4] = (uintptr_t)(_zzq_arg4);
352575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[5] = (uintptr_t)(_zzq_arg5);
353575ce8ef8fa86a502dabe152293320676922dcfebart    __asm { __asm lea eax, _zzq_args __asm mov edx, _zzq_default
354575ce8ef8fa86a502dabe152293320676922dcfebart            __SPECIAL_INSTRUCTION_PREAMBLE
355575ce8ef8fa86a502dabe152293320676922dcfebart            /* %EDX = client_request ( %EAX ) */
356575ce8ef8fa86a502dabe152293320676922dcfebart            __asm xchg ebx,ebx
357575ce8ef8fa86a502dabe152293320676922dcfebart            __asm mov _zzq_result, edx
358575ce8ef8fa86a502dabe152293320676922dcfebart    }
359575ce8ef8fa86a502dabe152293320676922dcfebart    return _zzq_result;
360575ce8ef8fa86a502dabe152293320676922dcfebart}
3617f489813d200fb614a0856fca05e2f9ebf66dd48bart
3627f489813d200fb614a0856fca05e2f9ebf66dd48bart#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
3637f489813d200fb614a0856fca05e2f9ebf66dd48bart  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
3647f489813d200fb614a0856fca05e2f9ebf66dd48bart    volatile unsigned int __addr;                                 \
3657f489813d200fb614a0856fca05e2f9ebf66dd48bart    __asm { __SPECIAL_INSTRUCTION_PREAMBLE                        \
3667f489813d200fb614a0856fca05e2f9ebf66dd48bart            /* %EAX = guest_NRADDR */                             \
3677f489813d200fb614a0856fca05e2f9ebf66dd48bart            __asm xchg ecx,ecx                                    \
3687f489813d200fb614a0856fca05e2f9ebf66dd48bart            __asm mov __addr, eax                                 \
3697f489813d200fb614a0856fca05e2f9ebf66dd48bart    }                                                             \
3707f489813d200fb614a0856fca05e2f9ebf66dd48bart    _zzq_orig->nraddr = __addr;                                   \
3717f489813d200fb614a0856fca05e2f9ebf66dd48bart  }
3727f489813d200fb614a0856fca05e2f9ebf66dd48bart
3737f489813d200fb614a0856fca05e2f9ebf66dd48bart#define VALGRIND_CALL_NOREDIR_EAX ERROR
3747f489813d200fb614a0856fca05e2f9ebf66dd48bart
375bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
376bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
377bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm { __SPECIAL_INSTRUCTION_PREAMBLE                       \
378bb913cd4cc1e56d7d7798a8b754361a05d01f916florian            __asm xchg edi,edi                                   \
379bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    }                                                            \
380bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
381bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
3827f489813d200fb614a0856fca05e2f9ebf66dd48bart#else
3837f489813d200fb614a0856fca05e2f9ebf66dd48bart#error Unsupported compiler.
3847f489813d200fb614a0856fca05e2f9ebf66dd48bart#endif
3857f489813d200fb614a0856fca05e2f9ebf66dd48bart
3867f489813d200fb614a0856fca05e2f9ebf66dd48bart#endif /* PLAT_x86_win32 */
3870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
388f76d27a697a7b0bf3b84490baf60623fc96a23afnjn/* ------------------------ amd64-{linux,darwin} --------------- */
3890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
390c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#if defined(PLAT_amd64_linux)  ||  defined(PLAT_amd64_darwin) \
391c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj    ||  (defined(PLAT_amd64_win64) && defined(__GNUC__))
392c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj
393c885844f7484a13bcf1c7f9b14cf5bc527462963sewardjtypedef
394c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   struct {
3953540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int nraddr; /* where's the code? */
396c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   }
397c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   OrigFn;
398c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj
3990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
4000ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "rolq $3,  %%rdi ; rolq $13, %%rdi\n\t"      \
4011a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "rolq $61, %%rdi ; rolq $51, %%rdi\n\t"
4020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
403575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
404575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
4059af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
406575ce8ef8fa86a502dabe152293320676922dcfebart    __extension__                                                 \
4073540ee89957c352912f3ffb90484abb17cc60675florian    ({ volatile unsigned long int _zzq_args[6];                   \
4083540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int _zzq_result;                       \
4093540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);             \
4103540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
4113540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
4123540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
4133540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
4143540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
4150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
4160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %RDX = client_request ( %RAX ) */         \
4170ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgq %%rbx,%%rbx"                          \
4180ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "=d" (_zzq_result)                         \
4190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
4200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "cc", "memory"                             \
4210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
422575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
423575ce8ef8fa86a502dabe152293320676922dcfebart    })
4240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
425c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
426c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
4273540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int __addr;                            \
4280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
4290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %RAX = guest_NRADDR */                    \
4300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgq %%rcx,%%rcx"                          \
4310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "=a" (__addr)                              \
4320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     :                                            \
4330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "cc", "memory"                             \
4340ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
435c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj    _zzq_orig->nraddr = __addr;                                   \
4362c48c7b0a453d32375a4df17e153011b797ef28csewardj  }
4370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
4380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_CALL_NOREDIR_RAX                                 \
4390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
4400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* call-noredir *%RAX */                     \
4410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgq %%rdx,%%rdx\n\t"
442bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
443bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
444bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
445bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
446bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "xchgq %%rdi,%%rdi\n\t"                     \
447bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     : : : "cc", "memory"                        \
448bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
449bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
450bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
451f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#endif /* PLAT_amd64_linux || PLAT_amd64_darwin */
4520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
453c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj/* ------------------------- amd64-Win64 ------------------------- */
454c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj
455c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#if defined(PLAT_amd64_win64) && !defined(__GNUC__)
456c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj
457c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#error Unsupported compiler.
458c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj
459c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#endif /* PLAT_amd64_win64 */
460c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj
461f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* ------------------------ ppc32-linux ------------------------ */
4620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
463f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#if defined(PLAT_ppc32_linux)
464d68ac3e974d25f88492774f6baa491999afde9f9sewardj
465d68ac3e974d25f88492774f6baa491999afde9f9sewardjtypedef
466d68ac3e974d25f88492774f6baa491999afde9f9sewardj   struct {
467c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj      unsigned int nraddr; /* where's the code? */
468d68ac3e974d25f88492774f6baa491999afde9f9sewardj   }
469d68ac3e974d25f88492774f6baa491999afde9f9sewardj   OrigFn;
470d68ac3e974d25f88492774f6baa491999afde9f9sewardj
4710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
4724decb2697c3e367d9599b0ee8a11db8148bb7147sewardj                    "rlwinm 0,0,3,0,31  ; rlwinm 0,0,13,0,31\n\t" \
4734decb2697c3e367d9599b0ee8a11db8148bb7147sewardj                    "rlwinm 0,0,29,0,31 ; rlwinm 0,0,19,0,31\n\t"
4740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
475575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
476575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
4779af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
4780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                                                                  \
479575ce8ef8fa86a502dabe152293320676922dcfebart    __extension__                                                 \
480575ce8ef8fa86a502dabe152293320676922dcfebart  ({         unsigned int  _zzq_args[6];                          \
4811c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj             unsigned int  _zzq_result;                           \
4821c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj             unsigned int* _zzq_ptr;                              \
4830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
4840ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
4850ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
4860ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
4870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
4889af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
4890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_ptr = _zzq_args;                                         \
4901c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj    __asm__ volatile("mr 3,%1\n\t" /*default*/                    \
4911c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "mr 4,%2\n\t" /*ptr*/                        \
4921c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
4930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %R3 = client_request ( %R4 ) */           \
4941c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "or 1,1,1\n\t"                               \
4951c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "mr %0,3"     /*result*/                     \
4961c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "=b" (_zzq_result)                         \
4971c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "b" (_zzq_default), "b" (_zzq_ptr)         \
4981c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "cc", "memory", "r3", "r4");               \
499575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
500575ce8ef8fa86a502dabe152293320676922dcfebart    })
5010ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
502d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
503d68ac3e974d25f88492774f6baa491999afde9f9sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
5041c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj    unsigned int __addr;                                          \
5050ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
5060ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %R3 = guest_NRADDR */                     \
5071c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "or 2,2,2\n\t"                               \
5081c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "mr %0,3"                                    \
5091c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "=b" (__addr)                              \
5100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     :                                            \
5111c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "cc", "memory", "r3"                       \
5120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
513d68ac3e974d25f88492774f6baa491999afde9f9sewardj    _zzq_orig->nraddr = __addr;                                   \
5140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj  }
5150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
5160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                   \
5170ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
5180ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* branch-and-link-to-noredir *%R11 */       \
5190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "or 3,3,3\n\t"
5204d261bbb67135fef7b1f947b025a0ff6b512cc57florian
5214d261bbb67135fef7b1f947b025a0ff6b512cc57florian#define VALGRIND_VEX_INJECT_IR()                                 \
5224d261bbb67135fef7b1f947b025a0ff6b512cc57florian do {                                                            \
5234d261bbb67135fef7b1f947b025a0ff6b512cc57florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
5244d261bbb67135fef7b1f947b025a0ff6b512cc57florian                     "or 5,5,5\n\t"                              \
5254d261bbb67135fef7b1f947b025a0ff6b512cc57florian                    );                                           \
5264d261bbb67135fef7b1f947b025a0ff6b512cc57florian } while (0)
5274d261bbb67135fef7b1f947b025a0ff6b512cc57florian
528f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#endif /* PLAT_ppc32_linux */
5290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
530f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* ------------------------ ppc64-linux ------------------------ */
5310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
532cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#if defined(PLAT_ppc64be_linux)
533d68ac3e974d25f88492774f6baa491999afde9f9sewardj
534d68ac3e974d25f88492774f6baa491999afde9f9sewardjtypedef
535d68ac3e974d25f88492774f6baa491999afde9f9sewardj   struct {
5363540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int nraddr; /* where's the code? */
5373540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int r2;  /* what tocptr do we need? */
538d68ac3e974d25f88492774f6baa491999afde9f9sewardj   }
539d68ac3e974d25f88492774f6baa491999afde9f9sewardj   OrigFn;
540d68ac3e974d25f88492774f6baa491999afde9f9sewardj
5411a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
5421a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "rotldi 0,0,3  ; rotldi 0,0,13\n\t"          \
5431a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "rotldi 0,0,61 ; rotldi 0,0,51\n\t"
5441a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj
545575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
546575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
5479af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
5480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                                                                  \
549575ce8ef8fa86a502dabe152293320676922dcfebart  __extension__                                                   \
5503540ee89957c352912f3ffb90484abb17cc60675florian  ({         unsigned long int  _zzq_args[6];                     \
5513540ee89957c352912f3ffb90484abb17cc60675florian             unsigned long int  _zzq_result;                      \
5523540ee89957c352912f3ffb90484abb17cc60675florian             unsigned long int* _zzq_ptr;                         \
5533540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);             \
5543540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
5553540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
5563540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
5573540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
5583540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
5590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_ptr = _zzq_args;                                         \
5608258a3a849f8bf47146ff1740d2dac429bb453a5sewardj    __asm__ volatile("mr 3,%1\n\t" /*default*/                    \
5618258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "mr 4,%2\n\t" /*ptr*/                        \
5628258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
5631a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     /* %R3 = client_request ( %R4 ) */           \
5648258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "or 1,1,1\n\t"                               \
5658258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "mr %0,3"     /*result*/                     \
5668258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "=b" (_zzq_result)                         \
5678258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "b" (_zzq_default), "b" (_zzq_ptr)         \
5688258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "cc", "memory", "r3", "r4");               \
569575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
570575ce8ef8fa86a502dabe152293320676922dcfebart  })
5711a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj
572d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
573d68ac3e974d25f88492774f6baa491999afde9f9sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
5743540ee89957c352912f3ffb90484abb17cc60675florian    unsigned long int __addr;                                     \
5751a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
5761a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     /* %R3 = guest_NRADDR */                     \
5778258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "or 2,2,2\n\t"                               \
5788258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "mr %0,3"                                    \
5798258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "=b" (__addr)                              \
5801a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     :                                            \
5818258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "cc", "memory", "r3"                       \
5821a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                    );                                            \
583d68ac3e974d25f88492774f6baa491999afde9f9sewardj    _zzq_orig->nraddr = __addr;                                   \
584d68ac3e974d25f88492774f6baa491999afde9f9sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
585d68ac3e974d25f88492774f6baa491999afde9f9sewardj                     /* %R3 = guest_NRADDR_GPR2 */                \
5868258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "or 4,4,4\n\t"                               \
5878258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "mr %0,3"                                    \
5888258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "=b" (__addr)                              \
589d68ac3e974d25f88492774f6baa491999afde9f9sewardj                     :                                            \
5908258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "cc", "memory", "r3"                       \
591d68ac3e974d25f88492774f6baa491999afde9f9sewardj                    );                                            \
592d68ac3e974d25f88492774f6baa491999afde9f9sewardj    _zzq_orig->r2 = __addr;                                       \
5930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj  }
5941a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj
5951a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                   \
5961a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
5971a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     /* branch-and-link-to-noredir *%R11 */       \
5981a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "or 3,3,3\n\t"
5991a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj
600bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
601bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
602bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
603bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "or 5,5,5\n\t"                              \
604bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
605bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
606bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
607cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#endif /* PLAT_ppc64be_linux */
608cae0cc22b83ffb260ee8379e92099c5a701944cbcarll
609582d58245637ab05272d89fb94b12fd0f18fa0f8carll#if defined(PLAT_ppc64le_linux)
610582d58245637ab05272d89fb94b12fd0f18fa0f8carll
611582d58245637ab05272d89fb94b12fd0f18fa0f8carlltypedef
612582d58245637ab05272d89fb94b12fd0f18fa0f8carll   struct {
6133540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int nraddr; /* where's the code? */
6143540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int r2;     /* what tocptr do we need? */
615582d58245637ab05272d89fb94b12fd0f18fa0f8carll   }
616582d58245637ab05272d89fb94b12fd0f18fa0f8carll   OrigFn;
617582d58245637ab05272d89fb94b12fd0f18fa0f8carll
618582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
619582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "rotldi 0,0,3  ; rotldi 0,0,13\n\t"          \
620582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "rotldi 0,0,61 ; rotldi 0,0,51\n\t"
621582d58245637ab05272d89fb94b12fd0f18fa0f8carll
622582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
623582d58245637ab05272d89fb94b12fd0f18fa0f8carll        _zzq_default, _zzq_request,                               \
624582d58245637ab05272d89fb94b12fd0f18fa0f8carll        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
625582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                                                  \
626582d58245637ab05272d89fb94b12fd0f18fa0f8carll  __extension__                                                   \
6273540ee89957c352912f3ffb90484abb17cc60675florian  ({         unsigned long int  _zzq_args[6];                     \
6283540ee89957c352912f3ffb90484abb17cc60675florian             unsigned long int  _zzq_result;                      \
6293540ee89957c352912f3ffb90484abb17cc60675florian             unsigned long int* _zzq_ptr;                         \
6303540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);             \
6313540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
6323540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
6333540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
6343540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
6353540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
636582d58245637ab05272d89fb94b12fd0f18fa0f8carll    _zzq_ptr = _zzq_args;                                         \
637582d58245637ab05272d89fb94b12fd0f18fa0f8carll    __asm__ volatile("mr 3,%1\n\t" /*default*/                    \
638582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "mr 4,%2\n\t" /*ptr*/                        \
639582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     __SPECIAL_INSTRUCTION_PREAMBLE               \
640582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     /* %R3 = client_request ( %R4 ) */           \
641582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 1,1,1\n\t"                               \
642582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "mr %0,3"     /*result*/                     \
643582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "=b" (_zzq_result)                         \
644582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "b" (_zzq_default), "b" (_zzq_ptr)         \
645582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "cc", "memory", "r3", "r4");               \
646582d58245637ab05272d89fb94b12fd0f18fa0f8carll    _zzq_result;                                                  \
647582d58245637ab05272d89fb94b12fd0f18fa0f8carll  })
648582d58245637ab05272d89fb94b12fd0f18fa0f8carll
649582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
650582d58245637ab05272d89fb94b12fd0f18fa0f8carll  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
6513540ee89957c352912f3ffb90484abb17cc60675florian    unsigned long int __addr;                                     \
652582d58245637ab05272d89fb94b12fd0f18fa0f8carll    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
653582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     /* %R3 = guest_NRADDR */                     \
654582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 2,2,2\n\t"                               \
655582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "mr %0,3"                                    \
656582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "=b" (__addr)                              \
657582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     :                                            \
658582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "cc", "memory", "r3"                       \
659582d58245637ab05272d89fb94b12fd0f18fa0f8carll                    );                                            \
660582d58245637ab05272d89fb94b12fd0f18fa0f8carll    _zzq_orig->nraddr = __addr;                                   \
661582d58245637ab05272d89fb94b12fd0f18fa0f8carll    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
662582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     /* %R3 = guest_NRADDR_GPR2 */                \
663582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 4,4,4\n\t"                               \
664582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "mr %0,3"                                    \
665582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "=b" (__addr)                              \
666582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     :                                            \
667582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "cc", "memory", "r3"                       \
668582d58245637ab05272d89fb94b12fd0f18fa0f8carll                    );                                            \
669582d58245637ab05272d89fb94b12fd0f18fa0f8carll    _zzq_orig->r2 = __addr;                                       \
670582d58245637ab05272d89fb94b12fd0f18fa0f8carll  }
671582d58245637ab05272d89fb94b12fd0f18fa0f8carll
672582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                   \
673582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     __SPECIAL_INSTRUCTION_PREAMBLE               \
674582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     /* branch-and-link-to-noredir *%R12 */       \
675582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 3,3,3\n\t"
676582d58245637ab05272d89fb94b12fd0f18fa0f8carll
677582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_VEX_INJECT_IR()                                 \
678582d58245637ab05272d89fb94b12fd0f18fa0f8carll do {                                                            \
679582d58245637ab05272d89fb94b12fd0f18fa0f8carll    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
680582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 5,5,5\n\t"                              \
681582d58245637ab05272d89fb94b12fd0f18fa0f8carll                    );                                           \
682582d58245637ab05272d89fb94b12fd0f18fa0f8carll } while (0)
683582d58245637ab05272d89fb94b12fd0f18fa0f8carll
684582d58245637ab05272d89fb94b12fd0f18fa0f8carll#endif /* PLAT_ppc64le_linux */
685f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj
68659570ffbe31930ab4d678754daaeec0715117a3dsewardj/* ------------------------- arm-linux ------------------------- */
68759570ffbe31930ab4d678754daaeec0715117a3dsewardj
68859570ffbe31930ab4d678754daaeec0715117a3dsewardj#if defined(PLAT_arm_linux)
68959570ffbe31930ab4d678754daaeec0715117a3dsewardj
69059570ffbe31930ab4d678754daaeec0715117a3dsewardjtypedef
69159570ffbe31930ab4d678754daaeec0715117a3dsewardj   struct {
69259570ffbe31930ab4d678754daaeec0715117a3dsewardj      unsigned int nraddr; /* where's the code? */
69359570ffbe31930ab4d678754daaeec0715117a3dsewardj   }
69459570ffbe31930ab4d678754daaeec0715117a3dsewardj   OrigFn;
69559570ffbe31930ab4d678754daaeec0715117a3dsewardj
69659570ffbe31930ab4d678754daaeec0715117a3dsewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
69759570ffbe31930ab4d678754daaeec0715117a3dsewardj            "mov r12, r12, ror #3  ; mov r12, r12, ror #13 \n\t"  \
69859570ffbe31930ab4d678754daaeec0715117a3dsewardj            "mov r12, r12, ror #29 ; mov r12, r12, ror #19 \n\t"
69959570ffbe31930ab4d678754daaeec0715117a3dsewardj
700575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
701575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
70259570ffbe31930ab4d678754daaeec0715117a3dsewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
70359570ffbe31930ab4d678754daaeec0715117a3dsewardj                                                                  \
704575ce8ef8fa86a502dabe152293320676922dcfebart  __extension__                                                   \
705575ce8ef8fa86a502dabe152293320676922dcfebart  ({volatile unsigned int  _zzq_args[6];                          \
70659570ffbe31930ab4d678754daaeec0715117a3dsewardj    volatile unsigned int  _zzq_result;                           \
70759570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
70859570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
70959570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
71059570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
71159570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
71259570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
71359570ffbe31930ab4d678754daaeec0715117a3dsewardj    __asm__ volatile("mov r3, %1\n\t" /*default*/                 \
71459570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "mov r4, %2\n\t" /*ptr*/                     \
71559570ffbe31930ab4d678754daaeec0715117a3dsewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
71659570ffbe31930ab4d678754daaeec0715117a3dsewardj                     /* R3 = client_request ( R4 ) */             \
71759570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "orr r10, r10, r10\n\t"                      \
71859570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "mov %0, r3"     /*result*/                  \
71959570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "=r" (_zzq_result)                         \
72059570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "r" (_zzq_default), "r" (&_zzq_args[0])    \
72159570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "cc","memory", "r3", "r4");                \
722575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
723575ce8ef8fa86a502dabe152293320676922dcfebart  })
72459570ffbe31930ab4d678754daaeec0715117a3dsewardj
72559570ffbe31930ab4d678754daaeec0715117a3dsewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
72659570ffbe31930ab4d678754daaeec0715117a3dsewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
72759570ffbe31930ab4d678754daaeec0715117a3dsewardj    unsigned int __addr;                                          \
72859570ffbe31930ab4d678754daaeec0715117a3dsewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
72959570ffbe31930ab4d678754daaeec0715117a3dsewardj                     /* R3 = guest_NRADDR */                      \
73059570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "orr r11, r11, r11\n\t"                      \
73159570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "mov %0, r3"                                 \
73259570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "=r" (__addr)                              \
73359570ffbe31930ab4d678754daaeec0715117a3dsewardj                     :                                            \
73459570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "cc", "memory", "r3"                       \
73559570ffbe31930ab4d678754daaeec0715117a3dsewardj                    );                                            \
73659570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_orig->nraddr = __addr;                                   \
73759570ffbe31930ab4d678754daaeec0715117a3dsewardj  }
73859570ffbe31930ab4d678754daaeec0715117a3dsewardj
73959570ffbe31930ab4d678754daaeec0715117a3dsewardj#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                    \
74059570ffbe31930ab4d678754daaeec0715117a3dsewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
74159570ffbe31930ab4d678754daaeec0715117a3dsewardj                     /* branch-and-link-to-noredir *%R4 */        \
74259570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "orr r12, r12, r12\n\t"
74359570ffbe31930ab4d678754daaeec0715117a3dsewardj
744bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
745bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
746bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
747c379fec53a1e7a2ba8698f339ad67e370c9f0886sewardj                     "orr r9, r9, r9\n\t"                        \
748bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     : : : "cc", "memory"                        \
749bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
750bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
751bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
75259570ffbe31930ab4d678754daaeec0715117a3dsewardj#endif /* PLAT_arm_linux */
75359570ffbe31930ab4d678754daaeec0715117a3dsewardj
754f0c1250e324f6684757c6a15545366447ef1d64fsewardj/* ------------------------ arm64-linux ------------------------- */
755f0c1250e324f6684757c6a15545366447ef1d64fsewardj
756f0c1250e324f6684757c6a15545366447ef1d64fsewardj#if defined(PLAT_arm64_linux)
757f0c1250e324f6684757c6a15545366447ef1d64fsewardj
758f0c1250e324f6684757c6a15545366447ef1d64fsewardjtypedef
759f0c1250e324f6684757c6a15545366447ef1d64fsewardj   struct {
7603540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int nraddr; /* where's the code? */
761f0c1250e324f6684757c6a15545366447ef1d64fsewardj   }
762f0c1250e324f6684757c6a15545366447ef1d64fsewardj   OrigFn;
763f0c1250e324f6684757c6a15545366447ef1d64fsewardj
764f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
765f0c1250e324f6684757c6a15545366447ef1d64fsewardj            "ror x12, x12, #3  ;  ror x12, x12, #13 \n\t"         \
766f0c1250e324f6684757c6a15545366447ef1d64fsewardj            "ror x12, x12, #51 ;  ror x12, x12, #61 \n\t"
767f0c1250e324f6684757c6a15545366447ef1d64fsewardj
768f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
769f0c1250e324f6684757c6a15545366447ef1d64fsewardj        _zzq_default, _zzq_request,                               \
770f0c1250e324f6684757c6a15545366447ef1d64fsewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
771f0c1250e324f6684757c6a15545366447ef1d64fsewardj                                                                  \
772f0c1250e324f6684757c6a15545366447ef1d64fsewardj  __extension__                                                   \
7733540ee89957c352912f3ffb90484abb17cc60675florian  ({volatile unsigned long int  _zzq_args[6];                     \
7743540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int  _zzq_result;                      \
7753540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);             \
7763540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
7773540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
7783540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
7793540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
7803540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
781f0c1250e324f6684757c6a15545366447ef1d64fsewardj    __asm__ volatile("mov x3, %1\n\t" /*default*/                 \
782f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "mov x4, %2\n\t" /*ptr*/                     \
783f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
784f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     /* X3 = client_request ( X4 ) */             \
785f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "orr x10, x10, x10\n\t"                      \
786f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "mov %0, x3"     /*result*/                  \
787f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "=r" (_zzq_result)                         \
788f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "r" (_zzq_default), "r" (&_zzq_args[0])    \
789f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "cc","memory", "x3", "x4");                \
790f0c1250e324f6684757c6a15545366447ef1d64fsewardj    _zzq_result;                                                  \
791f0c1250e324f6684757c6a15545366447ef1d64fsewardj  })
792f0c1250e324f6684757c6a15545366447ef1d64fsewardj
793f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
794f0c1250e324f6684757c6a15545366447ef1d64fsewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
7953540ee89957c352912f3ffb90484abb17cc60675florian    unsigned long int __addr;                                     \
796f0c1250e324f6684757c6a15545366447ef1d64fsewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
797f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     /* X3 = guest_NRADDR */                      \
798f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "orr x11, x11, x11\n\t"                      \
799f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "mov %0, x3"                                 \
800f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "=r" (__addr)                              \
801f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     :                                            \
802f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "cc", "memory", "x3"                       \
803f0c1250e324f6684757c6a15545366447ef1d64fsewardj                    );                                            \
804f0c1250e324f6684757c6a15545366447ef1d64fsewardj    _zzq_orig->nraddr = __addr;                                   \
805f0c1250e324f6684757c6a15545366447ef1d64fsewardj  }
806f0c1250e324f6684757c6a15545366447ef1d64fsewardj
807f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                    \
808f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
809f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     /* branch-and-link-to-noredir X8 */          \
810f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "orr x12, x12, x12\n\t"
811f0c1250e324f6684757c6a15545366447ef1d64fsewardj
812f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define VALGRIND_VEX_INJECT_IR()                                 \
813f0c1250e324f6684757c6a15545366447ef1d64fsewardj do {                                                            \
814f0c1250e324f6684757c6a15545366447ef1d64fsewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
815f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "orr x9, x9, x9\n\t"                        \
816f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : : : "cc", "memory"                        \
817f0c1250e324f6684757c6a15545366447ef1d64fsewardj                    );                                           \
818f0c1250e324f6684757c6a15545366447ef1d64fsewardj } while (0)
819f0c1250e324f6684757c6a15545366447ef1d64fsewardj
820f0c1250e324f6684757c6a15545366447ef1d64fsewardj#endif /* PLAT_arm64_linux */
821f0c1250e324f6684757c6a15545366447ef1d64fsewardj
822b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* ------------------------ s390x-linux ------------------------ */
823b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
824b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#if defined(PLAT_s390x_linux)
825b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
826b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardjtypedef
827b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj  struct {
8283540ee89957c352912f3ffb90484abb17cc60675florian     unsigned long int nraddr; /* where's the code? */
829b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj  }
830b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj  OrigFn;
831b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
832b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* __SPECIAL_INSTRUCTION_PREAMBLE will be used to identify Valgrind specific
833b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj * code. This detection is implemented in platform specific toIR.c
834b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj * (e.g. VEX/priv/guest_s390_decoder.c).
835b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj */
836b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                           \
837b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     "lr 15,15\n\t"                              \
838b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     "lr 1,1\n\t"                                \
839b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     "lr 2,2\n\t"                                \
840b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     "lr 3,3\n\t"
841b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
842b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __CLIENT_REQUEST_CODE "lr 2,2\n\t"
843b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __GET_NR_CONTEXT_CODE "lr 3,3\n\t"
844b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __CALL_NO_REDIR_CODE  "lr 4,4\n\t"
845bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define __VEX_INJECT_IR_CODE  "lr 5,5\n\t"
846b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
847575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                         \
848575ce8ef8fa86a502dabe152293320676922dcfebart       _zzq_default, _zzq_request,                               \
849b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj       _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
850575ce8ef8fa86a502dabe152293320676922dcfebart  __extension__                                                  \
8513540ee89957c352912f3ffb90484abb17cc60675florian ({volatile unsigned long int _zzq_args[6];                      \
8523540ee89957c352912f3ffb90484abb17cc60675florian   volatile unsigned long int _zzq_result;                       \
8533540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[0] = (unsigned long int)(_zzq_request);             \
8543540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
8553540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
8563540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
8573540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
8583540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
859b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   __asm__ volatile(/* r2 = args */                              \
860b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    "lgr 2,%1\n\t"                               \
861b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    /* r3 = default */                           \
862b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    "lgr 3,%2\n\t"                               \
863b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __SPECIAL_INSTRUCTION_PREAMBLE               \
864b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __CLIENT_REQUEST_CODE                        \
865b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    /* results = r3 */                           \
866b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    "lgr %0, 3\n\t"                              \
867b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "=d" (_zzq_result)                         \
868b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
869b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "cc", "2", "3", "memory"                   \
870b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                   );                                            \
871575ce8ef8fa86a502dabe152293320676922dcfebart   _zzq_result;                                                  \
872575ce8ef8fa86a502dabe152293320676922dcfebart })
873b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
874b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                      \
875b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
8763540ee89957c352912f3ffb90484abb17cc60675florian   volatile unsigned long int __addr;                            \
877b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
878b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __GET_NR_CONTEXT_CODE                        \
879b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    "lgr %0, 3\n\t"                              \
880b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "=a" (__addr)                              \
881b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    :                                            \
882b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "cc", "3", "memory"                        \
883b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                   );                                            \
884b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   _zzq_orig->nraddr = __addr;                                   \
885b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj }
886b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
887b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define VALGRIND_CALL_NOREDIR_R1                                 \
888b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __SPECIAL_INSTRUCTION_PREAMBLE               \
889b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __CALL_NO_REDIR_CODE
890b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
891bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
892bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
893bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
894bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     __VEX_INJECT_IR_CODE);                      \
895bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
896bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
897b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#endif /* PLAT_s390x_linux */
898b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
8995db15403e889d4db339b342bc2a824ef0bfaa654sewardj/* ------------------------- mips32-linux ---------------- */
9005db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9015db15403e889d4db339b342bc2a824ef0bfaa654sewardj#if defined(PLAT_mips32_linux)
9025db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9035db15403e889d4db339b342bc2a824ef0bfaa654sewardjtypedef
9045db15403e889d4db339b342bc2a824ef0bfaa654sewardj   struct {
9055db15403e889d4db339b342bc2a824ef0bfaa654sewardj      unsigned int nraddr; /* where's the code? */
9065db15403e889d4db339b342bc2a824ef0bfaa654sewardj   }
9075db15403e889d4db339b342bc2a824ef0bfaa654sewardj   OrigFn;
9085db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9095db15403e889d4db339b342bc2a824ef0bfaa654sewardj/* .word  0x342
9105db15403e889d4db339b342bc2a824ef0bfaa654sewardj * .word  0x742
9115db15403e889d4db339b342bc2a824ef0bfaa654sewardj * .word  0xC2
9125db15403e889d4db339b342bc2a824ef0bfaa654sewardj * .word  0x4C2*/
9135db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE          \
9145db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "srl $0, $0, 13\n\t"       \
9155db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "srl $0, $0, 29\n\t"       \
9165db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "srl $0, $0, 3\n\t"        \
9175db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "srl $0, $0, 19\n\t"
9185db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9195db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
9205db15403e889d4db339b342bc2a824ef0bfaa654sewardj       _zzq_default, _zzq_request,                                \
9215db15403e889d4db339b342bc2a824ef0bfaa654sewardj       _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)     \
9225db15403e889d4db339b342bc2a824ef0bfaa654sewardj  __extension__                                                   \
9235db15403e889d4db339b342bc2a824ef0bfaa654sewardj  ({ volatile unsigned int _zzq_args[6];                          \
9245db15403e889d4db339b342bc2a824ef0bfaa654sewardj    volatile unsigned int _zzq_result;                            \
9255db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
9265db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
9275db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
9285db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
9295db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
9305db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
9315db15403e889d4db339b342bc2a824ef0bfaa654sewardj        __asm__ volatile("move $11, %1\n\t" /*default*/           \
9325db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "move $12, %2\n\t" /*ptr*/                   \
9335db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
9345db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     /* T3 = client_request ( T4 ) */             \
9355db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "or $13, $13, $13\n\t"                       \
9365db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "move %0, $11\n\t"     /*result*/            \
9375db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     : "=r" (_zzq_result)                         \
9385db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     : "r" (_zzq_default), "r" (&_zzq_args[0])    \
9394df0bfc0614379192c780c944415dc420d9cfe8epetarj                     : "$11", "$12");                             \
9405db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_result;                                                  \
9415db15403e889d4db339b342bc2a824ef0bfaa654sewardj  })
9425db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9435db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
9445db15403e889d4db339b342bc2a824ef0bfaa654sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
9455db15403e889d4db339b342bc2a824ef0bfaa654sewardj    volatile unsigned int __addr;                                 \
9465db15403e889d4db339b342bc2a824ef0bfaa654sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
9475db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     /* %t9 = guest_NRADDR */                     \
9485db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "or $14, $14, $14\n\t"                       \
9495db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "move %0, $11"     /*result*/                \
9505db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     : "=r" (__addr)                              \
9515db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     :                                            \
9524df0bfc0614379192c780c944415dc420d9cfe8epetarj                     : "$11"                                      \
9535db15403e889d4db339b342bc2a824ef0bfaa654sewardj                    );                                            \
9545db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_orig->nraddr = __addr;                                   \
9555db15403e889d4db339b342bc2a824ef0bfaa654sewardj  }
9565db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9575db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define VALGRIND_CALL_NOREDIR_T9                                 \
9585db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE              \
9595db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     /* call-noredir *%t9 */                     \
960bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "or $15, $15, $15\n\t"
961bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
962bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
963bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
964bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
965bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "or $11, $11, $11\n\t"                      \
966bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
967bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
968bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
969bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
9705db15403e889d4db339b342bc2a824ef0bfaa654sewardj#endif /* PLAT_mips32_linux */
9715db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9724df0bfc0614379192c780c944415dc420d9cfe8epetarj/* ------------------------- mips64-linux ---------------- */
9734df0bfc0614379192c780c944415dc420d9cfe8epetarj
9744df0bfc0614379192c780c944415dc420d9cfe8epetarj#if defined(PLAT_mips64_linux)
9754df0bfc0614379192c780c944415dc420d9cfe8epetarj
9764df0bfc0614379192c780c944415dc420d9cfe8epetarjtypedef
9774df0bfc0614379192c780c944415dc420d9cfe8epetarj   struct {
9783540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long nraddr; /* where's the code? */
9794df0bfc0614379192c780c944415dc420d9cfe8epetarj   }
9804df0bfc0614379192c780c944415dc420d9cfe8epetarj   OrigFn;
9814df0bfc0614379192c780c944415dc420d9cfe8epetarj
9824df0bfc0614379192c780c944415dc420d9cfe8epetarj/* dsll $0,$0, 3
9834df0bfc0614379192c780c944415dc420d9cfe8epetarj * dsll $0,$0, 13
9844df0bfc0614379192c780c944415dc420d9cfe8epetarj * dsll $0,$0, 29
9854df0bfc0614379192c780c944415dc420d9cfe8epetarj * dsll $0,$0, 19*/
9864df0bfc0614379192c780c944415dc420d9cfe8epetarj#define __SPECIAL_INSTRUCTION_PREAMBLE                              \
9874df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "dsll $0,$0, 3 ; dsll $0,$0,13\n\t"            \
9884df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "dsll $0,$0,29 ; dsll $0,$0,19\n\t"
9894df0bfc0614379192c780c944415dc420d9cfe8epetarj
9904df0bfc0614379192c780c944415dc420d9cfe8epetarj#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                            \
9914df0bfc0614379192c780c944415dc420d9cfe8epetarj       _zzq_default, _zzq_request,                                  \
9924df0bfc0614379192c780c944415dc420d9cfe8epetarj       _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)       \
9934df0bfc0614379192c780c944415dc420d9cfe8epetarj  __extension__                                                     \
9943540ee89957c352912f3ffb90484abb17cc60675florian  ({ volatile unsigned long int _zzq_args[6];                       \
9953540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int _zzq_result;                         \
9963540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);               \
9973540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                  \
9983540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                  \
9993540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                  \
10003540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                  \
10013540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                  \
10024df0bfc0614379192c780c944415dc420d9cfe8epetarj        __asm__ volatile("move $11, %1\n\t" /*default*/             \
10034df0bfc0614379192c780c944415dc420d9cfe8epetarj                         "move $12, %2\n\t" /*ptr*/                 \
10044df0bfc0614379192c780c944415dc420d9cfe8epetarj                         __SPECIAL_INSTRUCTION_PREAMBLE             \
10054df0bfc0614379192c780c944415dc420d9cfe8epetarj                         /* $11 = client_request ( $12 ) */         \
10064df0bfc0614379192c780c944415dc420d9cfe8epetarj                         "or $13, $13, $13\n\t"                     \
10074df0bfc0614379192c780c944415dc420d9cfe8epetarj                         "move %0, $11\n\t"     /*result*/          \
10084df0bfc0614379192c780c944415dc420d9cfe8epetarj                         : "=r" (_zzq_result)                       \
10094df0bfc0614379192c780c944415dc420d9cfe8epetarj                         : "r" (_zzq_default), "r" (&_zzq_args[0])  \
10104df0bfc0614379192c780c944415dc420d9cfe8epetarj                         : "$11", "$12");                           \
10114df0bfc0614379192c780c944415dc420d9cfe8epetarj    _zzq_result;                                                    \
10124df0bfc0614379192c780c944415dc420d9cfe8epetarj  })
10134df0bfc0614379192c780c944415dc420d9cfe8epetarj
10144df0bfc0614379192c780c944415dc420d9cfe8epetarj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                         \
10154df0bfc0614379192c780c944415dc420d9cfe8epetarj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                     \
10163540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int __addr;                              \
10174df0bfc0614379192c780c944415dc420d9cfe8epetarj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE                 \
10184df0bfc0614379192c780c944415dc420d9cfe8epetarj                     /* $11 = guest_NRADDR */                       \
10194df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "or $14, $14, $14\n\t"                         \
10204df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "move %0, $11"     /*result*/                  \
10214df0bfc0614379192c780c944415dc420d9cfe8epetarj                     : "=r" (__addr)                                \
10224df0bfc0614379192c780c944415dc420d9cfe8epetarj                     :                                              \
10234df0bfc0614379192c780c944415dc420d9cfe8epetarj                     : "$11");                                      \
10244df0bfc0614379192c780c944415dc420d9cfe8epetarj    _zzq_orig->nraddr = __addr;                                     \
10254df0bfc0614379192c780c944415dc420d9cfe8epetarj  }
10264df0bfc0614379192c780c944415dc420d9cfe8epetarj
10274df0bfc0614379192c780c944415dc420d9cfe8epetarj#define VALGRIND_CALL_NOREDIR_T9                                    \
10284df0bfc0614379192c780c944415dc420d9cfe8epetarj                     __SPECIAL_INSTRUCTION_PREAMBLE                 \
10294df0bfc0614379192c780c944415dc420d9cfe8epetarj                     /* call-noredir $25 */                         \
10304df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "or $15, $15, $15\n\t"
10314df0bfc0614379192c780c944415dc420d9cfe8epetarj
10324df0bfc0614379192c780c944415dc420d9cfe8epetarj#define VALGRIND_VEX_INJECT_IR()                                    \
10334df0bfc0614379192c780c944415dc420d9cfe8epetarj do {                                                               \
10344df0bfc0614379192c780c944415dc420d9cfe8epetarj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE                 \
10354df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "or $11, $11, $11\n\t"                         \
10364df0bfc0614379192c780c944415dc420d9cfe8epetarj                    );                                              \
10374df0bfc0614379192c780c944415dc420d9cfe8epetarj } while (0)
10384df0bfc0614379192c780c944415dc420d9cfe8epetarj
10394df0bfc0614379192c780c944415dc420d9cfe8epetarj#endif /* PLAT_mips64_linux */
10404df0bfc0614379192c780c944415dc420d9cfe8epetarj
1041112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/* ------------------------ tilegx-linux --------------- */
1042112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#if defined(PLAT_tilegx_linux)
1043112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1044112711afefcfcd43680c7c4aa8d38ef180e8811esewardjtypedef
1045112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   struct {
1046112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      unsigned long long int nraddr; /* where's the code? */
1047112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   }
1048112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   OrigFn;
1049112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/*** special instruction sequence.
1050112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     0:02b3c7ff91234fff { moveli zero, 4660 ; moveli zero, 22136 }
1051112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     8:0091a7ff95678fff { moveli zero, 22136 ; moveli zero, 4660 }
1052112711afefcfcd43680c7c4aa8d38ef180e8811esewardj****/
1053112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1054112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                             \
1055112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   ".quad  0x02b3c7ff91234fff\n"                                   \
1056112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   ".quad  0x0091a7ff95678fff\n"
1057112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1058112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                           \
1059112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   _zzq_default, _zzq_request,                                      \
1060112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)          \
1061112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   ({ volatile unsigned long long int _zzq_args[6];                \
1062112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long long int _zzq_result;                 \
1063112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[0] = (unsigned long long int)(_zzq_request);       \
1064112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[1] = (unsigned long long int)(_zzq_arg1);          \
1065112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[2] = (unsigned long long int)(_zzq_arg2);          \
1066112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[3] = (unsigned long long int)(_zzq_arg3);          \
1067112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[4] = (unsigned long long int)(_zzq_arg4);          \
1068112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[5] = (unsigned long long int)(_zzq_arg5);          \
1069112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile("move r11, %1\n\t" /*default*/              \
1070112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "move r12, %2\n\t" /*ptr*/                  \
1071112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       __SPECIAL_INSTRUCTION_PREAMBLE              \
1072112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       /* r11 = client_request */                  \
1073112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "or r13, r13, r13\n\t"                      \
1074112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "move %0, r11\n\t"     /*result*/           \
1075112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "=r" (_zzq_result)                        \
1076112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "r" (_zzq_default), "r" (&_zzq_args[0])   \
1077112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "memory", "r11", "r12");                  \
1078112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_result;                                                 \
1079112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   })
1080112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1081112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                        \
1082112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   {  volatile OrigFn* _zzq_orig = &(_zzq_rlval);                  \
1083112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long long int __addr;                      \
1084112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
1085112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       /* r11 = guest_NRADDR */                    \
1086112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "or r14, r14, r14\n"                        \
1087112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "move %0, r11\n"                            \
1088112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "=r" (__addr)                             \
1089112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       :                                           \
1090112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "memory", "r11"                           \
1091112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       );                                          \
1092112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_orig->nraddr = __addr;                                  \
1093112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   }
1094112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1095112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define VALGRIND_CALL_NOREDIR_R12                                  \
1096112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   __SPECIAL_INSTRUCTION_PREAMBLE                                  \
1097112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   "or r15, r15, r15\n\t"
1098112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1099112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define VALGRIND_VEX_INJECT_IR()                                   \
1100112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                            \
1101112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
1102112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "or r11, r11, r11\n\t"                      \
1103112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       );                                          \
1104112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
1105112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1106112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#endif /* PLAT_tilegx_linux */
1107112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1108f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* Insert assembly code for other platforms here... */
110926aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn
111037091fb739760631f436043c47de612cf9fd2dd1sewardj#endif /* NVALGRIND */
11112e93c50dc50235189661b70e3f27a4098d5cccccsewardj
111269d9c4625034b60c08e04cc246fcf8093d23fde5nethercote
111330d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* ------------------------------------------------------------------ */
1114f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* PLATFORM SPECIFICS for FUNCTION WRAPPING.  This is all very        */
11150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ugly.  It's the least-worst tradeoff I can think of.               */
11160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ------------------------------------------------------------------ */
11170ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11180ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* This section defines magic (a.k.a appalling-hack) macros for doing
11190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   guaranteed-no-redirection macros, so as to get from function
11200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   wrappers to the functions they are wrapping.  The whole point is to
11210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   construct standard call sequences, but to do the call itself with a
11220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   special no-redirect call pseudo-instruction that the JIT
11230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   understands and handles specially.  This section is long and
11240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   repetitious, and I can't see a way to make it shorter.
11250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   The naming scheme is as follows:
11270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      CALL_FN_{W,v}_{v,W,WW,WWW,WWWW,5W,6W,7W,etc}
11290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   'W' stands for "word" and 'v' for "void".  Hence there are
11310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   different macros for calling arity 0, 1, 2, 3, 4, etc, functions,
11320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   and for each, the possibility of returning a word-typed result, or
11330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   no result.
11340ec07f32bbbb209d749b9974408e6f025ad40b31sewardj*/
11350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* Use these to write the name of your wrapper.  NOTE: duplicates
113785cf90056b7a8d98d88335b47c599a35b35ff7casewardj   VG_WRAP_FUNCTION_Z{U,Z} in pub_tool_redir.h.  NOTE also: inserts
113885cf90056b7a8d98d88335b47c599a35b35ff7casewardj   the default behaviour equivalance class tag "0000" into the name.
113985cf90056b7a8d98d88335b47c599a35b35ff7casewardj   See pub_tool_redir.h for details -- normally you don't need to
114085cf90056b7a8d98d88335b47c599a35b35ff7casewardj   think about this, though. */
11410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11425f5ef2ae9e7c2ce5ebc36c1e2fc98e5f81650be3njn/* Use an extra level of macroisation so as to ensure the soname/fnname
11435f5ef2ae9e7c2ce5ebc36c1e2fc98e5f81650be3njn   args are fully macro-expanded before pasting them together. */
11445f5ef2ae9e7c2ce5ebc36c1e2fc98e5f81650be3njn#define VG_CONCAT4(_aa,_bb,_cc,_dd) _aa##_bb##_cc##_dd
11455f5ef2ae9e7c2ce5ebc36c1e2fc98e5f81650be3njn
11460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define I_WRAP_SONAME_FNNAME_ZU(soname,fnname)                    \
114796044842731e581702c9ed4104d2949fcde20fd8sewardj   VG_CONCAT4(_vgw00000ZU_,soname,_,fnname)
11480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname)                    \
115096044842731e581702c9ed4104d2949fcde20fd8sewardj   VG_CONCAT4(_vgw00000ZZ_,soname,_,fnname)
11510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1152d68ac3e974d25f88492774f6baa491999afde9f9sewardj/* Use this macro from within a wrapper function to collect the
1153d68ac3e974d25f88492774f6baa491999afde9f9sewardj   context (address and possibly other info) of the original function.
1154d68ac3e974d25f88492774f6baa491999afde9f9sewardj   Once you have that you can then use it in one of the CALL_FN_
1155d68ac3e974d25f88492774f6baa491999afde9f9sewardj   macros.  The type of the argument _lval is OrigFn. */
1156d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define VALGRIND_GET_ORIG_FN(_lval)  VALGRIND_GET_NR_CONTEXT(_lval)
11570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1158573f8bc106cf3646bdb62748820287c9c44bd432sewardj/* Also provide end-user facilities for function replacement, rather
1159573f8bc106cf3646bdb62748820287c9c44bd432sewardj   than wrapping.  A replacement function differs from a wrapper in
1160573f8bc106cf3646bdb62748820287c9c44bd432sewardj   that it has no way to get hold of the original function being
1161573f8bc106cf3646bdb62748820287c9c44bd432sewardj   called, and hence no way to call onwards to it.  In a replacement
1162573f8bc106cf3646bdb62748820287c9c44bd432sewardj   function, VALGRIND_GET_ORIG_FN always returns zero. */
1163573f8bc106cf3646bdb62748820287c9c44bd432sewardj
1164573f8bc106cf3646bdb62748820287c9c44bd432sewardj#define I_REPLACE_SONAME_FNNAME_ZU(soname,fnname)                 \
1165573f8bc106cf3646bdb62748820287c9c44bd432sewardj   VG_CONCAT4(_vgr00000ZU_,soname,_,fnname)
1166573f8bc106cf3646bdb62748820287c9c44bd432sewardj
1167573f8bc106cf3646bdb62748820287c9c44bd432sewardj#define I_REPLACE_SONAME_FNNAME_ZZ(soname,fnname)                 \
1168573f8bc106cf3646bdb62748820287c9c44bd432sewardj   VG_CONCAT4(_vgr00000ZZ_,soname,_,fnname)
1169573f8bc106cf3646bdb62748820287c9c44bd432sewardj
11700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* Derivatives of the main macros below, for calling functions
11710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   returning void. */
11720ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define CALL_FN_v_v(fnptr)                                        \
11740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do { volatile unsigned long _junk;                             \
11750ec07f32bbbb209d749b9974408e6f025ad40b31sewardj        CALL_FN_W_v(_junk,fnptr); } while (0)
11760ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define CALL_FN_v_W(fnptr, arg1)                                  \
11780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do { volatile unsigned long _junk;                             \
11790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj        CALL_FN_W_W(_junk,fnptr,arg1); } while (0)
11800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11810ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define CALL_FN_v_WW(fnptr, arg1,arg2)                            \
11820ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do { volatile unsigned long _junk;                             \
11830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj        CALL_FN_W_WW(_junk,fnptr,arg1,arg2); } while (0)
11840ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11855ce4b150ce5d32c9af07a24717081ea34568388asewardj#define CALL_FN_v_WWW(fnptr, arg1,arg2,arg3)                      \
11865ce4b150ce5d32c9af07a24717081ea34568388asewardj   do { volatile unsigned long _junk;                             \
11875ce4b150ce5d32c9af07a24717081ea34568388asewardj        CALL_FN_W_WWW(_junk,fnptr,arg1,arg2,arg3); } while (0)
11885ce4b150ce5d32c9af07a24717081ea34568388asewardj
11892b5f0a90334a2271791c110548a842fadb5ffc65njn#define CALL_FN_v_WWWW(fnptr, arg1,arg2,arg3,arg4)                \
11902b5f0a90334a2271791c110548a842fadb5ffc65njn   do { volatile unsigned long _junk;                             \
11912b5f0a90334a2271791c110548a842fadb5ffc65njn        CALL_FN_W_WWWW(_junk,fnptr,arg1,arg2,arg3,arg4); } while (0)
11922b5f0a90334a2271791c110548a842fadb5ffc65njn
11932b5f0a90334a2271791c110548a842fadb5ffc65njn#define CALL_FN_v_5W(fnptr, arg1,arg2,arg3,arg4,arg5)             \
11942b5f0a90334a2271791c110548a842fadb5ffc65njn   do { volatile unsigned long _junk;                             \
11952b5f0a90334a2271791c110548a842fadb5ffc65njn        CALL_FN_W_5W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5); } while (0)
11962b5f0a90334a2271791c110548a842fadb5ffc65njn
11972b5f0a90334a2271791c110548a842fadb5ffc65njn#define CALL_FN_v_6W(fnptr, arg1,arg2,arg3,arg4,arg5,arg6)        \
11982b5f0a90334a2271791c110548a842fadb5ffc65njn   do { volatile unsigned long _junk;                             \
11992b5f0a90334a2271791c110548a842fadb5ffc65njn        CALL_FN_W_6W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5,arg6); } while (0)
12002b5f0a90334a2271791c110548a842fadb5ffc65njn
12012b5f0a90334a2271791c110548a842fadb5ffc65njn#define CALL_FN_v_7W(fnptr, arg1,arg2,arg3,arg4,arg5,arg6,arg7)   \
12022b5f0a90334a2271791c110548a842fadb5ffc65njn   do { volatile unsigned long _junk;                             \
12032b5f0a90334a2271791c110548a842fadb5ffc65njn        CALL_FN_W_7W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5,arg6,arg7); } while (0)
12042b5f0a90334a2271791c110548a842fadb5ffc65njn
1205f76d27a697a7b0bf3b84490baf60623fc96a23afnjn/* ------------------------- x86-{linux,darwin} ---------------- */
12060ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1207f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#if defined(PLAT_x86_linux)  ||  defined(PLAT_x86_darwin)
12080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
12090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These regs are trashed by the hidden call.  No need to mention eax
12100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   as gcc can already see that, plus causes gcc to bomb. */
12110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __CALLER_SAVED_REGS /*"eax"*/ "ecx", "edx"
12120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
12134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
12144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
12154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
12164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
12174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
12184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
12194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "movl %%esp,%%edi\n\t"               \
12204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "andl $0xfffffff0,%%esp\n\t"
12214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
12224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "movl %%edi,%%esp\n\t"
12234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
12240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These CALL_FN_ macros assume that on x86-linux, sizeof(unsigned
12250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   long) == 4. */
12260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
122766226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_v(lval, orig)                                   \
12280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
122966226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
12300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[1];                          \
12310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
123266226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
12330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
12344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
12350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
12360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
12374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
12380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
12390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
12404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
12410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
12420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
12430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
12440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
124566226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
12460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
124766226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
12480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[2];                          \
12490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
125066226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
12510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
12520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
12534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
125487a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $12, %%esp\n\t"                                    \
12550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
12560ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
12570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
12584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
12590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
12600ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
12614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
12620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
12630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
12640ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
12650ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
126666226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
12670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
126866226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
12690ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[3];                          \
12700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
127166226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
12720ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
12730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
12740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
12754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
127687a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $8, %%esp\n\t"                                     \
12770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
12780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
12790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
12800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
12814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
12820ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
12839e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         : /*in*/    "a" (&_argvec[0])                            \
12844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
12859e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      );                                                          \
12869e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      lval = (__typeof__(lval)) _res;                             \
12879e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj   } while (0)
12889e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj
12899e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
12909e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj   do {                                                           \
12919e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      volatile OrigFn        _orig = (orig);                      \
12929e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      volatile unsigned long _argvec[4];                          \
12939e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      volatile unsigned long _res;                                \
12949e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
12959e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      _argvec[1] = (unsigned long)(arg1);                         \
12969e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      _argvec[2] = (unsigned long)(arg2);                         \
12979e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      _argvec[3] = (unsigned long)(arg3);                         \
12989e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      __asm__ volatile(                                           \
12994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
130087a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $4, %%esp\n\t"                                     \
13019e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         "pushl 12(%%eax)\n\t"                                    \
13029e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         "pushl 8(%%eax)\n\t"                                     \
13039e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         "pushl 4(%%eax)\n\t"                                     \
13049e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
13059e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         VALGRIND_CALL_NOREDIR_EAX                                \
13064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
13079e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         : /*out*/   "=a" (_res)                                  \
13080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
13094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
13100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
13110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
13120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
13130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
131466226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
13150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
131666226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
13170ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[5];                          \
13180ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
131966226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
13200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
13210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
13220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
13230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
13240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
13254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
13260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
13270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
13280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
13290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
13300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
13310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
13324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
13330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
13340ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
13354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
13360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
13370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
13380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
13390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
134066226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
13410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
134266226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
13430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[6];                          \
13440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
134566226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
13460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
13470ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
13480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
13490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
13500ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
13510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
13524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
135387a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $12, %%esp\n\t"                                    \
13540ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
13550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
13560ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
13570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
13580ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
13590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
13600ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
13614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
13620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
13630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
13644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
13650ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
13660ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
13670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
13680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
136966226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
13700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
137166226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
13720ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[7];                          \
13730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
137466226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
13750ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
13760ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
13770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
13780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
13790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
13800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[6] = (unsigned long)(arg6);                         \
13810ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
13824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
138387a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $8, %%esp\n\t"                                     \
13840ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 24(%%eax)\n\t"                                    \
13850ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
13860ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
13870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
13880ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
13890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
13900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
13910ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
13924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
13930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
13940ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
13954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
13960ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
13970ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
13980ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
13990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
140066226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
140166226cc1e5e852de3584c76984dace8679730b42sewardj                                 arg7)                            \
14020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
140366226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
14040ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[8];                          \
14050ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
140666226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
14070ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
14080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
14090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
14100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
14110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
14120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[6] = (unsigned long)(arg6);                         \
14130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[7] = (unsigned long)(arg7);                         \
14140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
14154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
141687a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $4, %%esp\n\t"                                     \
14170ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 28(%%eax)\n\t"                                    \
14180ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 24(%%eax)\n\t"                                    \
14190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
14200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
14210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
14220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
14230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
14240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
14250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
14264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
14270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
14280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
14294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
14300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
14310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
14320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
14330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
143466226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
143566226cc1e5e852de3584c76984dace8679730b42sewardj                                 arg7,arg8)                       \
14360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
143766226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
14380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[9];                          \
14390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
144066226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
14410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
14420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
14430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
14440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
14450ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
14460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[6] = (unsigned long)(arg6);                         \
14470ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[7] = (unsigned long)(arg7);                         \
14480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[8] = (unsigned long)(arg8);                         \
14490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
14504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
14510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 32(%%eax)\n\t"                                    \
14520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 28(%%eax)\n\t"                                    \
14530ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 24(%%eax)\n\t"                                    \
14540ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
14550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
14560ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
14570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
14580ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
14590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
14600ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
14614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
14620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
14630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
14644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
14650ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
14660ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
14670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
14680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
146945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
147045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj                                 arg7,arg8,arg9)                  \
147145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj   do {                                                           \
147245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile OrigFn        _orig = (orig);                      \
147345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile unsigned long _argvec[10];                         \
147445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile unsigned long _res;                                \
147545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
147645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[1] = (unsigned long)(arg1);                         \
147745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[2] = (unsigned long)(arg2);                         \
147845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[3] = (unsigned long)(arg3);                         \
147945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[4] = (unsigned long)(arg4);                         \
148045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[5] = (unsigned long)(arg5);                         \
148145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[6] = (unsigned long)(arg6);                         \
148245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[7] = (unsigned long)(arg7);                         \
148345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[8] = (unsigned long)(arg8);                         \
148445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[9] = (unsigned long)(arg9);                         \
148545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      __asm__ volatile(                                           \
14864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
148787a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $12, %%esp\n\t"                                    \
148845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 36(%%eax)\n\t"                                    \
148945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 32(%%eax)\n\t"                                    \
149045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 28(%%eax)\n\t"                                    \
149145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 24(%%eax)\n\t"                                    \
149245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 20(%%eax)\n\t"                                    \
149345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 16(%%eax)\n\t"                                    \
149445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 12(%%eax)\n\t"                                    \
149545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 8(%%eax)\n\t"                                     \
149645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 4(%%eax)\n\t"                                     \
149745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
149845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         VALGRIND_CALL_NOREDIR_EAX                                \
14994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
150045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         : /*out*/   "=a" (_res)                                  \
150145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         : /*in*/    "a" (&_argvec[0])                            \
15024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
150345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      );                                                          \
150445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      lval = (__typeof__(lval)) _res;                             \
150545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj   } while (0)
150645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj
150745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
150845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj                                  arg7,arg8,arg9,arg10)           \
150945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj   do {                                                           \
151045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile OrigFn        _orig = (orig);                      \
151145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile unsigned long _argvec[11];                         \
151245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile unsigned long _res;                                \
151345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
151445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[1] = (unsigned long)(arg1);                         \
151545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[2] = (unsigned long)(arg2);                         \
151645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[3] = (unsigned long)(arg3);                         \
151745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[4] = (unsigned long)(arg4);                         \
151845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[5] = (unsigned long)(arg5);                         \
151945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[6] = (unsigned long)(arg6);                         \
152045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[7] = (unsigned long)(arg7);                         \
152145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[8] = (unsigned long)(arg8);                         \
152245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[9] = (unsigned long)(arg9);                         \
152345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[10] = (unsigned long)(arg10);                       \
152445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      __asm__ volatile(                                           \
15254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
152687a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $8, %%esp\n\t"                                     \
152745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 40(%%eax)\n\t"                                    \
152845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 36(%%eax)\n\t"                                    \
152945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 32(%%eax)\n\t"                                    \
153045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 28(%%eax)\n\t"                                    \
153145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 24(%%eax)\n\t"                                    \
153245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 20(%%eax)\n\t"                                    \
153345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 16(%%eax)\n\t"                                    \
153445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 12(%%eax)\n\t"                                    \
153545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 8(%%eax)\n\t"                                     \
153645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 4(%%eax)\n\t"                                     \
153745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
153845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         VALGRIND_CALL_NOREDIR_EAX                                \
15394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
154045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         : /*out*/   "=a" (_res)                                  \
154145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         : /*in*/    "a" (&_argvec[0])                            \
15424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
154345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      );                                                          \
154445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      lval = (__typeof__(lval)) _res;                             \
154545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj   } while (0)
154645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj
15475ce4b150ce5d32c9af07a24717081ea34568388asewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
15485ce4b150ce5d32c9af07a24717081ea34568388asewardj                                  arg6,arg7,arg8,arg9,arg10,      \
15495ce4b150ce5d32c9af07a24717081ea34568388asewardj                                  arg11)                          \
15505ce4b150ce5d32c9af07a24717081ea34568388asewardj   do {                                                           \
15515ce4b150ce5d32c9af07a24717081ea34568388asewardj      volatile OrigFn        _orig = (orig);                      \
15525ce4b150ce5d32c9af07a24717081ea34568388asewardj      volatile unsigned long _argvec[12];                         \
15535ce4b150ce5d32c9af07a24717081ea34568388asewardj      volatile unsigned long _res;                                \
15545ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
15555ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[1] = (unsigned long)(arg1);                         \
15565ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[2] = (unsigned long)(arg2);                         \
15575ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[3] = (unsigned long)(arg3);                         \
15585ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[4] = (unsigned long)(arg4);                         \
15595ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[5] = (unsigned long)(arg5);                         \
15605ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[6] = (unsigned long)(arg6);                         \
15615ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[7] = (unsigned long)(arg7);                         \
15625ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[8] = (unsigned long)(arg8);                         \
15635ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[9] = (unsigned long)(arg9);                         \
15645ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[10] = (unsigned long)(arg10);                       \
15655ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[11] = (unsigned long)(arg11);                       \
15665ce4b150ce5d32c9af07a24717081ea34568388asewardj      __asm__ volatile(                                           \
15674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
156887a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $4, %%esp\n\t"                                     \
15695ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 44(%%eax)\n\t"                                    \
15705ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 40(%%eax)\n\t"                                    \
15715ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 36(%%eax)\n\t"                                    \
15725ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 32(%%eax)\n\t"                                    \
15735ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 28(%%eax)\n\t"                                    \
15745ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 24(%%eax)\n\t"                                    \
15755ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 20(%%eax)\n\t"                                    \
15765ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 16(%%eax)\n\t"                                    \
15775ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 12(%%eax)\n\t"                                    \
15785ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 8(%%eax)\n\t"                                     \
15795ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 4(%%eax)\n\t"                                     \
15805ce4b150ce5d32c9af07a24717081ea34568388asewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
15815ce4b150ce5d32c9af07a24717081ea34568388asewardj         VALGRIND_CALL_NOREDIR_EAX                                \
15824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
15835ce4b150ce5d32c9af07a24717081ea34568388asewardj         : /*out*/   "=a" (_res)                                  \
15845ce4b150ce5d32c9af07a24717081ea34568388asewardj         : /*in*/    "a" (&_argvec[0])                            \
15854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
15865ce4b150ce5d32c9af07a24717081ea34568388asewardj      );                                                          \
15875ce4b150ce5d32c9af07a24717081ea34568388asewardj      lval = (__typeof__(lval)) _res;                             \
15885ce4b150ce5d32c9af07a24717081ea34568388asewardj   } while (0)
15895ce4b150ce5d32c9af07a24717081ea34568388asewardj
159066226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
159166226cc1e5e852de3584c76984dace8679730b42sewardj                                  arg6,arg7,arg8,arg9,arg10,      \
159266226cc1e5e852de3584c76984dace8679730b42sewardj                                  arg11,arg12)                    \
15930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
159466226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
15950ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[13];                         \
15960ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
159766226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
15980ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
15990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
16000ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
16010ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
16020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
16030ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[6] = (unsigned long)(arg6);                         \
16040ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[7] = (unsigned long)(arg7);                         \
16050ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[8] = (unsigned long)(arg8);                         \
16060ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[9] = (unsigned long)(arg9);                         \
16070ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[10] = (unsigned long)(arg10);                       \
16080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[11] = (unsigned long)(arg11);                       \
16090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[12] = (unsigned long)(arg12);                       \
16100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
16114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
16120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 48(%%eax)\n\t"                                    \
16130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 44(%%eax)\n\t"                                    \
16140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 40(%%eax)\n\t"                                    \
16150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 36(%%eax)\n\t"                                    \
16160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 32(%%eax)\n\t"                                    \
16170ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 28(%%eax)\n\t"                                    \
16180ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 24(%%eax)\n\t"                                    \
16190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
16200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
16210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
16220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
16230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
16240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
16250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
16264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
16270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
16280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
16294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
16300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
16310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
16320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
16330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1634f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#endif /* PLAT_x86_linux || PLAT_x86_darwin */
16350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1636f76d27a697a7b0bf3b84490baf60623fc96a23afnjn/* ------------------------ amd64-{linux,darwin} --------------- */
16370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1638f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#if defined(PLAT_amd64_linux)  ||  defined(PLAT_amd64_darwin)
16390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
16400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ARGREGS: rdi rsi rdx rcx r8 r9 (the rest on stack in R-to-L order) */
16410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
16420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These regs are trashed by the hidden call. */
16430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __CALLER_SAVED_REGS /*"rax",*/ "rcx", "rdx", "rsi",       \
16440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                            "rdi", "r8", "r9", "r10", "r11"
16450ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1646dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj/* This is all pretty complex.  It's so as to make stack unwinding
1647dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   work reliably.  See bug 243270.  The basic problem is the sub and
1648dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   add of 128 of %rsp in all of the following macros.  If gcc believes
1649dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   the CFA is in %rsp, then unwinding may fail, because what's at the
1650dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   CFA is not what gcc "expected" when it constructs the CFIs for the
1651dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   places where the macros are instantiated.
1652dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1653dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   But we can't just add a CFI annotation to increase the CFA offset
1654dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   by 128, to match the sub of 128 from %rsp, because we don't know
1655dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   whether gcc has chosen %rsp as the CFA at that point, or whether it
1656dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   has chosen some other register (eg, %rbp).  In the latter case,
1657dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   adding a CFI annotation to change the CFA offset is simply wrong.
1658dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1659dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   So the solution is to get hold of the CFA using
16608d1dc150a77fe495682a928949c5d5b7443b045csewardj   __builtin_dwarf_cfa(), put it in a known register, and add a
1661dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   CFI annotation to say what the register is.  We choose %rbp for
1662dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   this (perhaps perversely), because:
1663dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1664dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   (1) %rbp is already subject to unwinding.  If a new register was
1665dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       chosen then the unwinder would have to unwind it in all stack
1666dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       traces, which is expensive, and
1667dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1668dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   (2) %rbp is already subject to precise exception updates in the
1669dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       JIT.  If a new register was chosen, we'd have to have precise
1670dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       exceptions for it too, which reduces performance of the
1671dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       generated code.
1672dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1673dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   However .. one extra complication.  We can't just whack the result
16748d1dc150a77fe495682a928949c5d5b7443b045csewardj   of __builtin_dwarf_cfa() into %rbp and then add %rbp to the
1675dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   list of trashed registers at the end of the inline assembly
1676dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   fragments; gcc won't allow %rbp to appear in that list.  Hence
1677dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   instead we need to stash %rbp in %r15 for the duration of the asm,
1678dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   and say that %r15 is trashed instead.  gcc seems happy to go with
1679dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   that.
1680dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1681dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   Oh .. and this all needs to be conditionalised so that it is
1682dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   unchanged from before this commit, when compiled with older gccs
16838d1dc150a77fe495682a928949c5d5b7443b045csewardj   that don't support __builtin_dwarf_cfa.  Furthermore, since
16848d1dc150a77fe495682a928949c5d5b7443b045csewardj   this header file is freestanding, it has to be independent of
16858d1dc150a77fe495682a928949c5d5b7443b045csewardj   config.h, and so the following conditionalisation cannot depend on
16868d1dc150a77fe495682a928949c5d5b7443b045csewardj   configure time checks.
16878d1dc150a77fe495682a928949c5d5b7443b045csewardj
16888d1dc150a77fe495682a928949c5d5b7443b045csewardj   Although it's not clear from
16898d1dc150a77fe495682a928949c5d5b7443b045csewardj   'defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)',
16908d1dc150a77fe495682a928949c5d5b7443b045csewardj   this expression excludes Darwin.
16918d1dc150a77fe495682a928949c5d5b7443b045csewardj   .cfi directives in Darwin assembly appear to be completely
16928d1dc150a77fe495682a928949c5d5b7443b045csewardj   different and I haven't investigated how they work.
16938d1dc150a77fe495682a928949c5d5b7443b045csewardj
16948d1dc150a77fe495682a928949c5d5b7443b045csewardj   For even more entertainment value, note we have to use the
16958d1dc150a77fe495682a928949c5d5b7443b045csewardj   completely undocumented __builtin_dwarf_cfa(), which appears to
16968d1dc150a77fe495682a928949c5d5b7443b045csewardj   really compute the CFA, whereas __builtin_frame_address(0) claims
16978d1dc150a77fe495682a928949c5d5b7443b045csewardj   to but actually doesn't.  See
16988d1dc150a77fe495682a928949c5d5b7443b045csewardj   https://bugs.kde.org/show_bug.cgi?id=243270#c47
1699dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj*/
17008d1dc150a77fe495682a928949c5d5b7443b045csewardj#if defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)
1701dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define __FRAME_POINTER                                         \
17028d1dc150a77fe495682a928949c5d5b7443b045csewardj      ,"r"(__builtin_dwarf_cfa())
1703dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define VALGRIND_CFI_PROLOGUE                                   \
1704dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj      "movq %%rbp, %%r15\n\t"                                     \
17058d1dc150a77fe495682a928949c5d5b7443b045csewardj      "movq %2, %%rbp\n\t"                                        \
17068d1dc150a77fe495682a928949c5d5b7443b045csewardj      ".cfi_remember_state\n\t"                                   \
1707dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj      ".cfi_def_cfa rbp, 0\n\t"
1708dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define VALGRIND_CFI_EPILOGUE                                   \
1709dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj      "movq %%r15, %%rbp\n\t"                                     \
1710dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj      ".cfi_restore_state\n\t"
1711dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#else
1712dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define __FRAME_POINTER
1713dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define VALGRIND_CFI_PROLOGUE
1714dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define VALGRIND_CFI_EPILOGUE
1715dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#endif
1716dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
17174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
17184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
17194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
17204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
17214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
17224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
17234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "movq %%rsp,%%r14\n\t"               \
17244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "andq $0xfffffffffffffff0,%%rsp\n\t"
17254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
17264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "movq %%r14,%%rsp\n\t"
1727dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
17280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These CALL_FN_ macros assume that on amd64-linux, sizeof(unsigned
17290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   long) == 8. */
17300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1731a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj/* NB 9 Sept 07.  There is a nasty kludge here in all these CALL_FN_
1732a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   macros.  In order not to trash the stack redzone, we need to drop
1733a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   %rsp by 128 before the hidden call, and restore afterwards.  The
1734a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   nastyness is that it is only by luck that the stack still appears
1735a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   to be unwindable during the hidden call - since then the behaviour
1736a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   of any routine using this macro does not match what the CFI data
1737a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   says.  Sigh.
1738a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj
1739a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   Why is this important?  Imagine that a wrapper has a stack
1740a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   allocated local, and passes to the hidden call, a pointer to it.
1741a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   Because gcc does not know about the hidden call, it may allocate
1742a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   that local in the redzone.  Unfortunately the hidden call may then
1743a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   trash it before it comes to use it.  So we must step clear of the
1744a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   redzone, for the duration of the hidden call, to make it safe.
1745a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj
1746a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   Probably the same problem afflicts the other redzone-style ABIs too
17476e9de463ef677f093e9f24f126e1b11c28cf59fdsewardj   (ppc64-linux); but for those, the stack is
1748a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   self describing (none of this CFI nonsense) so at least messing
1749a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   with the stack pointer doesn't give a danger of non-unwindable
1750a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   stack. */
1751a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj
17524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_v(lval, orig)                                        \
17534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
17544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
17554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[1];                               \
17564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
17574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
17584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
17594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
17604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
17614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
17624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
17634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
17644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
17654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
17664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
17674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
17684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
17694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
17704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
17714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
17724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
17734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_W(lval, orig, arg1)                                  \
17744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
17754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
17764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[2];                               \
17774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
17784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
17794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
17804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
17814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
17824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
17834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
17844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
17854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
17864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
17874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
17884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
17894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
17904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
17914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
17924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
17934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
17944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
17954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
17964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_WW(lval, orig, arg1,arg2)                            \
17974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
17984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
17994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[3];                               \
18004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
18014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
18024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
18034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
18044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
18054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
18064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
18074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
18084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
18094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
18104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
18114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
18124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
18134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
18144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
18154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
18164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
18174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
18184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
18194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
18204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
18214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                      \
18224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
18234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
18244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[4];                               \
18254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
18264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
18274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
18284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
18294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
18304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
18314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
18324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
18334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
18344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
18354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
18364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
18374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
18384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
18394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
18404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
18414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
18424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
18434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
18444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
18454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
18464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
18474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
18484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)                \
18494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
18504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
18514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[5];                               \
18524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
18534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
18544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
18554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
18564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
18574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
18584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
18594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
18604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
18614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
18624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
18634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
18644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
18654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
18664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
18674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
18684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
18694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
18704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
18714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
18724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
18734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
18744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
18754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
18764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
18774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)             \
18784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
18794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
18804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[6];                               \
18814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
18824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
18834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
18844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
18854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
18864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
18874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
18884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
18894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
18904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
18914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
18924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
18934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
18944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
18954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
18964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
18974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
18984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
18994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
19004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
19014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
19024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
19034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
19044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
19054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
19064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
19074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
19084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)        \
19094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
19104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
19114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[7];                               \
19124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
19134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
19144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
19154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
19164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
19174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
19184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
19194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
19204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
19214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
19224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
19234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
19244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
19254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
19264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
19274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
19284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
19294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
19304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
19314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
19324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
19334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
19344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
19354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
19364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
19374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
19384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
19394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
19404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
19414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,        \
19424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                 arg7)                                 \
19434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
19444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
19454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[8];                               \
19464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
19474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
19484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
19494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
19504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
19514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
19524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
19534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
19544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
19554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
19564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
19574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
19584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $136,%%rsp\n\t"                                         \
19594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
19604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
19614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
19624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
19634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
19644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
19654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
19664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
19674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
19684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
19694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
19704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
19714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
19724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
19734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
19744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
19754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
19764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
19774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,        \
19784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                 arg7,arg8)                            \
19794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
19804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
19814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[9];                               \
19824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
19834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
19844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
19854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
19864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
19874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
19884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
19894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
19904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
19914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
19924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
19934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
19944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
19954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
19964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
19974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
19984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
19994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
20004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
20014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
20024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
20034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
20044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
20054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
20064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
20074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
20084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
20094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
20104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
20114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
20124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
20134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
20144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
20154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,        \
20164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                 arg7,arg8,arg9)                       \
20174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
20184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
20194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[10];                              \
20204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
20214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
20224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
20234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
20244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
20254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
20264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
20274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
20284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
20294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
20304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[9] = (unsigned long)(arg9);                              \
20314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
20324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
20334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
20344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $136,%%rsp\n\t"                                         \
20354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 72(%%rax)\n\t"                                         \
20364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
20374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
20384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
20394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
20404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
20414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
20424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
20434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
20444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
20454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
20464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
20474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
20484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
20494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
20504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
20514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
20524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
20534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
20544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
20554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,       \
20564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                  arg7,arg8,arg9,arg10)                \
20574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
20584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
20594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[11];                              \
20604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
20614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
20624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
20634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
20644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
20654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
20664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
20674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
20684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
20694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
20704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[9] = (unsigned long)(arg9);                              \
20714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[10] = (unsigned long)(arg10);                            \
20724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
20734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
20744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
20754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
20764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 80(%%rax)\n\t"                                         \
20774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 72(%%rax)\n\t"                                         \
20784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
20794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
20804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
20814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
20824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
20834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
20844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
20854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
20864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
20874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
20884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
20894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
20904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
20914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
20924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
20934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
20944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
20954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
20964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
20974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,       \
20984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                  arg7,arg8,arg9,arg10,arg11)          \
20994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
21004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
21014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[12];                              \
21024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
21034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
21044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
21054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
21064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
21074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
21084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
21094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
21104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
21114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
21124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[9] = (unsigned long)(arg9);                              \
21134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[10] = (unsigned long)(arg10);                            \
21144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[11] = (unsigned long)(arg11);                            \
21154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
21164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
21174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
21184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $136,%%rsp\n\t"                                         \
21194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 88(%%rax)\n\t"                                         \
21204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 80(%%rax)\n\t"                                         \
21214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 72(%%rax)\n\t"                                         \
21224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
21234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
21244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
21254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
21264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
21274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
21284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
21294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
21304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
21314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
21324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
21334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
21344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
21354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
21364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
21374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
21384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
21394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
21404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
21414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,       \
21424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                arg7,arg8,arg9,arg10,arg11,arg12)      \
21434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
21444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
21454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[13];                              \
21464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
21474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
21484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
21494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
21504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
21514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
21524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
21534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
21544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
21554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
21564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[9] = (unsigned long)(arg9);                              \
21574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[10] = (unsigned long)(arg10);                            \
21584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[11] = (unsigned long)(arg11);                            \
21594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[12] = (unsigned long)(arg12);                            \
21604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
21614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
21624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
21634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
21644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 96(%%rax)\n\t"                                         \
21654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 88(%%rax)\n\t"                                         \
21664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 80(%%rax)\n\t"                                         \
21674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 72(%%rax)\n\t"                                         \
21684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
21694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
21704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
21714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
21724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
21734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
21744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
21754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
21764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
21774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
21784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
21794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
21804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
21814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
21824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
21834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
21844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
2185a50f9dcb3a7609e10047a4c6dfa3eb7363088bd2sewardj   } while (0)
2186a50f9dcb3a7609e10047a4c6dfa3eb7363088bd2sewardj
2187f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#endif /* PLAT_amd64_linux || PLAT_amd64_darwin */
21880ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2189f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* ------------------------ ppc32-linux ------------------------ */
21900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2191f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#if defined(PLAT_ppc32_linux)
21920ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2193ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj/* This is useful for finding out about the on-stack stuff:
2194ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2195ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   extern int f9  ( int,int,int,int,int,int,int,int,int );
2196ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   extern int f10 ( int,int,int,int,int,int,int,int,int,int );
2197ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   extern int f11 ( int,int,int,int,int,int,int,int,int,int,int );
2198ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   extern int f12 ( int,int,int,int,int,int,int,int,int,int,int,int );
2199ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2200ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   int g9 ( void ) {
2201ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      return f9(11,22,33,44,55,66,77,88,99);
2202ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   }
2203ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   int g10 ( void ) {
2204ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      return f10(11,22,33,44,55,66,77,88,99,110);
2205ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   }
2206ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   int g11 ( void ) {
2207ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      return f11(11,22,33,44,55,66,77,88,99,110,121);
2208ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   }
2209ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   int g12 ( void ) {
2210ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      return f12(11,22,33,44,55,66,77,88,99,110,121,132);
2211ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   }
2212ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj*/
2213ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
22140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
22150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
22160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These regs are trashed by the hidden call. */
2217ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define __CALLER_SAVED_REGS                                       \
2218ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   "lr", "ctr", "xer",                                            \
2219ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
2220ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
2221ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   "r11", "r12", "r13"
22220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
22234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
22244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
22254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
22264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
22274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
22284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
22294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "mr 28,1\n\t"                        \
22304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "rlwinm 1,1,0,0,27\n\t"
22314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
22324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "mr 1,28\n\t"
22334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
2234ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj/* These CALL_FN_ macros assume that on ppc32-linux,
2235ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   sizeof(unsigned long) == 4. */
22360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
223738de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj#define CALL_FN_W_v(lval, orig)                                   \
22380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
2239d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile OrigFn        _orig = (orig);                      \
22400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[1];                          \
22410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
2242d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
22430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
22444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
22450ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr 11,%1\n\t"                                           \
22460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
22470ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
22484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
22490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr %0,3"                                                \
22500ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=r" (_res)                                  \
22510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "r" (&_argvec[0])                            \
22524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
22530ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
22540ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
22550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
22560ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
225738de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
22580ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
225938de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj      volatile OrigFn        _orig = (orig);                      \
22600ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[2];                          \
22610ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
226238de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
22630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)arg1;                           \
22640ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
22654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
22660ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr 11,%1\n\t"                                           \
22670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
22680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
22690ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
22704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
22710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr %0,3"                                                \
22720ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=r" (_res)                                  \
22730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "r" (&_argvec[0])                            \
22744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
22750ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
22760ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
22770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
22780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
227938de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
22800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
228138de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj      volatile OrigFn        _orig = (orig);                      \
22820ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[3];                          \
22830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
228438de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
22850ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)arg1;                           \
22860ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)arg2;                           \
22870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
22884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
22890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr 11,%1\n\t"                                           \
22900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
22910ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 4,8(11)\n\t"                                        \
22920ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
22930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
22944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
22950ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr %0,3"                                                \
22960ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=r" (_res)                                  \
22970ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "r" (&_argvec[0])                            \
22984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
22990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
23000ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
23010ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
23020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2303ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
2304ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2305ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2306ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[4];                          \
2307ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2308ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2309ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2310ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2311ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2312ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
23134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2314ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2315ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2316ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2317ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2318ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2319ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
23204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2321ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2322ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2323ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
23244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2325ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2326ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2327ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2328ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2329ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
2330ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2331ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2332ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[5];                          \
2333ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2334ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2335ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2336ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2337ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2338ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2339ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
23404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2341ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2342ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2343ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2344ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2345ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2346ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2347ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
23484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2349ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2350ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2351ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
23524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2353ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2354ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2355ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2356ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2357ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
2358ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2359ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2360ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[6];                          \
2361ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2362ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2363ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2364ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2365ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2366ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2367ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2368ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
23694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2370ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2371ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2372ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2373ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2374ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2375ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2376ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2377ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
23784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2379ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2380ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2381ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
23824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2383ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2384ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2385ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2386ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2387ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
2388ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2389ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2390ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[7];                          \
2391ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2392ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2393ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2394ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2395ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2396ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2397ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2398ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2399ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
24004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2401ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2402ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2403ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2404ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2405ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2406ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2407ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2408ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2409ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
24104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2411ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2412ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2413ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
24144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2415ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2416ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2417ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2418ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2419ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2420ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                 arg7)                            \
2421ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2422ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2423ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[8];                          \
2424ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2425ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2426ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2427ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2428ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2429ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2430ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2431ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2432ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2433ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
24344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2435ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2436ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2437ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2438ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2439ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2440ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2441ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2442ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2443ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2444ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
24454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2446ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2447ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2448ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
24494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2450ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2451ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2452ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2453ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2454ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2455ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                 arg7,arg8)                       \
2456ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2457ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2458ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[9];                          \
2459ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2460ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2461ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2462ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2463ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2464ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2465ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2466ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2467ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2468ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2469ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
24704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2471ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2472ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2473ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2474ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2475ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2476ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2477ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2478ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2479ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2480ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2481ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
24824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2483ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2484ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2485ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
24864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2487ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2488ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2489ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2490ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2491ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2492ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                 arg7,arg8,arg9)                  \
2493ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2494ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2495ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[10];                         \
2496ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2497ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2498ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2499ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2500ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2501ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2502ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2503ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2504ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2505ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2506ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[9] = (unsigned long)arg9;                           \
2507ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
25084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2509ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2510ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "addi 1,1,-16\n\t"                                       \
2511ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg9 */                                               \
2512ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,36(11)\n\t"                                       \
2513ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,8(1)\n\t"                                         \
2514ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* args1-8 */                                            \
2515ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2516ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2517ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2518ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2519ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2520ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2521ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2522ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2523ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2524ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
25254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2526ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2527ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2528ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
25294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2530ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2531ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2532ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2533ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2534ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
2535ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                  arg7,arg8,arg9,arg10)           \
2536ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2537ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2538ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[11];                         \
2539ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2540ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2541ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2542ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2543ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2544ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2545ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2546ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2547ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2548ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2549ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[9] = (unsigned long)arg9;                           \
2550ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[10] = (unsigned long)arg10;                         \
2551ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
25524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2553ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2554ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "addi 1,1,-16\n\t"                                       \
2555ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg10 */                                              \
2556ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,40(11)\n\t"                                       \
2557ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,12(1)\n\t"                                        \
2558ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg9 */                                               \
2559ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,36(11)\n\t"                                       \
2560ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,8(1)\n\t"                                         \
2561ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* args1-8 */                                            \
2562ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2563ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2564ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2565ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2566ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2567ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2568ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2569ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2570ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2571ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
25724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2573ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2574ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2575ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
25764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2577ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2578ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2579ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2580ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2581ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
2582ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                  arg7,arg8,arg9,arg10,arg11)     \
2583ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2584ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2585ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[12];                         \
2586ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2587ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2588ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2589ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2590ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2591ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2592ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2593ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2594ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2595ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2596ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[9] = (unsigned long)arg9;                           \
2597ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[10] = (unsigned long)arg10;                         \
2598ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[11] = (unsigned long)arg11;                         \
2599ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
26004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2601ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2602ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "addi 1,1,-32\n\t"                                       \
2603ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg11 */                                              \
2604ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,44(11)\n\t"                                       \
2605ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,16(1)\n\t"                                        \
2606ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg10 */                                              \
2607ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,40(11)\n\t"                                       \
2608ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,12(1)\n\t"                                        \
2609ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg9 */                                               \
2610ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,36(11)\n\t"                                       \
2611ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,8(1)\n\t"                                         \
2612ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* args1-8 */                                            \
2613ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2614ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2615ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2616ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2617ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2618ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2619ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2620ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2621ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2622ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
26234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2624ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2625ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2626ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
26274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2628ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2629ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2630ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2631ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2632ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
2633ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                arg7,arg8,arg9,arg10,arg11,arg12) \
2634ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2635ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2636ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[13];                         \
2637ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2638ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2639ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2640ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2641ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2642ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2643ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2644ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2645ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2646ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2647ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[9] = (unsigned long)arg9;                           \
2648ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[10] = (unsigned long)arg10;                         \
2649ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[11] = (unsigned long)arg11;                         \
2650ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[12] = (unsigned long)arg12;                         \
2651ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
26524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2653ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2654ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "addi 1,1,-32\n\t"                                       \
2655ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg12 */                                              \
2656ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,48(11)\n\t"                                       \
2657ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,20(1)\n\t"                                        \
2658ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg11 */                                              \
2659ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,44(11)\n\t"                                       \
2660ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,16(1)\n\t"                                        \
2661ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg10 */                                              \
2662ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,40(11)\n\t"                                       \
2663ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,12(1)\n\t"                                        \
2664ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg9 */                                               \
2665ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,36(11)\n\t"                                       \
2666ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,8(1)\n\t"                                         \
2667ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* args1-8 */                                            \
2668ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2669ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2670ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2671ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2672ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2673ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2674ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2675ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2676ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2677ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
26784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2679ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2680ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2681ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
26824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2683ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2684ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2685ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2686ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2687f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#endif /* PLAT_ppc32_linux */
26880ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2689f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* ------------------------ ppc64-linux ------------------------ */
26900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2691cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#if defined(PLAT_ppc64be_linux)
26929734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
26939734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
26949734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
26959734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj/* These regs are trashed by the hidden call. */
2696cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define __CALLER_SAVED_REGS                                       \
2697cd63639e41d591b17cf8900e49e28048d39104c2sewardj   "lr", "ctr", "xer",                                            \
2698cd63639e41d591b17cf8900e49e28048d39104c2sewardj   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
2699cd63639e41d591b17cf8900e49e28048d39104c2sewardj   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
2700cd63639e41d591b17cf8900e49e28048d39104c2sewardj   "r11", "r12", "r13"
27019734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
27024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
27034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
27044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
27054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
27064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
27074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
27084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "mr 28,1\n\t"                        \
27094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "rldicr 1,1,0,59\n\t"
27104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
27114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "mr 1,28\n\t"
27124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
27139734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj/* These CALL_FN_ macros assume that on ppc64-linux, sizeof(unsigned
27149734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   long) == 8. */
27159734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
2716d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define CALL_FN_W_v(lval, orig)                                   \
27179734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   do {                                                           \
2718d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile OrigFn        _orig = (orig);                      \
2719d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile unsigned long _argvec[3+0];                        \
27209734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      volatile unsigned long _res;                                \
2721d68ac3e974d25f88492774f6baa491999afde9f9sewardj      /* _argvec[0] holds current r2 across the call */           \
2722d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[1] = (unsigned long)_orig.r2;                       \
2723d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2] = (unsigned long)_orig.nraddr;                   \
27249734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      __asm__ volatile(                                           \
27254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
27269734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
2727d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2728d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2729d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
27309734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
27319734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
27329734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr %0,3\n\t"                                            \
27334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
27344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
27359734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         : /*out*/   "=r" (_res)                                  \
2736d68ac3e974d25f88492774f6baa491999afde9f9sewardj         : /*in*/    "r" (&_argvec[2])                            \
27374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
27389734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      );                                                          \
27399734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      lval = (__typeof__(lval)) _res;                             \
27409734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   } while (0)
27419734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
2742d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
27439734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   do {                                                           \
2744d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile OrigFn        _orig = (orig);                      \
2745d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile unsigned long _argvec[3+1];                        \
27469734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      volatile unsigned long _res;                                \
2747d68ac3e974d25f88492774f6baa491999afde9f9sewardj      /* _argvec[0] holds current r2 across the call */           \
2748d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2749d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2750d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
27519734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      __asm__ volatile(                                           \
27524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
27539734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
2754d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2755d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2756d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2757d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
27589734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
27599734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
27609734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr %0,3\n\t"                                            \
27614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
27624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
27639734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         : /*out*/   "=r" (_res)                                  \
2764d68ac3e974d25f88492774f6baa491999afde9f9sewardj         : /*in*/    "r" (&_argvec[2])                            \
27654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
27669734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      );                                                          \
27679734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      lval = (__typeof__(lval)) _res;                             \
27689734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   } while (0)
27699734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
2770d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
27719734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   do {                                                           \
2772d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile OrigFn        _orig = (orig);                      \
2773d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile unsigned long _argvec[3+2];                        \
27749734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      volatile unsigned long _res;                                \
2775d68ac3e974d25f88492774f6baa491999afde9f9sewardj      /* _argvec[0] holds current r2 across the call */           \
2776d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2777d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2778d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2779d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
27809734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      __asm__ volatile(                                           \
27814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
27829734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
2783d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2784d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2785d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2786cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2787cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2788cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2789cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2790cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
27914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
27924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2793cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2794cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
27954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2796cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2797cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2798cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2799cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2800cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
2801cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2802cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2803cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+3];                        \
2804cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2805cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2806cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2807cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2808cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2809cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2810cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2811cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
28124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2813cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2814cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2815cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2816cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2817cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2818cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2819d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
28209734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
28219734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
28229734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr %0,3\n\t"                                            \
28234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
28244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
28259734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         : /*out*/   "=r" (_res)                                  \
2826d68ac3e974d25f88492774f6baa491999afde9f9sewardj         : /*in*/    "r" (&_argvec[2])                            \
28274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2828cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2829cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2830cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2831cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2832cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
2833cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2834cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2835cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+4];                        \
2836cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2837cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2838cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2839cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2840cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2841cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2842cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2843cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2844cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
28454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2846cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2847cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2848cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2849cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2850cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2851cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2852cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
2853cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2854cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2855cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2856cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
28574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
28584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2859cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2860cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
28614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2862cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2863cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2864cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2865cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2866cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
2867cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2868cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2869cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+5];                        \
2870cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2871cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2872cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2873cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2874cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2875cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2876cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2877cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2878cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
2879cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
28804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2881cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2882cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2883cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2884cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2885cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2886cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2887cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
2888cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
2889cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2890cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2891cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2892cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
28934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
28944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2895cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2896cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
28974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2898cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2899cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2900cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2901cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2902cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
2903cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2904cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2905cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+6];                        \
2906cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2907cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2908cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2909cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2910cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2911cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2912cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2913cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2914cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
2915cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
2916cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
29174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2918cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2919cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2920cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2921cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2922cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2923cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2924cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
2925cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
2926cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
2927cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2928cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2929cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2930cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
29314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
29324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2933cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2934cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
29354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2936cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2937cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2938cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2939cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2940cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2941cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                 arg7)                            \
2942cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2943cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2944cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+7];                        \
2945cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2946cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2947cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2948cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2949cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2950cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2951cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2952cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2953cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
2954cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
2955cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
2956cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
29574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2958cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2959cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2960cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2961cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2962cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2963cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2964cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
2965cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
2966cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
2967cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
2968cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2969cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2970cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2971cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
29724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
29734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2974cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2975cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
29764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2977cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2978cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2979cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2980cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2981cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2982cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                 arg7,arg8)                       \
2983cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2984cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2985cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+8];                        \
2986cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2987cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2988cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2989cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2990cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2991cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2992cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2993cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2994cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
2995cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
2996cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
2997cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
2998cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
29994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3000cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3001cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3002cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3003cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3004cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3005cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3006cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3007cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3008cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3009cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3010cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3011cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3012cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3013cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3014cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
30154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
30164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3017cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3018cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
30194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3020cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
3021cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
3022cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
3023cd63639e41d591b17cf8900e49e28048d39104c2sewardj
3024cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
3025cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                 arg7,arg8,arg9)                  \
3026cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
3027cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
3028cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+9];                        \
3029cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
3030cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3031cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3032cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3033cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3034cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3035cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3036cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3037cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3038cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3039cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3040cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3041cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+9] = (unsigned long)arg9;                         \
3042cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
30434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3044cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3045cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3046cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3047cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "addi 1,1,-128\n\t"  /* expand stack frame */            \
3048cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg9 */                                               \
3049cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,72(11)\n\t"                                       \
3050cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,112(1)\n\t"                                       \
3051cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* args1-8 */                                            \
3052cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3053cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3054cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3055cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3056cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3057cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3058cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3059cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3060cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3061cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3062cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3063cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
3064cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
30654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3066cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3067cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
30684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3069cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
3070cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
3071cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
3072cd63639e41d591b17cf8900e49e28048d39104c2sewardj
3073cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3074cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                  arg7,arg8,arg9,arg10)           \
3075cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
3076cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
3077cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+10];                       \
3078cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
3079cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3080cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3081cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3082cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3083cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3084cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3085cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3086cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3087cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3088cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3089cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3090cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+9] = (unsigned long)arg9;                         \
3091cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+10] = (unsigned long)arg10;                       \
3092cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
30934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3094cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3095cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3096cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3097cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "addi 1,1,-128\n\t"  /* expand stack frame */            \
3098cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg10 */                                              \
3099cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,80(11)\n\t"                                       \
3100cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,120(1)\n\t"                                       \
3101cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg9 */                                               \
3102cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,72(11)\n\t"                                       \
3103cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,112(1)\n\t"                                       \
3104cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* args1-8 */                                            \
3105cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3106cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3107cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3108cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3109cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3110cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3111cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3112cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3113cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3114cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3115cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3116cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
3117cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
31184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3119cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3120cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
31214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3122cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
3123cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
3124cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
3125cd63639e41d591b17cf8900e49e28048d39104c2sewardj
3126cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3127cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                  arg7,arg8,arg9,arg10,arg11)     \
3128cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
3129cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
3130cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+11];                       \
3131cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
3132cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3133cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3134cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3135cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3136cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3137cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3138cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3139cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3140cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3141cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3142cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3143cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+9] = (unsigned long)arg9;                         \
3144cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+10] = (unsigned long)arg10;                       \
3145cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+11] = (unsigned long)arg11;                       \
3146cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
31474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3148cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3149cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3150cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3151cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "addi 1,1,-144\n\t"  /* expand stack frame */            \
3152cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg11 */                                              \
3153cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,88(11)\n\t"                                       \
3154cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,128(1)\n\t"                                       \
3155cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg10 */                                              \
3156cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,80(11)\n\t"                                       \
3157cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,120(1)\n\t"                                       \
3158cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg9 */                                               \
3159cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,72(11)\n\t"                                       \
3160cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,112(1)\n\t"                                       \
3161cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* args1-8 */                                            \
3162cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3163cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3164cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3165cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3166cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3167cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3168cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3169cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3170cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3171cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3172cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3173cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
3174cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
31754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3176cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3177cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
31784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3179cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
3180cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
3181cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
3182cd63639e41d591b17cf8900e49e28048d39104c2sewardj
3183cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3184cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                arg7,arg8,arg9,arg10,arg11,arg12) \
3185cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
3186cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
3187cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+12];                       \
3188cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
3189cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3190cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3191cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3192cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3193cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3194cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3195cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3196cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3197cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3198cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3199cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3200cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+9] = (unsigned long)arg9;                         \
3201cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+10] = (unsigned long)arg10;                       \
3202cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+11] = (unsigned long)arg11;                       \
3203cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+12] = (unsigned long)arg12;                       \
3204cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
32054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3206cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3207cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3208cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3209cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "addi 1,1,-144\n\t"  /* expand stack frame */            \
3210cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg12 */                                              \
3211cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,96(11)\n\t"                                       \
3212cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,136(1)\n\t"                                       \
3213cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg11 */                                              \
3214cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,88(11)\n\t"                                       \
3215cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,128(1)\n\t"                                       \
3216cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg10 */                                              \
3217cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,80(11)\n\t"                                       \
3218cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,120(1)\n\t"                                       \
3219cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg9 */                                               \
3220cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,72(11)\n\t"                                       \
3221cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,112(1)\n\t"                                       \
3222cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* args1-8 */                                            \
3223cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3224cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3225cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3226cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3227cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3228cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3229cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3230cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3231cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3232cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3233cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3234cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
3235cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
32364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3237cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3238cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
32394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
32409734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      );                                                          \
32419734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      lval = (__typeof__(lval)) _res;                             \
32429734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   } while (0)
32439734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
3244cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#endif /* PLAT_ppc64be_linux */
3245f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj
3246582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* ------------------------- ppc64le-linux ----------------------- */
3247582d58245637ab05272d89fb94b12fd0f18fa0f8carll#if defined(PLAT_ppc64le_linux)
3248582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3249582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
3250582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3251582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* These regs are trashed by the hidden call. */
3252582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define __CALLER_SAVED_REGS                                       \
3253582d58245637ab05272d89fb94b12fd0f18fa0f8carll   "lr", "ctr", "xer",                                            \
3254582d58245637ab05272d89fb94b12fd0f18fa0f8carll   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
3255582d58245637ab05272d89fb94b12fd0f18fa0f8carll   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
3256582d58245637ab05272d89fb94b12fd0f18fa0f8carll   "r11", "r12", "r13"
3257582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3258582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* Macros to save and align the stack before making a function
3259582d58245637ab05272d89fb94b12fd0f18fa0f8carll   call and restore it afterwards as gcc may not keep the stack
3260582d58245637ab05272d89fb94b12fd0f18fa0f8carll   pointer aligned if it doesn't realise calls are being made
3261582d58245637ab05272d89fb94b12fd0f18fa0f8carll   to other functions. */
3262582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3263582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_ALIGN_STACK               \
3264582d58245637ab05272d89fb94b12fd0f18fa0f8carll      "mr 28,1\n\t"                        \
3265582d58245637ab05272d89fb94b12fd0f18fa0f8carll      "rldicr 1,1,0,59\n\t"
3266582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_RESTORE_STACK             \
3267582d58245637ab05272d89fb94b12fd0f18fa0f8carll      "mr 1,28\n\t"
3268582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3269582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* These CALL_FN_ macros assume that on ppc64-linux, sizeof(unsigned
3270582d58245637ab05272d89fb94b12fd0f18fa0f8carll   long) == 8. */
3271582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3272582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_v(lval, orig)                                   \
3273582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3274582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3275582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+0];                        \
3276582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3277582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3278582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1] = (unsigned long)_orig.r2;                       \
3279582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2] = (unsigned long)_orig.nraddr;                   \
3280582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3281582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3282582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3283582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3284582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3285582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3286582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3287582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3288582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3289582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3290582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3291582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3292582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3293582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3294582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3295582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3296582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3297582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3298582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_W(lval, orig, arg1)                             \
3299582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3300582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3301582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+1];                        \
3302582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3303582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3304582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3305582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3306582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3307582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3308582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3309582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3310582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3311582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3312582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3313582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3314582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3315582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3316582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3317582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3318582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3319582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3320582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3321582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3322582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3323582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3324582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3325582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3326582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
3327582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3328582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3329582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+2];                        \
3330582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3331582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3332582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3333582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3334582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3335582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3336582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3337582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3338582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3339582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3340582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3341582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3342582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3343582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3344582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3345582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3346582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3347582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3348582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3349582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3350582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3351582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3352582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3353582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3354582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3355582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3356582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
3357582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3358582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3359582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+3];                        \
3360582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3361582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3362582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3363582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3364582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3365582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3366582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3367582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3368582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3369582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3370582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3371582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3372582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3373582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3374582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3375582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3376582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3377582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3378582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3379582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3380582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3381582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3382582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3383582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3384582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3385582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3386582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3387582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3388582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
3389582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3390582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3391582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+4];                        \
3392582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3393582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3394582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3395582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3396582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3397582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3398582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3399582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3400582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3401582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3402582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3403582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3404582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3405582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3406582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3407582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3408582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3409582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3410582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3411582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3412582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3413582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3414582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3415582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3416582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3417582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3418582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3419582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3420582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3421582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3422582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
3423582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3424582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3425582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+5];                        \
3426582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3427582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3428582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3429582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3430582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3431582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3432582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3433582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3434582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3435582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3436582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3437582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3438582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3439582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3440582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3441582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3442582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3443582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3444582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3445582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3446582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3447582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3448582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3449582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3450582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3451582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3452582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3453582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3454582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3455582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3456582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3457582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3458582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
3459582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3460582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3461582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+6];                        \
3462582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3463582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3464582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3465582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3466582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3467582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3468582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3469582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3470582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3471582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3472582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3473582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3474582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3475582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3476582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3477582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3478582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3479582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3480582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3481582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3482582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3483582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3484582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3485582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3486582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3487582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3488582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3489582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3490582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3491582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3492582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3493582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3494582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3495582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3496582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
3497582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                 arg7)                            \
3498582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3499582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3500582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+7];                        \
3501582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3502582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3503582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3504582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3505582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3506582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3507582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3508582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3509582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3510582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3511582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3512582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3513582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3514582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3515582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3516582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3517582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3518582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3519582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3520582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3521582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3522582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3523582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3524582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3525582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3526582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3527582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3528582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3529582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3530582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3531582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3532582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3533582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3534582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3535582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3536582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3537582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
3538582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                 arg7,arg8)                       \
3539582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3540582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3541582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+8];                        \
3542582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3543582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3544582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3545582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3546582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3547582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3548582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3549582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3550582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3551582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3552582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3553582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3554582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3555582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3556582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3557582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3558582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3559582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3560582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3561582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3562582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3563582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3564582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3565582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3566582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3567582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3568582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3569582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3570582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3571582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3572582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3573582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3574582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3575582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3576582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3577582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3578582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3579582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3580582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
3581582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                 arg7,arg8,arg9)                  \
3582582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3583582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3584582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+9];                        \
3585582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3586582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3587582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3588582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3589582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3590582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3591582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3592582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3593582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3594582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3595582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3596582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3597582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+9] = (unsigned long)arg9;                         \
3598582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3599582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3600582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3601582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3602582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3603582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "addi 1,1,-128\n\t"  /* expand stack frame */            \
3604582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg9 */                                               \
3605582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,72(12)\n\t"                                       \
3606582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,96(1)\n\t"                                        \
3607582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* args1-8 */                                            \
3608582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3609582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3610582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3611582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3612582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3613582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3614582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3615582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3616582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3617582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3618582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3619582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3620582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3621582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3622582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3623582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3624582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3625582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3626582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3627582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3628582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3629582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3630582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                  arg7,arg8,arg9,arg10)           \
3631582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3632582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3633582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+10];                       \
3634582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3635582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3636582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3637582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3638582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3639582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3640582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3641582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3642582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3643582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3644582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3645582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3646582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+9] = (unsigned long)arg9;                         \
3647582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+10] = (unsigned long)arg10;                       \
3648582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3649582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3650582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3651582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3652582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3653582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "addi 1,1,-128\n\t"  /* expand stack frame */            \
3654582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg10 */                                              \
3655582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,80(12)\n\t"                                       \
3656582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,104(1)\n\t"                                       \
3657582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg9 */                                               \
3658582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,72(12)\n\t"                                       \
3659582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,96(1)\n\t"                                        \
3660582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* args1-8 */                                            \
3661582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3662582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3663582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3664582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3665582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3666582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3667582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3668582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3669582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3670582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3671582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3672582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3673582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3674582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3675582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3676582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3677582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3678582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3679582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3680582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3681582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3682582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3683582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                  arg7,arg8,arg9,arg10,arg11)     \
3684582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3685582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3686582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+11];                       \
3687582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3688582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3689582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3690582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3691582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3692582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3693582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3694582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3695582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3696582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3697582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3698582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3699582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+9] = (unsigned long)arg9;                         \
3700582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+10] = (unsigned long)arg10;                       \
3701582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+11] = (unsigned long)arg11;                       \
3702582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3703582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3704582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3705582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3706582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3707582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "addi 1,1,-144\n\t"  /* expand stack frame */            \
3708582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg11 */                                              \
3709582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,88(12)\n\t"                                       \
3710582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,112(1)\n\t"                                       \
3711582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg10 */                                              \
3712582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,80(12)\n\t"                                       \
3713582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,104(1)\n\t"                                       \
3714582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg9 */                                               \
3715582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,72(12)\n\t"                                       \
3716582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,96(1)\n\t"                                        \
3717582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* args1-8 */                                            \
3718582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3719582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3720582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3721582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3722582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3723582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3724582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3725582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3726582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3727582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3728582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3729582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3730582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3731582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3732582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3733582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3734582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3735582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3736582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3737582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3738582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3739582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3740582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                arg7,arg8,arg9,arg10,arg11,arg12) \
3741582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3742582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3743582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+12];                       \
3744582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3745582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3746582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3747582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3748582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3749582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3750582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3751582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3752582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3753582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3754582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3755582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3756582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+9] = (unsigned long)arg9;                         \
3757582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+10] = (unsigned long)arg10;                       \
3758582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+11] = (unsigned long)arg11;                       \
3759582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+12] = (unsigned long)arg12;                       \
3760582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3761582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3762582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3763582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3764582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3765582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "addi 1,1,-144\n\t"  /* expand stack frame */            \
3766582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg12 */                                              \
3767582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,96(12)\n\t"                                       \
3768582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,120(1)\n\t"                                       \
3769582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg11 */                                              \
3770582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,88(12)\n\t"                                       \
3771582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,112(1)\n\t"                                       \
3772582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg10 */                                              \
3773582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,80(12)\n\t"                                       \
3774582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,104(1)\n\t"                                       \
3775582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg9 */                                               \
3776582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,72(12)\n\t"                                       \
3777582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,96(1)\n\t"                                        \
3778582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* args1-8 */                                            \
3779582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3780582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3781582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3782582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3783582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3784582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3785582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3786582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3787582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3788582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3789582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3790582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3791582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3792582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3793582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3794582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3795582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3796582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3797582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3798582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3799582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3800582d58245637ab05272d89fb94b12fd0f18fa0f8carll#endif /* PLAT_ppc64le_linux */
3801582d58245637ab05272d89fb94b12fd0f18fa0f8carll
380259570ffbe31930ab4d678754daaeec0715117a3dsewardj/* ------------------------- arm-linux ------------------------- */
380359570ffbe31930ab4d678754daaeec0715117a3dsewardj
380459570ffbe31930ab4d678754daaeec0715117a3dsewardj#if defined(PLAT_arm_linux)
380559570ffbe31930ab4d678754daaeec0715117a3dsewardj
380659570ffbe31930ab4d678754daaeec0715117a3dsewardj/* These regs are trashed by the hidden call. */
380787d812e99f0e33604b268410a677793ef76229d9sewardj#define __CALLER_SAVED_REGS "r0", "r1", "r2", "r3","r4", "r12", "r14"
380859570ffbe31930ab4d678754daaeec0715117a3dsewardj
38094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
38104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
38114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
38124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
38134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
3814567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj/* This is a bit tricky.  We store the original stack pointer in r10
3815567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   as it is callee-saves.  gcc doesn't allow the use of r11 for some
3816567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   reason.  Also, we can't directly "bic" the stack pointer in thumb
3817567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   mode since r13 isn't an allowed register number in that context.
3818567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   So use r4 as a temporary, since that is about to get trashed
3819567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   anyway, just after each use of this macro.  Side effect is we need
3820567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   to be very careful about any future changes, since
3821567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   VALGRIND_ALIGN_STACK simply assumes r4 is usable. */
38224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
3823567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "mov r10, sp\n\t"                    \
3824567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "mov r4,  sp\n\t"                    \
3825567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "bic r4,  r4, #7\n\t"                \
3826567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "mov sp,  r4\n\t"
38274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
3828567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "mov sp,  r10\n\t"
38294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
383059570ffbe31930ab4d678754daaeec0715117a3dsewardj/* These CALL_FN_ macros assume that on arm-linux, sizeof(unsigned
383159570ffbe31930ab4d678754daaeec0715117a3dsewardj   long) == 4. */
383259570ffbe31930ab4d678754daaeec0715117a3dsewardj
383359570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_v(lval, orig)                                   \
383459570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
383559570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
383659570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[1];                          \
383759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
383859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
383959570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
38404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
384159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
384259570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
38434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
384459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0\n"                                           \
384559570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
384659570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3847567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
384859570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
384959570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
385059570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
385159570ffbe31930ab4d678754daaeec0715117a3dsewardj
385259570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
385359570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
385459570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
385559570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[2];                          \
385659570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
385759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
385859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
385959570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
38604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
386159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
386259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
386359570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
38644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
386559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0\n"                                           \
386659570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
386759570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3868567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
386959570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
387059570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
387159570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
387259570ffbe31930ab4d678754daaeec0715117a3dsewardj
387359570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
387459570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
387559570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
387659570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[3];                          \
387759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
387859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
387959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
388059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
388159570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
38824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
388359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
388459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
388559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
388659570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
38874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
388859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0\n"                                           \
388959570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
389059570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3891567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
389259570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
389359570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
389459570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
389559570ffbe31930ab4d678754daaeec0715117a3dsewardj
389659570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
389759570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
389859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
389959570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[4];                          \
390059570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
390159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
390259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
390359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
390459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
390559570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
39064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
390759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
390859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
390959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
391059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
391159570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
39124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
391359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0\n"                                           \
391459570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
391559570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3916567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
391759570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
391859570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
391959570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
392059570ffbe31930ab4d678754daaeec0715117a3dsewardj
392159570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
392259570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
392359570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
392459570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[5];                          \
392559570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
392659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
392759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
392859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
392959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
393059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
393159570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
39324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
393359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
393459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
393559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
393659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
393759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
393859570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
39394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
394059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
394159570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
394259570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3943567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
394459570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
394559570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
394659570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
394759570ffbe31930ab4d678754daaeec0715117a3dsewardj
394859570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
394959570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
395059570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
395159570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[6];                          \
395259570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
395359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
395459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
395559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
395659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
395759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
395859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
395959570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
39604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
39614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "sub sp, sp, #4 \n\t"                                    \
396259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
396359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0} \n\t"                                         \
396459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
396559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
396659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
396759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
396859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
396959570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
39704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
397159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
397259570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
397359570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3974567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
397559570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
397659570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
397759570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
397859570ffbe31930ab4d678754daaeec0715117a3dsewardj
397959570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
398059570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
398159570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
398259570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[7];                          \
398359570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
398459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
398559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
398659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
398759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
398859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
398959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
399059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
399159570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
39924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
399359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
399459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
399559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1} \n\t"                                     \
399659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
399759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
399859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
399959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
400059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
400159570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
40024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
400359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
400459570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
400559570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4006567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
400759570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
400859570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
400959570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
401059570ffbe31930ab4d678754daaeec0715117a3dsewardj
401159570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
401259570ffbe31930ab4d678754daaeec0715117a3dsewardj                                 arg7)                            \
401359570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
401459570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
401559570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[8];                          \
401659570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
401759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
401859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
401959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
402059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
402159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
402259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
402359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
402459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
402559570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
40264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
40274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "sub sp, sp, #4 \n\t"                                    \
402859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
402959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
403059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
403159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2} \n\t"                                 \
403259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
403359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
403459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
403559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
403659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
403759570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
40384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
403959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
404059570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
404159570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4042567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
404359570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
404459570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
404559570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
404659570ffbe31930ab4d678754daaeec0715117a3dsewardj
404759570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
404859570ffbe31930ab4d678754daaeec0715117a3dsewardj                                 arg7,arg8)                       \
404959570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
405059570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
405159570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[9];                          \
405259570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
405359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
405459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
405559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
405659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
405759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
405859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
405959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
406059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
406159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
406259570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
40634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
406459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
406559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
406659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
406759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
406859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3} \n\t"                             \
406959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
407059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
407159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
407259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
407359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
407459570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
40754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
407659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
407759570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
407859570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4079567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
408059570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
408159570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
408259570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
408359570ffbe31930ab4d678754daaeec0715117a3dsewardj
408459570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
408559570ffbe31930ab4d678754daaeec0715117a3dsewardj                                 arg7,arg8,arg9)                  \
408659570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
408759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
408859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[10];                         \
408959570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
409059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
409159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
409259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
409359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
409459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
409559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
409659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
409759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
409859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
409959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[9] = (unsigned long)(arg9);                         \
410059570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
41014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
41024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "sub sp, sp, #4 \n\t"                                    \
410359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
410459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
410559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
410659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
410759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1, #36] \n\t"                                 \
410859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3, r4} \n\t"                         \
410959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
411059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
411159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
411259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
411359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
411459570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
41154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
411659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
411759570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
411859570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4119567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
412059570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
412159570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
412259570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
412359570ffbe31930ab4d678754daaeec0715117a3dsewardj
412459570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
412559570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg7,arg8,arg9,arg10)           \
412659570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
412759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
412859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[11];                         \
412959570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
413059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
413159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
413259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
413359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
413459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
413559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
413659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
413759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
413859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
413959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[9] = (unsigned long)(arg9);                         \
414059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[10] = (unsigned long)(arg10);                       \
414159570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
41424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
414359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #40] \n\t"                                 \
414459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0} \n\t"                                         \
414559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
414659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
414759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
414859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
414959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1, #36] \n\t"                                 \
415059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3, r4} \n\t"                         \
415159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
415259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
415359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
415459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
415559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
415659570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
41574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
415859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
415959570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
416059570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4161567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
416259570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
416359570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
416459570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
416559570ffbe31930ab4d678754daaeec0715117a3dsewardj
416659570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
416759570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg6,arg7,arg8,arg9,arg10,      \
416859570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg11)                          \
416959570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
417059570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
417159570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[12];                         \
417259570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
417359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
417459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
417559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
417659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
417759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
417859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
417959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
418059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
418159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
418259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[9] = (unsigned long)(arg9);                         \
418359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[10] = (unsigned long)(arg10);                       \
418459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[11] = (unsigned long)(arg11);                       \
418559570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
41864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
41874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "sub sp, sp, #4 \n\t"                                    \
418859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #40] \n\t"                                 \
418959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #44] \n\t"                                 \
419059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1} \n\t"                                     \
419159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
419259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
419359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
419459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
419559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1, #36] \n\t"                                 \
419659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3, r4} \n\t"                         \
419759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
419859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
419959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
420059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
420159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
420259570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
42034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
420459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
420559570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
420659570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4207567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
420859570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
420959570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
421059570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
421159570ffbe31930ab4d678754daaeec0715117a3dsewardj
421259570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
421359570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg6,arg7,arg8,arg9,arg10,      \
421459570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg11,arg12)                    \
421559570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
421659570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
421759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[13];                         \
421859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
421959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
422059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
422159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
422259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
422359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
422459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
422559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
422659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
422759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
422859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[9] = (unsigned long)(arg9);                         \
422959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[10] = (unsigned long)(arg10);                       \
423059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[11] = (unsigned long)(arg11);                       \
423159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[12] = (unsigned long)(arg12);                       \
423259570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
42334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
423459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #40] \n\t"                                 \
423559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #44] \n\t"                                 \
423659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #48] \n\t"                                 \
423759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2} \n\t"                                 \
423859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
423959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
424059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
424159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
424259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1, #36] \n\t"                                 \
424359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3, r4} \n\t"                         \
424459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
424559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
424659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
424759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
424859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
424959570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
42504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
425159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
425259570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
425359570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4254567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
425559570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
425659570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
425759570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
425859570ffbe31930ab4d678754daaeec0715117a3dsewardj
425959570ffbe31930ab4d678754daaeec0715117a3dsewardj#endif /* PLAT_arm_linux */
426059570ffbe31930ab4d678754daaeec0715117a3dsewardj
4261f0c1250e324f6684757c6a15545366447ef1d64fsewardj/* ------------------------ arm64-linux ------------------------ */
4262f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4263f0c1250e324f6684757c6a15545366447ef1d64fsewardj#if defined(PLAT_arm64_linux)
4264f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4265f0c1250e324f6684757c6a15545366447ef1d64fsewardj/* These regs are trashed by the hidden call. */
4266f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define __CALLER_SAVED_REGS \
4267f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "x0", "x1", "x2", "x3","x4", "x5", "x6", "x7", "x8", "x9",   \
4268f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17",      \
4269bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj     "x18", "x19", "x20", "x30",                                  \
4270f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9",  \
4271f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "v10", "v11", "v12", "v13", "v14", "v15", "v16", "v17",      \
4272f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "v18", "v19", "v20", "v21", "v22", "v23", "v24", "v25",      \
4273f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "v26", "v27", "v28", "v29", "v30", "v31"
4274f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4275bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj/* x21 is callee-saved, so we can use it to save and restore SP around
4276bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj   the hidden call. */
4277bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj#define VALGRIND_ALIGN_STACK               \
4278bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj      "mov x21, sp\n\t"                    \
4279bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj      "bic sp, x21, #15\n\t"
4280bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj#define VALGRIND_RESTORE_STACK             \
4281bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj      "mov sp,  x21\n\t"
4282f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4283f0c1250e324f6684757c6a15545366447ef1d64fsewardj/* These CALL_FN_ macros assume that on arm64-linux,
4284f0c1250e324f6684757c6a15545366447ef1d64fsewardj   sizeof(unsigned long) == 8. */
4285f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4286f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_v(lval, orig)                                   \
4287f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4288f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4289f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[1];                          \
4290f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4291f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4292f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4293f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4294f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4295f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4296f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4297f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0\n"                                           \
4298f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4299f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
4300bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4301f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4302f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4303f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4304f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4305f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
4306f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4307f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4308f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[2];                          \
4309f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4310f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4311f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[1] = (unsigned long)(arg1);                         \
4312f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4313f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4314f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x0, [%1, #8] \n\t"                                  \
4315f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4316f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4317f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4318f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0\n"                                           \
4319f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4320f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
4321bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4322f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4323f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4324f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4325f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4326f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
4327f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4328f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4329f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[3];                          \
4330f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4331f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4332f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[1] = (unsigned long)(arg1);                         \
4333f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[2] = (unsigned long)(arg2);                         \
4334f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4335f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4336f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x0, [%1, #8] \n\t"                                  \
4337f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x1, [%1, #16] \n\t"                                 \
4338f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4339f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4340f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4341f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0\n"                                           \
4342f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4343f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
434491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4345f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4346f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4347f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4348f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4349f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
4350f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4351f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4352f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[4];                          \
4353f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4354f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4355f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[1] = (unsigned long)(arg1);                         \
4356f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[2] = (unsigned long)(arg2);                         \
4357f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[3] = (unsigned long)(arg3);                         \
4358f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4359f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4360f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x0, [%1, #8] \n\t"                                  \
4361f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x1, [%1, #16] \n\t"                                 \
4362f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x2, [%1, #24] \n\t"                                 \
4363f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4364f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4365f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4366f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0\n"                                           \
4367f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4368f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
436991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4370f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4371f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4372f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4373f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4374f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
4375f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4376f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4377f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[5];                          \
4378f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4379f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4380f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[1] = (unsigned long)(arg1);                         \
4381f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[2] = (unsigned long)(arg2);                         \
4382f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[3] = (unsigned long)(arg3);                         \
4383f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[4] = (unsigned long)(arg4);                         \
4384f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4385f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4386f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x0, [%1, #8] \n\t"                                  \
4387f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x1, [%1, #16] \n\t"                                 \
4388f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x2, [%1, #24] \n\t"                                 \
4389f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x3, [%1, #32] \n\t"                                 \
4390f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4391f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4392f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4393f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0"                                             \
4394f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4395f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
439691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
439791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
439891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
439991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
440091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
440191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
440291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
440391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
440491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[6];                          \
440591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
440691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
440791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
440891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
440991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
441091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
441191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
441291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
441391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
441491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
441591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
441691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
441791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
441891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
441991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
442091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
442191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
442291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
442391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
442491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
442591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
442691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
442791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
442891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
442991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
443091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
443191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
443291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
443391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[7];                          \
443491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
443591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
443691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
443791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
443891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
443991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
444091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
444191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
444291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
444391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
444491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
444591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
444691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
444791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
444891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
444991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
445091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
445191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
445291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
445391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
445491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
445591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
445691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
445791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
445891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
445991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
446091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
446191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
446291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                 arg7)                            \
446391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
446491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
446591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[8];                          \
446691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
446791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
446891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
446991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
447091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
447191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
447291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
447391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
447491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
447591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
447691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
447791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
447891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
447991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
448091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
448191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
448291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
448391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
448491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
448591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
448691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
448791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
448891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
448991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
449091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
449191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
449291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
449391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
449491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
449591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
449691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                 arg7,arg8)                       \
449791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
449891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
449991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[9];                          \
450091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
450191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
450291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
450391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
450491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
450591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
450691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
450791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
450891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
450991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
451091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
451191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
451291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
451391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
451491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
451591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
451691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
451791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
451891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
451991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
452091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
452191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
452291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
452391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
452491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
452591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
452691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
452791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
452891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
452991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
453091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
453191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
453291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                 arg7,arg8,arg9)                  \
453391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
453491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
453591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[10];                         \
453691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
453791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
453891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
453991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
454091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
454191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
454291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
454391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
454491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
454591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
454691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[9] = (unsigned long)(arg9);                         \
454791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
454891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
454991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "sub sp, sp, #0x20 \n\t"                                 \
455091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
455191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
455291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
455391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
455491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
455591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
455691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
455791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
455891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #72] \n\t"                                 \
455991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #0]  \n\t"                                 \
456091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
456191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
456291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
456391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
456491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
456591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
456691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
456791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
456891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
456991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
457091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
457191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
457291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                  arg7,arg8,arg9,arg10)           \
457391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
457491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
457591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[11];                         \
457691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
457791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
457891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
457991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
458091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
458191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
458291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
458391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
458491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
458591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
458691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[9] = (unsigned long)(arg9);                         \
458791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[10] = (unsigned long)(arg10);                       \
458891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
458991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
459091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "sub sp, sp, #0x20 \n\t"                                 \
459191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
459291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
459391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
459491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
459591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
459691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
459791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
459891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
459991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #72] \n\t"                                 \
460091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #0]  \n\t"                                 \
460191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #80] \n\t"                                 \
460291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #8]  \n\t"                                 \
460391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
460491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
460591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
460691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
460791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
460891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
460991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
461091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
461191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
461291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
461391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
461491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
461591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                  arg7,arg8,arg9,arg10,arg11)     \
461691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
461791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
461891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[12];                         \
461991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
462091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
462191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
462291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
462391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
462491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
462591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
462691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
462791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
462891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
462991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[9] = (unsigned long)(arg9);                         \
463091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[10] = (unsigned long)(arg10);                       \
463191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[11] = (unsigned long)(arg11);                       \
463291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
463391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
463491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "sub sp, sp, #0x30 \n\t"                                 \
463591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
463691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
463791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
463891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
463991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
464091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
464191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
464291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
464391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #72] \n\t"                                 \
464491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #0]  \n\t"                                 \
464591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #80] \n\t"                                 \
464691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #8]  \n\t"                                 \
464791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #88] \n\t"                                 \
464891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #16] \n\t"                                 \
464991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
465091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
465191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
465291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
465391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
465491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
465591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
465691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
465791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
465891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
465991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
466091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
466191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                  arg7,arg8,arg9,arg10,arg11,     \
466291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                  arg12)                          \
466391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
466491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
466591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[13];                         \
466691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
466791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
466891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
466991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
467091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
467191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
467291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
467391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
467491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
467591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
467691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[9] = (unsigned long)(arg9);                         \
467791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[10] = (unsigned long)(arg10);                       \
467891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[11] = (unsigned long)(arg11);                       \
467991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[12] = (unsigned long)(arg12);                       \
468091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
468191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
468291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "sub sp, sp, #0x30 \n\t"                                 \
468391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
468491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
468591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
468691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
468791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
468891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
468991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
469091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
469191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #72] \n\t"                                 \
469291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #0]  \n\t"                                 \
469391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #80] \n\t"                                 \
469491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #8]  \n\t"                                 \
469591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #88] \n\t"                                 \
469691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #16] \n\t"                                 \
469791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #96] \n\t"                                 \
469891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #24] \n\t"                                 \
469991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
470091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
470191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
470291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
470391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
470491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
470591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4706f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4707f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4708f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4709f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4710f0c1250e324f6684757c6a15545366447ef1d64fsewardj#endif /* PLAT_arm64_linux */
4711f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4712b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* ------------------------- s390x-linux ------------------------- */
4713b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4714b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#if defined(PLAT_s390x_linux)
4715b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4716b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* Similar workaround as amd64 (see above), but we use r11 as frame
4717b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   pointer and save the old r11 in r7. r11 might be used for
4718b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   argvec, therefore we copy argvec in r1 since r1 is clobbered
4719b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   after the call anyway.  */
4720b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#if defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)
4721b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define __FRAME_POINTER                                         \
4722b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      ,"d"(__builtin_dwarf_cfa())
4723b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define VALGRIND_CFI_PROLOGUE                                   \
4724b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      ".cfi_remember_state\n\t"                                   \
4725b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 1,%1\n\t" /* copy the argvec pointer in r1 */          \
4726b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 7,11\n\t"                                              \
4727b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 11,%2\n\t"                                             \
4728b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      ".cfi_def_cfa r11, 0\n\t"
4729b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define VALGRIND_CFI_EPILOGUE                                   \
4730b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 11, 7\n\t"                                             \
4731b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      ".cfi_restore_state\n\t"
4732b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#else
4733b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define __FRAME_POINTER
4734b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define VALGRIND_CFI_PROLOGUE                                   \
4735b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 1,%1\n\t"
4736b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define VALGRIND_CFI_EPILOGUE
4737b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#endif
4738b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
47399af940f5f1832ab887b89598c7f0df519d47a092florian/* Nb: On s390 the stack pointer is properly aligned *at all times*
47409af940f5f1832ab887b89598c7f0df519d47a092florian   according to the s390 GCC maintainer. (The ABI specification is not
47419af940f5f1832ab887b89598c7f0df519d47a092florian   precise in this regard.) Therefore, VALGRIND_ALIGN_STACK and
47429af940f5f1832ab887b89598c7f0df519d47a092florian   VALGRIND_RESTORE_STACK are not defined here. */
4743b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4744b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* These regs are trashed by the hidden call. Note that we overwrite
4745b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   r14 in s390_irgen_noredir (VEX/priv/guest_s390_irgen.c) to give the
4746b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   function a proper return address. All others are ABI defined call
4747b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   clobbers. */
4748b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __CALLER_SAVED_REGS "0","1","2","3","4","5","14", \
4749b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                           "f0","f1","f2","f3","f4","f5","f6","f7"
4750b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
47519af940f5f1832ab887b89598c7f0df519d47a092florian/* Nb: Although r11 is modified in the asm snippets below (inside
47529af940f5f1832ab887b89598c7f0df519d47a092florian   VALGRIND_CFI_PROLOGUE) it is not listed in the clobber section, for
47539af940f5f1832ab887b89598c7f0df519d47a092florian   two reasons:
47549af940f5f1832ab887b89598c7f0df519d47a092florian   (1) r11 is restored in VALGRIND_CFI_EPILOGUE, so effectively it is not
47559af940f5f1832ab887b89598c7f0df519d47a092florian       modified
47569af940f5f1832ab887b89598c7f0df519d47a092florian   (2) GCC will complain that r11 cannot appear inside a clobber section,
47579af940f5f1832ab887b89598c7f0df519d47a092florian       when compiled with -O -fno-omit-frame-pointer
47589af940f5f1832ab887b89598c7f0df519d47a092florian */
4759b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4760b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_v(lval, orig)                                  \
4761b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4762b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4763b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long  _argvec[1];                        \
4764b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4765b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4766b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4767b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4768b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4769b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"  /* target->r1 */                      \
4770b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4771b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4772b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4773b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4774b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4775b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "d" (&_argvec[0]) __FRAME_POINTER           \
4776b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4777b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4778b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4779b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4780b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4781b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* The call abi has the arguments in r2-r6 and stack */
4782b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_W(lval, orig, arg1)                            \
4783b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4784b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4785b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[2];                         \
4786b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4787b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4788b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4789b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4790b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4791b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4792b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4793b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4794b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4795b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4796b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4797b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4798b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4799b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4800b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4801b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4802b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4803b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4804b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4805b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_WW(lval, orig, arg1, arg2)                     \
4806b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4807b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4808b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[3];                         \
4809b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4810b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4811b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4812b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4813b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4814b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4815b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4816b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4817b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4818b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4819b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4820b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4821b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4822b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4823b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4824b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4825b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4826b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4827b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4828b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4829b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4830b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_WWW(lval, orig, arg1, arg2, arg3)              \
4831b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4832b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4833b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[4];                         \
4834b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4835b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4836b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4837b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4838b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4839b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4840b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4841b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4842b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4843b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4844b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4845b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4846b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4847b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4848b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4849b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4850b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4851b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4852b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4853b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4854b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4855b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4856b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4857b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_WWWW(lval, orig, arg1, arg2, arg3, arg4)       \
4858b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4859b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4860b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[5];                         \
4861b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4862b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4863b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4864b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4865b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4866b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4867b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4868b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4869b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4870b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4871b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4872b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4873b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
4874b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4875b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4876b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4877b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4878b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4879b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4880b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4881b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4882b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4883b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4884b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4885b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4886b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_5W(lval, orig, arg1, arg2, arg3, arg4, arg5)   \
4887b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4888b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4889b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[6];                         \
4890b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4891b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4892b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4893b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4894b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4895b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4896b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
4897b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4898b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4899b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4900b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4901b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4902b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4903b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
4904b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
4905b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4906b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4907b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4908b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4909b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4910b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4911b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4912b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
4913b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4914b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4915b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4916b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4917b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_6W(lval, orig, arg1, arg2, arg3, arg4, arg5,   \
4918b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6)                                       \
4919b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4920b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4921b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[7];                         \
4922b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4923b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4924b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4925b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4926b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4927b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4928b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
4929b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
4930b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4931b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4932b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-168\n\t"                                      \
4933b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4934b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4935b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4936b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
4937b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
4938b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
4939b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4940b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4941b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4942b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,168\n\t"                                       \
4943b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4944b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4945b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4946b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
4947b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4948b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4949b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4950b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4951b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_7W(lval, orig, arg1, arg2, arg3, arg4, arg5,   \
4952b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7)                                 \
4953b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4954b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4955b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[8];                         \
4956b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4957b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4958b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4959b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4960b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4961b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4962b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
4963b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
4964b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
4965b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4966b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4967b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-176\n\t"                                      \
4968b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4969b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4970b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4971b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
4972b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
4973b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
4974b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
4975b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4976b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4977b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4978b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,176\n\t"                                       \
4979b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4980b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4981b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4982b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
4983b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4984b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4985b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4986b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4987b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_8W(lval, orig, arg1, arg2, arg3, arg4, arg5,   \
4988b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8)                           \
4989b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4990b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4991b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[9];                         \
4992b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4993b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4994b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4995b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4996b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4997b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4998b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
4999b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5000b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5001b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5002b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5003b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5004b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-184\n\t"                                      \
5005b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5006b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5007b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5008b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5009b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5010b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5011b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5012b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5013b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5014b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5015b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5016b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,184\n\t"                                       \
5017b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5018b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5019b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5020b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5021b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5022b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5023b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5024b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5025b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_9W(lval, orig, arg1, arg2, arg3, arg4, arg5,   \
5026b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8, arg9)                     \
5027b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5028b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5029b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[10];                        \
5030b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5031b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5032b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5033b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5034b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5035b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5036b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5037b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5038b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5039b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5040b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[9] = (unsigned long)arg9;                          \
5041b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5042b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5043b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-192\n\t"                                      \
5044b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5045b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5046b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5047b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5048b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5049b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5050b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5051b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5052b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 184(8,15), 72(1)\n\t"                              \
5053b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5054b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5055b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5056b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,192\n\t"                                       \
5057b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5058b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5059b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5060b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5061b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5062b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5063b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5064b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5065b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_10W(lval, orig, arg1, arg2, arg3, arg4, arg5,  \
5066b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8, arg9, arg10)              \
5067b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5068b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5069b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[11];                        \
5070b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5071b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5072b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5073b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5074b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5075b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5076b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5077b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5078b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5079b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5080b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[9] = (unsigned long)arg9;                          \
5081b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[10] = (unsigned long)arg10;                        \
5082b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5083b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5084b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-200\n\t"                                      \
5085b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5086b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5087b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5088b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5089b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5090b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5091b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5092b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5093b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 184(8,15), 72(1)\n\t"                              \
5094b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 192(8,15), 80(1)\n\t"                              \
5095b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5096b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5097b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5098b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,200\n\t"                                       \
5099b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5100b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5101b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5102b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5103b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5104b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5105b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5106b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5107b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_11W(lval, orig, arg1, arg2, arg3, arg4, arg5,  \
5108b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8, arg9, arg10, arg11)       \
5109b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5110b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5111b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[12];                        \
5112b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5113b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5114b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5115b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5116b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5117b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5118b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5119b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5120b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5121b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5122b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[9] = (unsigned long)arg9;                          \
5123b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[10] = (unsigned long)arg10;                        \
5124b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[11] = (unsigned long)arg11;                        \
5125b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5126b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5127b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-208\n\t"                                      \
5128b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5129b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5130b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5131b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5132b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5133b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5134b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5135b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5136b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 184(8,15), 72(1)\n\t"                              \
5137b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 192(8,15), 80(1)\n\t"                              \
5138b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 200(8,15), 88(1)\n\t"                              \
5139b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5140b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5141b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5142b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,208\n\t"                                       \
5143b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5144b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5145b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5146b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5147b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5148b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5149b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5150b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5151b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_12W(lval, orig, arg1, arg2, arg3, arg4, arg5,  \
5152b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8, arg9, arg10, arg11, arg12)\
5153b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5154b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5155b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[13];                        \
5156b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5157b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5158b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5159b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5160b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5161b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5162b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5163b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5164b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5165b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5166b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[9] = (unsigned long)arg9;                          \
5167b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[10] = (unsigned long)arg10;                        \
5168b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[11] = (unsigned long)arg11;                        \
5169b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[12] = (unsigned long)arg12;                        \
5170b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5171b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5172b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-216\n\t"                                      \
5173b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5174b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5175b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5176b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5177b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5178b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5179b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5180b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5181b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 184(8,15), 72(1)\n\t"                              \
5182b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 192(8,15), 80(1)\n\t"                              \
5183b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 200(8,15), 88(1)\n\t"                              \
5184b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 208(8,15), 96(1)\n\t"                              \
5185b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5186b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5187b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5188b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,216\n\t"                                       \
5189b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5190b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5191b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5192b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5193b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5194b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5195b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5196b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5197b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5198b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#endif /* PLAT_s390x_linux */
5199b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
52004df0bfc0614379192c780c944415dc420d9cfe8epetarj/* ------------------------- mips32-linux ----------------------- */
52015db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52025db15403e889d4db339b342bc2a824ef0bfaa654sewardj#if defined(PLAT_mips32_linux)
52035db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52045db15403e889d4db339b342bc2a824ef0bfaa654sewardj/* These regs are trashed by the hidden call. */
52055db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define __CALLER_SAVED_REGS "$2", "$3", "$4", "$5", "$6",       \
52065db15403e889d4db339b342bc2a824ef0bfaa654sewardj"$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
52075db15403e889d4db339b342bc2a824ef0bfaa654sewardj"$25", "$31"
52085db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52095db15403e889d4db339b342bc2a824ef0bfaa654sewardj/* These CALL_FN_ macros assume that on mips-linux, sizeof(unsigned
52105db15403e889d4db339b342bc2a824ef0bfaa654sewardj   long) == 4. */
52115db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52125db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_v(lval, orig)                                   \
52135db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
52145db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
52155db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[1];                          \
52165db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
52175db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
52185db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
52195db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
52204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
52214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
52224df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 16 \n\t"                                 \
52234df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
52245db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
52255db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16\n\t"                                  \
52264df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
52274df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
52285db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
52294df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
52305db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
52315db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
52324df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
52335db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
52345db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
52355db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
52365db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52375db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
52385db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
52395db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
52405db15403e889d4db339b342bc2a824ef0bfaa654sewardj     volatile unsigned long _argvec[2];                           \
52415db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
52425db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
52435db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
52445db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
52455db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
52464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
52474df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
52485db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 16 \n\t"                                 \
52494df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"   /* arg1*/                          \
52504df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
52515db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
52525db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16 \n\t"                                 \
52534df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
52544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
52555db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
52564df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
52575db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
52584df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "0" (&_argvec[0])                            \
52594df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory",  __CALLER_SAVED_REGS               \
52605db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
52615db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
52625db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
52635db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52645db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
52655db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
52665db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
52675db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[3];                          \
52685db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
52695db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
52705db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
52715db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
52725db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
52735db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
52744df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
52754df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
52765db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 16 \n\t"                                 \
52774df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
52784df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
52794df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
52805db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
52815db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16 \n\t"                                 \
52824df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
52834df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
52845db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
52854df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
52865db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
52875db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
52884df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
52895db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
52905db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
52915db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
52925db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52935db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
52945db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
52955db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
52965db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[4];                          \
52975db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
52985db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
52995db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
53005db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
53015db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
53025db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
53035db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
53044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
53054df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
53065db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 16 \n\t"                                 \
53074df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
53084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
53094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
53104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
53115db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
53125db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16 \n\t"                                 \
53134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
53144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
53155db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
53164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
53175db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
53185db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
53194df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
53205db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
53215db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
53225db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
53235db15403e889d4db339b342bc2a824ef0bfaa654sewardj
53245db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
53255db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
53265db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
53275db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[5];                          \
53285db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
53295db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
53305db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
53315db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
53325db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
53335db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
53345db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
53355db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
53364df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
53374df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
53385db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 16 \n\t"                                 \
53394df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
53404df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
53414df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
53424df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
53434df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
53445db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
53455db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16 \n\t"                                 \
53464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
53474df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
53485db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
53494df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
53505db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
53515db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
53524df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
53535db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
53545db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
53555db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
53565db15403e889d4db339b342bc2a824ef0bfaa654sewardj
53575db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
53585db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
53595db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
53605db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[6];                          \
53615db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
53625db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
53635db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
53645db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
53655db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
53665db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
53675db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
53685db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
53695db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
53704df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
53714df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
53724df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
53734df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 24\n\t"                                  \
53744df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
53754df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
53764df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
53774df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
53784df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
53794df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
53805db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
53815db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 24 \n\t"                                 \
53824df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
53834df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
53844df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
53854df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
53865db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
53875db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
53884df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
53895db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
53905db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
53915db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
53925db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
53935db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
53945db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
53955db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[7];                          \
53965db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
53975db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
53985db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
53995db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
54005db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
54015db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
54025db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
54035db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
54045db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
54055db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
54064df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
54074df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
54084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
54094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 32\n\t"                                  \
54104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
54114df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
54125db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "nop\n\t"                                                \
54134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
54144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
54154df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
54164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
54174df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
54184df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
54195db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
54204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 32 \n\t"                                 \
54214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
54224df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
54234df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
54244df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
54255db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
54265db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
54274df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
54285db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
54295db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
54305db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
54315db15403e889d4db339b342bc2a824ef0bfaa654sewardj
54325db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
54335db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                 arg7)                            \
54345db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
54355db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
54365db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[8];                          \
54375db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
54385db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
54395db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
54405db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
54415db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
54425db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
54435db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
54445db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
54455db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
54465db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
54475db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
54484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
54494df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
54504df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
54514df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 32\n\t"                                  \
54524df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
54534df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
54544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
54554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
54564df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
54574df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
54584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
54594df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
54604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
54614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
54625db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
54634df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 32 \n\t"                                 \
54644df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
54654df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
54664df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
54674df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
54685db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
54695db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
54704df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
54715db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
54725db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
54735db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
54745db15403e889d4db339b342bc2a824ef0bfaa654sewardj
54755db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
54765db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                 arg7,arg8)                       \
54775db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
54785db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
54795db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[9];                          \
54805db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
54815db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
54825db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
54835db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
54845db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
54855db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
54865db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
54875db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
54885db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
54895db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
54905db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
54915db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
54924df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
54934df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
54944df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
54954df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 40\n\t"                                  \
54964df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
54974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
54984df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
54994df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
55004df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
55014df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
55024df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
55034df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
55044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
55054df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
55064df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
55074df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
55085db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
55094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 40 \n\t"                                 \
55104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
55114df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
55124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
55134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
55145db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
55155db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
55164df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
55175db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
55185db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
55195db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
55205db15403e889d4db339b342bc2a824ef0bfaa654sewardj
55215db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
55225db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                 arg7,arg8,arg9)                  \
55235db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
55245db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
55255db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[10];                         \
55265db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
55275db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
55285db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
55295db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
55305db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
55315db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
55325db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
55335db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
55345db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
55355db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
55365db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[9] = (unsigned long)(arg9);                         \
55375db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
55385db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
55394df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
55404df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
55414df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
55424df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 40\n\t"                                  \
55434df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
55444df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
55454df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
55464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
55474df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
55484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
55494df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
55504df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 36(%1) \n\t"                                     \
55514df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 32($29) \n\t"                                    \
55524df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
55534df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
55544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
55554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
55564df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
55575db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
55584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 40 \n\t"                                 \
55594df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
55604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
55614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
55624df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
55635db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
55645db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
55654df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
55665db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
55675db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
55685db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
55695db15403e889d4db339b342bc2a824ef0bfaa654sewardj
55705db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
55715db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg7,arg8,arg9,arg10)           \
55725db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
55735db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
55745db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[11];                         \
55755db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
55765db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
55775db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
55785db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
55795db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
55805db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
55815db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
55825db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
55835db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
55845db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
55855db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[9] = (unsigned long)(arg9);                         \
55865db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[10] = (unsigned long)(arg10);                       \
55875db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
55885db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
55894df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
55904df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
55914df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
55924df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 48\n\t"                                  \
55934df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
55944df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
55954df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
55964df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
55974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
55984df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
55994df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
56004df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 36(%1) \n\t"                                     \
56014df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 32($29) \n\t"                                    \
56024df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 40(%1) \n\t"                                     \
56034df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 36($29) \n\t"                                    \
56044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
56054df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
56064df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
56074df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
56084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
56095db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
56104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 48 \n\t"                                 \
56114df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
56124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
56134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
56144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
56155db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
56165db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
56174df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
56185db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
56195db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
56205db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
56215db15403e889d4db339b342bc2a824ef0bfaa654sewardj
56225db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
56235db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg6,arg7,arg8,arg9,arg10,      \
56245db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg11)                          \
56255db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
56265db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
56275db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[12];                         \
56285db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
56295db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
56305db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
56315db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
56325db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
56335db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
56345db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
56355db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
56365db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
56375db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
56385db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[9] = (unsigned long)(arg9);                         \
56395db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[10] = (unsigned long)(arg10);                       \
56405db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[11] = (unsigned long)(arg11);                       \
56415db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
56425db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
56434df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
56444df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
56454df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
56464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 48\n\t"                                  \
56474df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
56484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
56494df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
56504df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
56514df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
56524df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
56534df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
56544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 36(%1) \n\t"                                     \
56554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 32($29) \n\t"                                    \
56564df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 40(%1) \n\t"                                     \
56574df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 36($29) \n\t"                                    \
56584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 44(%1) \n\t"                                     \
56594df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 40($29) \n\t"                                    \
56604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
56614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
56624df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
56634df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
56644df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
56655db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
56664df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 48 \n\t"                                 \
56674df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
56684df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
56694df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
56704df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
56715db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
56725db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
56734df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
56745db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
56755db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
56765db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
56775db15403e889d4db339b342bc2a824ef0bfaa654sewardj
56785db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
56795db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg6,arg7,arg8,arg9,arg10,      \
56805db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg11,arg12)                    \
56815db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
56825db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
56835db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[13];                         \
56845db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
56855db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
56865db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
56875db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
56885db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
56895db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
56905db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
56915db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
56925db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
56935db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
56945db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[9] = (unsigned long)(arg9);                         \
56955db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[10] = (unsigned long)(arg10);                       \
56965db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[11] = (unsigned long)(arg11);                       \
56975db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[12] = (unsigned long)(arg12);                       \
56985db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
56995db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
57004df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
57014df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
57024df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
57034df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 56\n\t"                                  \
57044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
57054df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
57064df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
57074df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
57084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
57094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
57104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
57114df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 36(%1) \n\t"                                     \
57124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 32($29) \n\t"                                    \
57134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 40(%1) \n\t"                                     \
57144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 36($29) \n\t"                                    \
57154df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 44(%1) \n\t"                                     \
57164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 40($29) \n\t"                                    \
57174df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 48(%1) \n\t"                                     \
57184df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 44($29) \n\t"                                    \
57194df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
57204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
57214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
57224df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
57234df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
57245db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
57254df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 56 \n\t"                                 \
57264df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
57274df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
57284df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
57294df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
57305db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
57314df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
57324df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
57335db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
57345db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
57355db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
57365db15403e889d4db339b342bc2a824ef0bfaa654sewardj
57375db15403e889d4db339b342bc2a824ef0bfaa654sewardj#endif /* PLAT_mips32_linux */
57385db15403e889d4db339b342bc2a824ef0bfaa654sewardj
57394df0bfc0614379192c780c944415dc420d9cfe8epetarj/* ------------------------- mips64-linux ------------------------- */
57404df0bfc0614379192c780c944415dc420d9cfe8epetarj
57414df0bfc0614379192c780c944415dc420d9cfe8epetarj#if defined(PLAT_mips64_linux)
57424df0bfc0614379192c780c944415dc420d9cfe8epetarj
57434df0bfc0614379192c780c944415dc420d9cfe8epetarj/* These regs are trashed by the hidden call. */
57444df0bfc0614379192c780c944415dc420d9cfe8epetarj#define __CALLER_SAVED_REGS "$2", "$3", "$4", "$5", "$6",       \
57454df0bfc0614379192c780c944415dc420d9cfe8epetarj"$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
57464df0bfc0614379192c780c944415dc420d9cfe8epetarj"$25", "$31"
57474df0bfc0614379192c780c944415dc420d9cfe8epetarj
57484df0bfc0614379192c780c944415dc420d9cfe8epetarj/* These CALL_FN_ macros assume that on mips-linux, sizeof(unsigned
57494df0bfc0614379192c780c944415dc420d9cfe8epetarj   long) == 4. */
57504df0bfc0614379192c780c944415dc420d9cfe8epetarj
57514df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_v(lval, orig)                                   \
57524df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
57534df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
57544df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[1];                          \
57554df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
57564df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
57574df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
57584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
57594df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
57604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
57614df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
57624df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "0" (&_argvec[0])                            \
57634df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
57644df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
57654df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
57664df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
57674df0bfc0614379192c780c944415dc420d9cfe8epetarj
57684df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_W(lval, orig, arg1)                             \
57694df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
57704df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
57714df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[2];                          \
57724df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
57734df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
57744df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
57754df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
57764df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"   /* arg1*/                           \
57774df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
57784df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
57794df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
57804df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
57814df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
57824df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
57834df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
57844df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
57854df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
57864df0bfc0614379192c780c944415dc420d9cfe8epetarj
57874df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
57884df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
57894df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
57904df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[3];                          \
57914df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
57924df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
57934df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
57944df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
57954df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
57964df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
57974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
57984df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
57994df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
58004df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
58014df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
58024df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
58034df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
58044df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
58054df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
58064df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
58074df0bfc0614379192c780c944415dc420d9cfe8epetarj
58084df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
58094df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58104df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58114df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[4];                          \
58124df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
58134df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
58144df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
58154df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
58164df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
58174df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
58184df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
58194df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
58204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
58214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
58224df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
58234df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
58244df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
58254df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
58264df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
58274df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
58284df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
58294df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
58304df0bfc0614379192c780c944415dc420d9cfe8epetarj
58314df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
58324df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58334df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58344df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[5];                          \
58354df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
58364df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
58374df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
58384df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
58394df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
58404df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
58414df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
58424df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
58434df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
58444df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
58454df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
58464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
58474df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
58484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
58494df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
58504df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
58514df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
58524df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
58534df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
58544df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
58554df0bfc0614379192c780c944415dc420d9cfe8epetarj
58564df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
58574df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58584df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58594df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[6];                          \
58604df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
58614df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
58624df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
58634df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
58644df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
58654df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
58664df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
58674df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
58684df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
58694df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
58704df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
58714df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
58724df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
58734df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
58744df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
58754df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
58764df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
58774df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
58784df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
58794df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
58804df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
58814df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
58824df0bfc0614379192c780c944415dc420d9cfe8epetarj
58834df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
58844df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58854df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58864df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[7];                          \
58874df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
58884df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
58894df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
58904df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
58914df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
58924df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
58934df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
58944df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
58954df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
58964df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
58974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
58984df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
58994df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
59004df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
59014df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
59024df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
59034df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
59044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
59054df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
59064df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
59074df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
59084df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
59094df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
59104df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
59114df0bfc0614379192c780c944415dc420d9cfe8epetarj
59124df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
59134df0bfc0614379192c780c944415dc420d9cfe8epetarj                                 arg7)                            \
59144df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
59154df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
59164df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[8];                          \
59174df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
59184df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
59194df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
59204df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
59214df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
59224df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
59234df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
59244df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
59254df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
59264df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
59274df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
59284df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
59294df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
59304df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
59314df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
59324df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
59334df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
59344df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1) \n\t"  /* target->t9 */                   \
59354df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
59364df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
59374df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
59384df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
59394df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
59404df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
59414df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
59424df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
59434df0bfc0614379192c780c944415dc420d9cfe8epetarj
59444df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
59454df0bfc0614379192c780c944415dc420d9cfe8epetarj                                 arg7,arg8)                       \
59464df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
59474df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
59484df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[9];                          \
59494df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
59504df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
59514df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
59524df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
59534df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
59544df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
59554df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
59564df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
59574df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
59584df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
59594df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
59604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
59614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
59624df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
59634df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
59644df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
59654df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
59664df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
59674df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
59684df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1) \n\t"  /* target->t9 */                   \
59694df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
59704df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
59714df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
59724df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
59734df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
59744df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
59754df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
59764df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
59774df0bfc0614379192c780c944415dc420d9cfe8epetarj
59784df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
59794df0bfc0614379192c780c944415dc420d9cfe8epetarj                                 arg7,arg8,arg9)                  \
59804df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
59814df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
59824df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[10];                         \
59834df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
59844df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
59854df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
59864df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
59874df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
59884df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
59894df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
59904df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
59914df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
59924df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
59934df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[9] = (unsigned long)(arg9);                         \
59944df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
59954df0bfc0614379192c780c944415dc420d9cfe8epetarj         "dsubu $29, $29, 8\n\t"                                  \
59964df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 72(%1)\n\t"                                      \
59974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 0($29)\n\t"                                      \
59984df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
59994df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
60004df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
60014df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
60024df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
60034df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
60044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
60054df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
60064df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
60074df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
60084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "daddu $29, $29, 8\n\t"                                  \
60094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
60104df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
60114df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
60124df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
60134df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
60144df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
60154df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
60164df0bfc0614379192c780c944415dc420d9cfe8epetarj
60174df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
60184df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg7,arg8,arg9,arg10)           \
60194df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
60204df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
60214df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[11];                         \
60224df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
60234df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
60244df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
60254df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
60264df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
60274df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
60284df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
60294df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
60304df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
60314df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
60324df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[9] = (unsigned long)(arg9);                         \
60334df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[10] = (unsigned long)(arg10);                       \
60344df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
60354df0bfc0614379192c780c944415dc420d9cfe8epetarj         "dsubu $29, $29, 16\n\t"                                 \
60364df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 72(%1)\n\t"                                      \
60374df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 0($29)\n\t"                                      \
60384df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 80(%1)\n\t"                                      \
60394df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 8($29)\n\t"                                      \
60404df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
60414df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
60424df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
60434df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
60444df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
60454df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
60464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
60474df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
60484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
60494df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
60504df0bfc0614379192c780c944415dc420d9cfe8epetarj         "daddu $29, $29, 16\n\t"                                 \
60514df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
60524df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
60534df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
60544df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
60554df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
60564df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
60574df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
60584df0bfc0614379192c780c944415dc420d9cfe8epetarj
60594df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
60604df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg6,arg7,arg8,arg9,arg10,      \
60614df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg11)                          \
60624df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
60634df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
60644df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[12];                         \
60654df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
60664df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
60674df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
60684df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
60694df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
60704df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
60714df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
60724df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
60734df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
60744df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
60754df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[9] = (unsigned long)(arg9);                         \
60764df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[10] = (unsigned long)(arg10);                       \
60774df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[11] = (unsigned long)(arg11);                       \
60784df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
60794df0bfc0614379192c780c944415dc420d9cfe8epetarj         "dsubu $29, $29, 24\n\t"                                 \
60804df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 72(%1)\n\t"                                      \
60814df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 0($29)\n\t"                                      \
60824df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 80(%1)\n\t"                                      \
60834df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 8($29)\n\t"                                      \
60844df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 88(%1)\n\t"                                      \
60854df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 16($29)\n\t"                                     \
60864df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
60874df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
60884df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
60894df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
60904df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
60914df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
60924df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
60934df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
60944df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
60954df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
60964df0bfc0614379192c780c944415dc420d9cfe8epetarj         "daddu $29, $29, 24\n\t"                                 \
60974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
60984df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
60994df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
61004df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
61014df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
61024df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
61034df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
61044df0bfc0614379192c780c944415dc420d9cfe8epetarj
61054df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
61064df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg6,arg7,arg8,arg9,arg10,      \
61074df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg11,arg12)                    \
61084df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
61094df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
61104df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[13];                         \
61114df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
61124df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
61134df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
61144df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
61154df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
61164df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
61174df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
61184df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
61194df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
61204df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
61214df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[9] = (unsigned long)(arg9);                         \
61224df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[10] = (unsigned long)(arg10);                       \
61234df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[11] = (unsigned long)(arg11);                       \
61244df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[12] = (unsigned long)(arg12);                       \
61254df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
61264df0bfc0614379192c780c944415dc420d9cfe8epetarj         "dsubu $29, $29, 32\n\t"                                 \
61274df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 72(%1)\n\t"                                      \
61284df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 0($29)\n\t"                                      \
61294df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 80(%1)\n\t"                                      \
61304df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 8($29)\n\t"                                      \
61314df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 88(%1)\n\t"                                      \
61324df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 16($29)\n\t"                                     \
61334df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 96(%1)\n\t"                                      \
61344df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 24($29)\n\t"                                     \
61354df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
61364df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
61374df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
61384df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
61394df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
61404df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
61414df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
61424df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
61434df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
61444df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
61454df0bfc0614379192c780c944415dc420d9cfe8epetarj         "daddu $29, $29, 32\n\t"                                 \
61464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
61474df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
61484df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
61494df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
61504df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
61514df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
61524df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
61534df0bfc0614379192c780c944415dc420d9cfe8epetarj
61544df0bfc0614379192c780c944415dc420d9cfe8epetarj#endif /* PLAT_mips64_linux */
61554df0bfc0614379192c780c944415dc420d9cfe8epetarj
6156112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/* ------------------------ tilegx-linux ------------------------- */
6157112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6158112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#if defined(PLAT_tilegx_linux)
6159112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6160112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/* These regs are trashed by the hidden call. */
6161112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define __CALLER_SAVED_REGS "r0", "r1", "r2", "r3", "r4", "r5", \
6162112711afefcfcd43680c7c4aa8d38ef180e8811esewardj    "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14",  \
6163112711afefcfcd43680c7c4aa8d38ef180e8811esewardj    "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22",     \
6164112711afefcfcd43680c7c4aa8d38ef180e8811esewardj    "r23", "r24", "r25", "r26", "r27", "r28", "r29", "lr"
6165112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6166112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/* These CALL_FN_ macros assume that on tilegx-linux, sizeof(unsigned
6167112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   long) == 8. */
6168112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6169112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_v(lval, orig)                          \
6170112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                  \
6171112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);             \
6172112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[1];                 \
6173112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                       \
6174112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;          \
6175112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                  \
6176112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                          \
6177112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                        \
6178112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld r12, %1 \n\t"  /* target->r11 */            \
6179112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                       \
6180112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                          \
6181112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                         \
6182112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0 \n"                               \
6183112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                         \
6184112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                   \
6185112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);    \
6186112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                                                         \
6187112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                    \
6188112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6189112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6190112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_W(lval, orig, arg1)                   \
6191112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                 \
6192112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);            \
6193112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[2];                \
6194112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                      \
6195112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;         \
6196112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);               \
6197112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                 \
6198112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                         \
6199112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                       \
6200112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move r29, %1 \n\t"                            \
6201112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r12, r29, 8 \n\t"  /* target->r11 */   \
6202112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */       \
6203112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                      \
6204112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                         \
6205112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                        \
6206112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0\n"                               \
6207112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                        \
6208112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                  \
6209112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);   \
6210112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                   \
6211112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6212112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6213112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)             \
6214112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                 \
6215112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);            \
6216112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[3];                \
6217112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                      \
6218112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;         \
6219112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);               \
6220112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);               \
6221112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                 \
6222112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                         \
6223112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                       \
6224112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move r29, %1 \n\t"                            \
6225112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r12, r29, 8 \n\t"  /* target->r11 */   \
6226112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */       \
6227112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */       \
6228112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                      \
6229112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                         \
6230112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                        \
6231112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0\n"                               \
6232112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                        \
6233112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                  \
6234112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);   \
6235112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                   \
6236112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6237112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6238112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)       \
6239112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                 \
6240112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     volatile OrigFn        _orig = (orig);             \
6241112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     volatile unsigned long _argvec[4];                 \
6242112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     volatile unsigned long _res;                       \
6243112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     _argvec[0] = (unsigned long)_orig.nraddr;          \
6244112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     _argvec[1] = (unsigned long)(arg1);                \
6245112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     _argvec[2] = (unsigned long)(arg2);                \
6246112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     _argvec[3] = (unsigned long)(arg3);                \
6247112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     __asm__ volatile(                                  \
6248112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                          \
6249112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                        \
6250112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                             \
6251112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */    \
6252112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */        \
6253112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */        \
6254112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */        \
6255112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                       \
6256112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8 \n\t"                         \
6257112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                         \
6258112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                \
6259112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                         \
6260112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                   \
6261112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);    \
6262112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     lval = (__typeof__(lval)) _res;                    \
6263112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6264112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6265112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
6266112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                 \
6267112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);            \
6268112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[5];                \
6269112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                      \
6270112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;         \
6271112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);               \
6272112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);               \
6273112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);               \
6274112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);               \
6275112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                 \
6276112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                         \
6277112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                       \
6278112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move r29, %1 \n\t"                            \
6279112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r12, r29, 8 \n\t"  /* target->r11 */   \
6280112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */       \
6281112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */       \
6282112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */       \
6283112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */       \
6284112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                      \
6285112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                         \
6286112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                        \
6287112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0\n"                               \
6288112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                        \
6289112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                  \
6290112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);   \
6291112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                   \
6292112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6293112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6294112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)      \
6295112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6296112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6297112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[6];                        \
6298112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6299112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6300112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6301112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6302112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6303112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6304112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6305112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6306112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                                 \
6307112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                               \
6308112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move r29, %1 \n\t"                                    \
6309112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r12, r29, 8 \n\t"  /* target->r11 */           \
6310112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */               \
6311112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */               \
6312112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */               \
6313112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */               \
6314112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */               \
6315112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                              \
6316112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                                 \
6317112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                                \
6318112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0\n"                                       \
6319112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                                \
6320112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                          \
6321112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);           \
6322112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6323112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6324112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
6325112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6326112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6327112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[7];                        \
6328112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6329112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6330112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6331112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6332112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6333112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6334112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6335112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6336112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6337112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6338112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6339112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6340112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6341112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6342112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6343112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6344112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6345112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6346112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6347112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6348112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                  \
6349112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6350112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6351112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6352112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6353112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6354112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6355112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6356112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6357112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
6358112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                     arg7)                                      \
6359112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6360112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6361112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[8];                        \
6362112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6363112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6364112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6365112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6366112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6367112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6368112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6369112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6370112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6371112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6372112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6373112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6374112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6375112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6376112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6377112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6378112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6379112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6380112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6381112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6382112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6383112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6384112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                  \
6385112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6386112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6387112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6388112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6389112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6390112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6391112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6392112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6393112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
6394112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                     arg7,arg8)                                 \
6395112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6396112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6397112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[9];                        \
6398112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6399112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6400112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6401112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6402112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6403112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6404112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6405112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6406112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6407112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                       \
6408112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6409112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6410112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6411112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6412112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6413112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6414112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6415112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6416112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6417112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6418112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6419112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6420112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                \
6421112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6422112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                  \
6423112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6424112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6425112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6426112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6427112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6428112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6429112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6430112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6431112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
6432112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                     arg7,arg8,arg9)                            \
6433112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6434112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6435112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[10];                       \
6436112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6437112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6438112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6439112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6440112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6441112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6442112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6443112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6444112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6445112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                       \
6446112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[9] = (unsigned long)(arg9);                       \
6447112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6448112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6449112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6450112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6451112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6452112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6453112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6454112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6455112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6456112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6457112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6458112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6459112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                \
6460112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r8, r29, 8 \n\t" /*arg9 -> r8 */                \
6461112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6462112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                  \
6463112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6464112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6465112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6466112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6467112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6468112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6469112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6470112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6471112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,        \
6472112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg7,arg8,arg9,arg10)                             \
6473112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                                 \
6474112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                            \
6475112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[11];                               \
6476112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                                      \
6477112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                         \
6478112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                               \
6479112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                               \
6480112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                               \
6481112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                               \
6482112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                               \
6483112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                               \
6484112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                               \
6485112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                               \
6486112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[9] = (unsigned long)(arg9);                               \
6487112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[10] = (unsigned long)(arg10);                             \
6488112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                                 \
6489112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                          \
6490112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                        \
6491112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                             \
6492112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */                    \
6493112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                        \
6494112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                        \
6495112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                        \
6496112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                        \
6497112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                        \
6498112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                        \
6499112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                        \
6500112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                        \
6501112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r8, r29, 8 \n\t" /*arg9 -> r8 */                        \
6502112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r9, r29, 8 \n\t" /*arg10 -> r9 */                       \
6503112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                                       \
6504112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                          \
6505112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                         \
6506112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                                \
6507112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                         \
6508112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                                   \
6509112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);                    \
6510112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                                   \
6511112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6512112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6513112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,     \
6514112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg6,arg7,arg8,arg9,arg10,                \
6515112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg11)                                    \
6516112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6517112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6518112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[12];                       \
6519112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6520112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6521112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6522112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6523112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6524112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6525112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6526112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6527112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6528112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                       \
6529112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[9] = (unsigned long)(arg9);                       \
6530112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[10] = (unsigned long)(arg10);                     \
6531112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[11] = (unsigned long)(arg11);                     \
6532112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6533112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6534112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6535112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6536112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6537112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6538112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6539112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6540112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6541112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6542112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6543112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6544112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                \
6545112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r8, r29, 8 \n\t" /*arg9 -> r8 */                \
6546112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r9, r29, 8 \n\t" /*arg10 -> r9 */               \
6547112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld     r10, r29 \n\t"                                  \
6548112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, r10, -16 \n\t"                              \
6549112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6550112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 24 \n\t"                                \
6551112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6552112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6553112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6554112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6555112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6556112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6557112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6558112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6559112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,     \
6560112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg6,arg7,arg8,arg9,arg10,                \
6561112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg11,arg12)                              \
6562112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6563112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6564112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[13];                       \
6565112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6566112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6567112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6568112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6569112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6570112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6571112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6572112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6573112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6574112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                       \
6575112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[9] = (unsigned long)(arg9);                       \
6576112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[10] = (unsigned long)(arg10);                     \
6577112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[11] = (unsigned long)(arg11);                     \
6578112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[12] = (unsigned long)(arg12);                     \
6579112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6580112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6581112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6582112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6583112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6584112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6585112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6586112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6587112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6588112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6589112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6590112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6591112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                \
6592112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r8, r29, 8 \n\t" /*arg9 -> r8 */                \
6593112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r9, r29, 8 \n\t" /*arg10 -> r9 */               \
6594112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi r28, sp, -8 \n\t"                                 \
6595112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp,  sp, -24 \n\t"                                \
6596112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r10, r29, 8 \n\t"                               \
6597112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld     r11, r29 \n\t"                                  \
6598112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add r28, r10, 8 \n\t"                               \
6599112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st     r28, r11 \n\t"                                  \
6600112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6601112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 32 \n\t"                                \
6602112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6603112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6604112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6605112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6606112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6607112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6608112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6609112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#endif  /* PLAT_tilegx_linux */
66100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
66110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ------------------------------------------------------------------ */
66120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS.               */
66130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/*                                                                    */
661430d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* ------------------------------------------------------------------ */
661530d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn
66162e93c50dc50235189661b70e3f27a4098d5cccccsewardj/* Some request codes.  There are many more of these, but most are not
66172e93c50dc50235189661b70e3f27a4098d5cccccsewardj   exposed to end-user view.  These are the public ones, all of the
6618e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   form 0x1000 + small_number.
6619d799418996812817596beaa8b59563e3f3cb2ddanjn
66200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   Core ones are in the range 0x00000000--0x0000ffff.  The non-public
66210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   ones start at 0x2000.
66222e93c50dc50235189661b70e3f27a4098d5cccccsewardj*/
66232e93c50dc50235189661b70e3f27a4098d5cccccsewardj
66240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These macros are used by tools -- they must be public, but don't
66250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   embed them into other programs. */
6626fc26ff9ed636a3dd79ee3d90e5e521bc7749f105njn#define VG_USERREQ_TOOL_BASE(a,b) \
66274c791211835f0e90cbde578187c06e563de3b023njn   ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16))
6628fc26ff9ed636a3dd79ee3d90e5e521bc7749f105njn#define VG_IS_TOOL_USERREQ(a, b, v) \
6629fc26ff9ed636a3dd79ee3d90e5e521bc7749f105njn   (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000))
663034042515c1715b3e0c5c0a5e0bd033e9d4858f01sewardj
66315ce4b150ce5d32c9af07a24717081ea34568388asewardj/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !!
66325ce4b150ce5d32c9af07a24717081ea34568388asewardj   This enum comprises an ABI exported by Valgrind to programs
66335ce4b150ce5d32c9af07a24717081ea34568388asewardj   which use client requests.  DO NOT CHANGE THE ORDER OF THESE
66345ce4b150ce5d32c9af07a24717081ea34568388asewardj   ENTRIES, NOR DELETE ANY -- add new ones at the end. */
6635e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjntypedef
66364c791211835f0e90cbde578187c06e563de3b023njn   enum { VG_USERREQ__RUNNING_ON_VALGRIND  = 0x1001,
66374c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002,
66383e88418f808bf2840646504481d6a5be1df16541njn
66390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj          /* These allow any function to be called from the simulated
66400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             CPU but run on the real CPU.  Nb: the first arg passed to
66410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             the function is always the ThreadId of the running
66420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             thread!  So CLIENT_CALL0 actually requires a 1 arg
6643d4795be03ad94334c7517d93d3f5b35a97c7bba0njn             function, etc. */
66444c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__CLIENT_CALL0 = 0x1101,
66454c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__CLIENT_CALL1 = 0x1102,
66464c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__CLIENT_CALL2 = 0x1103,
66474c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__CLIENT_CALL3 = 0x1104,
66483e88418f808bf2840646504481d6a5be1df16541njn
66490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj          /* Can be useful in regression testing suites -- eg. can
66500ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             send Valgrind's output to /dev/null and still count
66510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             errors. */
66524c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__COUNT_ERRORS = 0x1201,
665347363aba8fa03b094195bca99fc232ce5f85605dnjn
665446207652a0c99a2c8b0f05eafce3ca3ec533c121philippe          /* Allows the client program and/or gdbserver to execute a monitor
665546207652a0c99a2c8b0f05eafce3ca3ec533c121philippe             command. */
66563b290486cd4cd601b20e04340e593c9ed9717e5fsewardj          VG_USERREQ__GDB_MONITOR_COMMAND = 0x1202,
66573b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
66580ec07f32bbbb209d749b9974408e6f025ad40b31sewardj          /* These are useful and can be interpreted by any tool that
66590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             tracks malloc() et al, by using vg_replace_malloc.c. */
6660d799418996812817596beaa8b59563e3f3cb2ddanjn          VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
6661913473803432ee37d6edaf232e21978d4f426125bart          VG_USERREQ__RESIZEINPLACE_BLOCK = 0x130b,
6662d799418996812817596beaa8b59563e3f3cb2ddanjn          VG_USERREQ__FREELIKE_BLOCK   = 0x1302,
6663bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          /* Memory pool support. */
6664bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          VG_USERREQ__CREATE_MEMPOOL   = 0x1303,
6665bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          VG_USERREQ__DESTROY_MEMPOOL  = 0x1304,
6666bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          VG_USERREQ__MEMPOOL_ALLOC    = 0x1305,
6667bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          VG_USERREQ__MEMPOOL_FREE     = 0x1306,
66682c1c9dfe806d62d43768b23c29799dc6a100cb09sewardj          VG_USERREQ__MEMPOOL_TRIM     = 0x1307,
6669c740d7660ad140b79e561e0d578ab8435a5a5289sewardj          VG_USERREQ__MOVE_MEMPOOL     = 0x1308,
6670c740d7660ad140b79e561e0d578ab8435a5a5289sewardj          VG_USERREQ__MEMPOOL_CHANGE   = 0x1309,
6671c740d7660ad140b79e561e0d578ab8435a5a5289sewardj          VG_USERREQ__MEMPOOL_EXISTS   = 0x130a,
6672d799418996812817596beaa8b59563e3f3cb2ddanjn
667339de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge          /* Allow printfs to valgrind log. */
6674c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          /* The first two pass the va_list argument by value, which
6675c560fb380ac83ad1957d3fdf92751645a55cf167sewardj             assumes it is the same size as or smaller than a UWord,
6676c560fb380ac83ad1957d3fdf92751645a55cf167sewardj             which generally isn't the case.  Hence are deprecated.
6677c560fb380ac83ad1957d3fdf92751645a55cf167sewardj             The second two pass the vargs by reference and so are
6678c560fb380ac83ad1957d3fdf92751645a55cf167sewardj             immune to this problem. */
6679c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          /* both :: char* fmt, va_list vargs (DEPRECATED) */
668030d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn          VG_USERREQ__PRINTF           = 0x1401,
66810140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh          VG_USERREQ__PRINTF_BACKTRACE = 0x1402,
6682c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          /* both :: char* fmt, va_list* vargs */
6683c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          VG_USERREQ__PRINTF_VALIST_BY_REF = 0x1403,
6684c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF = 0x1404,
66850140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh
66860140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh          /* Stack support. */
66870140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh          VG_USERREQ__STACK_REGISTER   = 0x1501,
66880140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh          VG_USERREQ__STACK_DEREGISTER = 0x1502,
6689c8259b85b701d25d72aabe9dc0a8154517f96913sewardj          VG_USERREQ__STACK_CHANGE     = 0x1503,
6690c8259b85b701d25d72aabe9dc0a8154517f96913sewardj
6691c8259b85b701d25d72aabe9dc0a8154517f96913sewardj          /* Wine support */
66925c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj          VG_USERREQ__LOAD_PDB_DEBUGINFO = 0x1601,
66935c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj
66945c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj          /* Querying of debug info. */
6695dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj          VG_USERREQ__MAP_IP_TO_SRCLOC = 0x1701,
6696dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj
6697dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj          /* Disable/enable error reporting level.  Takes a single
6698dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj             Word arg which is the delta to this thread's error
6699dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj             disablement indicator.  Hence 1 disables or further
6700dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj             disables errors, and -1 moves back towards enablement.
6701dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj             Other values are not allowed. */
6702bb913cd4cc1e56d7d7798a8b754361a05d01f916florian          VG_USERREQ__CHANGE_ERR_DISABLEMENT = 0x1801,
6703bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
6704bb913cd4cc1e56d7d7798a8b754361a05d01f916florian          /* Initialise IR injection */
6705bb913cd4cc1e56d7d7798a8b754361a05d01f916florian          VG_USERREQ__VEX_INIT_FOR_IRI = 0x1901
6706e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   } Vg_ClientRequest;
67072e93c50dc50235189661b70e3f27a4098d5cccccsewardj
67080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#if !defined(__GNUC__)
67090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#  define __extension__ /* */
6710c9b365507e9bd5d500476e3e83f4d30f9c68a351mueller#endif
67112e93c50dc50235189661b70e3f27a4098d5cccccsewardj
6712fa5115adb77868b1ee3efc8dce061b881e7833c5bart
67130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* Returns the number of Valgrinds this code is running under.  That
67140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   is, 0 if running natively, 1 if running under Valgrind, 2 if
67150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   running under Valgrind which is running under another Valgrind,
67160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   etc. */
6717fa5115adb77868b1ee3efc8dce061b881e7833c5bart#define RUNNING_ON_VALGRIND                                           \
6718575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* if not */,         \
6719fa5115adb77868b1ee3efc8dce061b881e7833c5bart                                    VG_USERREQ__RUNNING_ON_VALGRIND,  \
6720fa5115adb77868b1ee3efc8dce061b881e7833c5bart                                    0, 0, 0, 0, 0)                    \
6721de4a1d01951937632098a6cda45859afa587a06fsewardj
6722de4a1d01951937632098a6cda45859afa587a06fsewardj
672318d7513cc08bf982711c8a22b70d56af6aa87b33sewardj/* Discard translation of code in the range [_qzz_addr .. _qzz_addr +
672418d7513cc08bf982711c8a22b70d56af6aa87b33sewardj   _qzz_len - 1].  Useful if you are debugging a JITter or some such,
672518d7513cc08bf982711c8a22b70d56af6aa87b33sewardj   since it provides a way to make sure valgrind will retranslate the
672618d7513cc08bf982711c8a22b70d56af6aa87b33sewardj   invalidated area.  Returns no value. */
67274b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len)              \
67284b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DISCARD_TRANSLATIONS,  \
67294b3a74204894e943c43cb8e8aae39d813040702csewardj                                    _qzz_addr, _qzz_len, 0, 0, 0)
673018d7513cc08bf982711c8a22b70d56af6aa87b33sewardj
673126aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn
67320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These requests are for getting Valgrind itself to print something.
6733d55f0d924062c7b5b3453242a6f9611bd5ce7458njn   Possibly with a backtrace.  This is a really ugly hack.  The return value
6734d55f0d924062c7b5b3453242a6f9611bd5ce7458njn   is the number of characters printed, excluding the "**<pid>** " part at the
6735d55f0d924062c7b5b3453242a6f9611bd5ce7458njn   start and the backtrace (if present). */
67360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
673742f83fe6c64da13801d4eb54fa2aa6530679848abart#if defined(__GNUC__) || defined(__INTEL_COMPILER) && !defined(_MSC_VER)
67387eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardj/* Modern GCC will optimize the static routine out if unused,
67397eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardj   and unused attribute will shut down warnings about it.  */
67407eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardjstatic int VALGRIND_PRINTF(const char *format, ...)
67417eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardj   __attribute__((format(__printf__, 1, 2), __unused__));
67427f489813d200fb614a0856fca05e2f9ebf66dd48bart#endif
67437eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardjstatic int
67440da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#if defined(_MSC_VER)
67450da2c772047f3f6795dbb43dde5f5c9b43be73bbbart__inline
67460da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#endif
6747a09a1b5d4e02b7451345dac00f2d321d1b4b2ccefitzhardingeVALGRIND_PRINTF(const char *format, ...)
674839de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge{
67498c7e25f496b1771f21712db0b1f35935bacfaff3bart#if defined(NVALGRIND)
67508c7e25f496b1771f21712db0b1f35935bacfaff3bart   return 0;
67518c7e25f496b1771f21712db0b1f35935bacfaff3bart#else /* NVALGRIND */
6752aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#if defined(_MSC_VER) || defined(__MINGW64__)
6753575ce8ef8fa86a502dabe152293320676922dcfebart   uintptr_t _qzz_res;
6754575ce8ef8fa86a502dabe152293320676922dcfebart#else
6755c616819253fcf211745060b2be26076174b1df19njn   unsigned long _qzz_res;
6756575ce8ef8fa86a502dabe152293320676922dcfebart#endif
6757c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_list vargs;
6758c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_start(vargs, format);
6759aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#if defined(_MSC_VER) || defined(__MINGW64__)
6760575ce8ef8fa86a502dabe152293320676922dcfebart   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
67610da2c772047f3f6795dbb43dde5f5c9b43be73bbbart                              VG_USERREQ__PRINTF_VALIST_BY_REF,
6762fa5115adb77868b1ee3efc8dce061b881e7833c5bart                              (uintptr_t)format,
6763fa5115adb77868b1ee3efc8dce061b881e7833c5bart                              (uintptr_t)&vargs,
67640da2c772047f3f6795dbb43dde5f5c9b43be73bbbart                              0, 0, 0);
67650da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#else
6766575ce8ef8fa86a502dabe152293320676922dcfebart   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
6767c560fb380ac83ad1957d3fdf92751645a55cf167sewardj                              VG_USERREQ__PRINTF_VALIST_BY_REF,
676805b07158841423adc250f04e034bf11e6f892b23sewardj                              (unsigned long)format,
6769c560fb380ac83ad1957d3fdf92751645a55cf167sewardj                              (unsigned long)&vargs,
67709af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj                              0, 0, 0);
67710da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#endif
6772c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_end(vargs);
6773c616819253fcf211745060b2be26076174b1df19njn   return (int)_qzz_res;
67748c7e25f496b1771f21712db0b1f35935bacfaff3bart#endif /* NVALGRIND */
677539de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge}
677639de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge
677742f83fe6c64da13801d4eb54fa2aa6530679848abart#if defined(__GNUC__) || defined(__INTEL_COMPILER) && !defined(_MSC_VER)
67787eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardjstatic int VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
67797eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardj   __attribute__((format(__printf__, 1, 2), __unused__));
67807f489813d200fb614a0856fca05e2f9ebf66dd48bart#endif
67817eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardjstatic int
67820da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#if defined(_MSC_VER)
67830da2c772047f3f6795dbb43dde5f5c9b43be73bbbart__inline
67840da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#endif
6785a09a1b5d4e02b7451345dac00f2d321d1b4b2ccefitzhardingeVALGRIND_PRINTF_BACKTRACE(const char *format, ...)
678639de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge{
67878c7e25f496b1771f21712db0b1f35935bacfaff3bart#if defined(NVALGRIND)
67888c7e25f496b1771f21712db0b1f35935bacfaff3bart   return 0;
67898c7e25f496b1771f21712db0b1f35935bacfaff3bart#else /* NVALGRIND */
6790aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#if defined(_MSC_VER) || defined(__MINGW64__)
6791575ce8ef8fa86a502dabe152293320676922dcfebart   uintptr_t _qzz_res;
6792575ce8ef8fa86a502dabe152293320676922dcfebart#else
6793c616819253fcf211745060b2be26076174b1df19njn   unsigned long _qzz_res;
6794575ce8ef8fa86a502dabe152293320676922dcfebart#endif
6795c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_list vargs;
6796c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_start(vargs, format);
6797aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#if defined(_MSC_VER) || defined(__MINGW64__)
6798575ce8ef8fa86a502dabe152293320676922dcfebart   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
67990da2c772047f3f6795dbb43dde5f5c9b43be73bbbart                              VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF,
6800fa5115adb77868b1ee3efc8dce061b881e7833c5bart                              (uintptr_t)format,
6801fa5115adb77868b1ee3efc8dce061b881e7833c5bart                              (uintptr_t)&vargs,
68020da2c772047f3f6795dbb43dde5f5c9b43be73bbbart                              0, 0, 0);
68030da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#else
6804575ce8ef8fa86a502dabe152293320676922dcfebart   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
6805c560fb380ac83ad1957d3fdf92751645a55cf167sewardj                              VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF,
680605b07158841423adc250f04e034bf11e6f892b23sewardj                              (unsigned long)format,
6807c560fb380ac83ad1957d3fdf92751645a55cf167sewardj                              (unsigned long)&vargs,
68089af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj                              0, 0, 0);
68090da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#endif
6810c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_end(vargs);
6811c616819253fcf211745060b2be26076174b1df19njn   return (int)_qzz_res;
681239de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge#endif /* NVALGRIND */
68138c7e25f496b1771f21712db0b1f35935bacfaff3bart}
681418d7513cc08bf982711c8a22b70d56af6aa87b33sewardj
68150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
68163e88418f808bf2840646504481d6a5be1df16541njn/* These requests allow control to move from the simulated CPU to the
68171319b49115bd0763628273b8a3fe08ac30712e31njn   real CPU, calling an arbitary function.
68181319b49115bd0763628273b8a3fe08ac30712e31njn
68191319b49115bd0763628273b8a3fe08ac30712e31njn   Note that the current ThreadId is inserted as the first argument.
68201319b49115bd0763628273b8a3fe08ac30712e31njn   So this call:
68211319b49115bd0763628273b8a3fe08ac30712e31njn
68221319b49115bd0763628273b8a3fe08ac30712e31njn     VALGRIND_NON_SIMD_CALL2(f, arg1, arg2)
68231319b49115bd0763628273b8a3fe08ac30712e31njn
68241319b49115bd0763628273b8a3fe08ac30712e31njn   requires f to have this signature:
68251319b49115bd0763628273b8a3fe08ac30712e31njn
68261319b49115bd0763628273b8a3fe08ac30712e31njn     Word f(Word tid, Word arg1, Word arg2)
68271319b49115bd0763628273b8a3fe08ac30712e31njn
68281319b49115bd0763628273b8a3fe08ac30712e31njn   where "Word" is a word-sized type.
682945fb4d304f59e4e4cca917d372278eeb75be2c33njn
683045fb4d304f59e4e4cca917d372278eeb75be2c33njn   Note that these client requests are not entirely reliable.  For example,
683145fb4d304f59e4e4cca917d372278eeb75be2c33njn   if you call a function with them that subsequently calls printf(),
683245fb4d304f59e4e4cca917d372278eeb75be2c33njn   there's a high chance Valgrind will crash.  Generally, your prospects of
683345fb4d304f59e4e4cca917d372278eeb75be2c33njn   these working are made higher if the called function does not refer to
683445fb4d304f59e4e4cca917d372278eeb75be2c33njn   any global variables, and does not refer to any libc or other functions
683545fb4d304f59e4e4cca917d372278eeb75be2c33njn   (printf et al).  Any kind of entanglement with libc or dynamic linking is
683645fb4d304f59e4e4cca917d372278eeb75be2c33njn   likely to have a bad outcome, for tricky reasons which we've grappled
683745fb4d304f59e4e4cca917d372278eeb75be2c33njn   with a lot in the past.
68381319b49115bd0763628273b8a3fe08ac30712e31njn*/
68390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_NON_SIMD_CALL0(_qyy_fn)                          \
6840575ce8ef8fa86a502dabe152293320676922dcfebart    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,       \
6841575ce8ef8fa86a502dabe152293320676922dcfebart                                    VG_USERREQ__CLIENT_CALL0,     \
6842575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_fn,                      \
6843575ce8ef8fa86a502dabe152293320676922dcfebart                                    0, 0, 0, 0)
6844575ce8ef8fa86a502dabe152293320676922dcfebart
6845575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1)                    \
6846575ce8ef8fa86a502dabe152293320676922dcfebart    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,            \
6847575ce8ef8fa86a502dabe152293320676922dcfebart                                    VG_USERREQ__CLIENT_CALL1,          \
6848575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_fn,                           \
6849575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_arg1, 0, 0, 0)
6850575ce8ef8fa86a502dabe152293320676922dcfebart
6851575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2)         \
6852575ce8ef8fa86a502dabe152293320676922dcfebart    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,            \
6853575ce8ef8fa86a502dabe152293320676922dcfebart                                    VG_USERREQ__CLIENT_CALL2,          \
6854575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_fn,                           \
6855575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_arg1, _qyy_arg2, 0, 0)
68563e88418f808bf2840646504481d6a5be1df16541njn
68570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \
6858575ce8ef8fa86a502dabe152293320676922dcfebart    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,             \
6859575ce8ef8fa86a502dabe152293320676922dcfebart                                    VG_USERREQ__CLIENT_CALL3,           \
6860575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_fn,                            \
6861575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_arg1, _qyy_arg2,               \
6862575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_arg3, 0)
68633e88418f808bf2840646504481d6a5be1df16541njn
68643e88418f808bf2840646504481d6a5be1df16541njn
68657cc9c239f785f2903b597cdb34418bed42d25331nethercote/* Counts the number of errors that have been recorded by a tool.  Nb:
68667cc9c239f785f2903b597cdb34418bed42d25331nethercote   the tool must record the errors with VG_(maybe_record_error)() or
686747363aba8fa03b094195bca99fc232ce5f85605dnjn   VG_(unique_error)() for them to be counted. */
68680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_COUNT_ERRORS                                     \
6869575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(                    \
6870575ce8ef8fa86a502dabe152293320676922dcfebart                               0 /* default return */,            \
68710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                               VG_USERREQ__COUNT_ERRORS,          \
6872575ce8ef8fa86a502dabe152293320676922dcfebart                               0, 0, 0, 0, 0)
687347363aba8fa03b094195bca99fc232ce5f85605dnjn
68743ac96953bf8c912a2aaa2870652dda8b9b75337bnjn/* Several Valgrind tools (Memcheck, Massif, Helgrind, DRD) rely on knowing
68753ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   when heap blocks are allocated in order to give accurate results.  This
68763ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   happens automatically for the standard allocator functions such as
68773ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   malloc(), calloc(), realloc(), memalign(), new, new[], free(), delete,
68783ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   delete[], etc.
68793ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
68803ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   But if your program uses a custom allocator, this doesn't automatically
68813ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   happen, and Valgrind will not do as well.  For example, if you allocate
68823ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   superblocks with mmap() and then allocates chunks of the superblocks, all
68833ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Valgrind's observations will be at the mmap() level and it won't know that
68843ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   the chunks should be considered separate entities.  In Memcheck's case,
68853ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   that means you probably won't get heap block overrun detection (because
68863ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   there won't be redzones marked as unaddressable) and you definitely won't
68873ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   get any leak detection.
68883ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
68893ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   The following client requests allow a custom allocator to be annotated so
68903ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   that it can be handled accurately by Valgrind.
68913ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
68923ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   VALGRIND_MALLOCLIKE_BLOCK marks a region of memory as having been allocated
68933ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   by a malloc()-like function.  For Memcheck (an illustrative case), this
68943ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   does two things:
68953ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
68963ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   - It records that the block has been allocated.  This means any addresses
68973ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     within the block mentioned in error messages will be
68983ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     identified as belonging to the block.  It also means that if the block
68993ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     isn't freed it will be detected by the leak checker.
69003ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69013ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   - It marks the block as being addressable and undefined (if 'is_zeroed' is
69023ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     not set), or addressable and defined (if 'is_zeroed' is set).  This
69033ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     controls how accesses to the block by the program are handled.
69043ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69053ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   'addr' is the start of the usable block (ie. after any
69063ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   redzone), 'sizeB' is its size.  'rzB' is the redzone size if the allocator
69073ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   can apply redzones -- these are blocks of padding at the start and end of
69083ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   each block.  Adding redzones is recommended as it makes it much more likely
69093ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Valgrind will spot block overruns.  `is_zeroed' indicates if the memory is
69103ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   zeroed (or filled with another predictable value), as is the case for
69113ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   calloc().
69123ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69133ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   VALGRIND_MALLOCLIKE_BLOCK should be put immediately after the point where a
69143ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   heap block -- that will be used by the client program -- is allocated.
69153ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   It's best to put it at the outermost level of the allocator if possible;
69163ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   for example, if you have a function my_alloc() which calls
69173ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   internal_alloc(), and the client request is put inside internal_alloc(),
69183ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   stack traces relating to the heap block will contain entries for both
69193ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   my_alloc() and internal_alloc(), which is probably not what you want.
69203ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
6921b965efb4990bdedc3215ffcca8ea566d25874d26njn   For Memcheck users: if you use VALGRIND_MALLOCLIKE_BLOCK to carve out
6922b965efb4990bdedc3215ffcca8ea566d25874d26njn   custom blocks from within a heap block, B, that has been allocated with
6923b965efb4990bdedc3215ffcca8ea566d25874d26njn   malloc/calloc/new/etc, then block B will be *ignored* during leak-checking
6924b965efb4990bdedc3215ffcca8ea566d25874d26njn   -- the custom blocks will take precedence.
6925b965efb4990bdedc3215ffcca8ea566d25874d26njn
69263ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   VALGRIND_FREELIKE_BLOCK is the partner to VALGRIND_MALLOCLIKE_BLOCK.  For
69273ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Memcheck, it does two things:
69283ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69293ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   - It records that the block has been deallocated.  This assumes that the
69303ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     block was annotated as having been allocated via
69313ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     VALGRIND_MALLOCLIKE_BLOCK.  Otherwise, an error will be issued.
69323ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69333ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   - It marks the block as being unaddressable.
69343ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69353ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   VALGRIND_FREELIKE_BLOCK should be put immediately after the point where a
69363ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   heap block is deallocated.
69373ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
6938913473803432ee37d6edaf232e21978d4f426125bart   VALGRIND_RESIZEINPLACE_BLOCK informs a tool about reallocation. For
6939913473803432ee37d6edaf232e21978d4f426125bart   Memcheck, it does four things:
6940913473803432ee37d6edaf232e21978d4f426125bart
6941913473803432ee37d6edaf232e21978d4f426125bart   - It records that the size of a block has been changed.  This assumes that
6942913473803432ee37d6edaf232e21978d4f426125bart     the block was annotated as having been allocated via
6943913473803432ee37d6edaf232e21978d4f426125bart     VALGRIND_MALLOCLIKE_BLOCK.  Otherwise, an error will be issued.
6944913473803432ee37d6edaf232e21978d4f426125bart
6945913473803432ee37d6edaf232e21978d4f426125bart   - If the block shrunk, it marks the freed memory as being unaddressable.
6946913473803432ee37d6edaf232e21978d4f426125bart
6947913473803432ee37d6edaf232e21978d4f426125bart   - If the block grew, it marks the new area as undefined and defines a red
6948913473803432ee37d6edaf232e21978d4f426125bart     zone past the end of the new block.
6949913473803432ee37d6edaf232e21978d4f426125bart
6950913473803432ee37d6edaf232e21978d4f426125bart   - The V-bits of the overlap between the old and the new block are preserved.
6951913473803432ee37d6edaf232e21978d4f426125bart
6952913473803432ee37d6edaf232e21978d4f426125bart   VALGRIND_RESIZEINPLACE_BLOCK should be put after allocation of the new block
6953913473803432ee37d6edaf232e21978d4f426125bart   and before deallocation of the old block.
6954913473803432ee37d6edaf232e21978d4f426125bart
6955913473803432ee37d6edaf232e21978d4f426125bart   In many cases, these three client requests will not be enough to get your
69563ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   allocator working well with Memcheck.  More specifically, if your allocator
69573ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   writes to freed blocks in any way then a VALGRIND_MAKE_MEM_UNDEFINED call
69583ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   will be necessary to mark the memory as addressable just before the zeroing
69593ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   occurs, otherwise you'll get a lot of invalid write errors.  For example,
69603ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   you'll need to do this if your allocator recycles freed blocks, but it
69613ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   zeroes them before handing them back out (via VALGRIND_MALLOCLIKE_BLOCK).
69623ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Alternatively, if your allocator reuses freed blocks for allocator-internal
69633ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   data structures, VALGRIND_MAKE_MEM_UNDEFINED calls will also be necessary.
69643ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69653ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Really, what's happening is a blurring of the lines between the client
69663ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   program and the allocator... after VALGRIND_FREELIKE_BLOCK is called, the
69673ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   memory should be considered unaddressable to the client program, but the
69683ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   allocator knows more than the rest of the client program and so may be able
69693ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   to safely access it.  Extra client requests are necessary for Valgrind to
69703ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   understand the distinction between the allocator and the rest of the
69713ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   program.
69723ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
697332f8d8c0dcb3a7c3ff14aa9892ea2410eba3207cnjn   Ignored if addr == 0.
69743ac96953bf8c912a2aaa2870652dda8b9b75337bnjn*/
69754b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed)          \
69764b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MALLOCLIKE_BLOCK,       \
69774b3a74204894e943c43cb8e8aae39d813040702csewardj                                    addr, sizeB, rzB, is_zeroed, 0)
6978d799418996812817596beaa8b59563e3f3cb2ddanjn
697932f8d8c0dcb3a7c3ff14aa9892ea2410eba3207cnjn/* See the comment for VALGRIND_MALLOCLIKE_BLOCK for details.
698032f8d8c0dcb3a7c3ff14aa9892ea2410eba3207cnjn   Ignored if addr == 0.
698132f8d8c0dcb3a7c3ff14aa9892ea2410eba3207cnjn*/
69824b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_RESIZEINPLACE_BLOCK(addr, oldSizeB, newSizeB, rzB)     \
69834b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__RESIZEINPLACE_BLOCK,    \
69844b3a74204894e943c43cb8e8aae39d813040702csewardj                                    addr, oldSizeB, newSizeB, rzB, 0)
6985913473803432ee37d6edaf232e21978d4f426125bart
6986913473803432ee37d6edaf232e21978d4f426125bart/* See the comment for VALGRIND_MALLOCLIKE_BLOCK for details.
6987913473803432ee37d6edaf232e21978d4f426125bart   Ignored if addr == 0.
6988913473803432ee37d6edaf232e21978d4f426125bart*/
69894b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_FREELIKE_BLOCK(addr, rzB)                              \
69904b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__FREELIKE_BLOCK,         \
69914b3a74204894e943c43cb8e8aae39d813040702csewardj                                    addr, rzB, 0, 0, 0)
6992d799418996812817596beaa8b59563e3f3cb2ddanjn
6993bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh/* Create a memory pool. */
69940ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed)             \
69954b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__CREATE_MEMPOOL,   \
69964b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, rzB, is_zeroed, 0, 0)
6997bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh
6998bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh/* Destroy a memory pool. */
69990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_DESTROY_MEMPOOL(pool)                            \
70004b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DESTROY_MEMPOOL,  \
70014b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, 0, 0, 0, 0)
7002bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh
7003bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh/* Associate a piece of memory with a memory pool. */
70040ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size)                  \
70054b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MEMPOOL_ALLOC,    \
70064b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, addr, size, 0, 0)
7007bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh
7008bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh/* Disassociate a piece of memory from a memory pool. */
70090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_MEMPOOL_FREE(pool, addr)                         \
70104b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MEMPOOL_FREE,     \
70114b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, addr, 0, 0, 0)
7012bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh
70132c1c9dfe806d62d43768b23c29799dc6a100cb09sewardj/* Disassociate any pieces outside a particular range. */
70142c1c9dfe806d62d43768b23c29799dc6a100cb09sewardj#define VALGRIND_MEMPOOL_TRIM(pool, addr, size)                   \
70154b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MEMPOOL_TRIM,     \
70164b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, addr, size, 0, 0)
70172c1c9dfe806d62d43768b23c29799dc6a100cb09sewardj
7018c740d7660ad140b79e561e0d578ab8435a5a5289sewardj/* Resize and/or move a piece associated with a memory pool. */
7019c740d7660ad140b79e561e0d578ab8435a5a5289sewardj#define VALGRIND_MOVE_MEMPOOL(poolA, poolB)                       \
70204b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MOVE_MEMPOOL,     \
70214b3a74204894e943c43cb8e8aae39d813040702csewardj                                    poolA, poolB, 0, 0, 0)
7022c740d7660ad140b79e561e0d578ab8435a5a5289sewardj
7023c740d7660ad140b79e561e0d578ab8435a5a5289sewardj/* Resize and/or move a piece associated with a memory pool. */
7024c740d7660ad140b79e561e0d578ab8435a5a5289sewardj#define VALGRIND_MEMPOOL_CHANGE(pool, addrA, addrB, size)         \
70254b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MEMPOOL_CHANGE,   \
70264b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, addrA, addrB, size, 0)
7027c740d7660ad140b79e561e0d578ab8435a5a5289sewardj
7028c740d7660ad140b79e561e0d578ab8435a5a5289sewardj/* Return 1 if a mempool exists, else 0. */
7029c740d7660ad140b79e561e0d578ab8435a5a5289sewardj#define VALGRIND_MEMPOOL_EXISTS(pool)                             \
7030575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                  \
7031c740d7660ad140b79e561e0d578ab8435a5a5289sewardj                               VG_USERREQ__MEMPOOL_EXISTS,        \
7032575ce8ef8fa86a502dabe152293320676922dcfebart                               pool, 0, 0, 0, 0)
7033c740d7660ad140b79e561e0d578ab8435a5a5289sewardj
703438a74d2cc4670e3eb559adff51a376cd6ec98005philippe/* Mark a piece of memory as being a stack. Returns a stack id.
703538a74d2cc4670e3eb559adff51a376cd6ec98005philippe   start is the lowest addressable stack byte, end is the highest
703638a74d2cc4670e3eb559adff51a376cd6ec98005philippe   addressable stack byte. */
70370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_STACK_REGISTER(start, end)                       \
7038575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                  \
70390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                               VG_USERREQ__STACK_REGISTER,        \
7040575ce8ef8fa86a502dabe152293320676922dcfebart                               start, end, 0, 0, 0)
70410140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh
70420140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh/* Unmark the piece of memory associated with a stack id as being a
70430140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh   stack. */
70440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_STACK_DEREGISTER(id)                             \
70454b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__STACK_DEREGISTER, \
70464b3a74204894e943c43cb8e8aae39d813040702csewardj                                    id, 0, 0, 0, 0)
70470140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh
704838a74d2cc4670e3eb559adff51a376cd6ec98005philippe/* Change the start and end address of the stack id.
704938a74d2cc4670e3eb559adff51a376cd6ec98005philippe   start is the new lowest addressable stack byte, end is the new highest
705038a74d2cc4670e3eb559adff51a376cd6ec98005philippe   addressable stack byte. */
70510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_STACK_CHANGE(id, start, end)                     \
70524b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__STACK_CHANGE,     \
70534b3a74204894e943c43cb8e8aae39d813040702csewardj                                    id, start, end, 0, 0)
70540140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh
7055c8259b85b701d25d72aabe9dc0a8154517f96913sewardj/* Load PDB debug info for Wine PE image_map. */
70564b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_LOAD_PDB_DEBUGINFO(fd, ptr, total_size, delta)     \
70574b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__LOAD_PDB_DEBUGINFO, \
70584b3a74204894e943c43cb8e8aae39d813040702csewardj                                    fd, ptr, total_size, delta, 0)
7059c8259b85b701d25d72aabe9dc0a8154517f96913sewardj
70605c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj/* Map a code address to a source file name and line number.  buf64
70615c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj   must point to a 64-byte buffer in the caller's address space.  The
70625c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj   result will be dumped in there and is guaranteed to be zero
70635c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj   terminated.  If no info is found, the first byte is set to zero. */
70645c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj#define VALGRIND_MAP_IP_TO_SRCLOC(addr, buf64)                    \
7065575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                  \
70665c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj                               VG_USERREQ__MAP_IP_TO_SRCLOC,      \
7067575ce8ef8fa86a502dabe152293320676922dcfebart                               addr, buf64, 0, 0, 0)
70685c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj
7069dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj/* Disable error reporting for this thread.  Behaves in a stack like
7070dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   way, so you can safely call this multiple times provided that
7071dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   VALGRIND_ENABLE_ERROR_REPORTING is called the same number of times
7072dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   to re-enable reporting.  The first call of this macro disables
7073dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   reporting.  Subsequent calls have no effect except to increase the
7074dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   number of VALGRIND_ENABLE_ERROR_REPORTING calls needed to re-enable
7075dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   reporting.  Child threads do not inherit this setting from their
7076dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   parents -- they are always created with reporting enabled. */
707706e9bf06cf953602adaf5e2a0a3f5522e4dc7f50bart#define VALGRIND_DISABLE_ERROR_REPORTING                                \
70784b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__CHANGE_ERR_DISABLEMENT, \
70794b3a74204894e943c43cb8e8aae39d813040702csewardj                                    1, 0, 0, 0, 0)
7080dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj
7081dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj/* Re-enable error reporting, as per comments on
7082dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   VALGRIND_DISABLE_ERROR_REPORTING. */
708306e9bf06cf953602adaf5e2a0a3f5522e4dc7f50bart#define VALGRIND_ENABLE_ERROR_REPORTING                                 \
70844b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__CHANGE_ERR_DISABLEMENT, \
70854b3a74204894e943c43cb8e8aae39d813040702csewardj                                    -1, 0, 0, 0, 0)
70860ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
708746207652a0c99a2c8b0f05eafce3ca3ec533c121philippe/* Execute a monitor command from the client program.
708846207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   If a connection is opened with GDB, the output will be sent
708946207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   according to the output mode set for vgdb.
709046207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   If no connection is opened, output will go to the log output.
709146207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   Returns 1 if command not recognised, 0 otherwise. */
709246207652a0c99a2c8b0f05eafce3ca3ec533c121philippe#define VALGRIND_MONITOR_COMMAND(command)                               \
709346207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   VALGRIND_DO_CLIENT_REQUEST_EXPR(0, VG_USERREQ__GDB_MONITOR_COMMAND, \
709446207652a0c99a2c8b0f05eafce3ca3ec533c121philippe                                   command, 0, 0, 0, 0)
709546207652a0c99a2c8b0f05eafce3ca3ec533c121philippe
709646207652a0c99a2c8b0f05eafce3ca3ec533c121philippe
7097c112c8ea1262761630f2f17ada4d53697b1242fasewardj#undef PLAT_x86_darwin
7098c112c8ea1262761630f2f17ada4d53697b1242fasewardj#undef PLAT_amd64_darwin
7099c112c8ea1262761630f2f17ada4d53697b1242fasewardj#undef PLAT_x86_win32
7100aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#undef PLAT_amd64_win64
7101f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_x86_linux
7102f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_amd64_linux
7103f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_ppc32_linux
7104cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#undef PLAT_ppc64be_linux
7105582d58245637ab05272d89fb94b12fd0f18fa0f8carll#undef PLAT_ppc64le_linux
710659570ffbe31930ab4d678754daaeec0715117a3dsewardj#undef PLAT_arm_linux
7107b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#undef PLAT_s390x_linux
71085db15403e889d4db339b342bc2a824ef0bfaa654sewardj#undef PLAT_mips32_linux
71094df0bfc0614379192c780c944415dc420d9cfe8epetarj#undef PLAT_mips64_linux
7110112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#undef PLAT_tilegx_linux
71110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
71123e88418f808bf2840646504481d6a5be1df16541njn#endif   /* __VALGRIND_H */
7113