summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_time.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 417a754..46645ea 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -214,7 +214,12 @@ clock_getres(struct thread *td, struct clock_getres_args *uap)
error = 0;
if (SCARG(uap, tp)) {
ts.tv_sec = 0;
- ts.tv_nsec = 1000000000 / tc_getfrequency();
+ /*
+ * Round up the result of the division cheaply by adding 1.
+ * Rounding up is especially important if rounding down
+ * would give 0. Perfect rounding is unimportant.
+ */
+ ts.tv_nsec = 1000000000 / tc_getfrequency() + 1;
error = copyout(&ts, SCARG(uap, tp), sizeof(ts));
}
return (error);
OpenPOWER on IntegriCloud