qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 19/20] get_env accel wrapper


From: Glauber Costa
Subject: [Qemu-devel] [PATCH 19/20] get_env accel wrapper
Date: Fri, 27 Jun 2008 17:38:22 -0300

Allow the current accelerator to provide it's own, customized
address of the CPUState structure used for the env variable.

Signed-off-by: Glauber Costa <address@hidden>
---
 accel.h              |    8 ++++++++
 target-i386/helper.c |    2 +-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/accel.h b/accel.h
index 52b95e4..08ad337 100644
--- a/accel.h
+++ b/accel.h
@@ -1,6 +1,7 @@
 typedef struct QEMUAccel {
     char *name;
     void (*cpu_interrupt)(CPUState *env);
+    CPUState *(*get_env)(void);
     void (*init_env)(CPUState *env);
     int (*start)(void);
     void (*flush_cache)(CPUState *env, int global);
@@ -76,6 +77,13 @@ static inline void accel_start(void)
     }
 }
 
+static inline CPUState *accel_get_env(void)
+{
+    if (current_accel && current_accel->get_env)
+        return current_accel->get_env();
+    return qemu_mallocz(sizeof(CPUState));
+}
+
 static inline void accel_init_env(CPUState *env)
 {
     if (current_accel && current_accel->init_env)
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 4febc45..9bb726f 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -98,7 +98,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
     CPUX86State *env;
     static int inited;
 
-    env = qemu_mallocz(sizeof(CPUX86State));
+    env = accel_get_env();
     if (!env)
         return NULL;
     cpu_exec_init(env);
-- 
1.5.5.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]