On 5/11/2026 12:06 PM, Richard Henderson wrote:
> Expose a const TargetInfo structure instead of a function
> returning a const pointer.
>
> Signed-off-by: Richard Henderson <[email protected]>
> ---
> include/qemu/target-info-impl.h | 11 ++++----
> include/qemu/target-info-init.h | 45 ++++++++++++++++++++++---------
> configs/targets/aarch64-softmmu.c | 18 +++----------
> configs/targets/arm-softmmu.c | 18 +++----------
> page-vary-common.c | 8 ++----
> page-vary-system.c | 6 ++---
> target-info-qom.c | 11 +++-----
> target-info-stub.c | 28 ++++---------------
> target-info.c | 12 ++++-----
> 9 files changed, 65 insertions(+), 92 deletions(-)
>
...
> diff --git a/configs/targets/aarch64-softmmu.c
> b/configs/targets/aarch64-softmmu.c
> index 75d95b0e74..4f43f3e89a 100644
> --- a/configs/targets/aarch64-softmmu.c
> +++ b/configs/targets/aarch64-softmmu.c
> @@ -7,21 +7,11 @@
> */
>
> #include "qemu/osdep.h"
> -#include "qemu/target-info-impl.h"
> -#include "qemu/target-info-init.h"
> #include "hw/arm/machines-qom.h"
> #include "target/arm/cpu-qom.h"
> #include "target/arm/cpu-param.h"
> +#include "qemu/target-info-impl.h"
> +#include "qemu/target-info-init.h"
>
> -static const TargetInfo target_info_aarch64_system = {
> - .target_name = "aarch64",
> - .target_arch = SYS_EMU_TARGET_AARCH64,
> - .long_bits = 64,
> - .cpu_type = TYPE_ARM_CPU,
> - .machine_typename = TYPE_TARGET_AARCH64_MACHINE,
> - .endianness = ENDIAN_MODE_LITTLE,
> - .page_bits_vary = true,
> - .page_bits_init = TARGET_PAGE_BITS_LEGACY,
> -};
> -
> -target_info_init(target_info_aarch64_system)
> +DEF_TARGET_INFO(target_info_aarch64_system,
> + TYPE_ARM_CPU, TYPE_TARGET_AARCH64_MACHINE)
While it's definitely less code to type, I don't think it's really good
to bury that under yet another macro. Code repetition is not always a
bad thing, as long as it's not code we'll have to modify everyday. Those
definitions will probably never be modified in the future.
In a single grep, developer can directly see the specifics of this
target, without having to guess any header name or refer to another
file. As well, the target_info_init patterns follows the x_init pattern
coming from module_init.
Regards,
Pierrick