This will replace foo_env_get_cpu with a generic definition.
No changes to the target specific code so far.
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
int cpu_exec(CPUState *cpu);
+/**
+ * env_archcpu(env)
+ * @env: The architecture environment
+ *
+ * Return the ArchCPU associated with the environment.
+ */
+static inline ArchCPU *env_archcpu(CPUArchState *env)
+{
+ return container_of(env, ArchCPU, env);
+}
+
/**
* env_cpu(env)
* @env: The architecture environment
*/
static inline CPUState *env_cpu(CPUArchState *env)
{
- ArchCPU *arch_cpu = container_of(env, ArchCPU, env);
- return &arch_cpu->parent_obj;
+ return &env_archcpu(env)->parent_obj;
}
#endif /* CPU_ALL_H */