[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 15/18] cpus: Open code OBJECT_DECLARE_TYPE() in OBJECT_DECLARE_CP
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 15/18] cpus: Open code OBJECT_DECLARE_TYPE() in OBJECT_DECLARE_CPU_TYPE() |
Date: |
Tue, 10 Oct 2023 11:28:57 +0200 |
Since the OBJECT_DECLARE_CPU_TYPE() macro uses the abstract ArchCPU
type, when declaring multiple CPUs of the same ArchCPU type we get
an error related to the indirect G_DEFINE_AUTOPTR_CLEANUP_FUNC()
use within OBJECT_DECLARE_TYPE():
target/mips/cpu-qom.h:31:1: error: redefinition of
'glib_autoptr_clear_ArchCPU'
OBJECT_DECLARE_CPU_TYPE(MIPS64CPU, MIPSCPUClass, MIPS64_CPU)
^
include/hw/core/cpu.h:82:5: note: expanded from macro
'OBJECT_DECLARE_CPU_TYPE'
OBJECT_DECLARE_TYPE(ArchCPU, CpuClassType, CPU_MODULE_OBJ_NAME);
^
include/qom/object.h:237:5: note: expanded from macro 'OBJECT_DECLARE_TYPE'
G_DEFINE_AUTOPTR_CLEANUP_FUNC(InstanceType, object_unref) \
^
/usr/include/glib-2.0/glib/gmacros.h:1371:3: note: expanded from macro
'G_DEFINE_AUTOPTR_CLEANUP_FUNC'
_GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, TypeName, func)
^
/usr/include/glib-2.0/glib/gmacros.h:1354:36: note: expanded from macro
'_GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS'
static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName)
(TypeName *_ptr) \
^
/usr/include/glib-2.0/glib/gmacros.h:1338:49: note: expanded from macro
'_GLIB_AUTOPTR_CLEAR_FUNC_NAME'
#define _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) glib_autoptr_clear_##TypeName
^
<scratch space>:54:1: note: expanded from here
glib_autoptr_clear_ArchCPU
^
target/mips/cpu-qom.h:30:1: note: previous definition is here
OBJECT_DECLARE_CPU_TYPE(MIPS32CPU, MIPSCPUClass, MIPS32_CPU)
^
Avoid that problem by expanding the OBJECT_DECLARE_TYPE() macro
within OBJECT_DECLARE_CPU_TYPE().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/core/cpu.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index e02bc5980f..ab724fab3a 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -79,7 +79,12 @@ DECLARE_CLASS_CHECKERS(CPUClass, CPU,
*/
#define OBJECT_DECLARE_CPU_TYPE(CpuInstanceType, CpuClassType,
CPU_MODULE_OBJ_NAME) \
typedef struct ArchCPU CpuInstanceType; \
- OBJECT_DECLARE_TYPE(ArchCPU, CpuClassType, CPU_MODULE_OBJ_NAME);
+ typedef struct CpuClassType CpuClassType; \
+ \
+ G_DEFINE_AUTOPTR_CLEANUP_FUNC(CpuInstanceType, object_unref) \
+ \
+ DECLARE_OBJ_CHECKERS(CpuInstanceType, CpuClassType, \
+ CPU_MODULE_OBJ_NAME, TYPE_##CPU_MODULE_OBJ_NAME)
typedef enum MMUAccessType {
MMU_DATA_LOAD = 0,
--
2.41.0
- [PATCH 08/18] target/openrisc: Declare QOM definitions in 'cpu-qom.h', (continued)
- [PATCH 08/18] target/openrisc: Declare QOM definitions in 'cpu-qom.h', Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 10/18] target/riscv: Inline target specific TYPE_RISCV_CPU_BASE definition, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 09/18] target/i386: Inline target specific TARGET_DEFAULT_CPU_TYPE definition, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 12/18] target/mips: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 11/18] target/i386: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 13/18] target/ppc: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 14/18] target/sparc: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 15/18] cpus: Open code OBJECT_DECLARE_TYPE() in OBJECT_DECLARE_CPU_TYPE(),
Philippe Mathieu-Daudé <=
- [PATCH 16/18] target/i386: Make X86_CPU common to new I386_CPU / X86_64_CPU types, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 17/18] target/mips: Make MIPS_CPU common to new MIPS32_CPU / MIPS64_CPU types, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 18/18] target/sparc: Make SPARC_CPU common to new SPARC32_CPU/SPARC64_CPU types, Philippe Mathieu-Daudé, 2023/10/10