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
15b3a1e4bffbdbbf38304f216af405009868f43628sewardj   Copyright (C) 2000-2015 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
923260a71774b2d4475b85b10fad0255e9cb638bdbsewardj#define __VALGRIND_MINOR__    12
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
1268eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#undef PLAT_x86_solaris
1278eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#undef PLAT_amd64_solaris
128b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
129f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj
1306e9de463ef677f093e9f24f126e1b11c28cf59fdsewardj#if defined(__APPLE__) && defined(__i386__)
131f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#  define PLAT_x86_darwin 1
132f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#elif defined(__APPLE__) && defined(__x86_64__)
133f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#  define PLAT_amd64_darwin 1
134c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#elif (defined(__MINGW32__) && !defined(__MINGW64__)) \
135c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj      || defined(__CYGWIN32__) \
1366e9de463ef677f093e9f24f126e1b11c28cf59fdsewardj      || (defined(_WIN32) && defined(_M_IX86))
1377f489813d200fb614a0856fca05e2f9ebf66dd48bart#  define PLAT_x86_win32 1
138c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#elif defined(__MINGW64__) \
139c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj      || (defined(_WIN64) && defined(_M_X64))
140aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#  define PLAT_amd64_win64 1
14159570ffbe31930ab4d678754daaeec0715117a3dsewardj#elif defined(__linux__) && defined(__i386__)
142f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#  define PLAT_x86_linux 1
143f1c8e6c2748201f194d55893e89b3a1453c9b5bdbart#elif defined(__linux__) && defined(__x86_64__) && !defined(__ILP32__)
144f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#  define PLAT_amd64_linux 1
14559570ffbe31930ab4d678754daaeec0715117a3dsewardj#elif defined(__linux__) && defined(__powerpc__) && !defined(__powerpc64__)
146f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#  define PLAT_ppc32_linux 1
147cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__) && _CALL_ELF != 2
148cae0cc22b83ffb260ee8379e92099c5a701944cbcarll/* Big Endian uses ELF version 1 */
149cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#  define PLAT_ppc64be_linux 1
150582d58245637ab05272d89fb94b12fd0f18fa0f8carll#elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__) && _CALL_ELF == 2
151582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* Little Endian uses ELF version 2 */
152582d58245637ab05272d89fb94b12fd0f18fa0f8carll#  define PLAT_ppc64le_linux 1
153f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(__linux__) && defined(__arm__) && !defined(__aarch64__)
15459570ffbe31930ab4d678754daaeec0715117a3dsewardj#  define PLAT_arm_linux 1
155f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(__linux__) && defined(__aarch64__) && !defined(__arm__)
156f0c1250e324f6684757c6a15545366447ef1d64fsewardj#  define PLAT_arm64_linux 1
157b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#elif defined(__linux__) && defined(__s390__) && defined(__s390x__)
158b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define PLAT_s390x_linux 1
159f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(__linux__) && defined(__mips__) && (__mips==64)
1604df0bfc0614379192c780c944415dc420d9cfe8epetarj#  define PLAT_mips64_linux 1
161f0c1250e324f6684757c6a15545366447ef1d64fsewardj#elif defined(__linux__) && defined(__mips__) && (__mips!=64)
1625db15403e889d4db339b342bc2a824ef0bfaa654sewardj#  define PLAT_mips32_linux 1
163112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#elif defined(__linux__) && defined(__tilegx__)
164112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#  define PLAT_tilegx_linux 1
1658eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#elif defined(__sun) && defined(__i386__)
1668eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#  define PLAT_x86_solaris 1
1678eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#elif defined(__sun) && defined(__x86_64__)
1688eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#  define PLAT_amd64_solaris 1
169f76d27a697a7b0bf3b84490baf60623fc96a23afnjn#else
170f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* If we're not compiling for our target platform, don't generate
1710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   any inline asms.  */
1720ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#  if !defined(NVALGRIND)
1730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#    define NVALGRIND 1
1740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#  endif
175b5f6f51ebcac183818061bf53427a3e7808ef10dsewardj#endif
176b5f6f51ebcac183818061bf53427a3e7808ef10dsewardj
1770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
17830d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* ------------------------------------------------------------------ */
1790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ARCHITECTURE SPECIFICS for SPECIAL INSTRUCTIONS.  There is nothing */
1800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* in here of use to end-users -- skip to the next section.           */
18130d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* ------------------------------------------------------------------ */
182de4a1d01951937632098a6cda45859afa587a06fsewardj
183575ce8ef8fa86a502dabe152293320676922dcfebart/*
184575ce8ef8fa86a502dabe152293320676922dcfebart * VALGRIND_DO_CLIENT_REQUEST(): a statement that invokes a Valgrind client
185575ce8ef8fa86a502dabe152293320676922dcfebart * request. Accepts both pointers and integers as arguments.
186575ce8ef8fa86a502dabe152293320676922dcfebart *
1874b3a74204894e943c43cb8e8aae39d813040702csewardj * VALGRIND_DO_CLIENT_REQUEST_STMT(): a statement that invokes a Valgrind
1884b3a74204894e943c43cb8e8aae39d813040702csewardj * client request that does not return a value.
1894b3a74204894e943c43cb8e8aae39d813040702csewardj
190575ce8ef8fa86a502dabe152293320676922dcfebart * VALGRIND_DO_CLIENT_REQUEST_EXPR(): a C expression that invokes a Valgrind
1914b3a74204894e943c43cb8e8aae39d813040702csewardj * client request and whose value equals the client request result.  Accepts
1924b3a74204894e943c43cb8e8aae39d813040702csewardj * both pointers and integers as arguments.  Note that such calls are not
1934b3a74204894e943c43cb8e8aae39d813040702csewardj * necessarily pure functions -- they may have side effects.
194575ce8ef8fa86a502dabe152293320676922dcfebart */
195575ce8ef8fa86a502dabe152293320676922dcfebart
196575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST(_zzq_rlval, _zzq_default,            \
197575ce8ef8fa86a502dabe152293320676922dcfebart                                   _zzq_request, _zzq_arg1, _zzq_arg2,  \
198575ce8ef8fa86a502dabe152293320676922dcfebart                                   _zzq_arg3, _zzq_arg4, _zzq_arg5)     \
19917dfe1addc98de357b9e24ddbe4ad7df4454873aflorian  do { (_zzq_rlval) = VALGRIND_DO_CLIENT_REQUEST_EXPR((_zzq_default),   \
200575ce8ef8fa86a502dabe152293320676922dcfebart                        (_zzq_request), (_zzq_arg1), (_zzq_arg2),       \
20117dfe1addc98de357b9e24ddbe4ad7df4454873aflorian                        (_zzq_arg3), (_zzq_arg4), (_zzq_arg5)); } while (0)
202575ce8ef8fa86a502dabe152293320676922dcfebart
2034b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_DO_CLIENT_REQUEST_STMT(_zzq_request, _zzq_arg1,        \
2044b3a74204894e943c43cb8e8aae39d813040702csewardj                           _zzq_arg2,  _zzq_arg3, _zzq_arg4, _zzq_arg5) \
2054b3a74204894e943c43cb8e8aae39d813040702csewardj  do { (void) VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                        \
2064b3a74204894e943c43cb8e8aae39d813040702csewardj                    (_zzq_request), (_zzq_arg1), (_zzq_arg2),           \
2074b3a74204894e943c43cb8e8aae39d813040702csewardj                    (_zzq_arg3), (_zzq_arg4), (_zzq_arg5)); } while (0)
2084b3a74204894e943c43cb8e8aae39d813040702csewardj
2090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#if defined(NVALGRIND)
21026aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn
21126aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn/* Define NVALGRIND to completely remove the Valgrind magic sequence
2120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   from the compiled code (analogous to NDEBUG's effects on
2130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   assert()) */
214575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
215575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
2169af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
217575ce8ef8fa86a502dabe152293320676922dcfebart      (_zzq_default)
21826aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn
2190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#else  /* ! NVALGRIND */
2200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* The following defines the magic code sequences which the JITter
2220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   spots and handles magically.  Don't look too closely at them as
2230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   they will rot your brain.
224de4a1d01951937632098a6cda45859afa587a06fsewardj
2250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   The assembly code sequences for all architectures is in this one
2260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   file.  This is because this file must be stand-alone, and we don't
2270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   want to have multiple files.
2280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   For VALGRIND_DO_CLIENT_REQUEST, we must ensure that the default
2300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   value gets put in the return slot, so that everything works when
2310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   this is executed not under Valgrind.  Args are passed in a memory
2320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   block, and so there's no intrinsic limit to the number that could
2339af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj   be passed, but it's currently five.
234e90c6836fd430124799e52896c99ea27b1c88541nethercote
2355426544c9c3fc835ead99fae9e2054625110ef3enethercote   The macro args are:
2365426544c9c3fc835ead99fae9e2054625110ef3enethercote      _zzq_rlval    result lvalue
2375426544c9c3fc835ead99fae9e2054625110ef3enethercote      _zzq_default  default value (result returned when running on real CPU)
2385426544c9c3fc835ead99fae9e2054625110ef3enethercote      _zzq_request  request code
2399af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj      _zzq_arg1..5  request params
2405426544c9c3fc835ead99fae9e2054625110ef3enethercote
2410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   The other two macros are used to support function wrapping, and are
242d68ac3e974d25f88492774f6baa491999afde9f9sewardj   a lot simpler.  VALGRIND_GET_NR_CONTEXT returns the value of the
243d68ac3e974d25f88492774f6baa491999afde9f9sewardj   guest's NRADDR pseudo-register and whatever other information is
244d68ac3e974d25f88492774f6baa491999afde9f9sewardj   needed to safely run the call original from the wrapper: on
245d68ac3e974d25f88492774f6baa491999afde9f9sewardj   ppc64-linux, the R2 value at the divert point is also needed.  This
246d68ac3e974d25f88492774f6baa491999afde9f9sewardj   information is abstracted into a user-visible type, OrigFn.
247d68ac3e974d25f88492774f6baa491999afde9f9sewardj
248d68ac3e974d25f88492774f6baa491999afde9f9sewardj   VALGRIND_CALL_NOREDIR_* behaves the same as the following on the
249d68ac3e974d25f88492774f6baa491999afde9f9sewardj   guest, but guarantees that the branch instruction will not be
250d68ac3e974d25f88492774f6baa491999afde9f9sewardj   redirected: x86: call *%eax, amd64: call *%rax, ppc32/ppc64:
251d68ac3e974d25f88492774f6baa491999afde9f9sewardj   branch-and-link-to-r11.  VALGRIND_CALL_NOREDIR is just text, not a
252d68ac3e974d25f88492774f6baa491999afde9f9sewardj   complete inline asm, since it needs to be combined with more magic
253d68ac3e974d25f88492774f6baa491999afde9f9sewardj   inline asm stuff to be useful.
254e90c6836fd430124799e52896c99ea27b1c88541nethercote*/
255de4a1d01951937632098a6cda45859afa587a06fsewardj
2568eb8bab992e3998c33770b0cdb16059a8b918a06sewardj/* ----------------- x86-{linux,darwin,solaris} ---------------- */
2570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
258520a03a4c59703908bae4cc437814abf0a24cdcdsewardj#if defined(PLAT_x86_linux)  ||  defined(PLAT_x86_darwin)  \
2598eb8bab992e3998c33770b0cdb16059a8b918a06sewardj    ||  (defined(PLAT_x86_win32) && defined(__GNUC__)) \
2608eb8bab992e3998c33770b0cdb16059a8b918a06sewardj    ||  defined(PLAT_x86_solaris)
261c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj
262c885844f7484a13bcf1c7f9b14cf5bc527462963sewardjtypedef
263c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   struct {
264c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj      unsigned int nraddr; /* where's the code? */
265c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   }
266c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   OrigFn;
267c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj
2680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
2690ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "roll $3,  %%edi ; roll $13, %%edi\n\t"      \
2701a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "roll $29, %%edi ; roll $19, %%edi\n\t"
2710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
272575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
273575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
2749af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
275575ce8ef8fa86a502dabe152293320676922dcfebart  __extension__                                                   \
276575ce8ef8fa86a502dabe152293320676922dcfebart  ({volatile unsigned int _zzq_args[6];                           \
2770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    volatile unsigned int _zzq_result;                            \
2780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
2790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
2800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
2810ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
2820ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
2839af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
2840ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
2850ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %EDX = client_request ( %EAX ) */         \
2860ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgl %%ebx,%%ebx"                          \
2870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "=d" (_zzq_result)                         \
2880ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
2890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "cc", "memory"                             \
2900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
291575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
292575ce8ef8fa86a502dabe152293320676922dcfebart  })
2930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
294c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
295c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
296c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj    volatile unsigned int __addr;                                 \
2970ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
2980ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %EAX = guest_NRADDR */                    \
2990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgl %%ecx,%%ecx"                          \
3000ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "=a" (__addr)                              \
3010ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     :                                            \
3020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "cc", "memory"                             \
3030ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
304c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj    _zzq_orig->nraddr = __addr;                                   \
305ca0518df66f8c3375a860f1a55a51f18e2a16c44njn  }
3060ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
3070ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_CALL_NOREDIR_EAX                                 \
3080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
3090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* call-noredir *%EAX */                     \
3100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgl %%edx,%%edx\n\t"
311bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
312bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
313bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
314bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
315bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "xchgl %%edi,%%edi\n\t"                     \
316bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     : : : "cc", "memory"                        \
317bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
318bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
319bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
3208eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#endif /* PLAT_x86_linux || PLAT_x86_darwin || (PLAT_x86_win32 && __GNUC__)
3218eb8bab992e3998c33770b0cdb16059a8b918a06sewardj          || PLAT_x86_solaris */
3227f489813d200fb614a0856fca05e2f9ebf66dd48bart
3237f489813d200fb614a0856fca05e2f9ebf66dd48bart/* ------------------------- x86-Win32 ------------------------- */
3247f489813d200fb614a0856fca05e2f9ebf66dd48bart
3257f489813d200fb614a0856fca05e2f9ebf66dd48bart#if defined(PLAT_x86_win32) && !defined(__GNUC__)
3267f489813d200fb614a0856fca05e2f9ebf66dd48bart
3277f489813d200fb614a0856fca05e2f9ebf66dd48barttypedef
3287f489813d200fb614a0856fca05e2f9ebf66dd48bart   struct {
3297f489813d200fb614a0856fca05e2f9ebf66dd48bart      unsigned int nraddr; /* where's the code? */
3307f489813d200fb614a0856fca05e2f9ebf66dd48bart   }
3317f489813d200fb614a0856fca05e2f9ebf66dd48bart   OrigFn;
3327f489813d200fb614a0856fca05e2f9ebf66dd48bart
3337f489813d200fb614a0856fca05e2f9ebf66dd48bart#if defined(_MSC_VER)
3347f489813d200fb614a0856fca05e2f9ebf66dd48bart
3357f489813d200fb614a0856fca05e2f9ebf66dd48bart#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
3367f489813d200fb614a0856fca05e2f9ebf66dd48bart                     __asm rol edi, 3  __asm rol edi, 13          \
3377f489813d200fb614a0856fca05e2f9ebf66dd48bart                     __asm rol edi, 29 __asm rol edi, 19
3387f489813d200fb614a0856fca05e2f9ebf66dd48bart
339575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
340575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
3417f489813d200fb614a0856fca05e2f9ebf66dd48bart        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
342575ce8ef8fa86a502dabe152293320676922dcfebart    valgrind_do_client_request_expr((uintptr_t)(_zzq_default),    \
343575ce8ef8fa86a502dabe152293320676922dcfebart        (uintptr_t)(_zzq_request), (uintptr_t)(_zzq_arg1),        \
344575ce8ef8fa86a502dabe152293320676922dcfebart        (uintptr_t)(_zzq_arg2), (uintptr_t)(_zzq_arg3),           \
345575ce8ef8fa86a502dabe152293320676922dcfebart        (uintptr_t)(_zzq_arg4), (uintptr_t)(_zzq_arg5))
346575ce8ef8fa86a502dabe152293320676922dcfebart
347575ce8ef8fa86a502dabe152293320676922dcfebartstatic __inline uintptr_t
348575ce8ef8fa86a502dabe152293320676922dcfebartvalgrind_do_client_request_expr(uintptr_t _zzq_default, uintptr_t _zzq_request,
349575ce8ef8fa86a502dabe152293320676922dcfebart                                uintptr_t _zzq_arg1, uintptr_t _zzq_arg2,
350575ce8ef8fa86a502dabe152293320676922dcfebart                                uintptr_t _zzq_arg3, uintptr_t _zzq_arg4,
351575ce8ef8fa86a502dabe152293320676922dcfebart                                uintptr_t _zzq_arg5)
352575ce8ef8fa86a502dabe152293320676922dcfebart{
353575ce8ef8fa86a502dabe152293320676922dcfebart    volatile uintptr_t _zzq_args[6];
354575ce8ef8fa86a502dabe152293320676922dcfebart    volatile unsigned int _zzq_result;
355575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[0] = (uintptr_t)(_zzq_request);
356575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[1] = (uintptr_t)(_zzq_arg1);
357575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[2] = (uintptr_t)(_zzq_arg2);
358575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[3] = (uintptr_t)(_zzq_arg3);
359575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[4] = (uintptr_t)(_zzq_arg4);
360575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_args[5] = (uintptr_t)(_zzq_arg5);
361575ce8ef8fa86a502dabe152293320676922dcfebart    __asm { __asm lea eax, _zzq_args __asm mov edx, _zzq_default
362575ce8ef8fa86a502dabe152293320676922dcfebart            __SPECIAL_INSTRUCTION_PREAMBLE
363575ce8ef8fa86a502dabe152293320676922dcfebart            /* %EDX = client_request ( %EAX ) */
364575ce8ef8fa86a502dabe152293320676922dcfebart            __asm xchg ebx,ebx
365575ce8ef8fa86a502dabe152293320676922dcfebart            __asm mov _zzq_result, edx
366575ce8ef8fa86a502dabe152293320676922dcfebart    }
367575ce8ef8fa86a502dabe152293320676922dcfebart    return _zzq_result;
368575ce8ef8fa86a502dabe152293320676922dcfebart}
3697f489813d200fb614a0856fca05e2f9ebf66dd48bart
3707f489813d200fb614a0856fca05e2f9ebf66dd48bart#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
3717f489813d200fb614a0856fca05e2f9ebf66dd48bart  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
3727f489813d200fb614a0856fca05e2f9ebf66dd48bart    volatile unsigned int __addr;                                 \
3737f489813d200fb614a0856fca05e2f9ebf66dd48bart    __asm { __SPECIAL_INSTRUCTION_PREAMBLE                        \
3747f489813d200fb614a0856fca05e2f9ebf66dd48bart            /* %EAX = guest_NRADDR */                             \
3757f489813d200fb614a0856fca05e2f9ebf66dd48bart            __asm xchg ecx,ecx                                    \
3767f489813d200fb614a0856fca05e2f9ebf66dd48bart            __asm mov __addr, eax                                 \
3777f489813d200fb614a0856fca05e2f9ebf66dd48bart    }                                                             \
3787f489813d200fb614a0856fca05e2f9ebf66dd48bart    _zzq_orig->nraddr = __addr;                                   \
3797f489813d200fb614a0856fca05e2f9ebf66dd48bart  }
3807f489813d200fb614a0856fca05e2f9ebf66dd48bart
3817f489813d200fb614a0856fca05e2f9ebf66dd48bart#define VALGRIND_CALL_NOREDIR_EAX ERROR
3827f489813d200fb614a0856fca05e2f9ebf66dd48bart
383bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
384bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
385bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm { __SPECIAL_INSTRUCTION_PREAMBLE                       \
386bb913cd4cc1e56d7d7798a8b754361a05d01f916florian            __asm xchg edi,edi                                   \
387bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    }                                                            \
388bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
389bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
3907f489813d200fb614a0856fca05e2f9ebf66dd48bart#else
3917f489813d200fb614a0856fca05e2f9ebf66dd48bart#error Unsupported compiler.
3927f489813d200fb614a0856fca05e2f9ebf66dd48bart#endif
3937f489813d200fb614a0856fca05e2f9ebf66dd48bart
3947f489813d200fb614a0856fca05e2f9ebf66dd48bart#endif /* PLAT_x86_win32 */
3950ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
3968eb8bab992e3998c33770b0cdb16059a8b918a06sewardj/* ----------------- amd64-{linux,darwin,solaris} --------------- */
3970ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
398c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#if defined(PLAT_amd64_linux)  ||  defined(PLAT_amd64_darwin) \
3998eb8bab992e3998c33770b0cdb16059a8b918a06sewardj    ||  defined(PLAT_amd64_solaris) \
400c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj    ||  (defined(PLAT_amd64_win64) && defined(__GNUC__))
401c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj
402c885844f7484a13bcf1c7f9b14cf5bc527462963sewardjtypedef
403c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   struct {
4043540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int nraddr; /* where's the code? */
405c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   }
406c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj   OrigFn;
407c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj
4080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
4090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "rolq $3,  %%rdi ; rolq $13, %%rdi\n\t"      \
4101a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "rolq $61, %%rdi ; rolq $51, %%rdi\n\t"
4110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
412575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
413575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
4149af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
415575ce8ef8fa86a502dabe152293320676922dcfebart    __extension__                                                 \
4163540ee89957c352912f3ffb90484abb17cc60675florian    ({ volatile unsigned long int _zzq_args[6];                   \
4173540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int _zzq_result;                       \
4183540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);             \
4193540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
4203540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
4213540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
4223540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
4233540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
4240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
4250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %RDX = client_request ( %RAX ) */         \
4260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgq %%rbx,%%rbx"                          \
4270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "=d" (_zzq_result)                         \
4280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
4290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "cc", "memory"                             \
4300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
431575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
432575ce8ef8fa86a502dabe152293320676922dcfebart    })
4330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
434c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
435c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
4363540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int __addr;                            \
4370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
4380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %RAX = guest_NRADDR */                    \
4390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgq %%rcx,%%rcx"                          \
4400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "=a" (__addr)                              \
4410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     :                                            \
4420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     : "cc", "memory"                             \
4430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
444c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj    _zzq_orig->nraddr = __addr;                                   \
4452c48c7b0a453d32375a4df17e153011b797ef28csewardj  }
4460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
4470ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_CALL_NOREDIR_RAX                                 \
4480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
4490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* call-noredir *%RAX */                     \
4500ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "xchgq %%rdx,%%rdx\n\t"
451bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
452bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
453bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
454bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
455bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "xchgq %%rdi,%%rdi\n\t"                     \
456bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     : : : "cc", "memory"                        \
457bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
458bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
459bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
4608eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#endif /* PLAT_amd64_linux || PLAT_amd64_darwin || PLAT_amd64_solaris */
4610ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
462c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj/* ------------------------- amd64-Win64 ------------------------- */
463c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj
464c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#if defined(PLAT_amd64_win64) && !defined(__GNUC__)
465c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj
466c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#error Unsupported compiler.
467c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj
468c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj#endif /* PLAT_amd64_win64 */
469c913c8e1a75c78cd653fec8076c07ee4bfb56824sewardj
470f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* ------------------------ ppc32-linux ------------------------ */
4710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
472f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#if defined(PLAT_ppc32_linux)
473d68ac3e974d25f88492774f6baa491999afde9f9sewardj
474d68ac3e974d25f88492774f6baa491999afde9f9sewardjtypedef
475d68ac3e974d25f88492774f6baa491999afde9f9sewardj   struct {
476c885844f7484a13bcf1c7f9b14cf5bc527462963sewardj      unsigned int nraddr; /* where's the code? */
477d68ac3e974d25f88492774f6baa491999afde9f9sewardj   }
478d68ac3e974d25f88492774f6baa491999afde9f9sewardj   OrigFn;
479d68ac3e974d25f88492774f6baa491999afde9f9sewardj
4800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
4814decb2697c3e367d9599b0ee8a11db8148bb7147sewardj                    "rlwinm 0,0,3,0,31  ; rlwinm 0,0,13,0,31\n\t" \
4824decb2697c3e367d9599b0ee8a11db8148bb7147sewardj                    "rlwinm 0,0,29,0,31 ; rlwinm 0,0,19,0,31\n\t"
4830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
484575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
485575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
4869af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
4870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                                                                  \
488575ce8ef8fa86a502dabe152293320676922dcfebart    __extension__                                                 \
489575ce8ef8fa86a502dabe152293320676922dcfebart  ({         unsigned int  _zzq_args[6];                          \
4901c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj             unsigned int  _zzq_result;                           \
4911c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj             unsigned int* _zzq_ptr;                              \
4920ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
4930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
4940ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
4950ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
4960ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
4979af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
4980ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_ptr = _zzq_args;                                         \
4991c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj    __asm__ volatile("mr 3,%1\n\t" /*default*/                    \
5001c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "mr 4,%2\n\t" /*ptr*/                        \
5011c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
5020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %R3 = client_request ( %R4 ) */           \
5031c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "or 1,1,1\n\t"                               \
5041c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "mr %0,3"     /*result*/                     \
5051c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "=b" (_zzq_result)                         \
5061c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "b" (_zzq_default), "b" (_zzq_ptr)         \
5071c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "cc", "memory", "r3", "r4");               \
508575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
509575ce8ef8fa86a502dabe152293320676922dcfebart    })
5100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
511d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
512d68ac3e974d25f88492774f6baa491999afde9f9sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
5131c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj    unsigned int __addr;                                          \
5140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
5150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* %R3 = guest_NRADDR */                     \
5161c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "or 2,2,2\n\t"                               \
5171c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     "mr %0,3"                                    \
5181c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "=b" (__addr)                              \
5190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     :                                            \
5201c5bcb1e17532ec1630056fb2e58ef8e15267f15sewardj                     : "cc", "memory", "r3"                       \
5210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                    );                                            \
522d68ac3e974d25f88492774f6baa491999afde9f9sewardj    _zzq_orig->nraddr = __addr;                                   \
5230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj  }
5240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
5250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                   \
5260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
5270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     /* branch-and-link-to-noredir *%R11 */       \
5280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                     "or 3,3,3\n\t"
5294d261bbb67135fef7b1f947b025a0ff6b512cc57florian
5304d261bbb67135fef7b1f947b025a0ff6b512cc57florian#define VALGRIND_VEX_INJECT_IR()                                 \
5314d261bbb67135fef7b1f947b025a0ff6b512cc57florian do {                                                            \
5324d261bbb67135fef7b1f947b025a0ff6b512cc57florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
5334d261bbb67135fef7b1f947b025a0ff6b512cc57florian                     "or 5,5,5\n\t"                              \
5344d261bbb67135fef7b1f947b025a0ff6b512cc57florian                    );                                           \
5354d261bbb67135fef7b1f947b025a0ff6b512cc57florian } while (0)
5364d261bbb67135fef7b1f947b025a0ff6b512cc57florian
537f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#endif /* PLAT_ppc32_linux */
5380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
539f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* ------------------------ ppc64-linux ------------------------ */
5400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
541cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#if defined(PLAT_ppc64be_linux)
542d68ac3e974d25f88492774f6baa491999afde9f9sewardj
543d68ac3e974d25f88492774f6baa491999afde9f9sewardjtypedef
544d68ac3e974d25f88492774f6baa491999afde9f9sewardj   struct {
5453540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int nraddr; /* where's the code? */
5463540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int r2;  /* what tocptr do we need? */
547d68ac3e974d25f88492774f6baa491999afde9f9sewardj   }
548d68ac3e974d25f88492774f6baa491999afde9f9sewardj   OrigFn;
549d68ac3e974d25f88492774f6baa491999afde9f9sewardj
5501a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
5511a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "rotldi 0,0,3  ; rotldi 0,0,13\n\t"          \
5521a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "rotldi 0,0,61 ; rotldi 0,0,51\n\t"
5531a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj
554575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
555575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
5569af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
5570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                                                                  \
558575ce8ef8fa86a502dabe152293320676922dcfebart  __extension__                                                   \
5593540ee89957c352912f3ffb90484abb17cc60675florian  ({         unsigned long int  _zzq_args[6];                     \
5603540ee89957c352912f3ffb90484abb17cc60675florian             unsigned long int  _zzq_result;                      \
5613540ee89957c352912f3ffb90484abb17cc60675florian             unsigned long int* _zzq_ptr;                         \
5623540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);             \
5633540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
5643540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
5653540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
5663540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
5673540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
5680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj    _zzq_ptr = _zzq_args;                                         \
5698258a3a849f8bf47146ff1740d2dac429bb453a5sewardj    __asm__ volatile("mr 3,%1\n\t" /*default*/                    \
5708258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "mr 4,%2\n\t" /*ptr*/                        \
5718258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
5721a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     /* %R3 = client_request ( %R4 ) */           \
5738258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "or 1,1,1\n\t"                               \
5748258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "mr %0,3"     /*result*/                     \
5758258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "=b" (_zzq_result)                         \
5768258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "b" (_zzq_default), "b" (_zzq_ptr)         \
5778258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "cc", "memory", "r3", "r4");               \
578575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
579575ce8ef8fa86a502dabe152293320676922dcfebart  })
5801a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj
581d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
582d68ac3e974d25f88492774f6baa491999afde9f9sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
5833540ee89957c352912f3ffb90484abb17cc60675florian    unsigned long int __addr;                                     \
5841a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
5851a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     /* %R3 = guest_NRADDR */                     \
5868258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "or 2,2,2\n\t"                               \
5878258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "mr %0,3"                                    \
5888258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "=b" (__addr)                              \
5891a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     :                                            \
5908258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "cc", "memory", "r3"                       \
5911a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                    );                                            \
592d68ac3e974d25f88492774f6baa491999afde9f9sewardj    _zzq_orig->nraddr = __addr;                                   \
593d68ac3e974d25f88492774f6baa491999afde9f9sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
594d68ac3e974d25f88492774f6baa491999afde9f9sewardj                     /* %R3 = guest_NRADDR_GPR2 */                \
5958258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "or 4,4,4\n\t"                               \
5968258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     "mr %0,3"                                    \
5978258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "=b" (__addr)                              \
598d68ac3e974d25f88492774f6baa491999afde9f9sewardj                     :                                            \
5998258a3a849f8bf47146ff1740d2dac429bb453a5sewardj                     : "cc", "memory", "r3"                       \
600d68ac3e974d25f88492774f6baa491999afde9f9sewardj                    );                                            \
601d68ac3e974d25f88492774f6baa491999afde9f9sewardj    _zzq_orig->r2 = __addr;                                       \
6020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj  }
6031a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj
6041a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                   \
6051a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
6061a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     /* branch-and-link-to-noredir *%R11 */       \
6071a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj                     "or 3,3,3\n\t"
6081a85f4f4e5e1ec2518137ffa9a6a9bf7d9c50df9sewardj
609bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
610bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
611bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
612bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "or 5,5,5\n\t"                              \
613bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
614bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
615bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
616cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#endif /* PLAT_ppc64be_linux */
617cae0cc22b83ffb260ee8379e92099c5a701944cbcarll
618582d58245637ab05272d89fb94b12fd0f18fa0f8carll#if defined(PLAT_ppc64le_linux)
619582d58245637ab05272d89fb94b12fd0f18fa0f8carll
620582d58245637ab05272d89fb94b12fd0f18fa0f8carlltypedef
621582d58245637ab05272d89fb94b12fd0f18fa0f8carll   struct {
6223540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int nraddr; /* where's the code? */
6233540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int r2;     /* what tocptr do we need? */
624582d58245637ab05272d89fb94b12fd0f18fa0f8carll   }
625582d58245637ab05272d89fb94b12fd0f18fa0f8carll   OrigFn;
626582d58245637ab05272d89fb94b12fd0f18fa0f8carll
627582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
628582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "rotldi 0,0,3  ; rotldi 0,0,13\n\t"          \
629582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "rotldi 0,0,61 ; rotldi 0,0,51\n\t"
630582d58245637ab05272d89fb94b12fd0f18fa0f8carll
631582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
632582d58245637ab05272d89fb94b12fd0f18fa0f8carll        _zzq_default, _zzq_request,                               \
633582d58245637ab05272d89fb94b12fd0f18fa0f8carll        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
634582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                                                  \
635582d58245637ab05272d89fb94b12fd0f18fa0f8carll  __extension__                                                   \
6363540ee89957c352912f3ffb90484abb17cc60675florian  ({         unsigned long int  _zzq_args[6];                     \
6373540ee89957c352912f3ffb90484abb17cc60675florian             unsigned long int  _zzq_result;                      \
6383540ee89957c352912f3ffb90484abb17cc60675florian             unsigned long int* _zzq_ptr;                         \
6393540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);             \
6403540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
6413540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
6423540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
6433540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
6443540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
645582d58245637ab05272d89fb94b12fd0f18fa0f8carll    _zzq_ptr = _zzq_args;                                         \
646582d58245637ab05272d89fb94b12fd0f18fa0f8carll    __asm__ volatile("mr 3,%1\n\t" /*default*/                    \
647582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "mr 4,%2\n\t" /*ptr*/                        \
648582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     __SPECIAL_INSTRUCTION_PREAMBLE               \
649582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     /* %R3 = client_request ( %R4 ) */           \
650582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 1,1,1\n\t"                               \
651582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "mr %0,3"     /*result*/                     \
652582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "=b" (_zzq_result)                         \
653582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "b" (_zzq_default), "b" (_zzq_ptr)         \
654582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "cc", "memory", "r3", "r4");               \
655582d58245637ab05272d89fb94b12fd0f18fa0f8carll    _zzq_result;                                                  \
656582d58245637ab05272d89fb94b12fd0f18fa0f8carll  })
657582d58245637ab05272d89fb94b12fd0f18fa0f8carll
658582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
659582d58245637ab05272d89fb94b12fd0f18fa0f8carll  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
6603540ee89957c352912f3ffb90484abb17cc60675florian    unsigned long int __addr;                                     \
661582d58245637ab05272d89fb94b12fd0f18fa0f8carll    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
662582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     /* %R3 = guest_NRADDR */                     \
663582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 2,2,2\n\t"                               \
664582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "mr %0,3"                                    \
665582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "=b" (__addr)                              \
666582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     :                                            \
667582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "cc", "memory", "r3"                       \
668582d58245637ab05272d89fb94b12fd0f18fa0f8carll                    );                                            \
669582d58245637ab05272d89fb94b12fd0f18fa0f8carll    _zzq_orig->nraddr = __addr;                                   \
670582d58245637ab05272d89fb94b12fd0f18fa0f8carll    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
671582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     /* %R3 = guest_NRADDR_GPR2 */                \
672582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 4,4,4\n\t"                               \
673582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "mr %0,3"                                    \
674582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "=b" (__addr)                              \
675582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     :                                            \
676582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     : "cc", "memory", "r3"                       \
677582d58245637ab05272d89fb94b12fd0f18fa0f8carll                    );                                            \
678582d58245637ab05272d89fb94b12fd0f18fa0f8carll    _zzq_orig->r2 = __addr;                                       \
679582d58245637ab05272d89fb94b12fd0f18fa0f8carll  }
680582d58245637ab05272d89fb94b12fd0f18fa0f8carll
681582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                   \
682582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     __SPECIAL_INSTRUCTION_PREAMBLE               \
683582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     /* branch-and-link-to-noredir *%R12 */       \
684582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 3,3,3\n\t"
685582d58245637ab05272d89fb94b12fd0f18fa0f8carll
686582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_VEX_INJECT_IR()                                 \
687582d58245637ab05272d89fb94b12fd0f18fa0f8carll do {                                                            \
688582d58245637ab05272d89fb94b12fd0f18fa0f8carll    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
689582d58245637ab05272d89fb94b12fd0f18fa0f8carll                     "or 5,5,5\n\t"                              \
690582d58245637ab05272d89fb94b12fd0f18fa0f8carll                    );                                           \
691582d58245637ab05272d89fb94b12fd0f18fa0f8carll } while (0)
692582d58245637ab05272d89fb94b12fd0f18fa0f8carll
693582d58245637ab05272d89fb94b12fd0f18fa0f8carll#endif /* PLAT_ppc64le_linux */
694f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj
69559570ffbe31930ab4d678754daaeec0715117a3dsewardj/* ------------------------- arm-linux ------------------------- */
69659570ffbe31930ab4d678754daaeec0715117a3dsewardj
69759570ffbe31930ab4d678754daaeec0715117a3dsewardj#if defined(PLAT_arm_linux)
69859570ffbe31930ab4d678754daaeec0715117a3dsewardj
69959570ffbe31930ab4d678754daaeec0715117a3dsewardjtypedef
70059570ffbe31930ab4d678754daaeec0715117a3dsewardj   struct {
70159570ffbe31930ab4d678754daaeec0715117a3dsewardj      unsigned int nraddr; /* where's the code? */
70259570ffbe31930ab4d678754daaeec0715117a3dsewardj   }
70359570ffbe31930ab4d678754daaeec0715117a3dsewardj   OrigFn;
70459570ffbe31930ab4d678754daaeec0715117a3dsewardj
70559570ffbe31930ab4d678754daaeec0715117a3dsewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
70659570ffbe31930ab4d678754daaeec0715117a3dsewardj            "mov r12, r12, ror #3  ; mov r12, r12, ror #13 \n\t"  \
70759570ffbe31930ab4d678754daaeec0715117a3dsewardj            "mov r12, r12, ror #29 ; mov r12, r12, ror #19 \n\t"
70859570ffbe31930ab4d678754daaeec0715117a3dsewardj
709575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
710575ce8ef8fa86a502dabe152293320676922dcfebart        _zzq_default, _zzq_request,                               \
71159570ffbe31930ab4d678754daaeec0715117a3dsewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
71259570ffbe31930ab4d678754daaeec0715117a3dsewardj                                                                  \
713575ce8ef8fa86a502dabe152293320676922dcfebart  __extension__                                                   \
714575ce8ef8fa86a502dabe152293320676922dcfebart  ({volatile unsigned int  _zzq_args[6];                          \
71559570ffbe31930ab4d678754daaeec0715117a3dsewardj    volatile unsigned int  _zzq_result;                           \
71659570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
71759570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
71859570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
71959570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
72059570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
72159570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
72259570ffbe31930ab4d678754daaeec0715117a3dsewardj    __asm__ volatile("mov r3, %1\n\t" /*default*/                 \
72359570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "mov r4, %2\n\t" /*ptr*/                     \
72459570ffbe31930ab4d678754daaeec0715117a3dsewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
72559570ffbe31930ab4d678754daaeec0715117a3dsewardj                     /* R3 = client_request ( R4 ) */             \
72659570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "orr r10, r10, r10\n\t"                      \
72759570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "mov %0, r3"     /*result*/                  \
72859570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "=r" (_zzq_result)                         \
72959570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "r" (_zzq_default), "r" (&_zzq_args[0])    \
73059570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "cc","memory", "r3", "r4");                \
731575ce8ef8fa86a502dabe152293320676922dcfebart    _zzq_result;                                                  \
732575ce8ef8fa86a502dabe152293320676922dcfebart  })
73359570ffbe31930ab4d678754daaeec0715117a3dsewardj
73459570ffbe31930ab4d678754daaeec0715117a3dsewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
73559570ffbe31930ab4d678754daaeec0715117a3dsewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
73659570ffbe31930ab4d678754daaeec0715117a3dsewardj    unsigned int __addr;                                          \
73759570ffbe31930ab4d678754daaeec0715117a3dsewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
73859570ffbe31930ab4d678754daaeec0715117a3dsewardj                     /* R3 = guest_NRADDR */                      \
73959570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "orr r11, r11, r11\n\t"                      \
74059570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "mov %0, r3"                                 \
74159570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "=r" (__addr)                              \
74259570ffbe31930ab4d678754daaeec0715117a3dsewardj                     :                                            \
74359570ffbe31930ab4d678754daaeec0715117a3dsewardj                     : "cc", "memory", "r3"                       \
74459570ffbe31930ab4d678754daaeec0715117a3dsewardj                    );                                            \
74559570ffbe31930ab4d678754daaeec0715117a3dsewardj    _zzq_orig->nraddr = __addr;                                   \
74659570ffbe31930ab4d678754daaeec0715117a3dsewardj  }
74759570ffbe31930ab4d678754daaeec0715117a3dsewardj
74859570ffbe31930ab4d678754daaeec0715117a3dsewardj#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                    \
74959570ffbe31930ab4d678754daaeec0715117a3dsewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
75059570ffbe31930ab4d678754daaeec0715117a3dsewardj                     /* branch-and-link-to-noredir *%R4 */        \
75159570ffbe31930ab4d678754daaeec0715117a3dsewardj                     "orr r12, r12, r12\n\t"
75259570ffbe31930ab4d678754daaeec0715117a3dsewardj
753bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
754bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
755bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
756c379fec53a1e7a2ba8698f339ad67e370c9f0886sewardj                     "orr r9, r9, r9\n\t"                        \
757bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     : : : "cc", "memory"                        \
758bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
759bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
760bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
76159570ffbe31930ab4d678754daaeec0715117a3dsewardj#endif /* PLAT_arm_linux */
76259570ffbe31930ab4d678754daaeec0715117a3dsewardj
763f0c1250e324f6684757c6a15545366447ef1d64fsewardj/* ------------------------ arm64-linux ------------------------- */
764f0c1250e324f6684757c6a15545366447ef1d64fsewardj
765f0c1250e324f6684757c6a15545366447ef1d64fsewardj#if defined(PLAT_arm64_linux)
766f0c1250e324f6684757c6a15545366447ef1d64fsewardj
767f0c1250e324f6684757c6a15545366447ef1d64fsewardjtypedef
768f0c1250e324f6684757c6a15545366447ef1d64fsewardj   struct {
7693540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long int nraddr; /* where's the code? */
770f0c1250e324f6684757c6a15545366447ef1d64fsewardj   }
771f0c1250e324f6684757c6a15545366447ef1d64fsewardj   OrigFn;
772f0c1250e324f6684757c6a15545366447ef1d64fsewardj
773f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                            \
774f0c1250e324f6684757c6a15545366447ef1d64fsewardj            "ror x12, x12, #3  ;  ror x12, x12, #13 \n\t"         \
775f0c1250e324f6684757c6a15545366447ef1d64fsewardj            "ror x12, x12, #51 ;  ror x12, x12, #61 \n\t"
776f0c1250e324f6684757c6a15545366447ef1d64fsewardj
777f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
778f0c1250e324f6684757c6a15545366447ef1d64fsewardj        _zzq_default, _zzq_request,                               \
779f0c1250e324f6684757c6a15545366447ef1d64fsewardj        _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
780f0c1250e324f6684757c6a15545366447ef1d64fsewardj                                                                  \
781f0c1250e324f6684757c6a15545366447ef1d64fsewardj  __extension__                                                   \
7823540ee89957c352912f3ffb90484abb17cc60675florian  ({volatile unsigned long int  _zzq_args[6];                     \
7833540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int  _zzq_result;                      \
7843540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);             \
7853540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
7863540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
7873540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
7883540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
7893540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
790f0c1250e324f6684757c6a15545366447ef1d64fsewardj    __asm__ volatile("mov x3, %1\n\t" /*default*/                 \
791f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "mov x4, %2\n\t" /*ptr*/                     \
792f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
793f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     /* X3 = client_request ( X4 ) */             \
794f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "orr x10, x10, x10\n\t"                      \
795f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "mov %0, x3"     /*result*/                  \
796f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "=r" (_zzq_result)                         \
797470e245039eeb703d2f887fa3ff4a1fef116d23esewardj                     : "r" ((unsigned long int)(_zzq_default)),   \
798470e245039eeb703d2f887fa3ff4a1fef116d23esewardj                       "r" (&_zzq_args[0])                        \
799f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "cc","memory", "x3", "x4");                \
800f0c1250e324f6684757c6a15545366447ef1d64fsewardj    _zzq_result;                                                  \
801f0c1250e324f6684757c6a15545366447ef1d64fsewardj  })
802f0c1250e324f6684757c6a15545366447ef1d64fsewardj
803f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
804f0c1250e324f6684757c6a15545366447ef1d64fsewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
8053540ee89957c352912f3ffb90484abb17cc60675florian    unsigned long int __addr;                                     \
806f0c1250e324f6684757c6a15545366447ef1d64fsewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
807f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     /* X3 = guest_NRADDR */                      \
808f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "orr x11, x11, x11\n\t"                      \
809f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "mov %0, x3"                                 \
810f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "=r" (__addr)                              \
811f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     :                                            \
812f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : "cc", "memory", "x3"                       \
813f0c1250e324f6684757c6a15545366447ef1d64fsewardj                    );                                            \
814f0c1250e324f6684757c6a15545366447ef1d64fsewardj    _zzq_orig->nraddr = __addr;                                   \
815f0c1250e324f6684757c6a15545366447ef1d64fsewardj  }
816f0c1250e324f6684757c6a15545366447ef1d64fsewardj
817f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                    \
818f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
819f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     /* branch-and-link-to-noredir X8 */          \
820f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "orr x12, x12, x12\n\t"
821f0c1250e324f6684757c6a15545366447ef1d64fsewardj
822f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define VALGRIND_VEX_INJECT_IR()                                 \
823f0c1250e324f6684757c6a15545366447ef1d64fsewardj do {                                                            \
824f0c1250e324f6684757c6a15545366447ef1d64fsewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
825f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     "orr x9, x9, x9\n\t"                        \
826f0c1250e324f6684757c6a15545366447ef1d64fsewardj                     : : : "cc", "memory"                        \
827f0c1250e324f6684757c6a15545366447ef1d64fsewardj                    );                                           \
828f0c1250e324f6684757c6a15545366447ef1d64fsewardj } while (0)
829f0c1250e324f6684757c6a15545366447ef1d64fsewardj
830f0c1250e324f6684757c6a15545366447ef1d64fsewardj#endif /* PLAT_arm64_linux */
831f0c1250e324f6684757c6a15545366447ef1d64fsewardj
832b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* ------------------------ s390x-linux ------------------------ */
833b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
834b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#if defined(PLAT_s390x_linux)
835b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
836b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardjtypedef
837b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj  struct {
8383540ee89957c352912f3ffb90484abb17cc60675florian     unsigned long int nraddr; /* where's the code? */
839b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj  }
840b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj  OrigFn;
841b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
842b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* __SPECIAL_INSTRUCTION_PREAMBLE will be used to identify Valgrind specific
843b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj * code. This detection is implemented in platform specific toIR.c
844b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj * (e.g. VEX/priv/guest_s390_decoder.c).
845b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj */
846b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                           \
847b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     "lr 15,15\n\t"                              \
848b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     "lr 1,1\n\t"                                \
849b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     "lr 2,2\n\t"                                \
850b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     "lr 3,3\n\t"
851b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
852b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __CLIENT_REQUEST_CODE "lr 2,2\n\t"
853b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __GET_NR_CONTEXT_CODE "lr 3,3\n\t"
854b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __CALL_NO_REDIR_CODE  "lr 4,4\n\t"
855bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define __VEX_INJECT_IR_CODE  "lr 5,5\n\t"
856b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
857575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                         \
858575ce8ef8fa86a502dabe152293320676922dcfebart       _zzq_default, _zzq_request,                               \
859b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj       _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)    \
860575ce8ef8fa86a502dabe152293320676922dcfebart  __extension__                                                  \
8613540ee89957c352912f3ffb90484abb17cc60675florian ({volatile unsigned long int _zzq_args[6];                      \
8623540ee89957c352912f3ffb90484abb17cc60675florian   volatile unsigned long int _zzq_result;                       \
8633540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[0] = (unsigned long int)(_zzq_request);             \
8643540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[1] = (unsigned long int)(_zzq_arg1);                \
8653540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[2] = (unsigned long int)(_zzq_arg2);                \
8663540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[3] = (unsigned long int)(_zzq_arg3);                \
8673540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[4] = (unsigned long int)(_zzq_arg4);                \
8683540ee89957c352912f3ffb90484abb17cc60675florian   _zzq_args[5] = (unsigned long int)(_zzq_arg5);                \
869b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   __asm__ volatile(/* r2 = args */                              \
870b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    "lgr 2,%1\n\t"                               \
871b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    /* r3 = default */                           \
872b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    "lgr 3,%2\n\t"                               \
873b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __SPECIAL_INSTRUCTION_PREAMBLE               \
874b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __CLIENT_REQUEST_CODE                        \
875b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    /* results = r3 */                           \
876b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    "lgr %0, 3\n\t"                              \
877b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "=d" (_zzq_result)                         \
878b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "a" (&_zzq_args[0]), "0" (_zzq_default)    \
879b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "cc", "2", "3", "memory"                   \
880b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                   );                                            \
881575ce8ef8fa86a502dabe152293320676922dcfebart   _zzq_result;                                                  \
882575ce8ef8fa86a502dabe152293320676922dcfebart })
883b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
884b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                      \
885b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
8863540ee89957c352912f3ffb90484abb17cc60675florian   volatile unsigned long int __addr;                            \
887b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
888b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __GET_NR_CONTEXT_CODE                        \
889b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    "lgr %0, 3\n\t"                              \
890b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "=a" (__addr)                              \
891b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    :                                            \
892b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    : "cc", "3", "memory"                        \
893b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                   );                                            \
894b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   _zzq_orig->nraddr = __addr;                                   \
895b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj }
896b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
897b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define VALGRIND_CALL_NOREDIR_R1                                 \
898b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __SPECIAL_INSTRUCTION_PREAMBLE               \
899b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                    __CALL_NO_REDIR_CODE
900b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
901bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
902bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
903bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
904bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     __VEX_INJECT_IR_CODE);                      \
905bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
906bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
907b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#endif /* PLAT_s390x_linux */
908b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
9095db15403e889d4db339b342bc2a824ef0bfaa654sewardj/* ------------------------- mips32-linux ---------------- */
9105db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9115db15403e889d4db339b342bc2a824ef0bfaa654sewardj#if defined(PLAT_mips32_linux)
9125db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9135db15403e889d4db339b342bc2a824ef0bfaa654sewardjtypedef
9145db15403e889d4db339b342bc2a824ef0bfaa654sewardj   struct {
9155db15403e889d4db339b342bc2a824ef0bfaa654sewardj      unsigned int nraddr; /* where's the code? */
9165db15403e889d4db339b342bc2a824ef0bfaa654sewardj   }
9175db15403e889d4db339b342bc2a824ef0bfaa654sewardj   OrigFn;
9185db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9195db15403e889d4db339b342bc2a824ef0bfaa654sewardj/* .word  0x342
9205db15403e889d4db339b342bc2a824ef0bfaa654sewardj * .word  0x742
9215db15403e889d4db339b342bc2a824ef0bfaa654sewardj * .word  0xC2
9225db15403e889d4db339b342bc2a824ef0bfaa654sewardj * .word  0x4C2*/
9235db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define __SPECIAL_INSTRUCTION_PREAMBLE          \
9245db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "srl $0, $0, 13\n\t"       \
9255db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "srl $0, $0, 29\n\t"       \
9265db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "srl $0, $0, 3\n\t"        \
9275db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "srl $0, $0, 19\n\t"
9285db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9295db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                          \
9305db15403e889d4db339b342bc2a824ef0bfaa654sewardj       _zzq_default, _zzq_request,                                \
9315db15403e889d4db339b342bc2a824ef0bfaa654sewardj       _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)     \
9325db15403e889d4db339b342bc2a824ef0bfaa654sewardj  __extension__                                                   \
9335db15403e889d4db339b342bc2a824ef0bfaa654sewardj  ({ volatile unsigned int _zzq_args[6];                          \
9345db15403e889d4db339b342bc2a824ef0bfaa654sewardj    volatile unsigned int _zzq_result;                            \
9355db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[0] = (unsigned int)(_zzq_request);                  \
9365db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[1] = (unsigned int)(_zzq_arg1);                     \
9375db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[2] = (unsigned int)(_zzq_arg2);                     \
9385db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[3] = (unsigned int)(_zzq_arg3);                     \
9395db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[4] = (unsigned int)(_zzq_arg4);                     \
9405db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_args[5] = (unsigned int)(_zzq_arg5);                     \
9415db15403e889d4db339b342bc2a824ef0bfaa654sewardj        __asm__ volatile("move $11, %1\n\t" /*default*/           \
9425db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "move $12, %2\n\t" /*ptr*/                   \
9435db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE               \
9445db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     /* T3 = client_request ( T4 ) */             \
9455db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "or $13, $13, $13\n\t"                       \
9465db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "move %0, $11\n\t"     /*result*/            \
9475db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     : "=r" (_zzq_result)                         \
9485db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     : "r" (_zzq_default), "r" (&_zzq_args[0])    \
9494df0bfc0614379192c780c944415dc420d9cfe8epetarj                     : "$11", "$12");                             \
9505db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_result;                                                  \
9515db15403e889d4db339b342bc2a824ef0bfaa654sewardj  })
9525db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9535db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
9545db15403e889d4db339b342bc2a824ef0bfaa654sewardj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
9555db15403e889d4db339b342bc2a824ef0bfaa654sewardj    volatile unsigned int __addr;                                 \
9565db15403e889d4db339b342bc2a824ef0bfaa654sewardj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
9575db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     /* %t9 = guest_NRADDR */                     \
9585db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "or $14, $14, $14\n\t"                       \
9595db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     "move %0, $11"     /*result*/                \
9605db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     : "=r" (__addr)                              \
9615db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     :                                            \
9624df0bfc0614379192c780c944415dc420d9cfe8epetarj                     : "$11"                                      \
9635db15403e889d4db339b342bc2a824ef0bfaa654sewardj                    );                                            \
9645db15403e889d4db339b342bc2a824ef0bfaa654sewardj    _zzq_orig->nraddr = __addr;                                   \
9655db15403e889d4db339b342bc2a824ef0bfaa654sewardj  }
9665db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9675db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define VALGRIND_CALL_NOREDIR_T9                                 \
9685db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     __SPECIAL_INSTRUCTION_PREAMBLE              \
9695db15403e889d4db339b342bc2a824ef0bfaa654sewardj                     /* call-noredir *%t9 */                     \
970bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "or $15, $15, $15\n\t"
971bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
972bb913cd4cc1e56d7d7798a8b754361a05d01f916florian#define VALGRIND_VEX_INJECT_IR()                                 \
973bb913cd4cc1e56d7d7798a8b754361a05d01f916florian do {                                                            \
974bb913cd4cc1e56d7d7798a8b754361a05d01f916florian    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
975bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                     "or $11, $11, $11\n\t"                      \
976bb913cd4cc1e56d7d7798a8b754361a05d01f916florian                    );                                           \
977bb913cd4cc1e56d7d7798a8b754361a05d01f916florian } while (0)
978bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
979bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
9805db15403e889d4db339b342bc2a824ef0bfaa654sewardj#endif /* PLAT_mips32_linux */
9815db15403e889d4db339b342bc2a824ef0bfaa654sewardj
9824df0bfc0614379192c780c944415dc420d9cfe8epetarj/* ------------------------- mips64-linux ---------------- */
9834df0bfc0614379192c780c944415dc420d9cfe8epetarj
9844df0bfc0614379192c780c944415dc420d9cfe8epetarj#if defined(PLAT_mips64_linux)
9854df0bfc0614379192c780c944415dc420d9cfe8epetarj
9864df0bfc0614379192c780c944415dc420d9cfe8epetarjtypedef
9874df0bfc0614379192c780c944415dc420d9cfe8epetarj   struct {
9883540ee89957c352912f3ffb90484abb17cc60675florian      unsigned long nraddr; /* where's the code? */
9894df0bfc0614379192c780c944415dc420d9cfe8epetarj   }
9904df0bfc0614379192c780c944415dc420d9cfe8epetarj   OrigFn;
9914df0bfc0614379192c780c944415dc420d9cfe8epetarj
9924df0bfc0614379192c780c944415dc420d9cfe8epetarj/* dsll $0,$0, 3
9934df0bfc0614379192c780c944415dc420d9cfe8epetarj * dsll $0,$0, 13
9944df0bfc0614379192c780c944415dc420d9cfe8epetarj * dsll $0,$0, 29
9954df0bfc0614379192c780c944415dc420d9cfe8epetarj * dsll $0,$0, 19*/
9964df0bfc0614379192c780c944415dc420d9cfe8epetarj#define __SPECIAL_INSTRUCTION_PREAMBLE                              \
9974df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "dsll $0,$0, 3 ; dsll $0,$0,13\n\t"            \
9984df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "dsll $0,$0,29 ; dsll $0,$0,19\n\t"
9994df0bfc0614379192c780c944415dc420d9cfe8epetarj
10004df0bfc0614379192c780c944415dc420d9cfe8epetarj#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                            \
10014df0bfc0614379192c780c944415dc420d9cfe8epetarj       _zzq_default, _zzq_request,                                  \
10024df0bfc0614379192c780c944415dc420d9cfe8epetarj       _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)       \
10034df0bfc0614379192c780c944415dc420d9cfe8epetarj  __extension__                                                     \
10043540ee89957c352912f3ffb90484abb17cc60675florian  ({ volatile unsigned long int _zzq_args[6];                       \
10053540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int _zzq_result;                         \
10063540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[0] = (unsigned long int)(_zzq_request);               \
10073540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[1] = (unsigned long int)(_zzq_arg1);                  \
10083540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[2] = (unsigned long int)(_zzq_arg2);                  \
10093540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[3] = (unsigned long int)(_zzq_arg3);                  \
10103540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[4] = (unsigned long int)(_zzq_arg4);                  \
10113540ee89957c352912f3ffb90484abb17cc60675florian    _zzq_args[5] = (unsigned long int)(_zzq_arg5);                  \
10124df0bfc0614379192c780c944415dc420d9cfe8epetarj        __asm__ volatile("move $11, %1\n\t" /*default*/             \
10134df0bfc0614379192c780c944415dc420d9cfe8epetarj                         "move $12, %2\n\t" /*ptr*/                 \
10144df0bfc0614379192c780c944415dc420d9cfe8epetarj                         __SPECIAL_INSTRUCTION_PREAMBLE             \
10154df0bfc0614379192c780c944415dc420d9cfe8epetarj                         /* $11 = client_request ( $12 ) */         \
10164df0bfc0614379192c780c944415dc420d9cfe8epetarj                         "or $13, $13, $13\n\t"                     \
10174df0bfc0614379192c780c944415dc420d9cfe8epetarj                         "move %0, $11\n\t"     /*result*/          \
10184df0bfc0614379192c780c944415dc420d9cfe8epetarj                         : "=r" (_zzq_result)                       \
10194df0bfc0614379192c780c944415dc420d9cfe8epetarj                         : "r" (_zzq_default), "r" (&_zzq_args[0])  \
10204df0bfc0614379192c780c944415dc420d9cfe8epetarj                         : "$11", "$12");                           \
10214df0bfc0614379192c780c944415dc420d9cfe8epetarj    _zzq_result;                                                    \
10224df0bfc0614379192c780c944415dc420d9cfe8epetarj  })
10234df0bfc0614379192c780c944415dc420d9cfe8epetarj
10244df0bfc0614379192c780c944415dc420d9cfe8epetarj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                         \
10254df0bfc0614379192c780c944415dc420d9cfe8epetarj  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                     \
10263540ee89957c352912f3ffb90484abb17cc60675florian    volatile unsigned long int __addr;                              \
10274df0bfc0614379192c780c944415dc420d9cfe8epetarj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE                 \
10284df0bfc0614379192c780c944415dc420d9cfe8epetarj                     /* $11 = guest_NRADDR */                       \
10294df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "or $14, $14, $14\n\t"                         \
10304df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "move %0, $11"     /*result*/                  \
10314df0bfc0614379192c780c944415dc420d9cfe8epetarj                     : "=r" (__addr)                                \
10324df0bfc0614379192c780c944415dc420d9cfe8epetarj                     :                                              \
10334df0bfc0614379192c780c944415dc420d9cfe8epetarj                     : "$11");                                      \
10344df0bfc0614379192c780c944415dc420d9cfe8epetarj    _zzq_orig->nraddr = __addr;                                     \
10354df0bfc0614379192c780c944415dc420d9cfe8epetarj  }
10364df0bfc0614379192c780c944415dc420d9cfe8epetarj
10374df0bfc0614379192c780c944415dc420d9cfe8epetarj#define VALGRIND_CALL_NOREDIR_T9                                    \
10384df0bfc0614379192c780c944415dc420d9cfe8epetarj                     __SPECIAL_INSTRUCTION_PREAMBLE                 \
10394df0bfc0614379192c780c944415dc420d9cfe8epetarj                     /* call-noredir $25 */                         \
10404df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "or $15, $15, $15\n\t"
10414df0bfc0614379192c780c944415dc420d9cfe8epetarj
10424df0bfc0614379192c780c944415dc420d9cfe8epetarj#define VALGRIND_VEX_INJECT_IR()                                    \
10434df0bfc0614379192c780c944415dc420d9cfe8epetarj do {                                                               \
10444df0bfc0614379192c780c944415dc420d9cfe8epetarj    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE                 \
10454df0bfc0614379192c780c944415dc420d9cfe8epetarj                     "or $11, $11, $11\n\t"                         \
10464df0bfc0614379192c780c944415dc420d9cfe8epetarj                    );                                              \
10474df0bfc0614379192c780c944415dc420d9cfe8epetarj } while (0)
10484df0bfc0614379192c780c944415dc420d9cfe8epetarj
10494df0bfc0614379192c780c944415dc420d9cfe8epetarj#endif /* PLAT_mips64_linux */
10504df0bfc0614379192c780c944415dc420d9cfe8epetarj
1051112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/* ------------------------ tilegx-linux --------------- */
1052112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#if defined(PLAT_tilegx_linux)
1053112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1054112711afefcfcd43680c7c4aa8d38ef180e8811esewardjtypedef
1055112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   struct {
1056112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      unsigned long long int nraddr; /* where's the code? */
1057112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   }
1058112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   OrigFn;
1059112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/*** special instruction sequence.
1060112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     0:02b3c7ff91234fff { moveli zero, 4660 ; moveli zero, 22136 }
1061112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     8:0091a7ff95678fff { moveli zero, 22136 ; moveli zero, 4660 }
1062112711afefcfcd43680c7c4aa8d38ef180e8811esewardj****/
1063112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1064112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define __SPECIAL_INSTRUCTION_PREAMBLE                             \
1065112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   ".quad  0x02b3c7ff91234fff\n"                                   \
1066112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   ".quad  0x0091a7ff95678fff\n"
1067112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1068112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define VALGRIND_DO_CLIENT_REQUEST_EXPR(                           \
1069112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   _zzq_default, _zzq_request,                                      \
1070112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5)          \
1071112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   ({ volatile unsigned long long int _zzq_args[6];                \
1072112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long long int _zzq_result;                 \
1073112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[0] = (unsigned long long int)(_zzq_request);       \
1074112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[1] = (unsigned long long int)(_zzq_arg1);          \
1075112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[2] = (unsigned long long int)(_zzq_arg2);          \
1076112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[3] = (unsigned long long int)(_zzq_arg3);          \
1077112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[4] = (unsigned long long int)(_zzq_arg4);          \
1078112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_args[5] = (unsigned long long int)(_zzq_arg5);          \
1079112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile("move r11, %1\n\t" /*default*/              \
1080112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "move r12, %2\n\t" /*ptr*/                  \
1081112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       __SPECIAL_INSTRUCTION_PREAMBLE              \
1082112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       /* r11 = client_request */                  \
1083112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "or r13, r13, r13\n\t"                      \
1084112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "move %0, r11\n\t"     /*result*/           \
1085112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "=r" (_zzq_result)                        \
1086112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "r" (_zzq_default), "r" (&_zzq_args[0])   \
1087112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "memory", "r11", "r12");                  \
1088112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_result;                                                 \
1089112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   })
1090112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1091112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                        \
1092112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   {  volatile OrigFn* _zzq_orig = &(_zzq_rlval);                  \
1093112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long long int __addr;                      \
1094112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
1095112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       /* r11 = guest_NRADDR */                    \
1096112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "or r14, r14, r14\n"                        \
1097112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "move %0, r11\n"                            \
1098112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "=r" (__addr)                             \
1099112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       :                                           \
1100112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       : "memory", "r11"                           \
1101112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       );                                          \
1102112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _zzq_orig->nraddr = __addr;                                  \
1103112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   }
1104112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1105112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define VALGRIND_CALL_NOREDIR_R12                                  \
1106112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   __SPECIAL_INSTRUCTION_PREAMBLE                                  \
1107112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   "or r15, r15, r15\n\t"
1108112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1109112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define VALGRIND_VEX_INJECT_IR()                                   \
1110112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                            \
1111112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE              \
1112112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       "or r11, r11, r11\n\t"                      \
1113112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                       );                                          \
1114112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
1115112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1116112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#endif /* PLAT_tilegx_linux */
1117112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
1118f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* Insert assembly code for other platforms here... */
111926aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn
112037091fb739760631f436043c47de612cf9fd2dd1sewardj#endif /* NVALGRIND */
11212e93c50dc50235189661b70e3f27a4098d5cccccsewardj
112269d9c4625034b60c08e04cc246fcf8093d23fde5nethercote
112330d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* ------------------------------------------------------------------ */
1124f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* PLATFORM SPECIFICS for FUNCTION WRAPPING.  This is all very        */
11250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ugly.  It's the least-worst tradeoff I can think of.               */
11260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ------------------------------------------------------------------ */
11270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* This section defines magic (a.k.a appalling-hack) macros for doing
11290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   guaranteed-no-redirection macros, so as to get from function
11300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   wrappers to the functions they are wrapping.  The whole point is to
11310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   construct standard call sequences, but to do the call itself with a
11320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   special no-redirect call pseudo-instruction that the JIT
11330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   understands and handles specially.  This section is long and
11340ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   repetitious, and I can't see a way to make it shorter.
11350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   The naming scheme is as follows:
11370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      CALL_FN_{W,v}_{v,W,WW,WWW,WWWW,5W,6W,7W,etc}
11390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   'W' stands for "word" and 'v' for "void".  Hence there are
11410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   different macros for calling arity 0, 1, 2, 3, 4, etc, functions,
11420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   and for each, the possibility of returning a word-typed result, or
11430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   no result.
11440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj*/
11450ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* Use these to write the name of your wrapper.  NOTE: duplicates
114785cf90056b7a8d98d88335b47c599a35b35ff7casewardj   VG_WRAP_FUNCTION_Z{U,Z} in pub_tool_redir.h.  NOTE also: inserts
114885cf90056b7a8d98d88335b47c599a35b35ff7casewardj   the default behaviour equivalance class tag "0000" into the name.
114985cf90056b7a8d98d88335b47c599a35b35ff7casewardj   See pub_tool_redir.h for details -- normally you don't need to
115085cf90056b7a8d98d88335b47c599a35b35ff7casewardj   think about this, though. */
11510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11525f5ef2ae9e7c2ce5ebc36c1e2fc98e5f81650be3njn/* Use an extra level of macroisation so as to ensure the soname/fnname
11535f5ef2ae9e7c2ce5ebc36c1e2fc98e5f81650be3njn   args are fully macro-expanded before pasting them together. */
11545f5ef2ae9e7c2ce5ebc36c1e2fc98e5f81650be3njn#define VG_CONCAT4(_aa,_bb,_cc,_dd) _aa##_bb##_cc##_dd
11555f5ef2ae9e7c2ce5ebc36c1e2fc98e5f81650be3njn
11560ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define I_WRAP_SONAME_FNNAME_ZU(soname,fnname)                    \
115796044842731e581702c9ed4104d2949fcde20fd8sewardj   VG_CONCAT4(_vgw00000ZU_,soname,_,fnname)
11580ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname)                    \
116096044842731e581702c9ed4104d2949fcde20fd8sewardj   VG_CONCAT4(_vgw00000ZZ_,soname,_,fnname)
11610ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1162d68ac3e974d25f88492774f6baa491999afde9f9sewardj/* Use this macro from within a wrapper function to collect the
1163d68ac3e974d25f88492774f6baa491999afde9f9sewardj   context (address and possibly other info) of the original function.
1164d68ac3e974d25f88492774f6baa491999afde9f9sewardj   Once you have that you can then use it in one of the CALL_FN_
1165d68ac3e974d25f88492774f6baa491999afde9f9sewardj   macros.  The type of the argument _lval is OrigFn. */
1166d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define VALGRIND_GET_ORIG_FN(_lval)  VALGRIND_GET_NR_CONTEXT(_lval)
11670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1168573f8bc106cf3646bdb62748820287c9c44bd432sewardj/* Also provide end-user facilities for function replacement, rather
1169573f8bc106cf3646bdb62748820287c9c44bd432sewardj   than wrapping.  A replacement function differs from a wrapper in
1170573f8bc106cf3646bdb62748820287c9c44bd432sewardj   that it has no way to get hold of the original function being
1171573f8bc106cf3646bdb62748820287c9c44bd432sewardj   called, and hence no way to call onwards to it.  In a replacement
1172573f8bc106cf3646bdb62748820287c9c44bd432sewardj   function, VALGRIND_GET_ORIG_FN always returns zero. */
1173573f8bc106cf3646bdb62748820287c9c44bd432sewardj
1174573f8bc106cf3646bdb62748820287c9c44bd432sewardj#define I_REPLACE_SONAME_FNNAME_ZU(soname,fnname)                 \
1175573f8bc106cf3646bdb62748820287c9c44bd432sewardj   VG_CONCAT4(_vgr00000ZU_,soname,_,fnname)
1176573f8bc106cf3646bdb62748820287c9c44bd432sewardj
1177573f8bc106cf3646bdb62748820287c9c44bd432sewardj#define I_REPLACE_SONAME_FNNAME_ZZ(soname,fnname)                 \
1178573f8bc106cf3646bdb62748820287c9c44bd432sewardj   VG_CONCAT4(_vgr00000ZZ_,soname,_,fnname)
1179573f8bc106cf3646bdb62748820287c9c44bd432sewardj
11800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* Derivatives of the main macros below, for calling functions
11810ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   returning void. */
11820ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define CALL_FN_v_v(fnptr)                                        \
11840ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do { volatile unsigned long _junk;                             \
11850ec07f32bbbb209d749b9974408e6f025ad40b31sewardj        CALL_FN_W_v(_junk,fnptr); } while (0)
11860ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define CALL_FN_v_W(fnptr, arg1)                                  \
11880ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do { volatile unsigned long _junk;                             \
11890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj        CALL_FN_W_W(_junk,fnptr,arg1); } while (0)
11900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11910ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define CALL_FN_v_WW(fnptr, arg1,arg2)                            \
11920ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do { volatile unsigned long _junk;                             \
11930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj        CALL_FN_W_WW(_junk,fnptr,arg1,arg2); } while (0)
11940ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
11955ce4b150ce5d32c9af07a24717081ea34568388asewardj#define CALL_FN_v_WWW(fnptr, arg1,arg2,arg3)                      \
11965ce4b150ce5d32c9af07a24717081ea34568388asewardj   do { volatile unsigned long _junk;                             \
11975ce4b150ce5d32c9af07a24717081ea34568388asewardj        CALL_FN_W_WWW(_junk,fnptr,arg1,arg2,arg3); } while (0)
11985ce4b150ce5d32c9af07a24717081ea34568388asewardj
11992b5f0a90334a2271791c110548a842fadb5ffc65njn#define CALL_FN_v_WWWW(fnptr, arg1,arg2,arg3,arg4)                \
12002b5f0a90334a2271791c110548a842fadb5ffc65njn   do { volatile unsigned long _junk;                             \
12012b5f0a90334a2271791c110548a842fadb5ffc65njn        CALL_FN_W_WWWW(_junk,fnptr,arg1,arg2,arg3,arg4); } while (0)
12022b5f0a90334a2271791c110548a842fadb5ffc65njn
12032b5f0a90334a2271791c110548a842fadb5ffc65njn#define CALL_FN_v_5W(fnptr, arg1,arg2,arg3,arg4,arg5)             \
12042b5f0a90334a2271791c110548a842fadb5ffc65njn   do { volatile unsigned long _junk;                             \
12052b5f0a90334a2271791c110548a842fadb5ffc65njn        CALL_FN_W_5W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5); } while (0)
12062b5f0a90334a2271791c110548a842fadb5ffc65njn
12072b5f0a90334a2271791c110548a842fadb5ffc65njn#define CALL_FN_v_6W(fnptr, arg1,arg2,arg3,arg4,arg5,arg6)        \
12082b5f0a90334a2271791c110548a842fadb5ffc65njn   do { volatile unsigned long _junk;                             \
12092b5f0a90334a2271791c110548a842fadb5ffc65njn        CALL_FN_W_6W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5,arg6); } while (0)
12102b5f0a90334a2271791c110548a842fadb5ffc65njn
12112b5f0a90334a2271791c110548a842fadb5ffc65njn#define CALL_FN_v_7W(fnptr, arg1,arg2,arg3,arg4,arg5,arg6,arg7)   \
12122b5f0a90334a2271791c110548a842fadb5ffc65njn   do { volatile unsigned long _junk;                             \
12132b5f0a90334a2271791c110548a842fadb5ffc65njn        CALL_FN_W_7W(_junk,fnptr,arg1,arg2,arg3,arg4,arg5,arg6,arg7); } while (0)
12142b5f0a90334a2271791c110548a842fadb5ffc65njn
12158eb8bab992e3998c33770b0cdb16059a8b918a06sewardj/* ----------------- x86-{linux,darwin,solaris} ---------------- */
12160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
12178eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#if defined(PLAT_x86_linux)  ||  defined(PLAT_x86_darwin) \
12188eb8bab992e3998c33770b0cdb16059a8b918a06sewardj    ||  defined(PLAT_x86_solaris)
12190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
12200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These regs are trashed by the hidden call.  No need to mention eax
12210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   as gcc can already see that, plus causes gcc to bomb. */
12220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __CALLER_SAVED_REGS /*"eax"*/ "ecx", "edx"
12230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
12244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
12254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
12264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
12274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
12284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
12294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
12304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "movl %%esp,%%edi\n\t"               \
12314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "andl $0xfffffff0,%%esp\n\t"
12324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
12334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "movl %%edi,%%esp\n\t"
12344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
12350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These CALL_FN_ macros assume that on x86-linux, sizeof(unsigned
12360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   long) == 4. */
12370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
123866226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_v(lval, orig)                                   \
12390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
124066226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
12410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[1];                          \
12420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
124366226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
12440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
12454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
12460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
12470ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
12484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
12490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
12500ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
12514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
12520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
12530ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
12540ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
12550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
125666226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
12570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
125866226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
12590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[2];                          \
12600ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
126166226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
12620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
12630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
12644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
126587a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $12, %%esp\n\t"                                    \
12660ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
12670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
12680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
12694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
12700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
12710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
12724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
12730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
12740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
12750ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
12760ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
127766226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
12780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
127966226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
12800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[3];                          \
12810ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
128266226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
12830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
12840ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
12850ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
12864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
128787a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $8, %%esp\n\t"                                     \
12880ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
12890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
12900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
12910ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
12924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
12930ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
12949e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         : /*in*/    "a" (&_argvec[0])                            \
12954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
12969e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      );                                                          \
12979e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      lval = (__typeof__(lval)) _res;                             \
12989e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj   } while (0)
12999e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj
13009e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
13019e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj   do {                                                           \
13029e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      volatile OrigFn        _orig = (orig);                      \
13039e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      volatile unsigned long _argvec[4];                          \
13049e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      volatile unsigned long _res;                                \
13059e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
13069e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      _argvec[1] = (unsigned long)(arg1);                         \
13079e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      _argvec[2] = (unsigned long)(arg2);                         \
13089e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      _argvec[3] = (unsigned long)(arg3);                         \
13099e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj      __asm__ volatile(                                           \
13104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
131187a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $4, %%esp\n\t"                                     \
13129e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         "pushl 12(%%eax)\n\t"                                    \
13139e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         "pushl 8(%%eax)\n\t"                                     \
13149e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         "pushl 4(%%eax)\n\t"                                     \
13159e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
13169e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         VALGRIND_CALL_NOREDIR_EAX                                \
13174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
13189e8b07ab0fb74fb15098c406a5dc71e273d50b1csewardj         : /*out*/   "=a" (_res)                                  \
13190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
13204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
13210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
13220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
13230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
13240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
132566226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
13260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
132766226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
13280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[5];                          \
13290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
133066226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
13310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
13320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
13330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
13340ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
13350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
13364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
13370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
13380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
13390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
13400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
13410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
13420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
13434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
13440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
13450ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
13464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
13470ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
13480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
13490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
13500ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
135166226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
13520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
135366226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
13540ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[6];                          \
13550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
135666226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
13570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
13580ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
13590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
13600ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
13610ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
13620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
13634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
136487a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $12, %%esp\n\t"                                    \
13650ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
13660ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
13670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
13680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
13690ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
13700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
13710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
13724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
13730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
13740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
13754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
13760ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
13770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
13780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
13790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
138066226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
13810ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
138266226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
13830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[7];                          \
13840ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
138566226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
13860ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
13870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
13880ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
13890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
13900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
13910ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[6] = (unsigned long)(arg6);                         \
13920ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
13934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
139487a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $8, %%esp\n\t"                                     \
13950ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 24(%%eax)\n\t"                                    \
13960ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
13970ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
13980ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
13990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
14000ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
14010ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
14020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
14034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
14040ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
14050ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
14064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
14070ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
14080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
14090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
14100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
141166226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
141266226cc1e5e852de3584c76984dace8679730b42sewardj                                 arg7)                            \
14130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
141466226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
14150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[8];                          \
14160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
141766226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
14180ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
14190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
14200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
14210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
14220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
14230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[6] = (unsigned long)(arg6);                         \
14240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[7] = (unsigned long)(arg7);                         \
14250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
14264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
142787a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $4, %%esp\n\t"                                     \
14280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 28(%%eax)\n\t"                                    \
14290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 24(%%eax)\n\t"                                    \
14300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
14310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
14320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
14330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
14340ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
14350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
14360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
14374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
14380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
14390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
14404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
14410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
14420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
14430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
14440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
144566226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
144666226cc1e5e852de3584c76984dace8679730b42sewardj                                 arg7,arg8)                       \
14470ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
144866226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
14490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[9];                          \
14500ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
145166226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
14520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
14530ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
14540ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
14550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
14560ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
14570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[6] = (unsigned long)(arg6);                         \
14580ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[7] = (unsigned long)(arg7);                         \
14590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[8] = (unsigned long)(arg8);                         \
14600ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
14614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
14620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 32(%%eax)\n\t"                                    \
14630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 28(%%eax)\n\t"                                    \
14640ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 24(%%eax)\n\t"                                    \
14650ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
14660ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
14670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
14680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
14690ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
14700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
14710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
14724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
14730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
14740ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
14754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
14760ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
14770ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
14780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
14790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
148045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
148145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj                                 arg7,arg8,arg9)                  \
148245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj   do {                                                           \
148345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile OrigFn        _orig = (orig);                      \
148445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile unsigned long _argvec[10];                         \
148545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile unsigned long _res;                                \
148645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
148745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[1] = (unsigned long)(arg1);                         \
148845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[2] = (unsigned long)(arg2);                         \
148945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[3] = (unsigned long)(arg3);                         \
149045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[4] = (unsigned long)(arg4);                         \
149145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[5] = (unsigned long)(arg5);                         \
149245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[6] = (unsigned long)(arg6);                         \
149345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[7] = (unsigned long)(arg7);                         \
149445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[8] = (unsigned long)(arg8);                         \
149545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[9] = (unsigned long)(arg9);                         \
149645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      __asm__ volatile(                                           \
14974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
149887a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $12, %%esp\n\t"                                    \
149945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 36(%%eax)\n\t"                                    \
150045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 32(%%eax)\n\t"                                    \
150145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 28(%%eax)\n\t"                                    \
150245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 24(%%eax)\n\t"                                    \
150345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 20(%%eax)\n\t"                                    \
150445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 16(%%eax)\n\t"                                    \
150545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 12(%%eax)\n\t"                                    \
150645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 8(%%eax)\n\t"                                     \
150745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 4(%%eax)\n\t"                                     \
150845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
150945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         VALGRIND_CALL_NOREDIR_EAX                                \
15104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
151145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         : /*out*/   "=a" (_res)                                  \
151245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         : /*in*/    "a" (&_argvec[0])                            \
15134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
151445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      );                                                          \
151545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      lval = (__typeof__(lval)) _res;                             \
151645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj   } while (0)
151745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj
151845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
151945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj                                  arg7,arg8,arg9,arg10)           \
152045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj   do {                                                           \
152145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile OrigFn        _orig = (orig);                      \
152245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile unsigned long _argvec[11];                         \
152345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      volatile unsigned long _res;                                \
152445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
152545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[1] = (unsigned long)(arg1);                         \
152645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[2] = (unsigned long)(arg2);                         \
152745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[3] = (unsigned long)(arg3);                         \
152845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[4] = (unsigned long)(arg4);                         \
152945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[5] = (unsigned long)(arg5);                         \
153045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[6] = (unsigned long)(arg6);                         \
153145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[7] = (unsigned long)(arg7);                         \
153245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[8] = (unsigned long)(arg8);                         \
153345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[9] = (unsigned long)(arg9);                         \
153445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      _argvec[10] = (unsigned long)(arg10);                       \
153545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      __asm__ volatile(                                           \
15364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
153787a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $8, %%esp\n\t"                                     \
153845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 40(%%eax)\n\t"                                    \
153945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 36(%%eax)\n\t"                                    \
154045fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 32(%%eax)\n\t"                                    \
154145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 28(%%eax)\n\t"                                    \
154245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 24(%%eax)\n\t"                                    \
154345fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 20(%%eax)\n\t"                                    \
154445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 16(%%eax)\n\t"                                    \
154545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 12(%%eax)\n\t"                                    \
154645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 8(%%eax)\n\t"                                     \
154745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "pushl 4(%%eax)\n\t"                                     \
154845fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
154945fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         VALGRIND_CALL_NOREDIR_EAX                                \
15504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
155145fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         : /*out*/   "=a" (_res)                                  \
155245fa5b0cef1884f5025e64401a1443d3e129ed5esewardj         : /*in*/    "a" (&_argvec[0])                            \
15534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
155445fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      );                                                          \
155545fa5b0cef1884f5025e64401a1443d3e129ed5esewardj      lval = (__typeof__(lval)) _res;                             \
155645fa5b0cef1884f5025e64401a1443d3e129ed5esewardj   } while (0)
155745fa5b0cef1884f5025e64401a1443d3e129ed5esewardj
15585ce4b150ce5d32c9af07a24717081ea34568388asewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
15595ce4b150ce5d32c9af07a24717081ea34568388asewardj                                  arg6,arg7,arg8,arg9,arg10,      \
15605ce4b150ce5d32c9af07a24717081ea34568388asewardj                                  arg11)                          \
15615ce4b150ce5d32c9af07a24717081ea34568388asewardj   do {                                                           \
15625ce4b150ce5d32c9af07a24717081ea34568388asewardj      volatile OrigFn        _orig = (orig);                      \
15635ce4b150ce5d32c9af07a24717081ea34568388asewardj      volatile unsigned long _argvec[12];                         \
15645ce4b150ce5d32c9af07a24717081ea34568388asewardj      volatile unsigned long _res;                                \
15655ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
15665ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[1] = (unsigned long)(arg1);                         \
15675ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[2] = (unsigned long)(arg2);                         \
15685ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[3] = (unsigned long)(arg3);                         \
15695ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[4] = (unsigned long)(arg4);                         \
15705ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[5] = (unsigned long)(arg5);                         \
15715ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[6] = (unsigned long)(arg6);                         \
15725ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[7] = (unsigned long)(arg7);                         \
15735ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[8] = (unsigned long)(arg8);                         \
15745ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[9] = (unsigned long)(arg9);                         \
15755ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[10] = (unsigned long)(arg10);                       \
15765ce4b150ce5d32c9af07a24717081ea34568388asewardj      _argvec[11] = (unsigned long)(arg11);                       \
15775ce4b150ce5d32c9af07a24717081ea34568388asewardj      __asm__ volatile(                                           \
15784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
157987a287b47f496063f5869dc5039a81baeb6a29aesewardj         "subl $4, %%esp\n\t"                                     \
15805ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 44(%%eax)\n\t"                                    \
15815ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 40(%%eax)\n\t"                                    \
15825ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 36(%%eax)\n\t"                                    \
15835ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 32(%%eax)\n\t"                                    \
15845ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 28(%%eax)\n\t"                                    \
15855ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 24(%%eax)\n\t"                                    \
15865ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 20(%%eax)\n\t"                                    \
15875ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 16(%%eax)\n\t"                                    \
15885ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 12(%%eax)\n\t"                                    \
15895ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 8(%%eax)\n\t"                                     \
15905ce4b150ce5d32c9af07a24717081ea34568388asewardj         "pushl 4(%%eax)\n\t"                                     \
15915ce4b150ce5d32c9af07a24717081ea34568388asewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
15925ce4b150ce5d32c9af07a24717081ea34568388asewardj         VALGRIND_CALL_NOREDIR_EAX                                \
15934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
15945ce4b150ce5d32c9af07a24717081ea34568388asewardj         : /*out*/   "=a" (_res)                                  \
15955ce4b150ce5d32c9af07a24717081ea34568388asewardj         : /*in*/    "a" (&_argvec[0])                            \
15964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
15975ce4b150ce5d32c9af07a24717081ea34568388asewardj      );                                                          \
15985ce4b150ce5d32c9af07a24717081ea34568388asewardj      lval = (__typeof__(lval)) _res;                             \
15995ce4b150ce5d32c9af07a24717081ea34568388asewardj   } while (0)
16005ce4b150ce5d32c9af07a24717081ea34568388asewardj
160166226cc1e5e852de3584c76984dace8679730b42sewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
160266226cc1e5e852de3584c76984dace8679730b42sewardj                                  arg6,arg7,arg8,arg9,arg10,      \
160366226cc1e5e852de3584c76984dace8679730b42sewardj                                  arg11,arg12)                    \
16040ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
160566226cc1e5e852de3584c76984dace8679730b42sewardj      volatile OrigFn        _orig = (orig);                      \
16060ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[13];                         \
16070ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
160866226cc1e5e852de3584c76984dace8679730b42sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
16090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)(arg1);                         \
16100ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)(arg2);                         \
16110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[3] = (unsigned long)(arg3);                         \
16120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[4] = (unsigned long)(arg4);                         \
16130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[5] = (unsigned long)(arg5);                         \
16140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[6] = (unsigned long)(arg6);                         \
16150ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[7] = (unsigned long)(arg7);                         \
16160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[8] = (unsigned long)(arg8);                         \
16170ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[9] = (unsigned long)(arg9);                         \
16180ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[10] = (unsigned long)(arg10);                       \
16190ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[11] = (unsigned long)(arg11);                       \
16200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[12] = (unsigned long)(arg12);                       \
16210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
16224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
16230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 48(%%eax)\n\t"                                    \
16240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 44(%%eax)\n\t"                                    \
16250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 40(%%eax)\n\t"                                    \
16260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 36(%%eax)\n\t"                                    \
16270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 32(%%eax)\n\t"                                    \
16280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 28(%%eax)\n\t"                                    \
16290ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 24(%%eax)\n\t"                                    \
16300ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 20(%%eax)\n\t"                                    \
16310ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 16(%%eax)\n\t"                                    \
16320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 12(%%eax)\n\t"                                    \
16330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 8(%%eax)\n\t"                                     \
16340ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "pushl 4(%%eax)\n\t"                                     \
16350ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "movl (%%eax), %%eax\n\t"  /* target->%eax */            \
16360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_CALL_NOREDIR_EAX                                \
16374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
16380ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=a" (_res)                                  \
16390ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "a" (&_argvec[0])                            \
16404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "edi"   \
16410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
16420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
16430ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
16440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
16458eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#endif /* PLAT_x86_linux || PLAT_x86_darwin || PLAT_x86_solaris */
16460ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
16478eb8bab992e3998c33770b0cdb16059a8b918a06sewardj/* ---------------- amd64-{linux,darwin,solaris} --------------- */
16480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
16498eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#if defined(PLAT_amd64_linux)  ||  defined(PLAT_amd64_darwin) \
16508eb8bab992e3998c33770b0cdb16059a8b918a06sewardj    ||  defined(PLAT_amd64_solaris)
16510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
16520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ARGREGS: rdi rsi rdx rcx r8 r9 (the rest on stack in R-to-L order) */
16530ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
16540ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These regs are trashed by the hidden call. */
16550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define __CALLER_SAVED_REGS /*"rax",*/ "rcx", "rdx", "rsi",       \
16560ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                            "rdi", "r8", "r9", "r10", "r11"
16570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1658dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj/* This is all pretty complex.  It's so as to make stack unwinding
1659dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   work reliably.  See bug 243270.  The basic problem is the sub and
1660dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   add of 128 of %rsp in all of the following macros.  If gcc believes
1661dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   the CFA is in %rsp, then unwinding may fail, because what's at the
1662dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   CFA is not what gcc "expected" when it constructs the CFIs for the
1663dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   places where the macros are instantiated.
1664dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1665dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   But we can't just add a CFI annotation to increase the CFA offset
1666dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   by 128, to match the sub of 128 from %rsp, because we don't know
1667dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   whether gcc has chosen %rsp as the CFA at that point, or whether it
1668dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   has chosen some other register (eg, %rbp).  In the latter case,
1669dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   adding a CFI annotation to change the CFA offset is simply wrong.
1670dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1671dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   So the solution is to get hold of the CFA using
16728d1dc150a77fe495682a928949c5d5b7443b045csewardj   __builtin_dwarf_cfa(), put it in a known register, and add a
1673dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   CFI annotation to say what the register is.  We choose %rbp for
1674dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   this (perhaps perversely), because:
1675dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1676dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   (1) %rbp is already subject to unwinding.  If a new register was
1677dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       chosen then the unwinder would have to unwind it in all stack
1678dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       traces, which is expensive, and
1679dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1680dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   (2) %rbp is already subject to precise exception updates in the
1681dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       JIT.  If a new register was chosen, we'd have to have precise
1682dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       exceptions for it too, which reduces performance of the
1683dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj       generated code.
1684dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1685dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   However .. one extra complication.  We can't just whack the result
16868d1dc150a77fe495682a928949c5d5b7443b045csewardj   of __builtin_dwarf_cfa() into %rbp and then add %rbp to the
1687dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   list of trashed registers at the end of the inline assembly
1688dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   fragments; gcc won't allow %rbp to appear in that list.  Hence
1689dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   instead we need to stash %rbp in %r15 for the duration of the asm,
1690dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   and say that %r15 is trashed instead.  gcc seems happy to go with
1691dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   that.
1692dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
1693dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   Oh .. and this all needs to be conditionalised so that it is
1694dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj   unchanged from before this commit, when compiled with older gccs
16958d1dc150a77fe495682a928949c5d5b7443b045csewardj   that don't support __builtin_dwarf_cfa.  Furthermore, since
16968d1dc150a77fe495682a928949c5d5b7443b045csewardj   this header file is freestanding, it has to be independent of
16978d1dc150a77fe495682a928949c5d5b7443b045csewardj   config.h, and so the following conditionalisation cannot depend on
16988d1dc150a77fe495682a928949c5d5b7443b045csewardj   configure time checks.
16998d1dc150a77fe495682a928949c5d5b7443b045csewardj
17008d1dc150a77fe495682a928949c5d5b7443b045csewardj   Although it's not clear from
17018d1dc150a77fe495682a928949c5d5b7443b045csewardj   'defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)',
17028d1dc150a77fe495682a928949c5d5b7443b045csewardj   this expression excludes Darwin.
17038d1dc150a77fe495682a928949c5d5b7443b045csewardj   .cfi directives in Darwin assembly appear to be completely
17048d1dc150a77fe495682a928949c5d5b7443b045csewardj   different and I haven't investigated how they work.
17058d1dc150a77fe495682a928949c5d5b7443b045csewardj
17068d1dc150a77fe495682a928949c5d5b7443b045csewardj   For even more entertainment value, note we have to use the
17078d1dc150a77fe495682a928949c5d5b7443b045csewardj   completely undocumented __builtin_dwarf_cfa(), which appears to
17088d1dc150a77fe495682a928949c5d5b7443b045csewardj   really compute the CFA, whereas __builtin_frame_address(0) claims
17098d1dc150a77fe495682a928949c5d5b7443b045csewardj   to but actually doesn't.  See
17108d1dc150a77fe495682a928949c5d5b7443b045csewardj   https://bugs.kde.org/show_bug.cgi?id=243270#c47
1711dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj*/
17128d1dc150a77fe495682a928949c5d5b7443b045csewardj#if defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)
1713dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define __FRAME_POINTER                                         \
17148d1dc150a77fe495682a928949c5d5b7443b045csewardj      ,"r"(__builtin_dwarf_cfa())
1715dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define VALGRIND_CFI_PROLOGUE                                   \
1716dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj      "movq %%rbp, %%r15\n\t"                                     \
17178d1dc150a77fe495682a928949c5d5b7443b045csewardj      "movq %2, %%rbp\n\t"                                        \
17188d1dc150a77fe495682a928949c5d5b7443b045csewardj      ".cfi_remember_state\n\t"                                   \
1719dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj      ".cfi_def_cfa rbp, 0\n\t"
1720dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define VALGRIND_CFI_EPILOGUE                                   \
1721dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj      "movq %%r15, %%rbp\n\t"                                     \
1722dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj      ".cfi_restore_state\n\t"
1723dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#else
1724dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define __FRAME_POINTER
1725dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define VALGRIND_CFI_PROLOGUE
1726dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#  define VALGRIND_CFI_EPILOGUE
1727dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj#endif
1728dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
17294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
17304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
17314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
17324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
17334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
17344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
17354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "movq %%rsp,%%r14\n\t"               \
17364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "andq $0xfffffffffffffff0,%%rsp\n\t"
17374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
17384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "movq %%r14,%%rsp\n\t"
1739dfa55cf5263d1a105425fef13aff164e8cbb30f6sewardj
17400ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These CALL_FN_ macros assume that on amd64-linux, sizeof(unsigned
17410ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   long) == 8. */
17420ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
1743a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj/* NB 9 Sept 07.  There is a nasty kludge here in all these CALL_FN_
1744a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   macros.  In order not to trash the stack redzone, we need to drop
1745a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   %rsp by 128 before the hidden call, and restore afterwards.  The
1746a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   nastyness is that it is only by luck that the stack still appears
1747a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   to be unwindable during the hidden call - since then the behaviour
1748a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   of any routine using this macro does not match what the CFI data
1749a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   says.  Sigh.
1750a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj
1751a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   Why is this important?  Imagine that a wrapper has a stack
1752a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   allocated local, and passes to the hidden call, a pointer to it.
1753a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   Because gcc does not know about the hidden call, it may allocate
1754a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   that local in the redzone.  Unfortunately the hidden call may then
1755a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   trash it before it comes to use it.  So we must step clear of the
1756a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   redzone, for the duration of the hidden call, to make it safe.
1757a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj
1758a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   Probably the same problem afflicts the other redzone-style ABIs too
17596e9de463ef677f093e9f24f126e1b11c28cf59fdsewardj   (ppc64-linux); but for those, the stack is
1760a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   self describing (none of this CFI nonsense) so at least messing
1761a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   with the stack pointer doesn't give a danger of non-unwindable
1762a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj   stack. */
1763a07c2e157185dc577d6fa5fa154a44e4b3afe185sewardj
17644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_v(lval, orig)                                        \
17654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
17664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
17674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[1];                               \
17684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
17694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
17704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
17714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
17724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
17734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
17744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
17754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
17764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
17774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
17784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
17794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
17804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
17814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
17824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
17834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
17844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
17854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_W(lval, orig, arg1)                                  \
17864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
17874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
17884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[2];                               \
17894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
17904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
17914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
17924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
17934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
17944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
17954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
17964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
17974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
17984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
17994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
18004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
18014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
18024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
18034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
18044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
18054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
18064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
18074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
18084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_WW(lval, orig, arg1,arg2)                            \
18094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
18104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
18114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[3];                               \
18124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
18134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
18144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
18154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
18164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
18174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
18184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
18194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
18204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
18214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
18224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
18234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
18244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
18254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
18264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
18274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
18284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
18294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
18304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
18314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
18324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
18334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                      \
18344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
18354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
18364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[4];                               \
18374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
18384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
18394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
18404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
18414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
18424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
18434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
18444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
18454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
18464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
18474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
18484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
18494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
18504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
18514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
18524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
18534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
18544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
18554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
18564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
18574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
18584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
18594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
18604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)                \
18614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
18624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
18634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[5];                               \
18644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
18654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
18664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
18674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
18684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
18694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
18704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
18714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
18724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
18734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
18744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
18754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
18764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
18774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
18784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
18794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
18804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
18814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
18824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
18834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
18844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
18854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
18864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
18874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
18884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
18894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)             \
18904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
18914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
18924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[6];                               \
18934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
18944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
18954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
18964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
18974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
18984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
18994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
19004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
19014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
19024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
19034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
19044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
19054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
19064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
19074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
19084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
19094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
19104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
19114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
19124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
19134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
19144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
19154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
19164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
19174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
19184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
19194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
19204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)        \
19214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
19224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
19234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[7];                               \
19244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
19254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
19264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
19274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
19284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
19294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
19304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
19314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
19324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
19334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
19344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
19354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
19364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
19374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
19384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
19394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
19404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
19414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
19424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
19434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
19444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
19454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
19464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
19474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
19484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
19494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
19504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
19514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
19524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
19534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,        \
19544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                 arg7)                                 \
19554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
19564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
19574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[8];                               \
19584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
19594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
19604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
19614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
19624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
19634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
19644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
19654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
19664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
19674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
19684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
19694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
19704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $136,%%rsp\n\t"                                         \
19714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
19724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
19734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
19744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
19754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
19764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
19774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
19784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
19794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
19804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
19814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
19824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
19834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
19844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
19854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
19864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
19874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
19884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
19894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,        \
19904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                 arg7,arg8)                            \
19914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
19924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
19934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[9];                               \
19944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
19954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
19964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
19974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
19984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
19994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
20004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
20014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
20024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
20034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
20044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
20054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
20064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
20074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
20084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
20094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
20104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
20114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
20124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
20134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
20144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
20154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
20164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
20174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
20184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
20194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
20204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
20214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
20224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
20234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
20244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
20254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
20264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
20274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,        \
20284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                 arg7,arg8,arg9)                       \
20294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
20304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
20314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[10];                              \
20324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
20334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
20344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
20354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
20364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
20374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
20384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
20394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
20404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
20414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
20424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[9] = (unsigned long)(arg9);                              \
20434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
20444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
20454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
20464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $136,%%rsp\n\t"                                         \
20474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 72(%%rax)\n\t"                                         \
20484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
20494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
20504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
20514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
20524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
20534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
20544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
20554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
20564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
20574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
20584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
20594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
20604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
20614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
20624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
20634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
20644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
20654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
20664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
20674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,       \
20684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                  arg7,arg8,arg9,arg10)                \
20694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
20704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
20714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[11];                              \
20724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
20734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
20744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
20754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
20764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
20774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
20784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
20794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
20804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
20814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
20824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[9] = (unsigned long)(arg9);                              \
20834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[10] = (unsigned long)(arg10);                            \
20844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
20854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
20864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
20874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
20884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 80(%%rax)\n\t"                                         \
20894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 72(%%rax)\n\t"                                         \
20904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
20914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
20924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
20934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
20944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
20954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
20964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
20974118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
20984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
20994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
21004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
21014118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
21024118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
21034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
21044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
21054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
21064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
21074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
21084118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
21094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,       \
21104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                  arg7,arg8,arg9,arg10,arg11)          \
21114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
21124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
21134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[12];                              \
21144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
21154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
21164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
21174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
21184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
21194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
21204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
21214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
21224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
21234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
21244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[9] = (unsigned long)(arg9);                              \
21254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[10] = (unsigned long)(arg10);                            \
21264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[11] = (unsigned long)(arg11);                            \
21274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
21284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
21294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
21304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $136,%%rsp\n\t"                                         \
21314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 88(%%rax)\n\t"                                         \
21324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 80(%%rax)\n\t"                                         \
21334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 72(%%rax)\n\t"                                         \
21344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
21354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
21364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
21374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
21384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
21394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
21404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
21414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
21424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
21434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
21444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
21454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
21464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
21474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
21484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
21494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
21504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
21514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   } while (0)
21524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
21534118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,       \
21544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom                                arg7,arg8,arg9,arg10,arg11,arg12)      \
21554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   do {                                                                \
21564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile OrigFn        _orig = (orig);                           \
21574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _argvec[13];                              \
21584118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      volatile unsigned long _res;                                     \
21594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[0] = (unsigned long)_orig.nraddr;                        \
21604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[1] = (unsigned long)(arg1);                              \
21614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[2] = (unsigned long)(arg2);                              \
21624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[3] = (unsigned long)(arg3);                              \
21634118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[4] = (unsigned long)(arg4);                              \
21644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[5] = (unsigned long)(arg5);                              \
21654118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[6] = (unsigned long)(arg6);                              \
21664118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[7] = (unsigned long)(arg7);                              \
21674118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[8] = (unsigned long)(arg8);                              \
21684118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[9] = (unsigned long)(arg9);                              \
21694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[10] = (unsigned long)(arg10);                            \
21704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[11] = (unsigned long)(arg11);                            \
21714118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      _argvec[12] = (unsigned long)(arg12);                            \
21724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      __asm__ volatile(                                                \
21734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_PROLOGUE                                         \
21744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                          \
21754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "subq $128,%%rsp\n\t"                                         \
21764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 96(%%rax)\n\t"                                         \
21774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 88(%%rax)\n\t"                                         \
21784118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 80(%%rax)\n\t"                                         \
21794118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 72(%%rax)\n\t"                                         \
21804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 64(%%rax)\n\t"                                         \
21814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "pushq 56(%%rax)\n\t"                                         \
21824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 48(%%rax), %%r9\n\t"                                    \
21834118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 40(%%rax), %%r8\n\t"                                    \
21844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 32(%%rax), %%rcx\n\t"                                   \
21854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 24(%%rax), %%rdx\n\t"                                   \
21864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 16(%%rax), %%rsi\n\t"                                   \
21874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq 8(%%rax), %%rdi\n\t"                                    \
21884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "movq (%%rax), %%rax\n\t"  /* target->%rax */                 \
21894118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CALL_NOREDIR_RAX                                     \
21904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                        \
21914118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_CFI_EPILOGUE                                         \
21924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*out*/   "=a" (_res)                                       \
21934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER                 \
21944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r14", "r15" \
21954118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      );                                                               \
21964118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      lval = (__typeof__(lval)) _res;                                  \
2197a50f9dcb3a7609e10047a4c6dfa3eb7363088bd2sewardj   } while (0)
2198a50f9dcb3a7609e10047a4c6dfa3eb7363088bd2sewardj
21998eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#endif /* PLAT_amd64_linux || PLAT_amd64_darwin || PLAT_amd64_solaris */
22000ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2201f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* ------------------------ ppc32-linux ------------------------ */
22020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2203f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#if defined(PLAT_ppc32_linux)
22040ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2205ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj/* This is useful for finding out about the on-stack stuff:
2206ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2207ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   extern int f9  ( int,int,int,int,int,int,int,int,int );
2208ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   extern int f10 ( int,int,int,int,int,int,int,int,int,int );
2209ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   extern int f11 ( int,int,int,int,int,int,int,int,int,int,int );
2210ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   extern int f12 ( int,int,int,int,int,int,int,int,int,int,int,int );
2211ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2212ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   int g9 ( void ) {
2213ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      return f9(11,22,33,44,55,66,77,88,99);
2214ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   }
2215ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   int g10 ( void ) {
2216ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      return f10(11,22,33,44,55,66,77,88,99,110);
2217ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   }
2218ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   int g11 ( void ) {
2219ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      return f11(11,22,33,44,55,66,77,88,99,110,121);
2220ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   }
2221ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   int g12 ( void ) {
2222ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      return f12(11,22,33,44,55,66,77,88,99,110,121,132);
2223ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   }
2224ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj*/
2225ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
22260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
22270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
22280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These regs are trashed by the hidden call. */
2229ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define __CALLER_SAVED_REGS                                       \
2230ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   "lr", "ctr", "xer",                                            \
2231ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
2232ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
2233ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   "r11", "r12", "r13"
22340ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
22354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
22364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
22374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
22384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
22394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
22404118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
22414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "mr 28,1\n\t"                        \
22424118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "rlwinm 1,1,0,0,27\n\t"
22434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
22444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "mr 1,28\n\t"
22454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
2246ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj/* These CALL_FN_ macros assume that on ppc32-linux,
2247ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   sizeof(unsigned long) == 4. */
22480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
224938de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj#define CALL_FN_W_v(lval, orig)                                   \
22500ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
2251d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile OrigFn        _orig = (orig);                      \
22520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[1];                          \
22530ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
2254d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
22550ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
22564118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
22570ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr 11,%1\n\t"                                           \
22580ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
22590ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
22604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
22610ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr %0,3"                                                \
22620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=r" (_res)                                  \
22630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "r" (&_argvec[0])                            \
22644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
22650ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
22660ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
22670ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
22680ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
226938de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
22700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
227138de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj      volatile OrigFn        _orig = (orig);                      \
22720ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[2];                          \
22730ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
227438de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
22750ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)arg1;                           \
22760ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
22774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
22780ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr 11,%1\n\t"                                           \
22790ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
22800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
22810ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
22824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
22830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr %0,3"                                                \
22840ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=r" (_res)                                  \
22850ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "r" (&_argvec[0])                            \
22864118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
22870ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
22880ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
22890ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
22900ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
229138de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
22920ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   do {                                                           \
229338de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj      volatile OrigFn        _orig = (orig);                      \
22940ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _argvec[3];                          \
22950ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      volatile unsigned long _res;                                \
229638de0994e3561760a8e1ff2efd51a0c9217a3d8dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
22970ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[1] = (unsigned long)arg1;                           \
22980ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      _argvec[2] = (unsigned long)arg2;                           \
22990ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      __asm__ volatile(                                           \
23004118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
23010ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr 11,%1\n\t"                                           \
23020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
23030ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 4,8(11)\n\t"                                        \
23040ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
23050ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
23064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
23070ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         "mr %0,3"                                                \
23080ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*out*/   "=r" (_res)                                  \
23090ec07f32bbbb209d749b9974408e6f025ad40b31sewardj         : /*in*/    "r" (&_argvec[0])                            \
23104118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
23110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      );                                                          \
23120ec07f32bbbb209d749b9974408e6f025ad40b31sewardj      lval = (__typeof__(lval)) _res;                             \
23130ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   } while (0)
23140ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2315ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
2316ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2317ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2318ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[4];                          \
2319ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2320ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2321ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2322ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2323ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2324ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
23254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2326ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2327ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2328ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2329ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2330ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2331ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
23324118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2333ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2334ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2335ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
23364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2337ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2338ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2339ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2340ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2341ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
2342ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2343ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2344ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[5];                          \
2345ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2346ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2347ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2348ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2349ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2350ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2351ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
23524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2353ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2354ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2355ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2356ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2357ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2358ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2359ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
23604118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2361ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2362ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2363ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
23644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2365ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2366ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2367ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2368ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2369ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
2370ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2371ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2372ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[6];                          \
2373ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2374ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2375ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2376ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2377ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2378ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2379ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2380ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
23814118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2382ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2383ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2384ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2385ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2386ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2387ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2388ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2389ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
23904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2391ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2392ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2393ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
23944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2395ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2396ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2397ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2398ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2399ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
2400ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2401ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2402ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[7];                          \
2403ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2404ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2405ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2406ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2407ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2408ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2409ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2410ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2411ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
24124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2413ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2414ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2415ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2416ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2417ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2418ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2419ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2420ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2421ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
24224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2423ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2424ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2425ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
24264118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2427ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2428ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2429ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2430ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2431ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2432ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                 arg7)                            \
2433ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2434ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2435ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[8];                          \
2436ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2437ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2438ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2439ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2440ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2441ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2442ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2443ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2444ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2445ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
24464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2447ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2448ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2449ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2450ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2451ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2452ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2453ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2454ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2455ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2456ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
24574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2458ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2459ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2460ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
24614118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2462ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2463ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2464ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2465ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2466ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2467ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                 arg7,arg8)                       \
2468ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2469ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2470ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[9];                          \
2471ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2472ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2473ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2474ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2475ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2476ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2477ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2478ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2479ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2480ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2481ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
24824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2483ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2484ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2485ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2486ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2487ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2488ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2489ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2490ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2491ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2492ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2493ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
24944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2495ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2496ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2497ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
24984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2499ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2500ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2501ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2502ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2503ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2504ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                 arg7,arg8,arg9)                  \
2505ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2506ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2507ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[10];                         \
2508ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2509ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2510ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2511ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2512ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2513ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2514ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2515ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2516ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2517ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2518ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[9] = (unsigned long)arg9;                           \
2519ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
25204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2521ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2522ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "addi 1,1,-16\n\t"                                       \
2523ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg9 */                                               \
2524ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,36(11)\n\t"                                       \
2525ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,8(1)\n\t"                                         \
2526ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* args1-8 */                                            \
2527ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2528ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2529ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2530ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2531ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2532ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2533ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2534ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2535ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2536ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
25374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2538ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2539ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2540ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
25414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2542ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2543ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2544ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2545ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2546ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
2547ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                  arg7,arg8,arg9,arg10)           \
2548ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2549ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2550ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[11];                         \
2551ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2552ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2553ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2554ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2555ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2556ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2557ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2558ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2559ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2560ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2561ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[9] = (unsigned long)arg9;                           \
2562ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[10] = (unsigned long)arg10;                         \
2563ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
25644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2565ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2566ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "addi 1,1,-16\n\t"                                       \
2567ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg10 */                                              \
2568ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,40(11)\n\t"                                       \
2569ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,12(1)\n\t"                                        \
2570ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg9 */                                               \
2571ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,36(11)\n\t"                                       \
2572ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,8(1)\n\t"                                         \
2573ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* args1-8 */                                            \
2574ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2575ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2576ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2577ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2578ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2579ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2580ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2581ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2582ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2583ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
25844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2585ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2586ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2587ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
25884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2589ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2590ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2591ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2592ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2593ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
2594ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                  arg7,arg8,arg9,arg10,arg11)     \
2595ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2596ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2597ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[12];                         \
2598ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2599ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2600ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2601ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2602ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2603ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2604ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2605ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2606ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2607ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2608ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[9] = (unsigned long)arg9;                           \
2609ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[10] = (unsigned long)arg10;                         \
2610ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[11] = (unsigned long)arg11;                         \
2611ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
26124118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2613ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2614ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "addi 1,1,-32\n\t"                                       \
2615ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg11 */                                              \
2616ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,44(11)\n\t"                                       \
2617ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,16(1)\n\t"                                        \
2618ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg10 */                                              \
2619ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,40(11)\n\t"                                       \
2620ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,12(1)\n\t"                                        \
2621ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg9 */                                               \
2622ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,36(11)\n\t"                                       \
2623ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,8(1)\n\t"                                         \
2624ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* args1-8 */                                            \
2625ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2626ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2627ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2628ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2629ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2630ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2631ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2632ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2633ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2634ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
26354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2636ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2637ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2638ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
26394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2640ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2641ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2642ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2643ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2644ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
2645ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj                                arg7,arg8,arg9,arg10,arg11,arg12) \
2646ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   do {                                                           \
2647ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile OrigFn        _orig = (orig);                      \
2648ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _argvec[13];                         \
2649ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      volatile unsigned long _res;                                \
2650ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
2651ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[1] = (unsigned long)arg1;                           \
2652ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[2] = (unsigned long)arg2;                           \
2653ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[3] = (unsigned long)arg3;                           \
2654ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[4] = (unsigned long)arg4;                           \
2655ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[5] = (unsigned long)arg5;                           \
2656ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[6] = (unsigned long)arg6;                           \
2657ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[7] = (unsigned long)arg7;                           \
2658ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[8] = (unsigned long)arg8;                           \
2659ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[9] = (unsigned long)arg9;                           \
2660ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[10] = (unsigned long)arg10;                         \
2661ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[11] = (unsigned long)arg11;                         \
2662ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      _argvec[12] = (unsigned long)arg12;                         \
2663ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      __asm__ volatile(                                           \
26644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2665ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr 11,%1\n\t"                                           \
2666ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "addi 1,1,-32\n\t"                                       \
2667ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg12 */                                              \
2668ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,48(11)\n\t"                                       \
2669ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,20(1)\n\t"                                        \
2670ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg11 */                                              \
2671ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,44(11)\n\t"                                       \
2672ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,16(1)\n\t"                                        \
2673ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg10 */                                              \
2674ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,40(11)\n\t"                                       \
2675ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,12(1)\n\t"                                        \
2676ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* arg9 */                                               \
2677ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,36(11)\n\t"                                       \
2678ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "stw 3,8(1)\n\t"                                         \
2679ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         /* args1-8 */                                            \
2680ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 3,4(11)\n\t"   /* arg1->r3 */                       \
2681ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 4,8(11)\n\t"                                        \
2682ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 5,12(11)\n\t"                                       \
2683ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 6,16(11)\n\t"  /* arg4->r6 */                       \
2684ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 7,20(11)\n\t"                                       \
2685ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 8,24(11)\n\t"                                       \
2686ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 9,28(11)\n\t"                                       \
2687ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 10,32(11)\n\t" /* arg8->r10 */                      \
2688ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "lwz 11,0(11)\n\t"  /* target->r11 */                    \
2689ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
26904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2691ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         "mr %0,3"                                                \
2692ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*out*/   "=r" (_res)                                  \
2693ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj         : /*in*/    "r" (&_argvec[0])                            \
26944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2695ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      );                                                          \
2696ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj      lval = (__typeof__(lval)) _res;                             \
2697ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj   } while (0)
2698ead61df62ca9c9194f62d4c4a8ba288782acbb0esewardj
2699f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#endif /* PLAT_ppc32_linux */
27000ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2701f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj/* ------------------------ ppc64-linux ------------------------ */
27020ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
2703cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#if defined(PLAT_ppc64be_linux)
27049734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
27059734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
27069734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
27079734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj/* These regs are trashed by the hidden call. */
2708cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define __CALLER_SAVED_REGS                                       \
2709cd63639e41d591b17cf8900e49e28048d39104c2sewardj   "lr", "ctr", "xer",                                            \
2710cd63639e41d591b17cf8900e49e28048d39104c2sewardj   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
2711cd63639e41d591b17cf8900e49e28048d39104c2sewardj   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
2712cd63639e41d591b17cf8900e49e28048d39104c2sewardj   "r11", "r12", "r13"
27139734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
27144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
27154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
27164118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
27174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
27184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
27194118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
27204118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "mr 28,1\n\t"                        \
27214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "rldicr 1,1,0,59\n\t"
27224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
27234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom      "mr 1,28\n\t"
27244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
27259734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj/* These CALL_FN_ macros assume that on ppc64-linux, sizeof(unsigned
27269734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   long) == 8. */
27279734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
2728d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define CALL_FN_W_v(lval, orig)                                   \
27299734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   do {                                                           \
2730d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile OrigFn        _orig = (orig);                      \
2731d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile unsigned long _argvec[3+0];                        \
27329734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      volatile unsigned long _res;                                \
2733d68ac3e974d25f88492774f6baa491999afde9f9sewardj      /* _argvec[0] holds current r2 across the call */           \
2734d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[1] = (unsigned long)_orig.r2;                       \
2735d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2] = (unsigned long)_orig.nraddr;                   \
27369734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      __asm__ volatile(                                           \
27374118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
27389734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
2739d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2740d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2741d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
27429734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
27439734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
27449734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr %0,3\n\t"                                            \
27454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
27464118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
27479734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         : /*out*/   "=r" (_res)                                  \
2748d68ac3e974d25f88492774f6baa491999afde9f9sewardj         : /*in*/    "r" (&_argvec[2])                            \
27494118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
27509734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      );                                                          \
27519734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      lval = (__typeof__(lval)) _res;                             \
27529734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   } while (0)
27539734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
2754d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
27559734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   do {                                                           \
2756d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile OrigFn        _orig = (orig);                      \
2757d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile unsigned long _argvec[3+1];                        \
27589734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      volatile unsigned long _res;                                \
2759d68ac3e974d25f88492774f6baa491999afde9f9sewardj      /* _argvec[0] holds current r2 across the call */           \
2760d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2761d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2762d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
27639734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      __asm__ volatile(                                           \
27644118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
27659734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
2766d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2767d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2768d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2769d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
27709734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
27719734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
27729734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr %0,3\n\t"                                            \
27734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
27744118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
27759734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         : /*out*/   "=r" (_res)                                  \
2776d68ac3e974d25f88492774f6baa491999afde9f9sewardj         : /*in*/    "r" (&_argvec[2])                            \
27774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
27789734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      );                                                          \
27799734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      lval = (__typeof__(lval)) _res;                             \
27809734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   } while (0)
27819734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
2782d68ac3e974d25f88492774f6baa491999afde9f9sewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
27839734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   do {                                                           \
2784d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile OrigFn        _orig = (orig);                      \
2785d68ac3e974d25f88492774f6baa491999afde9f9sewardj      volatile unsigned long _argvec[3+2];                        \
27869734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      volatile unsigned long _res;                                \
2787d68ac3e974d25f88492774f6baa491999afde9f9sewardj      /* _argvec[0] holds current r2 across the call */           \
2788d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2789d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2790d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2791d68ac3e974d25f88492774f6baa491999afde9f9sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
27929734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      __asm__ volatile(                                           \
27934118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
27949734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
2795d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2796d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2797d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2798cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2799cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2800cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2801cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2802cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
28034118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
28044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2805cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2806cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
28074118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2808cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2809cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2810cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2811cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2812cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
2813cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2814cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2815cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+3];                        \
2816cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2817cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2818cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2819cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2820cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2821cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2822cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2823cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
28244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2825cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2826cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2827cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2828cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2829cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2830cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2831d68ac3e974d25f88492774f6baa491999afde9f9sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
28329734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
28339734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr 11,%1\n\t"                                           \
28349734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         "mr %0,3\n\t"                                            \
28354118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
28364118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
28379734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj         : /*out*/   "=r" (_res)                                  \
2838d68ac3e974d25f88492774f6baa491999afde9f9sewardj         : /*in*/    "r" (&_argvec[2])                            \
28394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2840cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2841cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2842cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2843cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2844cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
2845cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2846cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2847cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+4];                        \
2848cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2849cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2850cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2851cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2852cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2853cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2854cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2855cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2856cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
28574118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2858cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2859cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2860cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2861cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2862cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2863cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2864cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
2865cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2866cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2867cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2868cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
28694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
28704118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2871cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2872cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
28734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2874cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2875cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2876cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2877cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2878cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
2879cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2880cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2881cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+5];                        \
2882cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2883cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2884cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2885cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2886cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2887cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2888cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2889cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2890cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
2891cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
28924118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2893cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2894cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2895cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2896cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2897cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2898cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2899cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
2900cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
2901cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2902cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2903cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2904cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
29054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
29064118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2907cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2908cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
29094118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2910cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2911cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2912cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2913cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2914cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
2915cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2916cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2917cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+6];                        \
2918cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2919cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2920cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2921cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2922cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2923cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2924cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2925cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2926cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
2927cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
2928cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
29294118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2930cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2931cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2932cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2933cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2934cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2935cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2936cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
2937cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
2938cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
2939cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2940cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2941cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2942cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
29434118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
29444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2945cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2946cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
29474118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2948cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2949cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2950cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2951cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2952cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2953cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                 arg7)                            \
2954cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2955cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2956cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+7];                        \
2957cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2958cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
2959cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
2960cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
2961cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
2962cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
2963cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
2964cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
2965cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
2966cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
2967cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
2968cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
29694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
2970cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2971cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
2972cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
2973cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
2974cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
2975cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
2976cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
2977cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
2978cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
2979cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
2980cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
2981cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
2982cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
2983cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
29844118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
29854118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
2986cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
2987cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
29884118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
2989cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
2990cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
2991cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
2992cd63639e41d591b17cf8900e49e28048d39104c2sewardj
2993cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
2994cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                 arg7,arg8)                       \
2995cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
2996cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
2997cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+8];                        \
2998cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
2999cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3000cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3001cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3002cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3003cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3004cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3005cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3006cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3007cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3008cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3009cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3010cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
30114118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3012cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3013cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3014cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3015cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3016cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3017cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3018cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3019cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3020cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3021cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3022cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3023cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3024cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3025cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3026cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
30274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
30284118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3029cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3030cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
30314118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3032cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
3033cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
3034cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
3035cd63639e41d591b17cf8900e49e28048d39104c2sewardj
3036cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
3037cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                 arg7,arg8,arg9)                  \
3038cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
3039cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
3040cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+9];                        \
3041cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
3042cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3043cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3044cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3045cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3046cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3047cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3048cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3049cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3050cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3051cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3052cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3053cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+9] = (unsigned long)arg9;                         \
3054cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
30554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3056cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3057cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3058cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3059cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "addi 1,1,-128\n\t"  /* expand stack frame */            \
3060cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg9 */                                               \
3061cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,72(11)\n\t"                                       \
3062cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,112(1)\n\t"                                       \
3063cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* args1-8 */                                            \
3064cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3065cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3066cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3067cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3068cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3069cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3070cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3071cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3072cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3073cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3074cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3075cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
3076cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
30774118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3078cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3079cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
30804118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3081cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
3082cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
3083cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
3084cd63639e41d591b17cf8900e49e28048d39104c2sewardj
3085cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3086cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                  arg7,arg8,arg9,arg10)           \
3087cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
3088cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
3089cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+10];                       \
3090cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
3091cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3092cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3093cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3094cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3095cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3096cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3097cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3098cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3099cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3100cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3101cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3102cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+9] = (unsigned long)arg9;                         \
3103cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+10] = (unsigned long)arg10;                       \
3104cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
31054118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3106cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3107cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3108cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3109cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "addi 1,1,-128\n\t"  /* expand stack frame */            \
3110cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg10 */                                              \
3111cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,80(11)\n\t"                                       \
3112cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,120(1)\n\t"                                       \
3113cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg9 */                                               \
3114cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,72(11)\n\t"                                       \
3115cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,112(1)\n\t"                                       \
3116cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* args1-8 */                                            \
3117cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3118cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3119cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3120cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3121cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3122cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3123cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3124cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3125cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3126cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3127cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3128cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
3129cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
31304118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3131cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3132cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
31334118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3134cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
3135cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
3136cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
3137cd63639e41d591b17cf8900e49e28048d39104c2sewardj
3138cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3139cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                  arg7,arg8,arg9,arg10,arg11)     \
3140cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
3141cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
3142cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+11];                       \
3143cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
3144cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3145cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3146cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3147cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3148cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3149cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3150cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3151cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3152cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3153cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3154cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3155cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+9] = (unsigned long)arg9;                         \
3156cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+10] = (unsigned long)arg10;                       \
3157cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+11] = (unsigned long)arg11;                       \
3158cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
31594118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3160cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3161cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3162cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3163cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "addi 1,1,-144\n\t"  /* expand stack frame */            \
3164cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg11 */                                              \
3165cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,88(11)\n\t"                                       \
3166cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,128(1)\n\t"                                       \
3167cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg10 */                                              \
3168cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,80(11)\n\t"                                       \
3169cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,120(1)\n\t"                                       \
3170cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg9 */                                               \
3171cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,72(11)\n\t"                                       \
3172cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,112(1)\n\t"                                       \
3173cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* args1-8 */                                            \
3174cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3175cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3176cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3177cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3178cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3179cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3180cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3181cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3182cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3183cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3184cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3185cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
3186cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
31874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3188cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3189cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
31904118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3191cd63639e41d591b17cf8900e49e28048d39104c2sewardj      );                                                          \
3192cd63639e41d591b17cf8900e49e28048d39104c2sewardj      lval = (__typeof__(lval)) _res;                             \
3193cd63639e41d591b17cf8900e49e28048d39104c2sewardj   } while (0)
3194cd63639e41d591b17cf8900e49e28048d39104c2sewardj
3195cd63639e41d591b17cf8900e49e28048d39104c2sewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3196cd63639e41d591b17cf8900e49e28048d39104c2sewardj                                arg7,arg8,arg9,arg10,arg11,arg12) \
3197cd63639e41d591b17cf8900e49e28048d39104c2sewardj   do {                                                           \
3198cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile OrigFn        _orig = (orig);                      \
3199cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _argvec[3+12];                       \
3200cd63639e41d591b17cf8900e49e28048d39104c2sewardj      volatile unsigned long _res;                                \
3201cd63639e41d591b17cf8900e49e28048d39104c2sewardj      /* _argvec[0] holds current r2 across the call */           \
3202cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[1]   = (unsigned long)_orig.r2;                     \
3203cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3204cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+1] = (unsigned long)arg1;                         \
3205cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+2] = (unsigned long)arg2;                         \
3206cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+3] = (unsigned long)arg3;                         \
3207cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+4] = (unsigned long)arg4;                         \
3208cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+5] = (unsigned long)arg5;                         \
3209cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+6] = (unsigned long)arg6;                         \
3210cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+7] = (unsigned long)arg7;                         \
3211cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+8] = (unsigned long)arg8;                         \
3212cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+9] = (unsigned long)arg9;                         \
3213cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+10] = (unsigned long)arg10;                       \
3214cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+11] = (unsigned long)arg11;                       \
3215cd63639e41d591b17cf8900e49e28048d39104c2sewardj      _argvec[2+12] = (unsigned long)arg12;                       \
3216cd63639e41d591b17cf8900e49e28048d39104c2sewardj      __asm__ volatile(                                           \
32174118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
3218cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3219cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 2,-16(11)\n\t"  /* save tocptr */                   \
3220cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   2,-8(11)\n\t"  /* use nraddr's tocptr */           \
3221cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "addi 1,1,-144\n\t"  /* expand stack frame */            \
3222cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg12 */                                              \
3223cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,96(11)\n\t"                                       \
3224cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,136(1)\n\t"                                       \
3225cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg11 */                                              \
3226cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,88(11)\n\t"                                       \
3227cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,128(1)\n\t"                                       \
3228cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg10 */                                              \
3229cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,80(11)\n\t"                                       \
3230cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,120(1)\n\t"                                       \
3231cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* arg9 */                                               \
3232cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  3,72(11)\n\t"                                       \
3233cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "std 3,112(1)\n\t"                                       \
3234cd63639e41d591b17cf8900e49e28048d39104c2sewardj         /* args1-8 */                                            \
3235cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   3, 8(11)\n\t"  /* arg1->r3 */                      \
3236cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   4, 16(11)\n\t" /* arg2->r4 */                      \
3237cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   5, 24(11)\n\t" /* arg3->r5 */                      \
3238cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   6, 32(11)\n\t" /* arg4->r6 */                      \
3239cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   7, 40(11)\n\t" /* arg5->r7 */                      \
3240cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   8, 48(11)\n\t" /* arg6->r8 */                      \
3241cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld   9, 56(11)\n\t" /* arg7->r9 */                      \
3242cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  10, 64(11)\n\t" /* arg8->r10 */                     \
3243cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld  11, 0(11)\n\t"  /* target->r11 */                   \
3244cd63639e41d591b17cf8900e49e28048d39104c2sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11                  \
3245cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr 11,%1\n\t"                                           \
3246cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "mr %0,3\n\t"                                            \
3247cd63639e41d591b17cf8900e49e28048d39104c2sewardj         "ld 2,-16(11)\n\t" /* restore tocptr */                  \
32484118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
3249cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*out*/   "=r" (_res)                                  \
3250cd63639e41d591b17cf8900e49e28048d39104c2sewardj         : /*in*/    "r" (&_argvec[2])                            \
32514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
32529734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      );                                                          \
32539734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj      lval = (__typeof__(lval)) _res;                             \
32549734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj   } while (0)
32559734b20023ddaaf95a8d1f3849224ab27fe058bfsewardj
3256cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#endif /* PLAT_ppc64be_linux */
3257f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj
3258582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* ------------------------- ppc64le-linux ----------------------- */
3259582d58245637ab05272d89fb94b12fd0f18fa0f8carll#if defined(PLAT_ppc64le_linux)
3260582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3261582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */
3262582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3263582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* These regs are trashed by the hidden call. */
3264582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define __CALLER_SAVED_REGS                                       \
3265582d58245637ab05272d89fb94b12fd0f18fa0f8carll   "lr", "ctr", "xer",                                            \
3266582d58245637ab05272d89fb94b12fd0f18fa0f8carll   "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",        \
3267582d58245637ab05272d89fb94b12fd0f18fa0f8carll   "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",   \
3268582d58245637ab05272d89fb94b12fd0f18fa0f8carll   "r11", "r12", "r13"
3269582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3270582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* Macros to save and align the stack before making a function
3271582d58245637ab05272d89fb94b12fd0f18fa0f8carll   call and restore it afterwards as gcc may not keep the stack
3272582d58245637ab05272d89fb94b12fd0f18fa0f8carll   pointer aligned if it doesn't realise calls are being made
3273582d58245637ab05272d89fb94b12fd0f18fa0f8carll   to other functions. */
3274582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3275582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_ALIGN_STACK               \
3276582d58245637ab05272d89fb94b12fd0f18fa0f8carll      "mr 28,1\n\t"                        \
3277582d58245637ab05272d89fb94b12fd0f18fa0f8carll      "rldicr 1,1,0,59\n\t"
3278582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define VALGRIND_RESTORE_STACK             \
3279582d58245637ab05272d89fb94b12fd0f18fa0f8carll      "mr 1,28\n\t"
3280582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3281582d58245637ab05272d89fb94b12fd0f18fa0f8carll/* These CALL_FN_ macros assume that on ppc64-linux, sizeof(unsigned
3282582d58245637ab05272d89fb94b12fd0f18fa0f8carll   long) == 8. */
3283582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3284582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_v(lval, orig)                                   \
3285582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3286582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3287582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+0];                        \
3288582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3289582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3290582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1] = (unsigned long)_orig.r2;                       \
3291582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2] = (unsigned long)_orig.nraddr;                   \
3292582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3293582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3294582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3295582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3296582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3297582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3298582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3299582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3300582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3301582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3302582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3303582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3304582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3305582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3306582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3307582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3308582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3309582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3310582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_W(lval, orig, arg1)                             \
3311582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3312582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3313582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+1];                        \
3314582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3315582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3316582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3317582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3318582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3319582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3320582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3321582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3322582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3323582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3324582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3325582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3326582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3327582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3328582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3329582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3330582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3331582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3332582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3333582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3334582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3335582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3336582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3337582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3338582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
3339582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3340582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3341582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+2];                        \
3342582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3343582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3344582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3345582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3346582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3347582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3348582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3349582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3350582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3351582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3352582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3353582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3354582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3355582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3356582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3357582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3358582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3359582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3360582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3361582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3362582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3363582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3364582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3365582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3366582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3367582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3368582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
3369582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3370582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3371582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+3];                        \
3372582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3373582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3374582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3375582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3376582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3377582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3378582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3379582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3380582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3381582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3382582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3383582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3384582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3385582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3386582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3387582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3388582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3389582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3390582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3391582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3392582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3393582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3394582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3395582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3396582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3397582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3398582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3399582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3400582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
3401582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3402582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3403582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+4];                        \
3404582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3405582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3406582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3407582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3408582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3409582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3410582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3411582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3412582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3413582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3414582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3415582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3416582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3417582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3418582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3419582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3420582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3421582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3422582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3423582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3424582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3425582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3426582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3427582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3428582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3429582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3430582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3431582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3432582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3433582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3434582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
3435582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3436582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3437582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+5];                        \
3438582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3439582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3440582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3441582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3442582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3443582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3444582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3445582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3446582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3447582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3448582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3449582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3450582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3451582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3452582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3453582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3454582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3455582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3456582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3457582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3458582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3459582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3460582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3461582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3462582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3463582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3464582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3465582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3466582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3467582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3468582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3469582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3470582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
3471582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3472582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3473582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+6];                        \
3474582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3475582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3476582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3477582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3478582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3479582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3480582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3481582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3482582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3483582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3484582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3485582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3486582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3487582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3488582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3489582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3490582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3491582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3492582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3493582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3494582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3495582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3496582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3497582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3498582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3499582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3500582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3501582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3502582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3503582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3504582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3505582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3506582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3507582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3508582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
3509582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                 arg7)                            \
3510582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3511582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3512582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+7];                        \
3513582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3514582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3515582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3516582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3517582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3518582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3519582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3520582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3521582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3522582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3523582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3524582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3525582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3526582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3527582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3528582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3529582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3530582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3531582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3532582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3533582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3534582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3535582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3536582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3537582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3538582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3539582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3540582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3541582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3542582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3543582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3544582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3545582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3546582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3547582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3548582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3549582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
3550582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                 arg7,arg8)                       \
3551582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3552582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3553582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+8];                        \
3554582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3555582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3556582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3557582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3558582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3559582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3560582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3561582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3562582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3563582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3564582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3565582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3566582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3567582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3568582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3569582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3570582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3571582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3572582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3573582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3574582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3575582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3576582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3577582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3578582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3579582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3580582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3581582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3582582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3583582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3584582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3585582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3586582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3587582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3588582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3589582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3590582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3591582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3592582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
3593582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                 arg7,arg8,arg9)                  \
3594582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3595582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3596582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+9];                        \
3597582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3598582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3599582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3600582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3601582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3602582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3603582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3604582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3605582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3606582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3607582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3608582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3609582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+9] = (unsigned long)arg9;                         \
3610582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3611582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3612582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3613582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3614582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3615582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "addi 1,1,-128\n\t"  /* expand stack frame */            \
3616582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg9 */                                               \
3617582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,72(12)\n\t"                                       \
3618582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,96(1)\n\t"                                        \
3619582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* args1-8 */                                            \
3620582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3621582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3622582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3623582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3624582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3625582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3626582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3627582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3628582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3629582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3630582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3631582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3632582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3633582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3634582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3635582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3636582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3637582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3638582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3639582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3640582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3641582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3642582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                  arg7,arg8,arg9,arg10)           \
3643582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3644582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3645582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+10];                       \
3646582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3647582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3648582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3649582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3650582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3651582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3652582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3653582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3654582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3655582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3656582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3657582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3658582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+9] = (unsigned long)arg9;                         \
3659582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+10] = (unsigned long)arg10;                       \
3660582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3661582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3662582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3663582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3664582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3665582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "addi 1,1,-128\n\t"  /* expand stack frame */            \
3666582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg10 */                                              \
3667582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,80(12)\n\t"                                       \
3668582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,104(1)\n\t"                                       \
3669582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg9 */                                               \
3670582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,72(12)\n\t"                                       \
3671582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,96(1)\n\t"                                        \
3672582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* args1-8 */                                            \
3673582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3674582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3675582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3676582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3677582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3678582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3679582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3680582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3681582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3682582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3683582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3684582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3685582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3686582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3687582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3688582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3689582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3690582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3691582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3692582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3693582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3694582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3695582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                  arg7,arg8,arg9,arg10,arg11)     \
3696582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3697582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3698582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+11];                       \
3699582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3700582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3701582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3702582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3703582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3704582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3705582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3706582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3707582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3708582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3709582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3710582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3711582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+9] = (unsigned long)arg9;                         \
3712582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+10] = (unsigned long)arg10;                       \
3713582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+11] = (unsigned long)arg11;                       \
3714582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3715582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3716582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3717582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3718582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3719582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "addi 1,1,-144\n\t"  /* expand stack frame */            \
3720582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg11 */                                              \
3721582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,88(12)\n\t"                                       \
3722582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,112(1)\n\t"                                       \
3723582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg10 */                                              \
3724582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,80(12)\n\t"                                       \
3725582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,104(1)\n\t"                                       \
3726582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg9 */                                               \
3727582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,72(12)\n\t"                                       \
3728582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,96(1)\n\t"                                        \
3729582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* args1-8 */                                            \
3730582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3731582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3732582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3733582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3734582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3735582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3736582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3737582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3738582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3739582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3740582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3741582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3742582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3743582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3744582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3745582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3746582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3747582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3748582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3749582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3750582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3751582d58245637ab05272d89fb94b12fd0f18fa0f8carll#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
3752582d58245637ab05272d89fb94b12fd0f18fa0f8carll                                arg7,arg8,arg9,arg10,arg11,arg12) \
3753582d58245637ab05272d89fb94b12fd0f18fa0f8carll   do {                                                           \
3754582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile OrigFn        _orig = (orig);                      \
3755582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _argvec[3+12];                       \
3756582d58245637ab05272d89fb94b12fd0f18fa0f8carll      volatile unsigned long _res;                                \
3757582d58245637ab05272d89fb94b12fd0f18fa0f8carll      /* _argvec[0] holds current r2 across the call */           \
3758582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[1]   = (unsigned long)_orig.r2;                     \
3759582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2]   = (unsigned long)_orig.nraddr;                 \
3760582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+1] = (unsigned long)arg1;                         \
3761582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+2] = (unsigned long)arg2;                         \
3762582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+3] = (unsigned long)arg3;                         \
3763582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+4] = (unsigned long)arg4;                         \
3764582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+5] = (unsigned long)arg5;                         \
3765582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+6] = (unsigned long)arg6;                         \
3766582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+7] = (unsigned long)arg7;                         \
3767582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+8] = (unsigned long)arg8;                         \
3768582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+9] = (unsigned long)arg9;                         \
3769582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+10] = (unsigned long)arg10;                       \
3770582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+11] = (unsigned long)arg11;                       \
3771582d58245637ab05272d89fb94b12fd0f18fa0f8carll      _argvec[2+12] = (unsigned long)arg12;                       \
3772582d58245637ab05272d89fb94b12fd0f18fa0f8carll      __asm__ volatile(                                           \
3773582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_ALIGN_STACK                                     \
3774582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3775582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 2,-16(12)\n\t"  /* save tocptr */                   \
3776582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   2,-8(12)\n\t"  /* use nraddr's tocptr */           \
3777582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "addi 1,1,-144\n\t"  /* expand stack frame */            \
3778582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg12 */                                              \
3779582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,96(12)\n\t"                                       \
3780582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,120(1)\n\t"                                       \
3781582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg11 */                                              \
3782582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,88(12)\n\t"                                       \
3783582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,112(1)\n\t"                                       \
3784582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg10 */                                              \
3785582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,80(12)\n\t"                                       \
3786582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,104(1)\n\t"                                       \
3787582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* arg9 */                                               \
3788582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  3,72(12)\n\t"                                       \
3789582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "std 3,96(1)\n\t"                                        \
3790582d58245637ab05272d89fb94b12fd0f18fa0f8carll         /* args1-8 */                                            \
3791582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   3, 8(12)\n\t"  /* arg1->r3 */                      \
3792582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   4, 16(12)\n\t" /* arg2->r4 */                      \
3793582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   5, 24(12)\n\t" /* arg3->r5 */                      \
3794582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   6, 32(12)\n\t" /* arg4->r6 */                      \
3795582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   7, 40(12)\n\t" /* arg5->r7 */                      \
3796582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   8, 48(12)\n\t" /* arg6->r8 */                      \
3797582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld   9, 56(12)\n\t" /* arg7->r9 */                      \
3798582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  10, 64(12)\n\t" /* arg8->r10 */                     \
3799582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld  12, 0(12)\n\t"  /* target->r12 */                   \
3800582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R12                  \
3801582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr 12,%1\n\t"                                           \
3802582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "mr %0,3\n\t"                                            \
3803582d58245637ab05272d89fb94b12fd0f18fa0f8carll         "ld 2,-16(12)\n\t" /* restore tocptr */                  \
3804582d58245637ab05272d89fb94b12fd0f18fa0f8carll         VALGRIND_RESTORE_STACK                                   \
3805582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*out*/   "=r" (_res)                                  \
3806582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*in*/    "r" (&_argvec[2])                            \
3807582d58245637ab05272d89fb94b12fd0f18fa0f8carll         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r28"   \
3808582d58245637ab05272d89fb94b12fd0f18fa0f8carll      );                                                          \
3809582d58245637ab05272d89fb94b12fd0f18fa0f8carll      lval = (__typeof__(lval)) _res;                             \
3810582d58245637ab05272d89fb94b12fd0f18fa0f8carll   } while (0)
3811582d58245637ab05272d89fb94b12fd0f18fa0f8carll
3812582d58245637ab05272d89fb94b12fd0f18fa0f8carll#endif /* PLAT_ppc64le_linux */
3813582d58245637ab05272d89fb94b12fd0f18fa0f8carll
381459570ffbe31930ab4d678754daaeec0715117a3dsewardj/* ------------------------- arm-linux ------------------------- */
381559570ffbe31930ab4d678754daaeec0715117a3dsewardj
381659570ffbe31930ab4d678754daaeec0715117a3dsewardj#if defined(PLAT_arm_linux)
381759570ffbe31930ab4d678754daaeec0715117a3dsewardj
381859570ffbe31930ab4d678754daaeec0715117a3dsewardj/* These regs are trashed by the hidden call. */
381987d812e99f0e33604b268410a677793ef76229d9sewardj#define __CALLER_SAVED_REGS "r0", "r1", "r2", "r3","r4", "r12", "r14"
382059570ffbe31930ab4d678754daaeec0715117a3dsewardj
38214118e0f0df0468b3eccf2515d13c3d9c478d6f16tom/* Macros to save and align the stack before making a function
38224118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   call and restore it afterwards as gcc may not keep the stack
38234118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   pointer aligned if it doesn't realise calls are being made
38244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom   to other functions. */
38254118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
3826567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj/* This is a bit tricky.  We store the original stack pointer in r10
3827567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   as it is callee-saves.  gcc doesn't allow the use of r11 for some
3828567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   reason.  Also, we can't directly "bic" the stack pointer in thumb
3829567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   mode since r13 isn't an allowed register number in that context.
3830567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   So use r4 as a temporary, since that is about to get trashed
3831567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   anyway, just after each use of this macro.  Side effect is we need
3832567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   to be very careful about any future changes, since
3833567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj   VALGRIND_ALIGN_STACK simply assumes r4 is usable. */
38344118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_ALIGN_STACK               \
3835567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "mov r10, sp\n\t"                    \
3836567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "mov r4,  sp\n\t"                    \
3837567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "bic r4,  r4, #7\n\t"                \
3838567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "mov sp,  r4\n\t"
38394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom#define VALGRIND_RESTORE_STACK             \
3840567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj      "mov sp,  r10\n\t"
38414118e0f0df0468b3eccf2515d13c3d9c478d6f16tom
384259570ffbe31930ab4d678754daaeec0715117a3dsewardj/* These CALL_FN_ macros assume that on arm-linux, sizeof(unsigned
384359570ffbe31930ab4d678754daaeec0715117a3dsewardj   long) == 4. */
384459570ffbe31930ab4d678754daaeec0715117a3dsewardj
384559570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_v(lval, orig)                                   \
384659570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
384759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
384859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[1];                          \
384959570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
385059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
385159570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
38524118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
385359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
385459570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
38554118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
385659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0\n"                                           \
385759570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
385859570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3859567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
386059570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
386159570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
386259570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
386359570ffbe31930ab4d678754daaeec0715117a3dsewardj
386459570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
386559570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
386659570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
386759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[2];                          \
386859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
386959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
387059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
387159570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
38724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
387359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
387459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
387559570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
38764118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
387759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0\n"                                           \
387859570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
387959570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3880567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
388159570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
388259570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
388359570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
388459570ffbe31930ab4d678754daaeec0715117a3dsewardj
388559570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
388659570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
388759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
388859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[3];                          \
388959570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
389059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
389159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
389259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
389359570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
38944118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
389559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
389659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
389759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
389859570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
38994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
390059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0\n"                                           \
390159570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
390259570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3903567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
390459570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
390559570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
390659570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
390759570ffbe31930ab4d678754daaeec0715117a3dsewardj
390859570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
390959570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
391059570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
391159570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[4];                          \
391259570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
391359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
391459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
391559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
391659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
391759570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
39184118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
391959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
392059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
392159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
392259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
392359570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
39244118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
392559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0\n"                                           \
392659570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
392759570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3928567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
392959570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
393059570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
393159570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
393259570ffbe31930ab4d678754daaeec0715117a3dsewardj
393359570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
393459570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
393559570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
393659570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[5];                          \
393759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
393859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
393959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
394059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
394159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
394259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
394359570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
39444118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
394559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
394659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
394759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
394859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
394959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
395059570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
39514118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
395259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
395359570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
395459570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3955567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
395659570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
395759570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
395859570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
395959570ffbe31930ab4d678754daaeec0715117a3dsewardj
396059570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
396159570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
396259570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
396359570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[6];                          \
396459570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
396559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
396659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
396759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
396859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
396959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
397059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
397159570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
39724118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
39734118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "sub sp, sp, #4 \n\t"                                    \
397459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
397559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0} \n\t"                                         \
397659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
397759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
397859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
397959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
398059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
398159570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
39824118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
398359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
398459570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
398559570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
3986567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
398759570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
398859570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
398959570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
399059570ffbe31930ab4d678754daaeec0715117a3dsewardj
399159570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
399259570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
399359570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
399459570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[7];                          \
399559570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
399659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
399759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
399859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
399959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
400059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
400159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
400259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
400359570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
40044118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
400559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
400659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
400759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1} \n\t"                                     \
400859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
400959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
401059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
401159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
401259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
401359570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
40144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
401559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
401659570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
401759570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4018567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
401959570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
402059570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
402159570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
402259570ffbe31930ab4d678754daaeec0715117a3dsewardj
402359570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
402459570ffbe31930ab4d678754daaeec0715117a3dsewardj                                 arg7)                            \
402559570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
402659570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
402759570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[8];                          \
402859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
402959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
403059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
403159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
403259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
403359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
403459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
403559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
403659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
403759570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
40384118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
40394118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "sub sp, sp, #4 \n\t"                                    \
404059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
404159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
404259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
404359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2} \n\t"                                 \
404459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
404559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
404659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
404759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
404859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
404959570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
40504118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
405159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
405259570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
405359570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4054567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
405559570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
405659570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
405759570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
405859570ffbe31930ab4d678754daaeec0715117a3dsewardj
405959570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
406059570ffbe31930ab4d678754daaeec0715117a3dsewardj                                 arg7,arg8)                       \
406159570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
406259570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
406359570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[9];                          \
406459570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
406559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
406659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
406759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
406859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
406959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
407059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
407159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
407259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
407359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
407459570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
40754118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
407659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
407759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
407859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
407959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
408059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3} \n\t"                             \
408159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
408259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
408359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
408459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
408559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
408659570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
40874118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
408859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
408959570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
409059570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4091567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
409259570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
409359570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
409459570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
409559570ffbe31930ab4d678754daaeec0715117a3dsewardj
409659570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
409759570ffbe31930ab4d678754daaeec0715117a3dsewardj                                 arg7,arg8,arg9)                  \
409859570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
409959570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
410059570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[10];                         \
410159570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
410259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
410359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
410459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
410559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
410659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
410759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
410859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
410959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
411059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
411159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[9] = (unsigned long)(arg9);                         \
411259570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
41134118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
41144118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "sub sp, sp, #4 \n\t"                                    \
411559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
411659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
411759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
411859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
411959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1, #36] \n\t"                                 \
412059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3, r4} \n\t"                         \
412159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
412259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
412359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
412459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
412559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
412659570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
41274118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
412859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
412959570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
413059570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4131567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
413259570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
413359570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
413459570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
413559570ffbe31930ab4d678754daaeec0715117a3dsewardj
413659570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
413759570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg7,arg8,arg9,arg10)           \
413859570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
413959570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
414059570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[11];                         \
414159570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
414259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
414359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
414459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
414559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
414659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
414759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
414859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
414959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
415059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
415159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[9] = (unsigned long)(arg9);                         \
415259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[10] = (unsigned long)(arg10);                       \
415359570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
41544118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
415559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #40] \n\t"                                 \
415659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0} \n\t"                                         \
415759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
415859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
415959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
416059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
416159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1, #36] \n\t"                                 \
416259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3, r4} \n\t"                         \
416359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
416459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
416559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
416659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
416759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
416859570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
41694118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
417059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
417159570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
417259570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4173567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
417459570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
417559570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
417659570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
417759570ffbe31930ab4d678754daaeec0715117a3dsewardj
417859570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
417959570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg6,arg7,arg8,arg9,arg10,      \
418059570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg11)                          \
418159570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
418259570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
418359570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[12];                         \
418459570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
418559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
418659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
418759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
418859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
418959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
419059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
419159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
419259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
419359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
419459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[9] = (unsigned long)(arg9);                         \
419559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[10] = (unsigned long)(arg10);                       \
419659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[11] = (unsigned long)(arg11);                       \
419759570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
41984118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
41994118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         "sub sp, sp, #4 \n\t"                                    \
420059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #40] \n\t"                                 \
420159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #44] \n\t"                                 \
420259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1} \n\t"                                     \
420359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
420459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
420559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
420659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
420759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1, #36] \n\t"                                 \
420859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3, r4} \n\t"                         \
420959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
421059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
421159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
421259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
421359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
421459570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
42154118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
421659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
421759570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
421859570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4219567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
422059570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
422159570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
422259570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
422359570ffbe31930ab4d678754daaeec0715117a3dsewardj
422459570ffbe31930ab4d678754daaeec0715117a3dsewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
422559570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg6,arg7,arg8,arg9,arg10,      \
422659570ffbe31930ab4d678754daaeec0715117a3dsewardj                                  arg11,arg12)                    \
422759570ffbe31930ab4d678754daaeec0715117a3dsewardj   do {                                                           \
422859570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile OrigFn        _orig = (orig);                      \
422959570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _argvec[13];                         \
423059570ffbe31930ab4d678754daaeec0715117a3dsewardj      volatile unsigned long _res;                                \
423159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
423259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[1] = (unsigned long)(arg1);                         \
423359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[2] = (unsigned long)(arg2);                         \
423459570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[3] = (unsigned long)(arg3);                         \
423559570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[4] = (unsigned long)(arg4);                         \
423659570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[5] = (unsigned long)(arg5);                         \
423759570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[6] = (unsigned long)(arg6);                         \
423859570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[7] = (unsigned long)(arg7);                         \
423959570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[8] = (unsigned long)(arg8);                         \
424059570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[9] = (unsigned long)(arg9);                         \
424159570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[10] = (unsigned long)(arg10);                       \
424259570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[11] = (unsigned long)(arg11);                       \
424359570ffbe31930ab4d678754daaeec0715117a3dsewardj      _argvec[12] = (unsigned long)(arg12);                       \
424459570ffbe31930ab4d678754daaeec0715117a3dsewardj      __asm__ volatile(                                           \
42454118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_ALIGN_STACK                                     \
424659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #40] \n\t"                                 \
424759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #44] \n\t"                                 \
424859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #48] \n\t"                                 \
424959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2} \n\t"                                 \
425059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #20] \n\t"                                 \
425159570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #24] \n\t"                                 \
425259570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #28] \n\t"                                 \
425359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #32] \n\t"                                 \
425459570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1, #36] \n\t"                                 \
425559570ffbe31930ab4d678754daaeec0715117a3dsewardj         "push {r0, r1, r2, r3, r4} \n\t"                         \
425659570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r0, [%1, #4] \n\t"                                  \
425759570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r1, [%1, #8] \n\t"                                  \
425859570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r2, [%1, #12] \n\t"                                 \
425959570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r3, [%1, #16] \n\t"                                 \
426059570ffbe31930ab4d678754daaeec0715117a3dsewardj         "ldr r4, [%1] \n\t"  /* target->r4 */                    \
426159570ffbe31930ab4d678754daaeec0715117a3dsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R4                   \
42624118e0f0df0468b3eccf2515d13c3d9c478d6f16tom         VALGRIND_RESTORE_STACK                                   \
426359570ffbe31930ab4d678754daaeec0715117a3dsewardj         "mov %0, r0"                                             \
426459570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*out*/   "=r" (_res)                                  \
426559570ffbe31930ab4d678754daaeec0715117a3dsewardj         : /*in*/    "0" (&_argvec[0])                            \
4266567e5bb6edf4c1f5d8fe3e41aa0bbe63682bfeacsewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "r10"   \
426759570ffbe31930ab4d678754daaeec0715117a3dsewardj      );                                                          \
426859570ffbe31930ab4d678754daaeec0715117a3dsewardj      lval = (__typeof__(lval)) _res;                             \
426959570ffbe31930ab4d678754daaeec0715117a3dsewardj   } while (0)
427059570ffbe31930ab4d678754daaeec0715117a3dsewardj
427159570ffbe31930ab4d678754daaeec0715117a3dsewardj#endif /* PLAT_arm_linux */
427259570ffbe31930ab4d678754daaeec0715117a3dsewardj
4273f0c1250e324f6684757c6a15545366447ef1d64fsewardj/* ------------------------ arm64-linux ------------------------ */
4274f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4275f0c1250e324f6684757c6a15545366447ef1d64fsewardj#if defined(PLAT_arm64_linux)
4276f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4277f0c1250e324f6684757c6a15545366447ef1d64fsewardj/* These regs are trashed by the hidden call. */
4278f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define __CALLER_SAVED_REGS \
4279f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "x0", "x1", "x2", "x3","x4", "x5", "x6", "x7", "x8", "x9",   \
4280f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17",      \
4281bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj     "x18", "x19", "x20", "x30",                                  \
4282f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9",  \
4283f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "v10", "v11", "v12", "v13", "v14", "v15", "v16", "v17",      \
4284f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "v18", "v19", "v20", "v21", "v22", "v23", "v24", "v25",      \
4285f0c1250e324f6684757c6a15545366447ef1d64fsewardj     "v26", "v27", "v28", "v29", "v30", "v31"
4286f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4287bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj/* x21 is callee-saved, so we can use it to save and restore SP around
4288bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj   the hidden call. */
4289bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj#define VALGRIND_ALIGN_STACK               \
4290bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj      "mov x21, sp\n\t"                    \
4291bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj      "bic sp, x21, #15\n\t"
4292bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj#define VALGRIND_RESTORE_STACK             \
4293bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj      "mov sp,  x21\n\t"
4294f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4295f0c1250e324f6684757c6a15545366447ef1d64fsewardj/* These CALL_FN_ macros assume that on arm64-linux,
4296f0c1250e324f6684757c6a15545366447ef1d64fsewardj   sizeof(unsigned long) == 8. */
4297f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4298f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_v(lval, orig)                                   \
4299f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4300f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4301f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[1];                          \
4302f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4303f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4304f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4305f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4306f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4307f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4308f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4309f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0\n"                                           \
4310f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4311f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
4312bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4313f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4314f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4315f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4316f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4317f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
4318f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4319f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4320f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[2];                          \
4321f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4322f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4323f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[1] = (unsigned long)(arg1);                         \
4324f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4325f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4326f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x0, [%1, #8] \n\t"                                  \
4327f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4328f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4329f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4330f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0\n"                                           \
4331f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4332f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
4333bb9b1b9ac93f01cc216b548a6c8aeac59d4fd046sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4334f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4335f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4336f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4337f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4338f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
4339f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4340f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4341f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[3];                          \
4342f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4343f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4344f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[1] = (unsigned long)(arg1);                         \
4345f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[2] = (unsigned long)(arg2);                         \
4346f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4347f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4348f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x0, [%1, #8] \n\t"                                  \
4349f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x1, [%1, #16] \n\t"                                 \
4350f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4351f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4352f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4353f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0\n"                                           \
4354f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4355f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
435691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4357f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4358f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4359f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4360f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4361f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
4362f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4363f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4364f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[4];                          \
4365f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4366f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4367f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[1] = (unsigned long)(arg1);                         \
4368f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[2] = (unsigned long)(arg2);                         \
4369f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[3] = (unsigned long)(arg3);                         \
4370f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4371f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4372f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x0, [%1, #8] \n\t"                                  \
4373f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x1, [%1, #16] \n\t"                                 \
4374f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x2, [%1, #24] \n\t"                                 \
4375f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4376f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4377f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4378f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0\n"                                           \
4379f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4380f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
438191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4382f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4383f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4384f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4385f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4386f0c1250e324f6684757c6a15545366447ef1d64fsewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
4387f0c1250e324f6684757c6a15545366447ef1d64fsewardj   do {                                                           \
4388f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile OrigFn        _orig = (orig);                      \
4389f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _argvec[5];                          \
4390f0c1250e324f6684757c6a15545366447ef1d64fsewardj      volatile unsigned long _res;                                \
4391f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
4392f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[1] = (unsigned long)(arg1);                         \
4393f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[2] = (unsigned long)(arg2);                         \
4394f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[3] = (unsigned long)(arg3);                         \
4395f0c1250e324f6684757c6a15545366447ef1d64fsewardj      _argvec[4] = (unsigned long)(arg4);                         \
4396f0c1250e324f6684757c6a15545366447ef1d64fsewardj      __asm__ volatile(                                           \
4397f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_ALIGN_STACK                                     \
4398f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x0, [%1, #8] \n\t"                                  \
4399f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x1, [%1, #16] \n\t"                                 \
4400f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x2, [%1, #24] \n\t"                                 \
4401f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x3, [%1, #32] \n\t"                                 \
4402f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
4403f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
4404f0c1250e324f6684757c6a15545366447ef1d64fsewardj         VALGRIND_RESTORE_STACK                                   \
4405f0c1250e324f6684757c6a15545366447ef1d64fsewardj         "mov %0, x0"                                             \
4406f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*out*/   "=r" (_res)                                  \
4407f0c1250e324f6684757c6a15545366447ef1d64fsewardj         : /*in*/    "0" (&_argvec[0])                            \
440891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
440991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
441091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
441191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
441291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
441391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
441491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
441591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
441691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[6];                          \
441791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
441891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
441991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
442091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
442191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
442291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
442391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
442491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
442591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
442691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
442791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
442891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
442991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
443091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
443191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
443291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
443391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
443491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
443591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
443691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
443791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
443891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
443991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
444091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
444191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
444291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
444391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
444491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
444591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[7];                          \
444691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
444791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
444891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
444991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
445091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
445191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
445291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
445391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
445491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
445591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
445691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
445791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
445891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
445991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
446091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
446191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
446291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
446391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
446491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
446591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
446691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
446791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
446891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
446991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
447091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
447191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
447291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
447391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
447491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                 arg7)                            \
447591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
447691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
447791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[8];                          \
447891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
447991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
448091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
448191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
448291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
448391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
448491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
448591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
448691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
448791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
448891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
448991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
449091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
449191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
449291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
449391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
449491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
449591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
449691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
449791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
449891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
449991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
450091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
450191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
450291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
450391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
450491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
450591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
450691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
450791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
450891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                 arg7,arg8)                       \
450991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
451091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
451191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[9];                          \
451291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
451391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
451491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
451591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
451691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
451791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
451891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
451991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
452091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
452191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
452291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
452391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
452491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
452591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
452691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
452791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
452891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
452991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
453091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
453191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
453291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
453391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
453491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
453591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
453691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
453791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
453891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
453991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
454091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
454191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
454291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
454391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
454491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                 arg7,arg8,arg9)                  \
454591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
454691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
454791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[10];                         \
454891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
454991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
455091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
455191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
455291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
455391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
455491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
455591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
455691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
455791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
455891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[9] = (unsigned long)(arg9);                         \
455991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
456091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
456191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "sub sp, sp, #0x20 \n\t"                                 \
456291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
456391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
456491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
456591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
456691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
456791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
456891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
456991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
457091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #72] \n\t"                                 \
457191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #0]  \n\t"                                 \
457291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
457391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
457491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
457591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
457691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
457791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
457891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
457991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
458091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
458191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
458291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
458391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
458491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                  arg7,arg8,arg9,arg10)           \
458591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
458691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
458791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[11];                         \
458891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
458991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
459091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
459191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
459291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
459391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
459491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
459591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
459691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
459791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
459891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[9] = (unsigned long)(arg9);                         \
459991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[10] = (unsigned long)(arg10);                       \
460091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
460191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
460291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "sub sp, sp, #0x20 \n\t"                                 \
460391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
460491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
460591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
460691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
460791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
460891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
460991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
461091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
461191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #72] \n\t"                                 \
461291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #0]  \n\t"                                 \
461391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #80] \n\t"                                 \
461491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #8]  \n\t"                                 \
461591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
461691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
461791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
461891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
461991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
462091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
462191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
462291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
462391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
462491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
462591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
462691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
462791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                  arg7,arg8,arg9,arg10,arg11)     \
462891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
462991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
463091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[12];                         \
463191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
463291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
463391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
463491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
463591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
463691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
463791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
463891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
463991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
464091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
464191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[9] = (unsigned long)(arg9);                         \
464291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[10] = (unsigned long)(arg10);                       \
464391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[11] = (unsigned long)(arg11);                       \
464491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
464591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
464691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "sub sp, sp, #0x30 \n\t"                                 \
464791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
464891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
464991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
465091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
465191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
465291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
465391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
465491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
465591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #72] \n\t"                                 \
465691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #0]  \n\t"                                 \
465791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #80] \n\t"                                 \
465891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #8]  \n\t"                                 \
465991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #88] \n\t"                                 \
466091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #16] \n\t"                                 \
466191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
466291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
466391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
466491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
466591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
466691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
466791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
466891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      );                                                          \
466991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      lval = (__typeof__(lval)) _res;                             \
467091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   } while (0)
467191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj
467291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
467391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                  arg7,arg8,arg9,arg10,arg11,     \
467491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj                                  arg12)                          \
467591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj   do {                                                           \
467691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile OrigFn        _orig = (orig);                      \
467791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _argvec[13];                         \
467891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      volatile unsigned long _res;                                \
467991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
468091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[1] = (unsigned long)(arg1);                         \
468191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[2] = (unsigned long)(arg2);                         \
468291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[3] = (unsigned long)(arg3);                         \
468391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[4] = (unsigned long)(arg4);                         \
468491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[5] = (unsigned long)(arg5);                         \
468591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[6] = (unsigned long)(arg6);                         \
468691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[7] = (unsigned long)(arg7);                         \
468791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[8] = (unsigned long)(arg8);                         \
468891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[9] = (unsigned long)(arg9);                         \
468991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[10] = (unsigned long)(arg10);                       \
469091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[11] = (unsigned long)(arg11);                       \
469191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      _argvec[12] = (unsigned long)(arg12);                       \
469291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj      __asm__ volatile(                                           \
469391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_ALIGN_STACK                                     \
469491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "sub sp, sp, #0x30 \n\t"                                 \
469591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x0, [%1, #8] \n\t"                                  \
469691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x1, [%1, #16] \n\t"                                 \
469791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x2, [%1, #24] \n\t"                                 \
469891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x3, [%1, #32] \n\t"                                 \
469991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x4, [%1, #40] \n\t"                                 \
470091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x5, [%1, #48] \n\t"                                 \
470191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x6, [%1, #56] \n\t"                                 \
470291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x7, [%1, #64] \n\t"                                 \
470391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #72] \n\t"                                 \
470491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #0]  \n\t"                                 \
470591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #80] \n\t"                                 \
470691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #8]  \n\t"                                 \
470791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #88] \n\t"                                 \
470891e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #16] \n\t"                                 \
470991e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1, #96] \n\t"                                 \
471091e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "str x8, [sp, #24] \n\t"                                 \
471191e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "ldr x8, [%1] \n\t"  /* target->x8 */                    \
471291e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_X8                   \
471391e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         VALGRIND_RESTORE_STACK                                   \
471491e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         "mov %0, x0"                                             \
471591e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*out*/   "=r" (_res)                                  \
471691e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*in*/    "0" (&_argvec[0])                            \
471791e1460ca9b838a81fba6050f8a0eccf217ed010sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS, "x21"   \
4718f0c1250e324f6684757c6a15545366447ef1d64fsewardj      );                                                          \
4719f0c1250e324f6684757c6a15545366447ef1d64fsewardj      lval = (__typeof__(lval)) _res;                             \
4720f0c1250e324f6684757c6a15545366447ef1d64fsewardj   } while (0)
4721f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4722f0c1250e324f6684757c6a15545366447ef1d64fsewardj#endif /* PLAT_arm64_linux */
4723f0c1250e324f6684757c6a15545366447ef1d64fsewardj
4724b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* ------------------------- s390x-linux ------------------------- */
4725b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4726b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#if defined(PLAT_s390x_linux)
4727b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4728b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* Similar workaround as amd64 (see above), but we use r11 as frame
4729b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   pointer and save the old r11 in r7. r11 might be used for
4730b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   argvec, therefore we copy argvec in r1 since r1 is clobbered
4731b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   after the call anyway.  */
4732b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#if defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM)
4733b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define __FRAME_POINTER                                         \
4734b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      ,"d"(__builtin_dwarf_cfa())
4735b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define VALGRIND_CFI_PROLOGUE                                   \
4736b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      ".cfi_remember_state\n\t"                                   \
4737b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 1,%1\n\t" /* copy the argvec pointer in r1 */          \
4738b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 7,11\n\t"                                              \
4739b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 11,%2\n\t"                                             \
4740b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      ".cfi_def_cfa r11, 0\n\t"
4741b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define VALGRIND_CFI_EPILOGUE                                   \
4742b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 11, 7\n\t"                                             \
4743b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      ".cfi_restore_state\n\t"
4744b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#else
4745b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define __FRAME_POINTER
4746b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define VALGRIND_CFI_PROLOGUE                                   \
4747b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      "lgr 1,%1\n\t"
4748b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#  define VALGRIND_CFI_EPILOGUE
4749b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#endif
4750b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
47519af940f5f1832ab887b89598c7f0df519d47a092florian/* Nb: On s390 the stack pointer is properly aligned *at all times*
47529af940f5f1832ab887b89598c7f0df519d47a092florian   according to the s390 GCC maintainer. (The ABI specification is not
47539af940f5f1832ab887b89598c7f0df519d47a092florian   precise in this regard.) Therefore, VALGRIND_ALIGN_STACK and
47549af940f5f1832ab887b89598c7f0df519d47a092florian   VALGRIND_RESTORE_STACK are not defined here. */
4755b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4756b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* These regs are trashed by the hidden call. Note that we overwrite
4757b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   r14 in s390_irgen_noredir (VEX/priv/guest_s390_irgen.c) to give the
4758b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   function a proper return address. All others are ABI defined call
4759b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   clobbers. */
4760b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define __CALLER_SAVED_REGS "0","1","2","3","4","5","14", \
4761b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                           "f0","f1","f2","f3","f4","f5","f6","f7"
4762b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
47639af940f5f1832ab887b89598c7f0df519d47a092florian/* Nb: Although r11 is modified in the asm snippets below (inside
47649af940f5f1832ab887b89598c7f0df519d47a092florian   VALGRIND_CFI_PROLOGUE) it is not listed in the clobber section, for
47659af940f5f1832ab887b89598c7f0df519d47a092florian   two reasons:
47669af940f5f1832ab887b89598c7f0df519d47a092florian   (1) r11 is restored in VALGRIND_CFI_EPILOGUE, so effectively it is not
47679af940f5f1832ab887b89598c7f0df519d47a092florian       modified
47689af940f5f1832ab887b89598c7f0df519d47a092florian   (2) GCC will complain that r11 cannot appear inside a clobber section,
47699af940f5f1832ab887b89598c7f0df519d47a092florian       when compiled with -O -fno-omit-frame-pointer
47709af940f5f1832ab887b89598c7f0df519d47a092florian */
4771b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4772b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_v(lval, orig)                                  \
4773b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4774b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4775b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long  _argvec[1];                        \
4776b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4777b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4778b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4779b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4780b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4781b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"  /* target->r1 */                      \
4782b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4783b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4784b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4785b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4786b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4787b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "d" (&_argvec[0]) __FRAME_POINTER           \
4788b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4789b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4790b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4791b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4792b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4793b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj/* The call abi has the arguments in r2-r6 and stack */
4794b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_W(lval, orig, arg1)                            \
4795b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4796b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4797b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[2];                         \
4798b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4799b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4800b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4801b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4802b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4803b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4804b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4805b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4806b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4807b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4808b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4809b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4810b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4811b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4812b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4813b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4814b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4815b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4816b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4817b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_WW(lval, orig, arg1, arg2)                     \
4818b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4819b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4820b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[3];                         \
4821b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4822b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4823b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4824b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4825b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4826b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4827b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4828b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4829b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4830b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4831b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4832b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4833b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4834b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4835b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4836b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4837b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4838b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4839b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4840b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4841b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4842b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_WWW(lval, orig, arg1, arg2, arg3)              \
4843b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4844b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4845b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[4];                         \
4846b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4847b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4848b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4849b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4850b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4851b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4852b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4853b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4854b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4855b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4856b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4857b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4858b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4859b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4860b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4861b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4862b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4863b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4864b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4865b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4866b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4867b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4868b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4869b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_WWWW(lval, orig, arg1, arg2, arg3, arg4)       \
4870b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4871b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4872b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[5];                         \
4873b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4874b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4875b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4876b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4877b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4878b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4879b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4880b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4881b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4882b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4883b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4884b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4885b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
4886b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4887b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4888b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4889b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4890b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4891b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4892b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4893b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7"     \
4894b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4895b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4896b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4897b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4898b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_5W(lval, orig, arg1, arg2, arg3, arg4, arg5)   \
4899b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4900b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4901b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[6];                         \
4902b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4903b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4904b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4905b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4906b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4907b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4908b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
4909b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4910b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4911b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-160\n\t"                                      \
4912b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4913b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4914b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4915b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
4916b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
4917b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4918b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4919b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4920b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,160\n\t"                                       \
4921b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4922b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4923b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4924b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
4925b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4926b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4927b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4928b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4929b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_6W(lval, orig, arg1, arg2, arg3, arg4, arg5,   \
4930b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6)                                       \
4931b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4932b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4933b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[7];                         \
4934b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4935b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4936b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4937b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4938b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4939b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4940b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
4941b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
4942b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4943b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4944b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-168\n\t"                                      \
4945b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4946b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4947b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4948b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
4949b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
4950b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
4951b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4952b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4953b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4954b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,168\n\t"                                       \
4955b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4956b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4957b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4958b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
4959b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4960b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4961b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4962b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4963b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_7W(lval, orig, arg1, arg2, arg3, arg4, arg5,   \
4964b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7)                                 \
4965b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
4966b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
4967b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[8];                         \
4968b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
4969b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
4970b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
4971b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
4972b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
4973b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
4974b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
4975b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
4976b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
4977b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
4978b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
4979b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-176\n\t"                                      \
4980b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
4981b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
4982b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
4983b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
4984b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
4985b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
4986b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
4987b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
4988b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
4989b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
4990b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,176\n\t"                                       \
4991b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
4992b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
4993b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
4994b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
4995b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
4996b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
4997b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
4998b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
4999b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_8W(lval, orig, arg1, arg2, arg3, arg4, arg5,   \
5000b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8)                           \
5001b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5002b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5003b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[9];                         \
5004b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5005b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5006b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5007b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5008b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5009b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5010b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5011b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5012b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5013b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5014b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5015b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5016b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-184\n\t"                                      \
5017b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5018b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5019b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5020b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5021b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5022b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5023b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5024b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5025b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5026b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5027b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5028b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,184\n\t"                                       \
5029b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5030b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5031b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5032b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5033b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5034b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5035b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5036b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5037b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_9W(lval, orig, arg1, arg2, arg3, arg4, arg5,   \
5038b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8, arg9)                     \
5039b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5040b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5041b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[10];                        \
5042b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5043b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5044b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5045b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5046b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5047b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5048b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5049b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5050b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5051b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5052b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[9] = (unsigned long)arg9;                          \
5053b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5054b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5055b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-192\n\t"                                      \
5056b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5057b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5058b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5059b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5060b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5061b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5062b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5063b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5064b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 184(8,15), 72(1)\n\t"                              \
5065b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5066b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5067b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5068b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,192\n\t"                                       \
5069b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5070b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5071b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5072b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5073b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5074b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5075b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5076b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5077b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_10W(lval, orig, arg1, arg2, arg3, arg4, arg5,  \
5078b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8, arg9, arg10)              \
5079b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5080b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5081b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[11];                        \
5082b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5083b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5084b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5085b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5086b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5087b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5088b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5089b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5090b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5091b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5092b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[9] = (unsigned long)arg9;                          \
5093b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[10] = (unsigned long)arg10;                        \
5094b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5095b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5096b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-200\n\t"                                      \
5097b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5098b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5099b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5100b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5101b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5102b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5103b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5104b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5105b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 184(8,15), 72(1)\n\t"                              \
5106b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 192(8,15), 80(1)\n\t"                              \
5107b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5108b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5109b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5110b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,200\n\t"                                       \
5111b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5112b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5113b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5114b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5115b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5116b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5117b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5118b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5119b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_11W(lval, orig, arg1, arg2, arg3, arg4, arg5,  \
5120b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8, arg9, arg10, arg11)       \
5121b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5122b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5123b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[12];                        \
5124b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5125b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5126b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5127b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5128b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5129b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5130b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5131b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5132b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5133b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5134b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[9] = (unsigned long)arg9;                          \
5135b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[10] = (unsigned long)arg10;                        \
5136b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[11] = (unsigned long)arg11;                        \
5137b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5138b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5139b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-208\n\t"                                      \
5140b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5141b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5142b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5143b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5144b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5145b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5146b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5147b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5148b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 184(8,15), 72(1)\n\t"                              \
5149b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 192(8,15), 80(1)\n\t"                              \
5150b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 200(8,15), 88(1)\n\t"                              \
5151b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5152b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5153b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5154b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,208\n\t"                                       \
5155b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5156b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5157b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5158b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5159b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5160b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5161b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5162b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5163b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#define CALL_FN_W_12W(lval, orig, arg1, arg2, arg3, arg4, arg5,  \
5164b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj                     arg6, arg7 ,arg8, arg9, arg10, arg11, arg12)\
5165b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   do {                                                          \
5166b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile OrigFn        _orig = (orig);                     \
5167b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _argvec[13];                        \
5168b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      volatile unsigned long _res;                               \
5169b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                  \
5170b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[1] = (unsigned long)arg1;                          \
5171b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[2] = (unsigned long)arg2;                          \
5172b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[3] = (unsigned long)arg3;                          \
5173b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[4] = (unsigned long)arg4;                          \
5174b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[5] = (unsigned long)arg5;                          \
5175b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[6] = (unsigned long)arg6;                          \
5176b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[7] = (unsigned long)arg7;                          \
5177b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[8] = (unsigned long)arg8;                          \
5178b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[9] = (unsigned long)arg9;                          \
5179b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[10] = (unsigned long)arg10;                        \
5180b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[11] = (unsigned long)arg11;                        \
5181b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      _argvec[12] = (unsigned long)arg12;                        \
5182b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      __asm__ volatile(                                          \
5183b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_PROLOGUE                                   \
5184b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,-216\n\t"                                      \
5185b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 2, 8(1)\n\t"                                        \
5186b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 3,16(1)\n\t"                                        \
5187b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 4,24(1)\n\t"                                        \
5188b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 5,32(1)\n\t"                                        \
5189b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 6,40(1)\n\t"                                        \
5190b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 160(8,15), 48(1)\n\t"                              \
5191b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 168(8,15), 56(1)\n\t"                              \
5192b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 176(8,15), 64(1)\n\t"                              \
5193b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 184(8,15), 72(1)\n\t"                              \
5194b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 192(8,15), 80(1)\n\t"                              \
5195b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 200(8,15), 88(1)\n\t"                              \
5196b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "mvc 208(8,15), 96(1)\n\t"                              \
5197b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lg 1, 0(1)\n\t"                                        \
5198b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CALL_NOREDIR_R1                                \
5199b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "lgr %0, 2\n\t"                                         \
5200b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         "aghi 15,216\n\t"                                       \
5201b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         VALGRIND_CFI_EPILOGUE                                   \
5202b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*out*/   "=d" (_res)                                 \
5203b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*in*/    "a" (&_argvec[0]) __FRAME_POINTER           \
5204b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj         : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
5205b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      );                                                         \
5206b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj      lval = (__typeof__(lval)) _res;                            \
5207b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj   } while (0)
5208b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5209b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
5210b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#endif /* PLAT_s390x_linux */
5211b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj
52124df0bfc0614379192c780c944415dc420d9cfe8epetarj/* ------------------------- mips32-linux ----------------------- */
52135db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52145db15403e889d4db339b342bc2a824ef0bfaa654sewardj#if defined(PLAT_mips32_linux)
52155db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52165db15403e889d4db339b342bc2a824ef0bfaa654sewardj/* These regs are trashed by the hidden call. */
52175db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define __CALLER_SAVED_REGS "$2", "$3", "$4", "$5", "$6",       \
52185db15403e889d4db339b342bc2a824ef0bfaa654sewardj"$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
52195db15403e889d4db339b342bc2a824ef0bfaa654sewardj"$25", "$31"
52205db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52215db15403e889d4db339b342bc2a824ef0bfaa654sewardj/* These CALL_FN_ macros assume that on mips-linux, sizeof(unsigned
52225db15403e889d4db339b342bc2a824ef0bfaa654sewardj   long) == 4. */
52235db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52245db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_v(lval, orig)                                   \
52255db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
52265db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
52275db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[1];                          \
52285db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
52295db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
52305db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
52315db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
52324df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
52334df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
52344df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 16 \n\t"                                 \
52354df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
52365db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
52375db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16\n\t"                                  \
52384df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
52394df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
52405db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
52414df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
52425db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
52435db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
52444df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
52455db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
52465db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
52475db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
52485db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52495db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_W(lval, orig, arg1)                             \
52505db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
52515db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
52525db15403e889d4db339b342bc2a824ef0bfaa654sewardj     volatile unsigned long _argvec[2];                           \
52535db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
52545db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
52555db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
52565db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
52575db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
52584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
52594df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
52605db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 16 \n\t"                                 \
52614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"   /* arg1*/                          \
52624df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
52635db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
52645db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16 \n\t"                                 \
52654df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
52664df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
52675db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
52684df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
52695db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
52704df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "0" (&_argvec[0])                            \
52714df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory",  __CALLER_SAVED_REGS               \
52725db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
52735db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
52745db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
52755db15403e889d4db339b342bc2a824ef0bfaa654sewardj
52765db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
52775db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
52785db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
52795db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[3];                          \
52805db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
52815db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
52825db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
52835db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
52845db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
52855db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
52864df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
52874df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
52885db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 16 \n\t"                                 \
52894df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
52904df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
52914df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
52925db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
52935db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16 \n\t"                                 \
52944df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
52954df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
52965db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
52974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
52985db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
52995db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
53004df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
53015db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
53025db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
53035db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
53045db15403e889d4db339b342bc2a824ef0bfaa654sewardj
53055db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
53065db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
53075db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
53085db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[4];                          \
53095db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
53105db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
53115db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
53125db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
53135db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
53145db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
53155db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
53164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
53174df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
53185db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 16 \n\t"                                 \
53194df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
53204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
53214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
53224df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
53235db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
53245db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16 \n\t"                                 \
53254df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
53264df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
53275db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
53284df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
53295db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
53305db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
53314df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
53325db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
53335db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
53345db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
53355db15403e889d4db339b342bc2a824ef0bfaa654sewardj
53365db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
53375db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
53385db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
53395db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[5];                          \
53405db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
53415db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
53425db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
53435db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
53445db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
53455db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
53465db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
53475db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
53484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
53494df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
53505db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 16 \n\t"                                 \
53514df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
53524df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
53534df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
53544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
53554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
53565db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
53575db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 16 \n\t"                                 \
53584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
53594df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
53605db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 8 \n\t"                                  \
53614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
53625db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
53635db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
53644df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
53655db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
53665db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
53675db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
53685db15403e889d4db339b342bc2a824ef0bfaa654sewardj
53695db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
53705db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
53715db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
53725db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[6];                          \
53735db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
53745db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
53755db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
53765db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
53775db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
53785db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
53795db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
53805db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
53815db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
53824df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
53834df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
53844df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
53854df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 24\n\t"                                  \
53864df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
53874df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
53884df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
53894df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
53904df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
53914df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
53925db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
53935db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "addu $29, $29, 24 \n\t"                                 \
53944df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
53954df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
53964df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
53974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
53985db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
53995db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
54004df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
54015db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
54025db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
54035db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
54045db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
54055db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
54065db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
54075db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[7];                          \
54085db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
54095db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
54105db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
54115db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
54125db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
54135db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
54145db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
54155db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
54165db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
54175db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
54184df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
54194df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
54204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
54214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 32\n\t"                                  \
54224df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
54234df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
54245db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "nop\n\t"                                                \
54254df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
54264df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
54274df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
54284df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
54294df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
54304df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
54315db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
54324df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 32 \n\t"                                 \
54334df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
54344df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
54354df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
54364df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
54375db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
54385db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
54394df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
54405db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
54415db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
54425db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
54435db15403e889d4db339b342bc2a824ef0bfaa654sewardj
54445db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
54455db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                 arg7)                            \
54465db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
54475db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
54485db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[8];                          \
54495db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
54505db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
54515db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
54525db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
54535db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
54545db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
54555db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
54565db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
54575db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
54585db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
54595db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
54604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
54614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
54624df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
54634df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 32\n\t"                                  \
54644df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
54654df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
54664df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
54674df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
54684df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
54694df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
54704df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
54714df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
54724df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
54734df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
54745db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
54754df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 32 \n\t"                                 \
54764df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
54774df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
54784df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
54794df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
54805db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
54815db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
54824df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
54835db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
54845db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
54855db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
54865db15403e889d4db339b342bc2a824ef0bfaa654sewardj
54875db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
54885db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                 arg7,arg8)                       \
54895db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
54905db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
54915db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[9];                          \
54925db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
54935db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
54945db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
54955db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
54965db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
54975db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
54985db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
54995db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
55005db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
55015db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
55025db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
55035db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
55044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
55054df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
55064df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
55074df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 40\n\t"                                  \
55084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
55094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
55104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
55114df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
55124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
55134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
55144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
55154df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
55164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
55174df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
55184df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
55194df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
55205db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
55214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 40 \n\t"                                 \
55224df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
55234df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
55244df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
55254df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
55265db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
55275db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
55284df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
55295db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
55305db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
55315db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
55325db15403e889d4db339b342bc2a824ef0bfaa654sewardj
55335db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
55345db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                 arg7,arg8,arg9)                  \
55355db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
55365db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
55375db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[10];                         \
55385db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
55395db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
55405db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
55415db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
55425db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
55435db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
55445db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
55455db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
55465db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
55475db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
55485db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[9] = (unsigned long)(arg9);                         \
55495db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
55505db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
55514df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
55524df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
55534df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
55544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 40\n\t"                                  \
55554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
55564df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
55574df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
55584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
55594df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
55604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
55614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
55624df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 36(%1) \n\t"                                     \
55634df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 32($29) \n\t"                                    \
55644df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
55654df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
55664df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
55674df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
55684df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
55695db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
55704df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 40 \n\t"                                 \
55714df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
55724df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
55734df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
55744df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
55755db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
55765db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
55774df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
55785db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
55795db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
55805db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
55815db15403e889d4db339b342bc2a824ef0bfaa654sewardj
55825db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
55835db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg7,arg8,arg9,arg10)           \
55845db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
55855db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
55865db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[11];                         \
55875db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
55885db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
55895db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
55905db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
55915db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
55925db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
55935db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
55945db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
55955db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
55965db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
55975db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[9] = (unsigned long)(arg9);                         \
55985db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[10] = (unsigned long)(arg10);                       \
55995db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
56005db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
56014df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
56024df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
56034df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
56044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 48\n\t"                                  \
56054df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
56064df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
56074df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
56084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
56094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
56104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
56114df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
56124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 36(%1) \n\t"                                     \
56134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 32($29) \n\t"                                    \
56144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 40(%1) \n\t"                                     \
56154df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 36($29) \n\t"                                    \
56164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
56174df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
56184df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
56194df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
56204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
56215db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
56224df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 48 \n\t"                                 \
56234df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
56244df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
56254df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
56264df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
56275db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
56285db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
56294df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
56305db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
56315db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
56325db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
56335db15403e889d4db339b342bc2a824ef0bfaa654sewardj
56345db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
56355db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg6,arg7,arg8,arg9,arg10,      \
56365db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg11)                          \
56375db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
56385db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
56395db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[12];                         \
56405db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
56415db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
56425db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
56435db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
56445db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
56455db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
56465db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
56475db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
56485db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
56495db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
56505db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[9] = (unsigned long)(arg9);                         \
56515db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[10] = (unsigned long)(arg10);                       \
56525db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[11] = (unsigned long)(arg11);                       \
56535db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
56545db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
56554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
56564df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
56574df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
56584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 48\n\t"                                  \
56594df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
56604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
56614df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
56624df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
56634df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
56644df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
56654df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
56664df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 36(%1) \n\t"                                     \
56674df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 32($29) \n\t"                                    \
56684df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 40(%1) \n\t"                                     \
56694df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 36($29) \n\t"                                    \
56704df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 44(%1) \n\t"                                     \
56714df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 40($29) \n\t"                                    \
56724df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
56734df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
56744df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
56754df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
56764df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
56775db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
56784df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 48 \n\t"                                 \
56794df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
56804df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
56814df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
56824df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
56835db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
56845db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*in*/    "0" (&_argvec[0])                            \
56854df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
56865db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
56875db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
56885db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
56895db15403e889d4db339b342bc2a824ef0bfaa654sewardj
56905db15403e889d4db339b342bc2a824ef0bfaa654sewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
56915db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg6,arg7,arg8,arg9,arg10,      \
56925db15403e889d4db339b342bc2a824ef0bfaa654sewardj                                  arg11,arg12)                    \
56935db15403e889d4db339b342bc2a824ef0bfaa654sewardj   do {                                                           \
56945db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile OrigFn        _orig = (orig);                      \
56955db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _argvec[13];                         \
56965db15403e889d4db339b342bc2a824ef0bfaa654sewardj      volatile unsigned long _res;                                \
56975db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
56985db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[1] = (unsigned long)(arg1);                         \
56995db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[2] = (unsigned long)(arg2);                         \
57005db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[3] = (unsigned long)(arg3);                         \
57015db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[4] = (unsigned long)(arg4);                         \
57025db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[5] = (unsigned long)(arg5);                         \
57035db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[6] = (unsigned long)(arg6);                         \
57045db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[7] = (unsigned long)(arg7);                         \
57055db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[8] = (unsigned long)(arg8);                         \
57065db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[9] = (unsigned long)(arg9);                         \
57075db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[10] = (unsigned long)(arg10);                       \
57085db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[11] = (unsigned long)(arg11);                       \
57095db15403e889d4db339b342bc2a824ef0bfaa654sewardj      _argvec[12] = (unsigned long)(arg12);                       \
57105db15403e889d4db339b342bc2a824ef0bfaa654sewardj      __asm__ volatile(                                           \
57115db15403e889d4db339b342bc2a824ef0bfaa654sewardj         "subu $29, $29, 8 \n\t"                                  \
57124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $28, 0($29) \n\t"                                    \
57134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $31, 4($29) \n\t"                                    \
57144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 20(%1) \n\t"                                     \
57154df0bfc0614379192c780c944415dc420d9cfe8epetarj         "subu $29, $29, 56\n\t"                                  \
57164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 16($29) \n\t"                                    \
57174df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 24(%1) \n\t"                                     \
57184df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 20($29) \n\t"                                    \
57194df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 28(%1) \n\t"                                     \
57204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 24($29) \n\t"                                    \
57214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 32(%1) \n\t"                                     \
57224df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 28($29) \n\t"                                    \
57234df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 36(%1) \n\t"                                     \
57244df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 32($29) \n\t"                                    \
57254df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 40(%1) \n\t"                                     \
57264df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 36($29) \n\t"                                    \
57274df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 44(%1) \n\t"                                     \
57284df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 40($29) \n\t"                                    \
57294df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 48(%1) \n\t"                                     \
57304df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sw $4, 44($29) \n\t"                                    \
57314df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $4, 4(%1) \n\t"                                      \
57324df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $5, 8(%1) \n\t"                                      \
57334df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $6, 12(%1) \n\t"                                     \
57344df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $7, 16(%1) \n\t"                                     \
57354df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $25, 0(%1) \n\t"  /* target->t9 */                   \
57365db15403e889d4db339b342bc2a824ef0bfaa654sewardj         VALGRIND_CALL_NOREDIR_T9                                 \
57374df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 56 \n\t"                                 \
57384df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $28, 0($29) \n\t"                                    \
57394df0bfc0614379192c780c944415dc420d9cfe8epetarj         "lw $31, 4($29) \n\t"                                    \
57404df0bfc0614379192c780c944415dc420d9cfe8epetarj         "addu $29, $29, 8 \n\t"                                  \
57414df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
57425db15403e889d4db339b342bc2a824ef0bfaa654sewardj         : /*out*/   "=r" (_res)                                  \
57434df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
57444df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
57455db15403e889d4db339b342bc2a824ef0bfaa654sewardj      );                                                          \
57465db15403e889d4db339b342bc2a824ef0bfaa654sewardj      lval = (__typeof__(lval)) _res;                             \
57475db15403e889d4db339b342bc2a824ef0bfaa654sewardj   } while (0)
57485db15403e889d4db339b342bc2a824ef0bfaa654sewardj
57495db15403e889d4db339b342bc2a824ef0bfaa654sewardj#endif /* PLAT_mips32_linux */
57505db15403e889d4db339b342bc2a824ef0bfaa654sewardj
57514df0bfc0614379192c780c944415dc420d9cfe8epetarj/* ------------------------- mips64-linux ------------------------- */
57524df0bfc0614379192c780c944415dc420d9cfe8epetarj
57534df0bfc0614379192c780c944415dc420d9cfe8epetarj#if defined(PLAT_mips64_linux)
57544df0bfc0614379192c780c944415dc420d9cfe8epetarj
57554df0bfc0614379192c780c944415dc420d9cfe8epetarj/* These regs are trashed by the hidden call. */
57564df0bfc0614379192c780c944415dc420d9cfe8epetarj#define __CALLER_SAVED_REGS "$2", "$3", "$4", "$5", "$6",       \
57574df0bfc0614379192c780c944415dc420d9cfe8epetarj"$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
57584df0bfc0614379192c780c944415dc420d9cfe8epetarj"$25", "$31"
57594df0bfc0614379192c780c944415dc420d9cfe8epetarj
57604df0bfc0614379192c780c944415dc420d9cfe8epetarj/* These CALL_FN_ macros assume that on mips-linux, sizeof(unsigned
57614df0bfc0614379192c780c944415dc420d9cfe8epetarj   long) == 4. */
57624df0bfc0614379192c780c944415dc420d9cfe8epetarj
57634df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_v(lval, orig)                                   \
57644df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
57654df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
57664df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[1];                          \
57674df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
57684df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
57694df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
57704df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
57714df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
57724df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
57734df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
57744df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "0" (&_argvec[0])                            \
57754df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
57764df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
57774df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
57784df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
57794df0bfc0614379192c780c944415dc420d9cfe8epetarj
57804df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_W(lval, orig, arg1)                             \
57814df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
57824df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
57834df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[2];                          \
57844df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
57854df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
57864df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
57874df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
57884df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"   /* arg1*/                           \
57894df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
57904df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
57914df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
57924df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
57934df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
57944df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
57954df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
57964df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
57974df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
57984df0bfc0614379192c780c944415dc420d9cfe8epetarj
57994df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_WW(lval, orig, arg1,arg2)                       \
58004df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58014df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58024df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[3];                          \
58034df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
58044df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
58054df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
58064df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
58074df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
58084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
58094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
58104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
58114df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
58124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
58134df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
58144df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
58154df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
58164df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
58174df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
58184df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
58194df0bfc0614379192c780c944415dc420d9cfe8epetarj
58204df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)                 \
58214df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58224df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58234df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[4];                          \
58244df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
58254df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
58264df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
58274df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
58284df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
58294df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
58304df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
58314df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
58324df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
58334df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
58344df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
58354df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
58364df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
58374df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
58384df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
58394df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
58404df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
58414df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
58424df0bfc0614379192c780c944415dc420d9cfe8epetarj
58434df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4)           \
58444df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58454df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58464df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[5];                          \
58474df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
58484df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
58494df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
58504df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
58514df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
58524df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
58534df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
58544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
58554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
58564df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
58574df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
58584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
58594df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
58604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
58614df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
58624df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
58634df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
58644df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
58654df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
58664df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
58674df0bfc0614379192c780c944415dc420d9cfe8epetarj
58684df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)        \
58694df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58704df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58714df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[6];                          \
58724df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
58734df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
58744df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
58754df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
58764df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
58774df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
58784df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
58794df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
58804df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
58814df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
58824df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
58834df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
58844df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
58854df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
58864df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
58874df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
58884df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
58894df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
58904df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
58914df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
58924df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
58934df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
58944df0bfc0614379192c780c944415dc420d9cfe8epetarj
58954df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6)   \
58964df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
58974df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
58984df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[7];                          \
58994df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
59004df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
59014df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
59024df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
59034df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
59044df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
59054df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
59064df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
59074df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
59084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
59094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
59104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
59114df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
59124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
59134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
59144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
59154df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
59164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
59174df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
59184df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
59194df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
59204df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
59214df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
59224df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
59234df0bfc0614379192c780c944415dc420d9cfe8epetarj
59244df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
59254df0bfc0614379192c780c944415dc420d9cfe8epetarj                                 arg7)                            \
59264df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
59274df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
59284df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[8];                          \
59294df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
59304df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
59314df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
59324df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
59334df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
59344df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
59354df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
59364df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
59374df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
59384df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
59394df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
59404df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
59414df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
59424df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
59434df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
59444df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
59454df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
59464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1) \n\t"  /* target->t9 */                   \
59474df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
59484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
59494df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
59504df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
59514df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
59524df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
59534df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
59544df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
59554df0bfc0614379192c780c944415dc420d9cfe8epetarj
59564df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
59574df0bfc0614379192c780c944415dc420d9cfe8epetarj                                 arg7,arg8)                       \
59584df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
59594df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
59604df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[9];                          \
59614df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
59624df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
59634df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
59644df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
59654df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
59664df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
59674df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
59684df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
59694df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
59704df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
59714df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
59724df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
59734df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
59744df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
59754df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
59764df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
59774df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
59784df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
59794df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
59804df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1) \n\t"  /* target->t9 */                   \
59814df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
59824df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
59834df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
59844df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
59854df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
59864df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
59874df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
59884df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
59894df0bfc0614379192c780c944415dc420d9cfe8epetarj
59904df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,   \
59914df0bfc0614379192c780c944415dc420d9cfe8epetarj                                 arg7,arg8,arg9)                  \
59924df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
59934df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
59944df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[10];                         \
59954df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
59964df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
59974df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
59984df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
59994df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
60004df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
60014df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
60024df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
60034df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
60044df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
60054df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[9] = (unsigned long)(arg9);                         \
60064df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
60074df0bfc0614379192c780c944415dc420d9cfe8epetarj         "dsubu $29, $29, 8\n\t"                                  \
60084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 72(%1)\n\t"                                      \
60094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 0($29)\n\t"                                      \
60104df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
60114df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
60124df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
60134df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
60144df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
60154df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
60164df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
60174df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
60184df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
60194df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
60204df0bfc0614379192c780c944415dc420d9cfe8epetarj         "daddu $29, $29, 8\n\t"                                  \
60214df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
60224df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
60234df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
60244df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
60254df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
60264df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
60274df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
60284df0bfc0614379192c780c944415dc420d9cfe8epetarj
60294df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,  \
60304df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg7,arg8,arg9,arg10)           \
60314df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
60324df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
60334df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[11];                         \
60344df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
60354df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
60364df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
60374df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
60384df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
60394df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
60404df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
60414df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
60424df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
60434df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
60444df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[9] = (unsigned long)(arg9);                         \
60454df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[10] = (unsigned long)(arg10);                       \
60464df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
60474df0bfc0614379192c780c944415dc420d9cfe8epetarj         "dsubu $29, $29, 16\n\t"                                 \
60484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 72(%1)\n\t"                                      \
60494df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 0($29)\n\t"                                      \
60504df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 80(%1)\n\t"                                      \
60514df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 8($29)\n\t"                                      \
60524df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
60534df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
60544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
60554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
60564df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
60574df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
60584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
60594df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
60604df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
60614df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
60624df0bfc0614379192c780c944415dc420d9cfe8epetarj         "daddu $29, $29, 16\n\t"                                 \
60634df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
60644df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
60654df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
60664df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
60674df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
60684df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
60694df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
60704df0bfc0614379192c780c944415dc420d9cfe8epetarj
60714df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
60724df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg6,arg7,arg8,arg9,arg10,      \
60734df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg11)                          \
60744df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
60754df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
60764df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[12];                         \
60774df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
60784df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
60794df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
60804df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
60814df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
60824df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
60834df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
60844df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
60854df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
60864df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
60874df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[9] = (unsigned long)(arg9);                         \
60884df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[10] = (unsigned long)(arg10);                       \
60894df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[11] = (unsigned long)(arg11);                       \
60904df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
60914df0bfc0614379192c780c944415dc420d9cfe8epetarj         "dsubu $29, $29, 24\n\t"                                 \
60924df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 72(%1)\n\t"                                      \
60934df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 0($29)\n\t"                                      \
60944df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 80(%1)\n\t"                                      \
60954df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 8($29)\n\t"                                      \
60964df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 88(%1)\n\t"                                      \
60974df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 16($29)\n\t"                                     \
60984df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
60994df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
61004df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
61014df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
61024df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
61034df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
61044df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
61054df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
61064df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
61074df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
61084df0bfc0614379192c780c944415dc420d9cfe8epetarj         "daddu $29, $29, 24\n\t"                                 \
61094df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
61104df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
61114df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
61124df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
61134df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
61144df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
61154df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
61164df0bfc0614379192c780c944415dc420d9cfe8epetarj
61174df0bfc0614379192c780c944415dc420d9cfe8epetarj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,       \
61184df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg6,arg7,arg8,arg9,arg10,      \
61194df0bfc0614379192c780c944415dc420d9cfe8epetarj                                  arg11,arg12)                    \
61204df0bfc0614379192c780c944415dc420d9cfe8epetarj   do {                                                           \
61214df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile OrigFn        _orig = (orig);                      \
61224df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _argvec[13];                         \
61234df0bfc0614379192c780c944415dc420d9cfe8epetarj      volatile unsigned long _res;                                \
61244df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[0] = (unsigned long)_orig.nraddr;                   \
61254df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[1] = (unsigned long)(arg1);                         \
61264df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[2] = (unsigned long)(arg2);                         \
61274df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[3] = (unsigned long)(arg3);                         \
61284df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[4] = (unsigned long)(arg4);                         \
61294df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[5] = (unsigned long)(arg5);                         \
61304df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[6] = (unsigned long)(arg6);                         \
61314df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[7] = (unsigned long)(arg7);                         \
61324df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[8] = (unsigned long)(arg8);                         \
61334df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[9] = (unsigned long)(arg9);                         \
61344df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[10] = (unsigned long)(arg10);                       \
61354df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[11] = (unsigned long)(arg11);                       \
61364df0bfc0614379192c780c944415dc420d9cfe8epetarj      _argvec[12] = (unsigned long)(arg12);                       \
61374df0bfc0614379192c780c944415dc420d9cfe8epetarj      __asm__ volatile(                                           \
61384df0bfc0614379192c780c944415dc420d9cfe8epetarj         "dsubu $29, $29, 32\n\t"                                 \
61394df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 72(%1)\n\t"                                      \
61404df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 0($29)\n\t"                                      \
61414df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 80(%1)\n\t"                                      \
61424df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 8($29)\n\t"                                      \
61434df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 88(%1)\n\t"                                      \
61444df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 16($29)\n\t"                                     \
61454df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 96(%1)\n\t"                                      \
61464df0bfc0614379192c780c944415dc420d9cfe8epetarj         "sd $4, 24($29)\n\t"                                     \
61474df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $4, 8(%1)\n\t"                                       \
61484df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $5, 16(%1)\n\t"                                      \
61494df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $6, 24(%1)\n\t"                                      \
61504df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $7, 32(%1)\n\t"                                      \
61514df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $8, 40(%1)\n\t"                                      \
61524df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $9, 48(%1)\n\t"                                      \
61534df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $10, 56(%1)\n\t"                                     \
61544df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $11, 64(%1)\n\t"                                     \
61554df0bfc0614379192c780c944415dc420d9cfe8epetarj         "ld $25, 0(%1)\n\t"  /* target->t9 */                    \
61564df0bfc0614379192c780c944415dc420d9cfe8epetarj         VALGRIND_CALL_NOREDIR_T9                                 \
61574df0bfc0614379192c780c944415dc420d9cfe8epetarj         "daddu $29, $29, 32\n\t"                                 \
61584df0bfc0614379192c780c944415dc420d9cfe8epetarj         "move %0, $2\n"                                          \
61594df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*out*/   "=r" (_res)                                  \
61604df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*in*/    "r" (&_argvec[0])                            \
61614df0bfc0614379192c780c944415dc420d9cfe8epetarj         : /*trash*/ "memory", __CALLER_SAVED_REGS                \
61624df0bfc0614379192c780c944415dc420d9cfe8epetarj      );                                                          \
61634df0bfc0614379192c780c944415dc420d9cfe8epetarj      lval = (__typeof__(lval)) _res;                             \
61644df0bfc0614379192c780c944415dc420d9cfe8epetarj   } while (0)
61654df0bfc0614379192c780c944415dc420d9cfe8epetarj
61664df0bfc0614379192c780c944415dc420d9cfe8epetarj#endif /* PLAT_mips64_linux */
61674df0bfc0614379192c780c944415dc420d9cfe8epetarj
6168112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/* ------------------------ tilegx-linux ------------------------- */
6169112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6170112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#if defined(PLAT_tilegx_linux)
6171112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6172112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/* These regs are trashed by the hidden call. */
6173112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define __CALLER_SAVED_REGS "r0", "r1", "r2", "r3", "r4", "r5", \
6174112711afefcfcd43680c7c4aa8d38ef180e8811esewardj    "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14",  \
6175112711afefcfcd43680c7c4aa8d38ef180e8811esewardj    "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22",     \
6176112711afefcfcd43680c7c4aa8d38ef180e8811esewardj    "r23", "r24", "r25", "r26", "r27", "r28", "r29", "lr"
6177112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6178112711afefcfcd43680c7c4aa8d38ef180e8811esewardj/* These CALL_FN_ macros assume that on tilegx-linux, sizeof(unsigned
6179112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   long) == 8. */
6180112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6181112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_v(lval, orig)                          \
6182112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                  \
6183112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);             \
6184112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[1];                 \
6185112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                       \
6186112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;          \
6187112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                  \
6188112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                          \
6189112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                        \
6190112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld r12, %1 \n\t"  /* target->r11 */            \
6191112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                       \
6192112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                          \
6193112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                         \
6194112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0 \n"                               \
6195112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                         \
6196112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                   \
6197112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);    \
6198112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                                                         \
6199112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                    \
6200112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6201112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6202112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_W(lval, orig, arg1)                   \
6203112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                 \
6204112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);            \
6205112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[2];                \
6206112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                      \
6207112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;         \
6208112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);               \
6209112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                 \
6210112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                         \
6211112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                       \
6212112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move r29, %1 \n\t"                            \
6213112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r12, r29, 8 \n\t"  /* target->r11 */   \
6214112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */       \
6215112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                      \
6216112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                         \
6217112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                        \
6218112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0\n"                               \
6219112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                        \
6220112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                  \
6221112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);   \
6222112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                   \
6223112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6224112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6225112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_WW(lval, orig, arg1,arg2)             \
6226112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                 \
6227112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);            \
6228112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[3];                \
6229112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                      \
6230112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;         \
6231112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);               \
6232112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);               \
6233112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                 \
6234112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                         \
6235112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                       \
6236112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move r29, %1 \n\t"                            \
6237112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r12, r29, 8 \n\t"  /* target->r11 */   \
6238112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */       \
6239112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */       \
6240112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                      \
6241112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                         \
6242112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                        \
6243112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0\n"                               \
6244112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                        \
6245112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                  \
6246112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);   \
6247112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                   \
6248112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6249112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6250112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3)       \
6251112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                 \
6252112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     volatile OrigFn        _orig = (orig);             \
6253112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     volatile unsigned long _argvec[4];                 \
6254112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     volatile unsigned long _res;                       \
6255112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     _argvec[0] = (unsigned long)_orig.nraddr;          \
6256112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     _argvec[1] = (unsigned long)(arg1);                \
6257112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     _argvec[2] = (unsigned long)(arg2);                \
6258112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     _argvec[3] = (unsigned long)(arg3);                \
6259112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     __asm__ volatile(                                  \
6260112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                          \
6261112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                        \
6262112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                             \
6263112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */    \
6264112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */        \
6265112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */        \
6266112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */        \
6267112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                       \
6268112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8 \n\t"                         \
6269112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                         \
6270112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                \
6271112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                         \
6272112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                   \
6273112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);    \
6274112711afefcfcd43680c7c4aa8d38ef180e8811esewardj     lval = (__typeof__(lval)) _res;                    \
6275112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6276112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6277112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \
6278112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                 \
6279112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);            \
6280112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[5];                \
6281112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                      \
6282112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;         \
6283112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);               \
6284112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);               \
6285112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);               \
6286112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);               \
6287112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                 \
6288112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                         \
6289112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                       \
6290112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move r29, %1 \n\t"                            \
6291112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r12, r29, 8 \n\t"  /* target->r11 */   \
6292112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */       \
6293112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */       \
6294112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */       \
6295112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */       \
6296112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                      \
6297112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                         \
6298112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                        \
6299112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0\n"                               \
6300112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                        \
6301112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                  \
6302112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);   \
6303112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                   \
6304112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6305112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6306112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5)      \
6307112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6308112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6309112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[6];                        \
6310112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6311112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6312112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6313112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6314112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6315112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6316112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6317112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6318112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi sp, sp, -8 \n\t"                                 \
6319112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "st_add sp, lr, -8 \n\t"                               \
6320112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move r29, %1 \n\t"                                    \
6321112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r12, r29, 8 \n\t"  /* target->r11 */           \
6322112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */               \
6323112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */               \
6324112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */               \
6325112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */               \
6326112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */               \
6327112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         VALGRIND_CALL_NOREDIR_R12                              \
6328112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "addi   sp, sp, 8\n\t"                                 \
6329112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "ld_add lr, sp, 8 \n\t"                                \
6330112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         "move  %0, r0\n"                                       \
6331112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*out*/   "=r" (_res)                                \
6332112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*in*/    "r" (&_argvec[0])                          \
6333112711afefcfcd43680c7c4aa8d38ef180e8811esewardj         : /*trash*/  "memory", __CALLER_SAVED_REGS);           \
6334112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6335112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6336112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \
6337112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6338112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6339112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[7];                        \
6340112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6341112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6342112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6343112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6344112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6345112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6346112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6347112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6348112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6349112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6350112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6351112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6352112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6353112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6354112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6355112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6356112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6357112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6358112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6359112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6360112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                  \
6361112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6362112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6363112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6364112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6365112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6366112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6367112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6368112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6369112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
6370112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                     arg7)                                      \
6371112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6372112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6373112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[8];                        \
6374112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6375112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6376112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6377112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6378112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6379112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6380112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6381112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6382112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6383112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6384112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6385112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6386112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6387112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6388112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6389112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6390112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6391112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6392112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6393112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6394112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6395112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6396112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                  \
6397112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6398112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6399112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6400112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6401112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6402112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6403112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6404112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6405112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
6406112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                     arg7,arg8)                                 \
6407112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6408112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6409112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[9];                        \
6410112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6411112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6412112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6413112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6414112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6415112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6416112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6417112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6418112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6419112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                       \
6420112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6421112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6422112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6423112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6424112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6425112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6426112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6427112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6428112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6429112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6430112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6431112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6432112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                \
6433112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6434112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                  \
6435112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6436112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6437112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6438112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6439112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6440112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6441112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6442112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6443112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \
6444112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                     arg7,arg8,arg9)                            \
6445112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6446112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6447112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[10];                       \
6448112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6449112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6450112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6451112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6452112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6453112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6454112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6455112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6456112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6457112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                       \
6458112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[9] = (unsigned long)(arg9);                       \
6459112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6460112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6461112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6462112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6463112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6464112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6465112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6466112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6467112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6468112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6469112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6470112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6471112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                \
6472112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r8, r29, 8 \n\t" /*arg9 -> r8 */                \
6473112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6474112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                  \
6475112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6476112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6477112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6478112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6479112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6480112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6481112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6482112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6483112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6,        \
6484112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg7,arg8,arg9,arg10)                             \
6485112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                                 \
6486112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                            \
6487112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[11];                               \
6488112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                                      \
6489112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                         \
6490112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                               \
6491112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                               \
6492112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                               \
6493112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                               \
6494112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                               \
6495112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                               \
6496112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                               \
6497112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                               \
6498112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[9] = (unsigned long)(arg9);                               \
6499112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[10] = (unsigned long)(arg10);                             \
6500112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                                 \
6501112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                          \
6502112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                        \
6503112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                             \
6504112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */                    \
6505112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                        \
6506112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                        \
6507112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                        \
6508112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                        \
6509112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                        \
6510112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                        \
6511112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                        \
6512112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                        \
6513112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r8, r29, 8 \n\t" /*arg9 -> r8 */                        \
6514112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r9, r29, 8 \n\t" /*arg10 -> r9 */                       \
6515112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                                       \
6516112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 8\n\t"                                          \
6517112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                         \
6518112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                                \
6519112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                         \
6520112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                                   \
6521112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);                    \
6522112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                                   \
6523112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6524112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6525112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,     \
6526112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg6,arg7,arg8,arg9,arg10,                \
6527112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg11)                                    \
6528112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6529112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6530112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[12];                       \
6531112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6532112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6533112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6534112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6535112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6536112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6537112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6538112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6539112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6540112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                       \
6541112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[9] = (unsigned long)(arg9);                       \
6542112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[10] = (unsigned long)(arg10);                     \
6543112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[11] = (unsigned long)(arg11);                     \
6544112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6545112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6546112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6547112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6548112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6549112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6550112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6551112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6552112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6553112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6554112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6555112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6556112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                \
6557112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r8, r29, 8 \n\t" /*arg9 -> r8 */                \
6558112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r9, r29, 8 \n\t" /*arg10 -> r9 */               \
6559112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld     r10, r29 \n\t"                                  \
6560112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, r10, -16 \n\t"                              \
6561112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6562112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 24 \n\t"                                \
6563112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6564112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6565112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6566112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6567112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6568112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6569112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6570112711afefcfcd43680c7c4aa8d38ef180e8811esewardj
6571112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,     \
6572112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg6,arg7,arg8,arg9,arg10,                \
6573112711afefcfcd43680c7c4aa8d38ef180e8811esewardj                      arg11,arg12)                              \
6574112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   do {                                                         \
6575112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile OrigFn        _orig = (orig);                    \
6576112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _argvec[13];                       \
6577112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      volatile unsigned long _res;                              \
6578112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[0] = (unsigned long)_orig.nraddr;                 \
6579112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[1] = (unsigned long)(arg1);                       \
6580112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[2] = (unsigned long)(arg2);                       \
6581112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[3] = (unsigned long)(arg3);                       \
6582112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[4] = (unsigned long)(arg4);                       \
6583112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[5] = (unsigned long)(arg5);                       \
6584112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[6] = (unsigned long)(arg6);                       \
6585112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[7] = (unsigned long)(arg7);                       \
6586112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[8] = (unsigned long)(arg8);                       \
6587112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[9] = (unsigned long)(arg9);                       \
6588112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[10] = (unsigned long)(arg10);                     \
6589112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[11] = (unsigned long)(arg11);                     \
6590112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      _argvec[12] = (unsigned long)(arg12);                     \
6591112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      __asm__ volatile(                                         \
6592112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp, sp, -8 \n\t"                                  \
6593112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add sp, lr, -8 \n\t"                                \
6594112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move r29, %1 \n\t"                                     \
6595112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r12, r29, 8 \n\t"  /* target->r11 */            \
6596112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r0, r29, 8 \n\t" /*arg1 -> r0 */                \
6597112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r1, r29, 8 \n\t" /*arg2 -> r1 */                \
6598112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r2, r29, 8 \n\t" /*arg3 -> r2 */                \
6599112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r3, r29, 8 \n\t" /*arg4 -> r3 */                \
6600112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r4, r29, 8 \n\t" /*arg5 -> r4 */                \
6601112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r5, r29, 8 \n\t" /*arg6 -> r5 */                \
6602112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r6, r29, 8 \n\t" /*arg7 -> r6 */                \
6603112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r7, r29, 8 \n\t" /*arg8 -> r7 */                \
6604112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r8, r29, 8 \n\t" /*arg9 -> r8 */                \
6605112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r9, r29, 8 \n\t" /*arg10 -> r9 */               \
6606112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi r28, sp, -8 \n\t"                                 \
6607112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi sp,  sp, -24 \n\t"                                \
6608112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add r10, r29, 8 \n\t"                               \
6609112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld     r11, r29 \n\t"                                  \
6610112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st_add r28, r10, 8 \n\t"                               \
6611112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "st     r28, r11 \n\t"                                  \
6612112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        VALGRIND_CALL_NOREDIR_R12                               \
6613112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "addi   sp, sp, 32 \n\t"                                \
6614112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "ld_add lr, sp, 8 \n\t"                                 \
6615112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        "move  %0, r0\n"                                        \
6616112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*out*/   "=r" (_res)                                 \
6617112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*in*/    "r" (&_argvec[0])                           \
6618112711afefcfcd43680c7c4aa8d38ef180e8811esewardj        : /*trash*/  "memory", __CALLER_SAVED_REGS);            \
6619112711afefcfcd43680c7c4aa8d38ef180e8811esewardj      lval = (__typeof__(lval)) _res;                           \
6620112711afefcfcd43680c7c4aa8d38ef180e8811esewardj   } while (0)
6621112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#endif  /* PLAT_tilegx_linux */
66220ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
66230ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ------------------------------------------------------------------ */
66240ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS.               */
66250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/*                                                                    */
662630d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn/* ------------------------------------------------------------------ */
662730d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn
66282e93c50dc50235189661b70e3f27a4098d5cccccsewardj/* Some request codes.  There are many more of these, but most are not
66292e93c50dc50235189661b70e3f27a4098d5cccccsewardj   exposed to end-user view.  These are the public ones, all of the
6630e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   form 0x1000 + small_number.
6631d799418996812817596beaa8b59563e3f3cb2ddanjn
66320ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   Core ones are in the range 0x00000000--0x0000ffff.  The non-public
66330ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   ones start at 0x2000.
66342e93c50dc50235189661b70e3f27a4098d5cccccsewardj*/
66352e93c50dc50235189661b70e3f27a4098d5cccccsewardj
66360ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These macros are used by tools -- they must be public, but don't
66370ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   embed them into other programs. */
6638fc26ff9ed636a3dd79ee3d90e5e521bc7749f105njn#define VG_USERREQ_TOOL_BASE(a,b) \
66394c791211835f0e90cbde578187c06e563de3b023njn   ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16))
6640fc26ff9ed636a3dd79ee3d90e5e521bc7749f105njn#define VG_IS_TOOL_USERREQ(a, b, v) \
6641fc26ff9ed636a3dd79ee3d90e5e521bc7749f105njn   (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000))
664234042515c1715b3e0c5c0a5e0bd033e9d4858f01sewardj
66435ce4b150ce5d32c9af07a24717081ea34568388asewardj/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !!
66445ce4b150ce5d32c9af07a24717081ea34568388asewardj   This enum comprises an ABI exported by Valgrind to programs
66455ce4b150ce5d32c9af07a24717081ea34568388asewardj   which use client requests.  DO NOT CHANGE THE ORDER OF THESE
66465ce4b150ce5d32c9af07a24717081ea34568388asewardj   ENTRIES, NOR DELETE ANY -- add new ones at the end. */
6647e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjntypedef
66484c791211835f0e90cbde578187c06e563de3b023njn   enum { VG_USERREQ__RUNNING_ON_VALGRIND  = 0x1001,
66494c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002,
66503e88418f808bf2840646504481d6a5be1df16541njn
66510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj          /* These allow any function to be called from the simulated
66520ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             CPU but run on the real CPU.  Nb: the first arg passed to
66530ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             the function is always the ThreadId of the running
66540ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             thread!  So CLIENT_CALL0 actually requires a 1 arg
6655d4795be03ad94334c7517d93d3f5b35a97c7bba0njn             function, etc. */
66564c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__CLIENT_CALL0 = 0x1101,
66574c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__CLIENT_CALL1 = 0x1102,
66584c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__CLIENT_CALL2 = 0x1103,
66594c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__CLIENT_CALL3 = 0x1104,
66603e88418f808bf2840646504481d6a5be1df16541njn
66610ec07f32bbbb209d749b9974408e6f025ad40b31sewardj          /* Can be useful in regression testing suites -- eg. can
66620ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             send Valgrind's output to /dev/null and still count
66630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             errors. */
66644c791211835f0e90cbde578187c06e563de3b023njn          VG_USERREQ__COUNT_ERRORS = 0x1201,
666547363aba8fa03b094195bca99fc232ce5f85605dnjn
666646207652a0c99a2c8b0f05eafce3ca3ec533c121philippe          /* Allows the client program and/or gdbserver to execute a monitor
666746207652a0c99a2c8b0f05eafce3ca3ec533c121philippe             command. */
66683b290486cd4cd601b20e04340e593c9ed9717e5fsewardj          VG_USERREQ__GDB_MONITOR_COMMAND = 0x1202,
66693b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
66700ec07f32bbbb209d749b9974408e6f025ad40b31sewardj          /* These are useful and can be interpreted by any tool that
66710ec07f32bbbb209d749b9974408e6f025ad40b31sewardj             tracks malloc() et al, by using vg_replace_malloc.c. */
6672d799418996812817596beaa8b59563e3f3cb2ddanjn          VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
6673913473803432ee37d6edaf232e21978d4f426125bart          VG_USERREQ__RESIZEINPLACE_BLOCK = 0x130b,
6674d799418996812817596beaa8b59563e3f3cb2ddanjn          VG_USERREQ__FREELIKE_BLOCK   = 0x1302,
6675bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          /* Memory pool support. */
6676bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          VG_USERREQ__CREATE_MEMPOOL   = 0x1303,
6677bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          VG_USERREQ__DESTROY_MEMPOOL  = 0x1304,
6678bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          VG_USERREQ__MEMPOOL_ALLOC    = 0x1305,
6679bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh          VG_USERREQ__MEMPOOL_FREE     = 0x1306,
66802c1c9dfe806d62d43768b23c29799dc6a100cb09sewardj          VG_USERREQ__MEMPOOL_TRIM     = 0x1307,
6681c740d7660ad140b79e561e0d578ab8435a5a5289sewardj          VG_USERREQ__MOVE_MEMPOOL     = 0x1308,
6682c740d7660ad140b79e561e0d578ab8435a5a5289sewardj          VG_USERREQ__MEMPOOL_CHANGE   = 0x1309,
6683c740d7660ad140b79e561e0d578ab8435a5a5289sewardj          VG_USERREQ__MEMPOOL_EXISTS   = 0x130a,
6684d799418996812817596beaa8b59563e3f3cb2ddanjn
668539de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge          /* Allow printfs to valgrind log. */
6686c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          /* The first two pass the va_list argument by value, which
6687c560fb380ac83ad1957d3fdf92751645a55cf167sewardj             assumes it is the same size as or smaller than a UWord,
6688c560fb380ac83ad1957d3fdf92751645a55cf167sewardj             which generally isn't the case.  Hence are deprecated.
6689c560fb380ac83ad1957d3fdf92751645a55cf167sewardj             The second two pass the vargs by reference and so are
6690c560fb380ac83ad1957d3fdf92751645a55cf167sewardj             immune to this problem. */
6691c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          /* both :: char* fmt, va_list vargs (DEPRECATED) */
669230d76c6abc3e7d338b1ca81256fa3ce93eccc09fnjn          VG_USERREQ__PRINTF           = 0x1401,
66930140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh          VG_USERREQ__PRINTF_BACKTRACE = 0x1402,
6694c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          /* both :: char* fmt, va_list* vargs */
6695c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          VG_USERREQ__PRINTF_VALIST_BY_REF = 0x1403,
6696c560fb380ac83ad1957d3fdf92751645a55cf167sewardj          VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF = 0x1404,
66970140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh
66980140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh          /* Stack support. */
66990140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh          VG_USERREQ__STACK_REGISTER   = 0x1501,
67000140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh          VG_USERREQ__STACK_DEREGISTER = 0x1502,
6701c8259b85b701d25d72aabe9dc0a8154517f96913sewardj          VG_USERREQ__STACK_CHANGE     = 0x1503,
6702c8259b85b701d25d72aabe9dc0a8154517f96913sewardj
6703c8259b85b701d25d72aabe9dc0a8154517f96913sewardj          /* Wine support */
67045c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj          VG_USERREQ__LOAD_PDB_DEBUGINFO = 0x1601,
67055c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj
67065c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj          /* Querying of debug info. */
6707dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj          VG_USERREQ__MAP_IP_TO_SRCLOC = 0x1701,
6708dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj
6709dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj          /* Disable/enable error reporting level.  Takes a single
6710dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj             Word arg which is the delta to this thread's error
6711dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj             disablement indicator.  Hence 1 disables or further
6712dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj             disables errors, and -1 moves back towards enablement.
6713dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj             Other values are not allowed. */
6714bb913cd4cc1e56d7d7798a8b754361a05d01f916florian          VG_USERREQ__CHANGE_ERR_DISABLEMENT = 0x1801,
6715bb913cd4cc1e56d7d7798a8b754361a05d01f916florian
6716bb913cd4cc1e56d7d7798a8b754361a05d01f916florian          /* Initialise IR injection */
6717bb913cd4cc1e56d7d7798a8b754361a05d01f916florian          VG_USERREQ__VEX_INIT_FOR_IRI = 0x1901
6718e49d8e7dfd3a9c96feb9935b5920973dfc0b170anjn   } Vg_ClientRequest;
67192e93c50dc50235189661b70e3f27a4098d5cccccsewardj
67200ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#if !defined(__GNUC__)
67210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#  define __extension__ /* */
6722c9b365507e9bd5d500476e3e83f4d30f9c68a351mueller#endif
67232e93c50dc50235189661b70e3f27a4098d5cccccsewardj
6724fa5115adb77868b1ee3efc8dce061b881e7833c5bart
67250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* Returns the number of Valgrinds this code is running under.  That
67260ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   is, 0 if running natively, 1 if running under Valgrind, 2 if
67270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   running under Valgrind which is running under another Valgrind,
67280ec07f32bbbb209d749b9974408e6f025ad40b31sewardj   etc. */
6729fa5115adb77868b1ee3efc8dce061b881e7833c5bart#define RUNNING_ON_VALGRIND                                           \
6730575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* if not */,         \
6731fa5115adb77868b1ee3efc8dce061b881e7833c5bart                                    VG_USERREQ__RUNNING_ON_VALGRIND,  \
6732fa5115adb77868b1ee3efc8dce061b881e7833c5bart                                    0, 0, 0, 0, 0)                    \
6733de4a1d01951937632098a6cda45859afa587a06fsewardj
6734de4a1d01951937632098a6cda45859afa587a06fsewardj
673518d7513cc08bf982711c8a22b70d56af6aa87b33sewardj/* Discard translation of code in the range [_qzz_addr .. _qzz_addr +
673618d7513cc08bf982711c8a22b70d56af6aa87b33sewardj   _qzz_len - 1].  Useful if you are debugging a JITter or some such,
673718d7513cc08bf982711c8a22b70d56af6aa87b33sewardj   since it provides a way to make sure valgrind will retranslate the
673818d7513cc08bf982711c8a22b70d56af6aa87b33sewardj   invalidated area.  Returns no value. */
67394b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len)              \
67404b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DISCARD_TRANSLATIONS,  \
67414b3a74204894e943c43cb8e8aae39d813040702csewardj                                    _qzz_addr, _qzz_len, 0, 0, 0)
674218d7513cc08bf982711c8a22b70d56af6aa87b33sewardj
674326aba4d3ef6cebc34879e82d88bcbe3c3b3b9f9enjn
67440ec07f32bbbb209d749b9974408e6f025ad40b31sewardj/* These requests are for getting Valgrind itself to print something.
6745d55f0d924062c7b5b3453242a6f9611bd5ce7458njn   Possibly with a backtrace.  This is a really ugly hack.  The return value
6746d55f0d924062c7b5b3453242a6f9611bd5ce7458njn   is the number of characters printed, excluding the "**<pid>** " part at the
6747d55f0d924062c7b5b3453242a6f9611bd5ce7458njn   start and the backtrace (if present). */
67480ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
674942f83fe6c64da13801d4eb54fa2aa6530679848abart#if defined(__GNUC__) || defined(__INTEL_COMPILER) && !defined(_MSC_VER)
67507eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardj/* Modern GCC will optimize the static routine out if unused,
67517eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardj   and unused attribute will shut down warnings about it.  */
67527eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardjstatic int VALGRIND_PRINTF(const char *format, ...)
67537eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardj   __attribute__((format(__printf__, 1, 2), __unused__));
67547f489813d200fb614a0856fca05e2f9ebf66dd48bart#endif
67557eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardjstatic int
67560da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#if defined(_MSC_VER)
67570da2c772047f3f6795dbb43dde5f5c9b43be73bbbart__inline
67580da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#endif
6759a09a1b5d4e02b7451345dac00f2d321d1b4b2ccefitzhardingeVALGRIND_PRINTF(const char *format, ...)
676039de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge{
67618c7e25f496b1771f21712db0b1f35935bacfaff3bart#if defined(NVALGRIND)
67628c7e25f496b1771f21712db0b1f35935bacfaff3bart   return 0;
67638c7e25f496b1771f21712db0b1f35935bacfaff3bart#else /* NVALGRIND */
6764aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#if defined(_MSC_VER) || defined(__MINGW64__)
6765575ce8ef8fa86a502dabe152293320676922dcfebart   uintptr_t _qzz_res;
6766575ce8ef8fa86a502dabe152293320676922dcfebart#else
6767c616819253fcf211745060b2be26076174b1df19njn   unsigned long _qzz_res;
6768575ce8ef8fa86a502dabe152293320676922dcfebart#endif
6769c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_list vargs;
6770c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_start(vargs, format);
6771aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#if defined(_MSC_VER) || defined(__MINGW64__)
6772575ce8ef8fa86a502dabe152293320676922dcfebart   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
67730da2c772047f3f6795dbb43dde5f5c9b43be73bbbart                              VG_USERREQ__PRINTF_VALIST_BY_REF,
6774fa5115adb77868b1ee3efc8dce061b881e7833c5bart                              (uintptr_t)format,
6775fa5115adb77868b1ee3efc8dce061b881e7833c5bart                              (uintptr_t)&vargs,
67760da2c772047f3f6795dbb43dde5f5c9b43be73bbbart                              0, 0, 0);
67770da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#else
6778575ce8ef8fa86a502dabe152293320676922dcfebart   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
6779c560fb380ac83ad1957d3fdf92751645a55cf167sewardj                              VG_USERREQ__PRINTF_VALIST_BY_REF,
678005b07158841423adc250f04e034bf11e6f892b23sewardj                              (unsigned long)format,
6781c560fb380ac83ad1957d3fdf92751645a55cf167sewardj                              (unsigned long)&vargs,
67829af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj                              0, 0, 0);
67830da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#endif
6784c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_end(vargs);
6785c616819253fcf211745060b2be26076174b1df19njn   return (int)_qzz_res;
67868c7e25f496b1771f21712db0b1f35935bacfaff3bart#endif /* NVALGRIND */
678739de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge}
678839de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge
678942f83fe6c64da13801d4eb54fa2aa6530679848abart#if defined(__GNUC__) || defined(__INTEL_COMPILER) && !defined(_MSC_VER)
67907eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardjstatic int VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
67917eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardj   __attribute__((format(__printf__, 1, 2), __unused__));
67927f489813d200fb614a0856fca05e2f9ebf66dd48bart#endif
67937eca0cc8e2bc1c260be1b596c54e4b55d1e2517asewardjstatic int
67940da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#if defined(_MSC_VER)
67950da2c772047f3f6795dbb43dde5f5c9b43be73bbbart__inline
67960da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#endif
6797a09a1b5d4e02b7451345dac00f2d321d1b4b2ccefitzhardingeVALGRIND_PRINTF_BACKTRACE(const char *format, ...)
679839de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge{
67998c7e25f496b1771f21712db0b1f35935bacfaff3bart#if defined(NVALGRIND)
68008c7e25f496b1771f21712db0b1f35935bacfaff3bart   return 0;
68018c7e25f496b1771f21712db0b1f35935bacfaff3bart#else /* NVALGRIND */
6802aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#if defined(_MSC_VER) || defined(__MINGW64__)
6803575ce8ef8fa86a502dabe152293320676922dcfebart   uintptr_t _qzz_res;
6804575ce8ef8fa86a502dabe152293320676922dcfebart#else
6805c616819253fcf211745060b2be26076174b1df19njn   unsigned long _qzz_res;
6806575ce8ef8fa86a502dabe152293320676922dcfebart#endif
6807c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_list vargs;
6808c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_start(vargs, format);
6809aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#if defined(_MSC_VER) || defined(__MINGW64__)
6810575ce8ef8fa86a502dabe152293320676922dcfebart   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
68110da2c772047f3f6795dbb43dde5f5c9b43be73bbbart                              VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF,
6812fa5115adb77868b1ee3efc8dce061b881e7833c5bart                              (uintptr_t)format,
6813fa5115adb77868b1ee3efc8dce061b881e7833c5bart                              (uintptr_t)&vargs,
68140da2c772047f3f6795dbb43dde5f5c9b43be73bbbart                              0, 0, 0);
68150da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#else
6816575ce8ef8fa86a502dabe152293320676922dcfebart   _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0,
6817c560fb380ac83ad1957d3fdf92751645a55cf167sewardj                              VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF,
681805b07158841423adc250f04e034bf11e6f892b23sewardj                              (unsigned long)format,
6819c560fb380ac83ad1957d3fdf92751645a55cf167sewardj                              (unsigned long)&vargs,
68209af10a1c0d1b8897195ccfbc6dc46d8113d77153sewardj                              0, 0, 0);
68210da2c772047f3f6795dbb43dde5f5c9b43be73bbbart#endif
6822c560fb380ac83ad1957d3fdf92751645a55cf167sewardj   va_end(vargs);
6823c616819253fcf211745060b2be26076174b1df19njn   return (int)_qzz_res;
682439de4b473801ab10a48e356cddc863212dd28cd1fitzhardinge#endif /* NVALGRIND */
68258c7e25f496b1771f21712db0b1f35935bacfaff3bart}
682618d7513cc08bf982711c8a22b70d56af6aa87b33sewardj
68270ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
68283e88418f808bf2840646504481d6a5be1df16541njn/* These requests allow control to move from the simulated CPU to the
68291319b49115bd0763628273b8a3fe08ac30712e31njn   real CPU, calling an arbitary function.
68301319b49115bd0763628273b8a3fe08ac30712e31njn
68311319b49115bd0763628273b8a3fe08ac30712e31njn   Note that the current ThreadId is inserted as the first argument.
68321319b49115bd0763628273b8a3fe08ac30712e31njn   So this call:
68331319b49115bd0763628273b8a3fe08ac30712e31njn
68341319b49115bd0763628273b8a3fe08ac30712e31njn     VALGRIND_NON_SIMD_CALL2(f, arg1, arg2)
68351319b49115bd0763628273b8a3fe08ac30712e31njn
68361319b49115bd0763628273b8a3fe08ac30712e31njn   requires f to have this signature:
68371319b49115bd0763628273b8a3fe08ac30712e31njn
68381319b49115bd0763628273b8a3fe08ac30712e31njn     Word f(Word tid, Word arg1, Word arg2)
68391319b49115bd0763628273b8a3fe08ac30712e31njn
68401319b49115bd0763628273b8a3fe08ac30712e31njn   where "Word" is a word-sized type.
684145fb4d304f59e4e4cca917d372278eeb75be2c33njn
684245fb4d304f59e4e4cca917d372278eeb75be2c33njn   Note that these client requests are not entirely reliable.  For example,
684345fb4d304f59e4e4cca917d372278eeb75be2c33njn   if you call a function with them that subsequently calls printf(),
684445fb4d304f59e4e4cca917d372278eeb75be2c33njn   there's a high chance Valgrind will crash.  Generally, your prospects of
684545fb4d304f59e4e4cca917d372278eeb75be2c33njn   these working are made higher if the called function does not refer to
684645fb4d304f59e4e4cca917d372278eeb75be2c33njn   any global variables, and does not refer to any libc or other functions
684745fb4d304f59e4e4cca917d372278eeb75be2c33njn   (printf et al).  Any kind of entanglement with libc or dynamic linking is
684845fb4d304f59e4e4cca917d372278eeb75be2c33njn   likely to have a bad outcome, for tricky reasons which we've grappled
684945fb4d304f59e4e4cca917d372278eeb75be2c33njn   with a lot in the past.
68501319b49115bd0763628273b8a3fe08ac30712e31njn*/
68510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_NON_SIMD_CALL0(_qyy_fn)                          \
6852575ce8ef8fa86a502dabe152293320676922dcfebart    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,       \
6853575ce8ef8fa86a502dabe152293320676922dcfebart                                    VG_USERREQ__CLIENT_CALL0,     \
6854575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_fn,                      \
6855575ce8ef8fa86a502dabe152293320676922dcfebart                                    0, 0, 0, 0)
6856575ce8ef8fa86a502dabe152293320676922dcfebart
6857575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1)                    \
6858575ce8ef8fa86a502dabe152293320676922dcfebart    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,            \
6859575ce8ef8fa86a502dabe152293320676922dcfebart                                    VG_USERREQ__CLIENT_CALL1,          \
6860575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_fn,                           \
6861575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_arg1, 0, 0, 0)
6862575ce8ef8fa86a502dabe152293320676922dcfebart
6863575ce8ef8fa86a502dabe152293320676922dcfebart#define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2)         \
6864575ce8ef8fa86a502dabe152293320676922dcfebart    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,            \
6865575ce8ef8fa86a502dabe152293320676922dcfebart                                    VG_USERREQ__CLIENT_CALL2,          \
6866575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_fn,                           \
6867575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_arg1, _qyy_arg2, 0, 0)
68683e88418f808bf2840646504481d6a5be1df16541njn
68690ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \
6870575ce8ef8fa86a502dabe152293320676922dcfebart    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,             \
6871575ce8ef8fa86a502dabe152293320676922dcfebart                                    VG_USERREQ__CLIENT_CALL3,           \
6872575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_fn,                            \
6873575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_arg1, _qyy_arg2,               \
6874575ce8ef8fa86a502dabe152293320676922dcfebart                                    _qyy_arg3, 0)
68753e88418f808bf2840646504481d6a5be1df16541njn
68763e88418f808bf2840646504481d6a5be1df16541njn
68777cc9c239f785f2903b597cdb34418bed42d25331nethercote/* Counts the number of errors that have been recorded by a tool.  Nb:
68787cc9c239f785f2903b597cdb34418bed42d25331nethercote   the tool must record the errors with VG_(maybe_record_error)() or
687947363aba8fa03b094195bca99fc232ce5f85605dnjn   VG_(unique_error)() for them to be counted. */
68800ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_COUNT_ERRORS                                     \
6881575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(                    \
6882575ce8ef8fa86a502dabe152293320676922dcfebart                               0 /* default return */,            \
68830ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                               VG_USERREQ__COUNT_ERRORS,          \
6884575ce8ef8fa86a502dabe152293320676922dcfebart                               0, 0, 0, 0, 0)
688547363aba8fa03b094195bca99fc232ce5f85605dnjn
68863ac96953bf8c912a2aaa2870652dda8b9b75337bnjn/* Several Valgrind tools (Memcheck, Massif, Helgrind, DRD) rely on knowing
68873ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   when heap blocks are allocated in order to give accurate results.  This
68883ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   happens automatically for the standard allocator functions such as
68893ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   malloc(), calloc(), realloc(), memalign(), new, new[], free(), delete,
68903ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   delete[], etc.
68913ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
68923ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   But if your program uses a custom allocator, this doesn't automatically
68933ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   happen, and Valgrind will not do as well.  For example, if you allocate
68943ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   superblocks with mmap() and then allocates chunks of the superblocks, all
68953ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Valgrind's observations will be at the mmap() level and it won't know that
68963ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   the chunks should be considered separate entities.  In Memcheck's case,
68973ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   that means you probably won't get heap block overrun detection (because
68983ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   there won't be redzones marked as unaddressable) and you definitely won't
68993ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   get any leak detection.
69003ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69013ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   The following client requests allow a custom allocator to be annotated so
69023ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   that it can be handled accurately by Valgrind.
69033ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69043ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   VALGRIND_MALLOCLIKE_BLOCK marks a region of memory as having been allocated
69053ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   by a malloc()-like function.  For Memcheck (an illustrative case), this
69063ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   does two things:
69073ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69083ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   - It records that the block has been allocated.  This means any addresses
69093ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     within the block mentioned in error messages will be
69103ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     identified as belonging to the block.  It also means that if the block
69113ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     isn't freed it will be detected by the leak checker.
69123ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69133ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   - It marks the block as being addressable and undefined (if 'is_zeroed' is
69143ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     not set), or addressable and defined (if 'is_zeroed' is set).  This
69153ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     controls how accesses to the block by the program are handled.
69163ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69173ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   'addr' is the start of the usable block (ie. after any
69183ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   redzone), 'sizeB' is its size.  'rzB' is the redzone size if the allocator
69193ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   can apply redzones -- these are blocks of padding at the start and end of
69203ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   each block.  Adding redzones is recommended as it makes it much more likely
69213ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Valgrind will spot block overruns.  `is_zeroed' indicates if the memory is
69223ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   zeroed (or filled with another predictable value), as is the case for
69233ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   calloc().
69243ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69253ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   VALGRIND_MALLOCLIKE_BLOCK should be put immediately after the point where a
69263ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   heap block -- that will be used by the client program -- is allocated.
69273ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   It's best to put it at the outermost level of the allocator if possible;
69283ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   for example, if you have a function my_alloc() which calls
69293ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   internal_alloc(), and the client request is put inside internal_alloc(),
69303ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   stack traces relating to the heap block will contain entries for both
69313ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   my_alloc() and internal_alloc(), which is probably not what you want.
69323ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
6933b965efb4990bdedc3215ffcca8ea566d25874d26njn   For Memcheck users: if you use VALGRIND_MALLOCLIKE_BLOCK to carve out
6934b965efb4990bdedc3215ffcca8ea566d25874d26njn   custom blocks from within a heap block, B, that has been allocated with
6935b965efb4990bdedc3215ffcca8ea566d25874d26njn   malloc/calloc/new/etc, then block B will be *ignored* during leak-checking
6936b965efb4990bdedc3215ffcca8ea566d25874d26njn   -- the custom blocks will take precedence.
6937b965efb4990bdedc3215ffcca8ea566d25874d26njn
69383ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   VALGRIND_FREELIKE_BLOCK is the partner to VALGRIND_MALLOCLIKE_BLOCK.  For
69393ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Memcheck, it does two things:
69403ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69413ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   - It records that the block has been deallocated.  This assumes that the
69423ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     block was annotated as having been allocated via
69433ac96953bf8c912a2aaa2870652dda8b9b75337bnjn     VALGRIND_MALLOCLIKE_BLOCK.  Otherwise, an error will be issued.
69443ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69453ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   - It marks the block as being unaddressable.
69463ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69473ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   VALGRIND_FREELIKE_BLOCK should be put immediately after the point where a
69483ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   heap block is deallocated.
69493ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
6950913473803432ee37d6edaf232e21978d4f426125bart   VALGRIND_RESIZEINPLACE_BLOCK informs a tool about reallocation. For
6951913473803432ee37d6edaf232e21978d4f426125bart   Memcheck, it does four things:
6952913473803432ee37d6edaf232e21978d4f426125bart
6953913473803432ee37d6edaf232e21978d4f426125bart   - It records that the size of a block has been changed.  This assumes that
6954913473803432ee37d6edaf232e21978d4f426125bart     the block was annotated as having been allocated via
6955913473803432ee37d6edaf232e21978d4f426125bart     VALGRIND_MALLOCLIKE_BLOCK.  Otherwise, an error will be issued.
6956913473803432ee37d6edaf232e21978d4f426125bart
6957913473803432ee37d6edaf232e21978d4f426125bart   - If the block shrunk, it marks the freed memory as being unaddressable.
6958913473803432ee37d6edaf232e21978d4f426125bart
6959913473803432ee37d6edaf232e21978d4f426125bart   - If the block grew, it marks the new area as undefined and defines a red
6960913473803432ee37d6edaf232e21978d4f426125bart     zone past the end of the new block.
6961913473803432ee37d6edaf232e21978d4f426125bart
6962913473803432ee37d6edaf232e21978d4f426125bart   - The V-bits of the overlap between the old and the new block are preserved.
6963913473803432ee37d6edaf232e21978d4f426125bart
6964913473803432ee37d6edaf232e21978d4f426125bart   VALGRIND_RESIZEINPLACE_BLOCK should be put after allocation of the new block
6965913473803432ee37d6edaf232e21978d4f426125bart   and before deallocation of the old block.
6966913473803432ee37d6edaf232e21978d4f426125bart
6967913473803432ee37d6edaf232e21978d4f426125bart   In many cases, these three client requests will not be enough to get your
69683ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   allocator working well with Memcheck.  More specifically, if your allocator
69693ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   writes to freed blocks in any way then a VALGRIND_MAKE_MEM_UNDEFINED call
69703ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   will be necessary to mark the memory as addressable just before the zeroing
69713ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   occurs, otherwise you'll get a lot of invalid write errors.  For example,
69723ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   you'll need to do this if your allocator recycles freed blocks, but it
69733ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   zeroes them before handing them back out (via VALGRIND_MALLOCLIKE_BLOCK).
69743ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Alternatively, if your allocator reuses freed blocks for allocator-internal
69753ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   data structures, VALGRIND_MAKE_MEM_UNDEFINED calls will also be necessary.
69763ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
69773ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   Really, what's happening is a blurring of the lines between the client
69783ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   program and the allocator... after VALGRIND_FREELIKE_BLOCK is called, the
69793ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   memory should be considered unaddressable to the client program, but the
69803ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   allocator knows more than the rest of the client program and so may be able
69813ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   to safely access it.  Extra client requests are necessary for Valgrind to
69823ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   understand the distinction between the allocator and the rest of the
69833ac96953bf8c912a2aaa2870652dda8b9b75337bnjn   program.
69843ac96953bf8c912a2aaa2870652dda8b9b75337bnjn
698532f8d8c0dcb3a7c3ff14aa9892ea2410eba3207cnjn   Ignored if addr == 0.
69863ac96953bf8c912a2aaa2870652dda8b9b75337bnjn*/
69874b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed)          \
69884b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MALLOCLIKE_BLOCK,       \
69894b3a74204894e943c43cb8e8aae39d813040702csewardj                                    addr, sizeB, rzB, is_zeroed, 0)
6990d799418996812817596beaa8b59563e3f3cb2ddanjn
699132f8d8c0dcb3a7c3ff14aa9892ea2410eba3207cnjn/* See the comment for VALGRIND_MALLOCLIKE_BLOCK for details.
699232f8d8c0dcb3a7c3ff14aa9892ea2410eba3207cnjn   Ignored if addr == 0.
699332f8d8c0dcb3a7c3ff14aa9892ea2410eba3207cnjn*/
69944b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_RESIZEINPLACE_BLOCK(addr, oldSizeB, newSizeB, rzB)     \
69954b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__RESIZEINPLACE_BLOCK,    \
69964b3a74204894e943c43cb8e8aae39d813040702csewardj                                    addr, oldSizeB, newSizeB, rzB, 0)
6997913473803432ee37d6edaf232e21978d4f426125bart
6998913473803432ee37d6edaf232e21978d4f426125bart/* See the comment for VALGRIND_MALLOCLIKE_BLOCK for details.
6999913473803432ee37d6edaf232e21978d4f426125bart   Ignored if addr == 0.
7000913473803432ee37d6edaf232e21978d4f426125bart*/
70014b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_FREELIKE_BLOCK(addr, rzB)                              \
70024b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__FREELIKE_BLOCK,         \
70034b3a74204894e943c43cb8e8aae39d813040702csewardj                                    addr, rzB, 0, 0, 0)
7004d799418996812817596beaa8b59563e3f3cb2ddanjn
7005bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh/* Create a memory pool. */
70060ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed)             \
70074b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__CREATE_MEMPOOL,   \
70084b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, rzB, is_zeroed, 0, 0)
7009bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh
7010bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh/* Destroy a memory pool. */
70110ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_DESTROY_MEMPOOL(pool)                            \
70124b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DESTROY_MEMPOOL,  \
70134b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, 0, 0, 0, 0)
7014bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh
7015bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh/* Associate a piece of memory with a memory pool. */
70160ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size)                  \
70174b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MEMPOOL_ALLOC,    \
70184b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, addr, size, 0, 0)
7019bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh
7020bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh/* Disassociate a piece of memory from a memory pool. */
70210ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_MEMPOOL_FREE(pool, addr)                         \
70224b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MEMPOOL_FREE,     \
70234b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, addr, 0, 0, 0)
7024bc0bb8302c37c0c24aafbcfde0cc96d2c2805c94rjwalsh
70252c1c9dfe806d62d43768b23c29799dc6a100cb09sewardj/* Disassociate any pieces outside a particular range. */
70262c1c9dfe806d62d43768b23c29799dc6a100cb09sewardj#define VALGRIND_MEMPOOL_TRIM(pool, addr, size)                   \
70274b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MEMPOOL_TRIM,     \
70284b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, addr, size, 0, 0)
70292c1c9dfe806d62d43768b23c29799dc6a100cb09sewardj
7030c740d7660ad140b79e561e0d578ab8435a5a5289sewardj/* Resize and/or move a piece associated with a memory pool. */
7031c740d7660ad140b79e561e0d578ab8435a5a5289sewardj#define VALGRIND_MOVE_MEMPOOL(poolA, poolB)                       \
70324b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MOVE_MEMPOOL,     \
70334b3a74204894e943c43cb8e8aae39d813040702csewardj                                    poolA, poolB, 0, 0, 0)
7034c740d7660ad140b79e561e0d578ab8435a5a5289sewardj
7035c740d7660ad140b79e561e0d578ab8435a5a5289sewardj/* Resize and/or move a piece associated with a memory pool. */
7036c740d7660ad140b79e561e0d578ab8435a5a5289sewardj#define VALGRIND_MEMPOOL_CHANGE(pool, addrA, addrB, size)         \
70374b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MEMPOOL_CHANGE,   \
70384b3a74204894e943c43cb8e8aae39d813040702csewardj                                    pool, addrA, addrB, size, 0)
7039c740d7660ad140b79e561e0d578ab8435a5a5289sewardj
7040c740d7660ad140b79e561e0d578ab8435a5a5289sewardj/* Return 1 if a mempool exists, else 0. */
7041c740d7660ad140b79e561e0d578ab8435a5a5289sewardj#define VALGRIND_MEMPOOL_EXISTS(pool)                             \
7042575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                  \
7043c740d7660ad140b79e561e0d578ab8435a5a5289sewardj                               VG_USERREQ__MEMPOOL_EXISTS,        \
7044575ce8ef8fa86a502dabe152293320676922dcfebart                               pool, 0, 0, 0, 0)
7045c740d7660ad140b79e561e0d578ab8435a5a5289sewardj
704638a74d2cc4670e3eb559adff51a376cd6ec98005philippe/* Mark a piece of memory as being a stack. Returns a stack id.
704738a74d2cc4670e3eb559adff51a376cd6ec98005philippe   start is the lowest addressable stack byte, end is the highest
704838a74d2cc4670e3eb559adff51a376cd6ec98005philippe   addressable stack byte. */
70490ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_STACK_REGISTER(start, end)                       \
7050575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                  \
70510ec07f32bbbb209d749b9974408e6f025ad40b31sewardj                               VG_USERREQ__STACK_REGISTER,        \
7052575ce8ef8fa86a502dabe152293320676922dcfebart                               start, end, 0, 0, 0)
70530140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh
70540140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh/* Unmark the piece of memory associated with a stack id as being a
70550140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh   stack. */
70560ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_STACK_DEREGISTER(id)                             \
70574b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__STACK_DEREGISTER, \
70584b3a74204894e943c43cb8e8aae39d813040702csewardj                                    id, 0, 0, 0, 0)
70590140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh
706038a74d2cc4670e3eb559adff51a376cd6ec98005philippe/* Change the start and end address of the stack id.
706138a74d2cc4670e3eb559adff51a376cd6ec98005philippe   start is the new lowest addressable stack byte, end is the new highest
706238a74d2cc4670e3eb559adff51a376cd6ec98005philippe   addressable stack byte. */
70630ec07f32bbbb209d749b9974408e6f025ad40b31sewardj#define VALGRIND_STACK_CHANGE(id, start, end)                     \
70644b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__STACK_CHANGE,     \
70654b3a74204894e943c43cb8e8aae39d813040702csewardj                                    id, start, end, 0, 0)
70660140af5b913b1a57b5c28ef776bbb2dda23e8b64rjwalsh
7067c8259b85b701d25d72aabe9dc0a8154517f96913sewardj/* Load PDB debug info for Wine PE image_map. */
70684b3a74204894e943c43cb8e8aae39d813040702csewardj#define VALGRIND_LOAD_PDB_DEBUGINFO(fd, ptr, total_size, delta)     \
70694b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__LOAD_PDB_DEBUGINFO, \
70704b3a74204894e943c43cb8e8aae39d813040702csewardj                                    fd, ptr, total_size, delta, 0)
7071c8259b85b701d25d72aabe9dc0a8154517f96913sewardj
70725c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj/* Map a code address to a source file name and line number.  buf64
70735c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj   must point to a 64-byte buffer in the caller's address space.  The
70745c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj   result will be dumped in there and is guaranteed to be zero
70755c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj   terminated.  If no info is found, the first byte is set to zero. */
70765c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj#define VALGRIND_MAP_IP_TO_SRCLOC(addr, buf64)                    \
7077575ce8ef8fa86a502dabe152293320676922dcfebart    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                  \
70785c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj                               VG_USERREQ__MAP_IP_TO_SRCLOC,      \
7079575ce8ef8fa86a502dabe152293320676922dcfebart                               addr, buf64, 0, 0, 0)
70805c65962f59fb226d327a4860dfab27a1b19ce2e3sewardj
7081dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj/* Disable error reporting for this thread.  Behaves in a stack like
7082dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   way, so you can safely call this multiple times provided that
7083dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   VALGRIND_ENABLE_ERROR_REPORTING is called the same number of times
7084dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   to re-enable reporting.  The first call of this macro disables
7085dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   reporting.  Subsequent calls have no effect except to increase the
7086dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   number of VALGRIND_ENABLE_ERROR_REPORTING calls needed to re-enable
7087dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   reporting.  Child threads do not inherit this setting from their
7088dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   parents -- they are always created with reporting enabled. */
708906e9bf06cf953602adaf5e2a0a3f5522e4dc7f50bart#define VALGRIND_DISABLE_ERROR_REPORTING                                \
70904b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__CHANGE_ERR_DISABLEMENT, \
70914b3a74204894e943c43cb8e8aae39d813040702csewardj                                    1, 0, 0, 0, 0)
7092dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj
7093dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj/* Re-enable error reporting, as per comments on
7094dc873c08cc51930ecd35a976c1d03285f9a53b94sewardj   VALGRIND_DISABLE_ERROR_REPORTING. */
709506e9bf06cf953602adaf5e2a0a3f5522e4dc7f50bart#define VALGRIND_ENABLE_ERROR_REPORTING                                 \
70964b3a74204894e943c43cb8e8aae39d813040702csewardj    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__CHANGE_ERR_DISABLEMENT, \
70974b3a74204894e943c43cb8e8aae39d813040702csewardj                                    -1, 0, 0, 0, 0)
70980ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
709946207652a0c99a2c8b0f05eafce3ca3ec533c121philippe/* Execute a monitor command from the client program.
710046207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   If a connection is opened with GDB, the output will be sent
710146207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   according to the output mode set for vgdb.
710246207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   If no connection is opened, output will go to the log output.
710346207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   Returns 1 if command not recognised, 0 otherwise. */
710446207652a0c99a2c8b0f05eafce3ca3ec533c121philippe#define VALGRIND_MONITOR_COMMAND(command)                               \
710546207652a0c99a2c8b0f05eafce3ca3ec533c121philippe   VALGRIND_DO_CLIENT_REQUEST_EXPR(0, VG_USERREQ__GDB_MONITOR_COMMAND, \
710646207652a0c99a2c8b0f05eafce3ca3ec533c121philippe                                   command, 0, 0, 0, 0)
710746207652a0c99a2c8b0f05eafce3ca3ec533c121philippe
710846207652a0c99a2c8b0f05eafce3ca3ec533c121philippe
7109c112c8ea1262761630f2f17ada4d53697b1242fasewardj#undef PLAT_x86_darwin
7110c112c8ea1262761630f2f17ada4d53697b1242fasewardj#undef PLAT_amd64_darwin
7111c112c8ea1262761630f2f17ada4d53697b1242fasewardj#undef PLAT_x86_win32
7112aaaf21d21f5803b6b1a0fc558bb8db0fcb83a7a0bart#undef PLAT_amd64_win64
7113f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_x86_linux
7114f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_amd64_linux
7115f5c1a7f5a80a9268b181bf6b73e865eb10688b85sewardj#undef PLAT_ppc32_linux
7116cae0cc22b83ffb260ee8379e92099c5a701944cbcarll#undef PLAT_ppc64be_linux
7117582d58245637ab05272d89fb94b12fd0f18fa0f8carll#undef PLAT_ppc64le_linux
711859570ffbe31930ab4d678754daaeec0715117a3dsewardj#undef PLAT_arm_linux
7119b5b87408c0c99f9f6938d8cd921e2a5f420577c4sewardj#undef PLAT_s390x_linux
71205db15403e889d4db339b342bc2a824ef0bfaa654sewardj#undef PLAT_mips32_linux
71214df0bfc0614379192c780c944415dc420d9cfe8epetarj#undef PLAT_mips64_linux
7122112711afefcfcd43680c7c4aa8d38ef180e8811esewardj#undef PLAT_tilegx_linux
71238eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#undef PLAT_x86_solaris
71248eb8bab992e3998c33770b0cdb16059a8b918a06sewardj#undef PLAT_amd64_solaris
71250ec07f32bbbb209d749b9974408e6f025ad40b31sewardj
71263e88418f808bf2840646504481d6a5be1df16541njn#endif   /* __VALGRIND_H */
7127