From 9276a31c3484ff236a958a1e2a38beefb0eb7ebb Mon Sep 17 00:00:00 2001 From: Luis Pires Date: Mon, 25 Oct 2021 16:11:36 -0300 Subject: host-utils: move checks out of divu128/divs128 In preparation for changing the divu128/divs128 implementations to allow for quotients larger than 64 bits, move the div-by-zero and overflow checks to the callers. Signed-off-by: Luis Pires Reviewed-by: Richard Henderson Message-Id: <20211025191154.350831-2-luis.pires@eldorado.org.br> Signed-off-by: Richard Henderson --- include/hw/clock.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/hw') diff --git a/include/hw/clock.h b/include/hw/clock.h index 11f67fb..7443e6c 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -324,8 +324,9 @@ static inline uint64_t clock_ns_to_ticks(const Clock *clk, uint64_t ns) return 0; } /* - * Ignore divu128() return value as we've caught div-by-zero and don't - * need different behaviour for overflow. + * BUG: when CONFIG_INT128 is not defined, the current implementation of + * divu128 does not return a valid truncated quotient, so the result will + * be wrong. */ divu128(&lo, &hi, clk->period); return lo; -- cgit v1.1