aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShengYi Hung <aokblast@FreeBSD.org>2026-03-12 09:16:24 +0000
committerShengYi Hung <aokblast@FreeBSD.org>2026-03-14 04:21:26 +0000
commit728ae49a6b81edb3eec5ab70a63bb83db8f5dce5 (patch)
tree1d178e448dd6c884da87515cdbfe074fff6d2f6d
parent4f59a7eb878f8f084e86baa58e882bc55f460a40 (diff)
kern_time: Honor the precise option when counting diff
When preecise option is used, the true elapsed time should also use the precise timer. This fixes the test case sleep_for.signals.pass.cpp in libcxx. Reviewed by: kib, imp Approved by: lwhsu (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55824
-rw-r--r--sys/kern/kern_time.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 0c16045ca610..82c2f7367ab2 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -601,7 +601,9 @@ kern_clock_nanosleep(struct thread *td, clockid_t clock_id, int flags,
} while (error == 0 && is_abs_real && td->td_rtcgen == 0);
td->td_rtcgen = 0;
if (error != EWOULDBLOCK) {
- if (TIMESEL(&sbtt, tmp))
+ if (precise)
+ sbtt = sbinuptime();
+ else if (TIMESEL(&sbtt, tmp))
sbtt += tc_tick_sbt;
if (sbtt >= sbt)
return (0);