Introduce the target_cpu_type() helper to access the
CPU_RESOLVING_TYPE target-specific definition from
target-agnostic code.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 2 ++
meson.build | 2 ++
include/qemu/target_info.h | 19 +++++++++++++++++++
target_info-defs.c | 16 ++++++++++++++++
4 files changed, 39 insertions(+)
create mode 100644 include/qemu/target_info.h
create mode 100644 target_info-defs.c
diff --git a/MAINTAINERS b/MAINTAINERS
index c7083ab1d93..07ca088f7e8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -495,6 +495,7 @@ F: include/exec/cpu*.h
F: include/exec/exec-all.h
F: include/exec/target_long.h
F: include/qemu/accel.h
+F: include/qemu/target_info.h
F: include/system/accel-*.h
F: include/system/cpus.h
F: include/accel/accel-cpu-target.h
@@ -503,6 +504,7 @@ F: accel/Makefile.objs
F: accel/stubs/Makefile.objs
F: cpu-common.c
F: cpu-target.c
+F: target_info-defs.c
F: system/cpus.c
Apple Silicon HVF CPUs
diff --git a/meson.build b/meson.build
index bcb9d39a387..ad324d46428 100644
--- a/meson.build
+++ b/meson.build
@@ -3807,6 +3807,8 @@ endif
common_ss.add(pagevary)
specific_ss.add(files('page-target.c', 'page-vary-target.c'))
+specific_ss.add(files('target_info-defs.c'))
+
subdir('backends')
subdir('disas')
subdir('migration')
diff --git a/include/qemu/target_info.h b/include/qemu/target_info.h
new file mode 100644
index 00000000000..a53e632e735
--- /dev/null
+++ b/include/qemu/target_info.h
@@ -0,0 +1,19 @@
+/*
+ * QEMU binary/target helpers
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_TARGET_INFO_H
+#define QEMU_TARGET_INFO_H
+
+/**
+ * target_cpu_type:
+ *
+ * Returns: target CPU base QOM type name (i.e. TYPE_X86_CPU).
+ */
+const char *target_cpu_type(void);
+
+#endif
diff --git a/target_info-defs.c b/target_info-defs.c
new file mode 100644
index 00000000000..3ee89469855
--- /dev/null
+++ b/target_info-defs.c
@@ -0,0 +1,16 @@
+/*
+ * QEMU binary/target helpers (target specific)
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/target_info.h"
+#include "cpu.h"
+
+const char *target_cpu_type(void)
+{
+ return CPU_RESOLVING_TYPE;
+}
--
2.47.1