diff options
| -rw-r--r-- | sys/kern/kern_time.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 7c06c50da828..d32579033501 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -209,7 +209,12 @@ clock_getres(p, uap) error = 0; if (SCARG(uap, tp)) { ts.tv_sec = 0; - ts.tv_nsec = 1000000000 / timecounter->tc_frequency; + /* + * 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 / timecounter->tc_frequency + 1; error = copyout(&ts, SCARG(uap, tp), sizeof(ts)); } return (error); |
