Revision 24ebf5f3
b/cpu-exec.c | ||
---|---|---|
210 | 210 |
|
211 | 211 |
int cpu_exec(CPUState *env1) |
212 | 212 |
{ |
213 |
#define DECLARE_HOST_REGS 1 |
|
214 |
#include "hostregs_helper.h" |
|
213 |
host_reg_t saved_env_reg; |
|
215 | 214 |
int ret, interrupt_request; |
216 | 215 |
TranslationBlock *tb; |
217 | 216 |
uint8_t *tc_ptr; |
... | ... | |
222 | 221 |
|
223 | 222 |
cpu_single_env = env1; |
224 | 223 |
|
225 |
/* first we save global registers */ |
|
226 |
#define SAVE_HOST_REGS 1 |
|
227 |
#include "hostregs_helper.h" |
|
224 |
/* the access to env below is actually saving the global register's |
|
225 |
value, so that files not including target-xyz/exec.h are free to |
|
226 |
use it. */ |
|
227 |
QEMU_BUILD_BUG_ON (sizeof (saved_env_reg) != sizeof (env)); |
|
228 |
saved_env_reg = (host_reg_t) env; |
|
229 |
asm(""); |
|
228 | 230 |
env = env1; |
229 | 231 |
|
230 | 232 |
#if defined(TARGET_I386) |
... | ... | |
669 | 671 |
#endif |
670 | 672 |
|
671 | 673 |
/* restore global registers */ |
672 |
#include "hostregs_helper.h" |
|
674 |
asm(""); |
|
675 |
env = (void *) saved_env_reg; |
|
673 | 676 |
|
674 | 677 |
/* fail safe : never use cpu_single_env outside cpu_exec() */ |
675 | 678 |
cpu_single_env = NULL; |
/dev/null | ||
---|---|---|
1 |
/* |
|
2 |
* Save/restore host registers. |
|
3 |
* |
|
4 |
* Copyright (c) 2007 CodeSourcery |
|
5 |
* |
|
6 |
* This library is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU Lesser General Public |
|
8 |
* License as published by the Free Software Foundation; either |
|
9 |
* version 2 of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This library is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
* Lesser General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU Lesser General Public |
|
17 |
* License along with this library; if not, see <http://www.gnu.org/licenses/>. |
|
18 |
*/ |
|
19 |
|
|
20 |
/* The GCC global register variable extension is used to reserve some |
|
21 |
host registers for use by generated code. However only the core parts of |
|
22 |
the translation engine are compiled with these settings. We must manually |
|
23 |
save/restore these registers when called from regular code. |
|
24 |
It is not sufficient to save/restore T0 et. al. as these may be declared |
|
25 |
with a datatype smaller than the actual register. */ |
|
26 |
|
|
27 |
#if defined(DECLARE_HOST_REGS) |
|
28 |
|
|
29 |
#define DO_REG(REG) \ |
|
30 |
register host_reg_t reg_AREG##REG asm(AREG##REG); \ |
|
31 |
volatile host_reg_t saved_AREG##REG; |
|
32 |
|
|
33 |
#elif defined(SAVE_HOST_REGS) |
|
34 |
|
|
35 |
#define DO_REG(REG) \ |
|
36 |
__asm__ __volatile__ ("" : "=r" (reg_AREG##REG)); \ |
|
37 |
saved_AREG##REG = reg_AREG##REG; |
|
38 |
|
|
39 |
#else |
|
40 |
|
|
41 |
#define DO_REG(REG) \ |
|
42 |
reg_AREG##REG = saved_AREG##REG; \ |
|
43 |
__asm__ __volatile__ ("" : : "r" (reg_AREG##REG)); |
|
44 |
|
|
45 |
#endif |
|
46 |
|
|
47 |
#ifdef AREG0 |
|
48 |
DO_REG(0) |
|
49 |
#endif |
|
50 |
|
|
51 |
#ifdef AREG1 |
|
52 |
DO_REG(1) |
|
53 |
#endif |
|
54 |
|
|
55 |
#ifdef AREG2 |
|
56 |
DO_REG(2) |
|
57 |
#endif |
|
58 |
|
|
59 |
#undef SAVE_HOST_REGS |
|
60 |
#undef DECLARE_HOST_REGS |
|
61 |
#undef DO_REG |
b/qemu-common.h | ||
---|---|---|
11 | 11 |
#define QEMU_WARN_UNUSED_RESULT |
12 | 12 |
#endif |
13 | 13 |
|
14 |
#define QEMU_BUILD_BUG_ON(x) typedef char __build_bug_on__##__LINE__[(x)?-1:1]; |
|
15 |
|
|
14 | 16 |
/* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that |
15 | 17 |
cannot include the following headers without conflicts. This condition has |
16 | 18 |
to be removed once dyngen is gone. */ |
Also available in: Unified diff