@@ -250,6 +250,11 @@ static inline ArchCPU *env_archcpu(CPUArchState *env)
return (void *)env - sizeof(CPUState);
}
+static inline const ArchCPU *const_env_archcpu(const CPUArchState *env)
+{
+ return (const void *)env - sizeof(CPUState);
+}
+
/**
* env_cpu_const(env)
* @env: The architecture environment
@@ -588,6 +588,12 @@ static inline CPUArchState *cpu_env(CPUState *cpu)
return (CPUArchState *)(cpu + 1);
}
+static inline const CPUArchState *const_cpu_env(const CPUState *cpu)
+{
+ /* We validate that CPUArchState follows CPUState in cpu-all.h. */
+ return (const CPUArchState *)(cpu + 1);
+}
+
typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ;
extern CPUTailQ cpus_queue;
const_cpu_env() is similar to cpu_env() but return a const CPU 'env' state. Same for const_env_archcpu() w.r.t. env_archcpu(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/exec/cpu-common.h | 5 +++++ include/hw/core/cpu.h | 6 ++++++ 2 files changed, 11 insertions(+)