Module Name: src
Committed By: martin
Date: Fri Oct 11 17:07:17 UTC 2024
Modified Files:
src/share/man/man9 [netbsd-10]: ts2timo.9
src/sys/kern [netbsd-10]: subr_time.c
Log Message:
Pull up following revision(s) (requested by kre in ticket #942):
share/man/man9/ts2timo.9: revision 1.4
share/man/man9/ts2timo.9: revision 1.5
sys/kern/subr_time.c: revision 1.39
ts2timo() uses struct timespec, those don't have a tv_usec
field, they have tv_nsec instead. EINVAL will happen if the
tv_nsec field is invalid, not the non-existant tv_usec field.
PR kern/58733 - avoid ts2timo() clobbering its arg
See the PR for the gory details - in the TIMER_ABSTIME case
ts2timo() should not (really *must* not) alter the timespec
it is passed (in that case it should be const - but for now
anyway, cannot be for the TIMER_RELTIME case, and there is
just one of them!).
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.42.1 src/share/man/man9/ts2timo.9
cvs rdiff -u -r1.35 -r1.35.4.1 src/sys/kern/subr_time.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/share/man/man9/ts2timo.9
diff -u src/share/man/man9/ts2timo.9:1.3 src/share/man/man9/ts2timo.9:1.3.42.1
--- src/share/man/man9/ts2timo.9:1.3 Fri May 24 14:41:32 2013
+++ src/share/man/man9/ts2timo.9 Fri Oct 11 17:07:16 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: ts2timo.9,v 1.3 2013/05/24 14:41:32 njoly Exp $
+.\" $NetBSD: ts2timo.9,v 1.3.42.1 2024/10/11 17:07:16 martin Exp $
.\"
.\" Copyright (c) 2013 Christos Zoulas
.\" All rights reserved.
@@ -51,7 +51,7 @@ or
.Dv TIMER_RELTIME .
If the interval is specified as an absolute time, then the
.Fa clock_id
-clock is used to convert it to a relative time.
+clock is used to calculate the corresponding relative time.
If the
.Fa start
argument is not
@@ -63,18 +63,23 @@ clock is placed in that argument.
On success
.Fn ts2timo
returns
-.Dv 0 .
+.Dv 0 ,
+and places the computed number of ticks
+in the integer referenced by
+.Fa timo .
On failure it returns
.Er ETIMEDOUT
if interval computed was
.Dv 0
-or negative, and
+or negative, or
.Er EINVAL
-if
-.Fa ts->tv_usec
-field in the computed interval is out of range, or the
+if the
+.Fa ts->tv_nsec
+field is out of range, or the
.Fa clock_id
-argument is invalid.
+argument is invalid, or if
+computing the relative time from a supplied absolute value
+would cause an arithmetic overflow.
.Sh SEE ALSO
.Xr clock_gettime 2 ,
.Xr clock_nanosleep 2
Index: src/sys/kern/subr_time.c
diff -u src/sys/kern/subr_time.c:1.35 src/sys/kern/subr_time.c:1.35.4.1
--- src/sys/kern/subr_time.c:1.35 Tue Jun 28 02:04:51 2022
+++ src/sys/kern/subr_time.c Fri Oct 11 17:07:16 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_time.c,v 1.35 2022/06/28 02:04:51 riastradh Exp $ */
+/* $NetBSD: subr_time.c,v 1.35.4.1 2024/10/11 17:07:16 martin Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_time.c,v 1.35 2022/06/28 02:04:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_time.c,v 1.35.4.1 2024/10/11 17:07:16 martin Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -352,7 +352,8 @@ ts2timo(clockid_t clock_id, int flags, s
if ((flags & TIMER_ABSTIME) != 0) {
if (!timespecsubok(ts, &tsd))
return EINVAL;
- timespecsub(ts, &tsd, ts);
+ timespecsub(ts, &tsd, &tsd);
+ ts = &tsd;
}
error = itimespecfix(ts);