Make ts2timo(9) always return the absolute start time if the start argument

is present, and handle the TIMER_ABSTIME case in nanosleep1(9).
This commit is contained in:
christos 2013-05-22 16:00:52 +00:00
parent b2c25544ca
commit 39d23ee140
2 changed files with 14 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_time.c,v 1.178 2013/03/31 16:45:06 christos Exp $ */
/* $NetBSD: kern_time.c,v 1.179 2013/05/22 16:00:52 christos Exp $ */
/*-
* Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.178 2013/03/31 16:45:06 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.179 2013/05/22 16:00:52 christos Exp $");
#include <sys/param.h>
#include <sys/resourcevar.h>
@ -345,8 +345,12 @@ again:
(void)clock_gettime1(clock_id, &rmtend);
t = (rmt != NULL) ? rmt : &t0;
timespecsub(&rmtend, &rmtstart, t);
timespecsub(rqt, t, t);
if (flags & TIMER_ABSTIME) {
timespecsub(rqt, &rmtend, t);
} else {
timespecsub(&rmtend, &rmtstart, t);
timespecsub(rqt, t, t);
}
if (t->tv_sec < 0)
timespecclear(t);
if (error == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_time.c,v 1.16 2013/05/21 16:25:55 bouyer Exp $ */
/* $NetBSD: subr_time.c,v 1.17 2013/05/22 16:00:52 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_time.c,v 1.16 2013/05/21 16:25:55 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_time.c,v 1.17 2013/05/22 16:00:52 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -246,15 +246,13 @@ ts2timo(clockid_t clock_id, int flags, struct timespec *ts,
int error;
struct timespec tsd;
if (flags && start != NULL)
memset(start, 0, sizeof(*start));
flags &= TIMER_ABSTIME;
if (start == NULL || flags)
if (start == NULL)
start = &tsd;
if ((error = clock_gettime1(clock_id, start)) != 0)
return error;
if (flags || start != &tsd)
if ((error = clock_gettime1(clock_id, start)) != 0)
return error;
if (flags)
timespecsub(ts, start, ts);