diff mbox series

[RFC,09/19] accel: Factor accel_cpu_realize() out

Message ID 20250606164418.98655-10-philmd@linaro.org
State New
Headers show
Series accel: Preparatory cleanups for split-accel | expand

Commit Message

Philippe Mathieu-Daudé June 6, 2025, 4:44 p.m. UTC
Factor accel_cpu_realize() out of accel_cpu_common_realize()
for re-use.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/accel-internal.h |  2 ++
 include/qemu/accel.h   |  2 ++
 accel/accel-common.c   | 15 ++++++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

Comments

Alex Bennée June 11, 2025, 1:46 p.m. UTC | #1
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> Factor accel_cpu_realize() out of accel_cpu_common_realize()
> for re-use.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  accel/accel-internal.h |  2 ++
>  include/qemu/accel.h   |  2 ++
>  accel/accel-common.c   | 15 ++++++++++++---
>  3 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/accel/accel-internal.h b/accel/accel-internal.h
> index d3a4422cbf7..b541377c349 100644
> --- a/accel/accel-internal.h
> +++ b/accel/accel-internal.h
> @@ -14,4 +14,6 @@
>  
>  void accel_init_ops_interfaces(AccelClass *ac);
>  
> +bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp);
> +
>  #endif /* ACCEL_SYSTEM_H */
> diff --git a/include/qemu/accel.h b/include/qemu/accel.h
> index c660c5f4b11..3c9aaf9523c 100644
> --- a/include/qemu/accel.h
> +++ b/include/qemu/accel.h
> @@ -91,6 +91,8 @@ void accel_setup_post(MachineState *ms);
>   */
>  void accel_cpu_instance_init(CPUState *cpu);
>  
> +bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp);
> +

Duplicate forward declarations:

  FAILED: libuser.a.p/accel_accel-user.c.o 
  cc -m64 -Ilibuser.a.p -I. -I../.. -I../../common-user/host/x86_64 -I../../linux-user/include/host/x86_64 -I../../linux-user/include -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow=local -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /home/alex/lsrc/qemu.git/linux-headers -isystem linux-headers -iquote . -iquote /home/alex/lsrc/qemu.git -iquote /home/alex/lsrc/qemu.git/include -iquote /home/alex/lsrc/qemu.git/host/include/x86_64 -iquote /home/alex/lsrc/qemu.git/host/include/generic -iquote /home/alex/lsrc/qemu.git/tcg/i386 -pthread -mcx16 -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero -fzero-call-used-regs=used-gpr -gsplit-dwarf -fPIE -DCONFIG_USER_ONLY -DCOMPILING_SYSTEM_VS_USER -MD -MQ libuser.a.p/accel_accel-user.c.o -MF libuser.a.p/accel_accel-user.c.o.d -o libuser.a.p/accel_accel-user.c.o -c ../../accel/accel-user.c
  In file included from ../../accel/accel-user.c:12:
  ../../accel/accel-internal.h:17:6: error: redundant redeclaration of ‘accel_cpu_realize’ [-Werror=redundant-decls]
     17 | bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp);
        |      ^~~~~~~~~~~~~~~~~
  In file included from ../../accel/accel-user.c:11:
  /home/alex/lsrc/qemu.git/include/qemu/accel.h:94:6: note: previous declaration of ‘accel_cpu_realize’ with type ‘_Bool(AccelState *, CPUState *, Error **)’
     94 | bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp);
        |      ^~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
diff mbox series

Patch

diff --git a/accel/accel-internal.h b/accel/accel-internal.h
index d3a4422cbf7..b541377c349 100644
--- a/accel/accel-internal.h
+++ b/accel/accel-internal.h
@@ -14,4 +14,6 @@ 
 
 void accel_init_ops_interfaces(AccelClass *ac);
 
+bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp);
+
 #endif /* ACCEL_SYSTEM_H */
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index c660c5f4b11..3c9aaf9523c 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -91,6 +91,8 @@  void accel_setup_post(MachineState *ms);
  */
 void accel_cpu_instance_init(CPUState *cpu);
 
+bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp);
+
 /**
  * accel_cpu_common_realize:
  * @cpu: The CPU that needs to call accel-specific cpu realization.
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 4894b98d64a..4f3b42e7112 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -88,10 +88,14 @@  void accel_cpu_instance_init(CPUState *cpu)
     }
 }
 
-bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
+bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp)
 {
-    AccelState *accel = current_accel();
-    AccelClass *acc = ACCEL_GET_CLASS(accel);
+    AccelClass *acc;
+
+    if (!accel) {
+        accel = current_accel();
+    }
+    acc = ACCEL_GET_CLASS(accel);
 
     /* target specific realization */
     if (cpu->cc->accel_cpu
@@ -108,6 +112,11 @@  bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
     return true;
 }
 
+bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
+{
+    return accel_cpu_realize(NULL, cpu, errp);
+}
+
 void accel_cpu_common_unrealize(CPUState *cpu)
 {
     AccelState *accel = current_accel();