diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2020-12-15 15:09:26 +0000 |
|---|---|---|
| committer | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2021-01-04 23:24:44 +0100 |
| commit | 554d523785ef8681905ec13ad28a025ec0af40fe (patch) | |
| tree | 6fe5df390462c7057643ebcfcaec2624b5af2ef4 /hw/core/clock.c | |
| parent | 7886a674f13320c8e1a0744f3794e8caeeff874a (diff) | |
| download | focaccia-qemu-554d523785ef8681905ec13ad28a025ec0af40fe.tar.gz focaccia-qemu-554d523785ef8681905ec13ad28a025ec0af40fe.zip | |
clock: Introduce clock_ticks_to_ns()
The clock_get_ns() API claims to return the period of a clock in nanoseconds. Unfortunately since it returns an integer and a clock's period is represented in units of 2^-32 nanoseconds, the result is often an approximation, and calculating a clock expiry deadline by multiplying clock_get_ns() by a number-of-ticks is unacceptably inaccurate. Introduce a new API clock_ticks_to_ns() which returns the number of nanoseconds it takes the clock to make a given number of ticks. This function can do the complete calculation internally and will thus give a more accurate result. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Luc Michel <luc@lmichel.fr> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20201215150929.30311-2-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Diffstat (limited to 'hw/core/clock.c')
0 files changed, 0 insertions, 0 deletions