Commit 6e42be7c authored by Andreas Färber's avatar Andreas Färber
Browse files

cpu: Drop unnecessary dynamic casts in *_env_get_cpu()



A transition from CPUFooState to FooCPU can be considered safe,
just like FooCPU::env access in the opposite direction.
The only benefit of the FOO_CPU() casts would be protection against
bogus CPUFooState pointers, but then surrounding code would likely
break, too.

This should slightly improve interrupt etc. performance when going from
CPUFooState to FooCPU.
For any additional CPU() casts see 3556c233
(qom: allow turning cast debugging off).

Reported-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
Acked-by: default avatarRichard Henderson <rth@twiddle.net>
Signed-off-by: default avatarAndreas Färber <afaerber@suse.de>
parent 6291ad77
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ typedef struct AlphaCPU {

static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env)
{
    return ALPHA_CPU(container_of(env, AlphaCPU, env));
    return container_of(env, AlphaCPU, env);
}

#define ENV_GET_CPU(e) CPU(alpha_env_get_cpu(e))
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ typedef struct ARMCPU {

static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
{
    return ARM_CPU(container_of(env, ARMCPU, env));
    return container_of(env, ARMCPU, env);
}

#define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ typedef struct CRISCPU {

static inline CRISCPU *cris_env_get_cpu(CPUCRISState *env)
{
    return CRIS_CPU(container_of(env, CRISCPU, env));
    return container_of(env, CRISCPU, env);
}

#define ENV_GET_CPU(e) CPU(cris_env_get_cpu(e))
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ typedef struct X86CPU {

static inline X86CPU *x86_env_get_cpu(CPUX86State *env)
{
    return X86_CPU(container_of(env, X86CPU, env));
    return container_of(env, X86CPU, env);
}

#define ENV_GET_CPU(e) CPU(x86_env_get_cpu(e))
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ typedef struct LM32CPU {

static inline LM32CPU *lm32_env_get_cpu(CPULM32State *env)
{
    return LM32_CPU(container_of(env, LM32CPU, env));
    return container_of(env, LM32CPU, env);
}

#define ENV_GET_CPU(e) CPU(lm32_env_get_cpu(e))
Loading