On 2025/05/19 23:54, Alex Bennée wrote:
Akihiko Odaki <akihiko.od...@daynix.com> writes:
On 2025/05/06 21:57, Alex Bennée wrote:
It's easy to get lost in zeros while setting the numbers of
instructions per second. Add a scaling suffix to make things simpler.
Signed-off-by: Alex Bennée <alex.ben...@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouv...@linaro.org>
---
v2
- normalise the suffix before a full strcmp0
- check endptr actually set
- fix checkpatch
---
contrib/plugins/ips.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c
index e5297dbb01..9b166a7d6c 100644
--- a/contrib/plugins/ips.c
+++ b/contrib/plugins/ips.c
@@ -20,6 +20,8 @@
QEMU_PLUGIN_EXPORT int qemu_plugin_version =
QEMU_PLUGIN_VERSION;
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
G_N_ELEMENTS() is already available.
/* how many times do we update time per sec */
#define NUM_TIME_UPDATE_PER_SEC 10
#define NSEC_IN_ONE_SEC (1000 * 1000 * 1000)
@@ -129,6 +131,18 @@ static void plugin_exit(qemu_plugin_id_t id, void *udata)
qemu_plugin_scoreboard_free(vcpus);
}
+typedef struct {
+ const char *suffix;
+ unsigned long multipler;
I prefer to have an explicitly-sized type: uint32_t in this case. It
also saves typing several characters as a bonus.
4Ghz would be a reasonable size and that would overflow a simple
uint32_t unless we start casting.
unsigned long can be 32-bit so it should be uint64_t if you want to
avoid overflow without casting.
Regards,
Akihiko Odaki