From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com,
bmeng@tinylab.org, liweiwei@iscas.ac.cn,
zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Subject: [PATCH for-8.2 v2 5/7] target/riscv/cpu.c: add a ADD_CPU_PROPERTIES_ARRAY() macro
Date: Wed, 12 Jul 2023 17:57:46 -0300 [thread overview]
Message-ID: <20230712205748.446931-6-dbarboza@ventanamicro.com> (raw)
In-Reply-To: <20230712205748.446931-1-dbarboza@ventanamicro.com>
The code inside riscv_cpu_add_user_properties() became quite repetitive
after recent changes. Add a macro to hide the repetition away.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
target/riscv/cpu.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index c0826b449d..b61465c8c4 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1881,6 +1881,11 @@ static void cpu_set_cfg_unavailable(Object *obj, Visitor *v,
}
#endif
+#define ADD_CPU_PROPERTIES_ARRAY(_dev, _array) \
+ for (prop = _array; prop && prop->name; prop++) { \
+ qdev_property_add_static(_dev, prop); \
+ } \
+
/*
* Add CPU properties with user-facing flags.
*
@@ -1924,17 +1929,9 @@ static void riscv_cpu_add_user_properties(Object *obj)
qdev_property_add_static(dev, prop);
}
- for (prop = riscv_cpu_options; prop && prop->name; prop++) {
- qdev_property_add_static(dev, prop);
- }
-
- for (prop = riscv_cpu_vendor_exts; prop && prop->name; prop++) {
- qdev_property_add_static(dev, prop);
- }
-
- for (prop = riscv_cpu_experimental_exts; prop && prop->name; prop++) {
- qdev_property_add_static(dev, prop);
- }
+ ADD_CPU_PROPERTIES_ARRAY(dev, riscv_cpu_options);
+ ADD_CPU_PROPERTIES_ARRAY(dev, riscv_cpu_vendor_exts);
+ ADD_CPU_PROPERTIES_ARRAY(dev, riscv_cpu_experimental_exts);
}
static Property riscv_cpu_properties[] = {
--
2.41.0
next prev parent reply other threads:[~2023-07-12 20:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 20:57 [PATCH for-8.2 v2 0/7] target/riscv: add 'max' CPU type Daniel Henrique Barboza
2023-07-12 20:57 ` [PATCH for-8.2 v2 1/7] target/riscv/cpu.c: split CPU options from riscv_cpu_extensions[] Daniel Henrique Barboza
2023-07-14 3:13 ` Alistair Francis
2023-07-12 20:57 ` [PATCH for-8.2 v2 2/7] target/riscv/cpu.c: skip 'bool' check when filtering KVM props Daniel Henrique Barboza
2023-07-14 3:15 ` Alistair Francis
2023-07-12 20:57 ` [PATCH for-8.2 v2 3/7] target/riscv/cpu.c: split vendor exts from riscv_cpu_extensions[] Daniel Henrique Barboza
2023-07-14 3:14 ` Alistair Francis
2023-07-12 20:57 ` [PATCH for-8.2 v2 4/7] target/riscv/cpu.c: split non-ratified " Daniel Henrique Barboza
2023-07-14 3:15 ` Alistair Francis
2023-07-12 20:57 ` Daniel Henrique Barboza [this message]
2023-07-13 20:40 ` [PATCH for-8.2 v2 5/7] target/riscv/cpu.c: add a ADD_CPU_PROPERTIES_ARRAY() macro Richard Henderson
2023-07-13 21:27 ` Daniel Henrique Barboza
2023-07-14 6:30 ` Richard Henderson
2023-07-12 20:57 ` [PATCH for-8.2 v2 6/7] target/riscv: add 'max' CPU type Daniel Henrique Barboza
2023-07-14 3:10 ` Alistair Francis
2023-07-12 20:57 ` [PATCH for-8.2 v2 7/7] avocado, risc-v: add opensbi tests for 'max' CPU Daniel Henrique Barboza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230712205748.446931-6-dbarboza@ventanamicro.com \
--to=dbarboza@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=bmeng@tinylab.org \
--cc=liweiwei@iscas.ac.cn \
--cc=palmer@rivosinc.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).