aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-10-12 11:57:44 +0200
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-10-16 18:58:10 +0200
commit709616c713f9471a993ad7d16bce23e8b88ce958 (patch)
tree0229d332acaa18a1b3baf50137ef0f608f57ca9c /include
parent7daf8f8d011cdd5d3e86930ed2bde969425c790c (diff)
downloadqemu-709616c713f9471a993ad7d16bce23e8b88ce958.zip
qemu-709616c713f9471a993ad7d16bce23e8b88ce958.tar.gz
qemu-709616c713f9471a993ad7d16bce23e8b88ce958.tar.bz2
util/cutils: Introduce freq_to_str() to display Hertz units
Introduce freq_to_str() to convert frequency values in human friendly units using the SI units for Hertz. Suggested-by: Luc Michel <luc@lmichel.fr> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Luc Michel <luc@lmichel.fr> Message-Id: <20201012095804.3335117-2-f4bug@amsat.org>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/cutils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 3a86ec0..4bbf483 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -158,6 +158,18 @@ int qemu_strtosz_metric(const char *nptr, const char **end, uint64_t *result);
char *size_to_str(uint64_t val);
+/**
+ * freq_to_str:
+ * @freq_hz: frequency to stringify
+ *
+ * Return human readable string for frequency @freq_hz.
+ * Use SI units like KHz, MHz, and so forth.
+ *
+ * The caller is responsible for releasing the value returned
+ * with g_free() after use.
+ */
+char *freq_to_str(uint64_t freq_hz);
+
/* used to print char* safely */
#define STR_OR_NULL(str) ((str) ? (str) : "null")