diff mbox series

[PATCH-for-10.0,2/6] accel/tcg: Declare local tcg_ops variable in tcg_exec_realizefn()

Message ID 20241127121658.88966-3-philmd@linaro.org (mailing list archive)
State New
Headers show
Series accel/tcg: Allow tcg_exec_realizefn() initialize multiple frontends | expand

Commit Message

Philippe Mathieu-Daudé Nov. 27, 2024, 12:16 p.m. UTC
Ease reading code by declaring a local 'tcg_ops' variable.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/cpu-exec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Anton Johansson Nov. 27, 2024, 4:26 p.m. UTC | #1
On 27/11/24, Philippe Mathieu-Daudé wrote:
> Ease reading code by declaring a local 'tcg_ops' variable.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  accel/tcg/cpu-exec.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Anton Johansson <anjo@rev.ng>
Richard Henderson Nov. 27, 2024, 4:38 p.m. UTC | #2
On 11/27/24 06:16, Philippe Mathieu-Daudé wrote:
> Ease reading code by declaring a local 'tcg_ops' variable.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/tcg/cpu-exec.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

> 
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index 8163295f34b..18d9cf0ea58 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -1070,15 +1070,15 @@ int cpu_exec(CPUState *cpu)
>   
>   bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
>   {
> -    static bool tcg_target_initialized;
> +    const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
>   
>       if (!tcg_target_initialized) {
>           /* Check mandatory TCGCPUOps handlers */
>   #ifndef CONFIG_USER_ONLY
> -        assert(cpu->cc->tcg_ops->cpu_exec_halt);
> -        assert(cpu->cc->tcg_ops->cpu_exec_interrupt);
> +        assert(tcg_ops->cpu_exec_halt);
> +        assert(tcg_ops->cpu_exec_interrupt);
>   #endif /* !CONFIG_USER_ONLY */
> -        cpu->cc->tcg_ops->initialize();
> +        tcg_ops->initialize();
>           tcg_target_initialized = true;
>       }
>
Richard Henderson Nov. 27, 2024, 5:40 p.m. UTC | #3
On 11/27/24 06:16, Philippe Mathieu-Daudé wrote:
>   bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
>   {
> -    static bool tcg_target_initialized;

Error removing this variable before patch 6.

r~

> +    const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
>   
>       if (!tcg_target_initialized) {
>           /* Check mandatory TCGCPUOps handlers */
>   #ifndef CONFIG_USER_ONLY
> -        assert(cpu->cc->tcg_ops->cpu_exec_halt);
> -        assert(cpu->cc->tcg_ops->cpu_exec_interrupt);
> +        assert(tcg_ops->cpu_exec_halt);
> +        assert(tcg_ops->cpu_exec_interrupt);
>   #endif /* !CONFIG_USER_ONLY */
> -        cpu->cc->tcg_ops->initialize();
> +        tcg_ops->initialize();
>           tcg_target_initialized = true;
diff mbox series

Patch

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 8163295f34b..18d9cf0ea58 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -1070,15 +1070,15 @@  int cpu_exec(CPUState *cpu)
 
 bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
 {
-    static bool tcg_target_initialized;
+    const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
 
     if (!tcg_target_initialized) {
         /* Check mandatory TCGCPUOps handlers */
 #ifndef CONFIG_USER_ONLY
-        assert(cpu->cc->tcg_ops->cpu_exec_halt);
-        assert(cpu->cc->tcg_ops->cpu_exec_interrupt);
+        assert(tcg_ops->cpu_exec_halt);
+        assert(tcg_ops->cpu_exec_interrupt);
 #endif /* !CONFIG_USER_ONLY */
-        cpu->cc->tcg_ops->initialize();
+        tcg_ops->initialize();
         tcg_target_initialized = true;
     }