summaryrefslogtreecommitdiff
path: root/cpu-exec.c
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-17 07:38:10 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-17 07:38:10 +0000
commit572a9d4a880bdcc71c1880ee7416308259bda0d9 (patch)
tree1f9d584e048b740884430f4f6624f22c91b27300 /cpu-exec.c
parent79c638586e64dd666f8869771813a44248c61d83 (diff)
downloadqemu-572a9d4a880bdcc71c1880ee7416308259bda0d9.tar.gz
Improved workaround for the annoying glibc global register mangling bug
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4465 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'cpu-exec.c')
-rw-r--r--cpu-exec.c58
1 files changed, 11 insertions, 47 deletions
diff --git a/cpu-exec.c b/cpu-exec.c
index 5fd9cad4aa..49b4995445 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -37,53 +37,18 @@
#include <sys/ucontext.h>
#endif
+#if defined(__sparc__) && !defined(HOST_SOLARIS)
+// Work around ugly bugs in glibc that mangle global register contents
+#undef env
+#define env cpu_single_env
+#endif
+
int tb_invalidated_flag;
static unsigned long next_tb;
//#define DEBUG_EXEC
//#define DEBUG_SIGNAL
-#define SAVE_GLOBALS()
-#define RESTORE_GLOBALS()
-
-#if defined(__sparc__) && !defined(HOST_SOLARIS)
-#include <features.h>
-#if defined(__GLIBC__) && ((__GLIBC__ < 2) || \
- ((__GLIBC__ == 2) && (__GLIBC_MINOR__ <= 90)))
-// Work around ugly bugs in glibc that mangle global register contents
-
-static volatile void *saved_env;
-#undef SAVE_GLOBALS
-#define SAVE_GLOBALS() do { \
- saved_env = env; \
- } while(0)
-
-#undef RESTORE_GLOBALS
-#define RESTORE_GLOBALS() do { \
- env = (void *)saved_env; \
- } while(0)
-
-static int sparc_setjmp(jmp_buf buf)
-{
- int ret;
-
- SAVE_GLOBALS();
- ret = setjmp(buf);
- RESTORE_GLOBALS();
- return ret;
-}
-#undef setjmp
-#define setjmp(jmp_buf) sparc_setjmp(jmp_buf)
-
-static void sparc_longjmp(jmp_buf buf, int val)
-{
- SAVE_GLOBALS();
- longjmp(buf, val);
-}
-#define longjmp(jmp_buf, val) sparc_longjmp(jmp_buf, val)
-#endif
-#endif
-
void cpu_loop_exit(void)
{
/* NOTE: the register at this point must be saved by hand because
@@ -176,9 +141,7 @@ static TranslationBlock *tb_find_slow(target_ulong pc,
tb->tc_ptr = tc_ptr;
tb->cs_base = cs_base;
tb->flags = flags;
- SAVE_GLOBALS();
cpu_gen_code(env, tb, &code_gen_size);
- RESTORE_GLOBALS();
code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
/* check next page if needed */
@@ -302,7 +265,6 @@ int cpu_exec(CPUState *env1)
#define SAVE_HOST_REGS 1
#include "hostregs_helper.h"
env = env1;
- SAVE_GLOBALS();
env_to_regs();
#if defined(TARGET_I386)
@@ -414,7 +376,6 @@ int cpu_exec(CPUState *env1)
next_tb = 0; /* force lookup of first TB */
for(;;) {
- SAVE_GLOBALS();
interrupt_request = env->interrupt_request;
if (__builtin_expect(interrupt_request, 0)
#if defined(TARGET_I386)
@@ -633,7 +594,6 @@ int cpu_exec(CPUState *env1)
lookup_symbol(tb->pc));
}
#endif
- RESTORE_GLOBALS();
/* see if we can patch the calling TB. When the TB
spans two pages, we cannot safely do a direct
jump. */
@@ -651,6 +611,11 @@ int cpu_exec(CPUState *env1)
tc_ptr = tb->tc_ptr;
env->current_tb = tb;
/* execute the generated code */
+#if defined(__sparc__) && !defined(HOST_SOLARIS)
+#undef env
+ env = cpu_single_env;
+#define env cpu_single_env
+#endif
next_tb = tcg_qemu_tb_exec(tc_ptr);
env->current_tb = NULL;
/* reset soft MMU for next block (it can currently
@@ -701,7 +666,6 @@ int cpu_exec(CPUState *env1)
#endif
/* restore global registers */
- RESTORE_GLOBALS();
#include "hostregs_helper.h"
/* fail safe : never use cpu_single_env outside cpu_exec() */