[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-8.2 v3 5/8] target/riscv/cpu.c: add a ADD_CPU_PROPERTIES_ARRA
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH for-8.2 v3 5/8] target/riscv/cpu.c: add a ADD_CPU_PROPERTIES_ARRAY() macro |
Date: |
Fri, 14 Jul 2023 14:43:08 -0300 |
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 | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 5689368f02..f7083b2d5c 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1875,6 +1875,13 @@ static void cpu_set_cfg_unavailable(Object *obj, Visitor
*v,
}
#endif
+#define ADD_CPU_PROPERTIES_ARRAY(_dev, _array) \
+ do { \
+ for (int i = 0; i < ARRAY_SIZE(_array); i++) { \
+ qdev_property_add_static(_dev, &_array[i]); \
+ } \
+ } while (0)
+
/*
* Add CPU properties with user-facing flags.
*
@@ -1918,17 +1925,9 @@ static void riscv_cpu_add_user_properties(Object *obj)
qdev_property_add_static(dev, prop);
}
- for (int i = 0; i < ARRAY_SIZE(riscv_cpu_options); i++) {
- qdev_property_add_static(dev, &riscv_cpu_options[i]);
- }
-
- for (int i = 0; i < ARRAY_SIZE(riscv_cpu_vendor_exts); i++) {
- qdev_property_add_static(dev, &riscv_cpu_vendor_exts[i]);
- }
-
- for (int i = 0; i < ARRAY_SIZE(riscv_cpu_experimental_exts); i++) {
- qdev_property_add_static(dev, &riscv_cpu_experimental_exts[i]);
- }
+ 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
- [PATCH for-8.2 v3 0/8] target/riscv: add 'max' CPU, deprecate, Daniel Henrique Barboza, 2023/07/14
- [PATCH for-8.2 v3 1/8] target/riscv/cpu.c: split CPU options from riscv_cpu_extensions[], Daniel Henrique Barboza, 2023/07/14
- [PATCH for-8.2 v3 2/8] target/riscv/cpu.c: skip 'bool' check when filtering KVM props, Daniel Henrique Barboza, 2023/07/14
- [PATCH for-8.2 v3 3/8] target/riscv/cpu.c: split vendor exts from riscv_cpu_extensions[], Daniel Henrique Barboza, 2023/07/14
- [PATCH for-8.2 v3 4/8] target/riscv/cpu.c: split non-ratified exts from riscv_cpu_extensions[], Daniel Henrique Barboza, 2023/07/14
- [PATCH for-8.2 v3 5/8] target/riscv/cpu.c: add a ADD_CPU_PROPERTIES_ARRAY() macro,
Daniel Henrique Barboza <=
- [PATCH for-8.2 v3 6/8] target/riscv: add 'max' CPU type, Daniel Henrique Barboza, 2023/07/14
- [PATCH for-8.2 v3 7/8] avocado, risc-v: add opensbi tests for 'max' CPU, Daniel Henrique Barboza, 2023/07/14
- [PATCH for-8.2 v3 8/8] target/riscv: deprecate the 'any' CPU type, Daniel Henrique Barboza, 2023/07/14
- Re: [PATCH for-8.2 v3 0/8] target/riscv: add 'max' CPU, deprecate, Daniel Henrique Barboza, 2023/07/18