aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2018-07-30 15:46:40 +0000
committerAlan Somers <asomers@FreeBSD.org>2018-07-30 15:46:40 +0000
commit6040822c4e20fb46638ecaaad543fc56f6ec2b0f (patch)
tree133352663bf8c98c65abf581f6a4a8769325ca09 /sys/kern
parent19fe43f796f3d962b3bf023a4484a82d7b2a5711 (diff)
Notes
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_sig.c6
-rw-r--r--sys/kern/kern_tc.c2
-rw-r--r--sys/kern/kern_time.c20
-rw-r--r--sys/kern/kern_umtx.c10
-rw-r--r--sys/kern/subr_rtc.c4
-rw-r--r--sys/kern/uipc_mqueue.c6
-rw-r--r--sys/kern/uipc_sem.c2
7 files changed, 23 insertions, 27 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 9c25ed85e4ba..a2b07974bdb5 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1261,8 +1261,7 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, ksiginfo_t *ksi,
if (timeout->tv_nsec >= 0 && timeout->tv_nsec < 1000000000) {
timevalid = 1;
getnanouptime(&rts);
- ets = rts;
- timespecadd(&ets, timeout);
+ timespecadd(&rts, timeout, &ets);
}
}
ksiginfo_init(ksi);
@@ -1302,8 +1301,7 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, ksiginfo_t *ksi,
error = EAGAIN;
break;
}
- ts = ets;
- timespecsub(&ts, &rts);
+ timespecsub(&ets, &rts, &ts);
TIMESPEC_TO_TIMEVAL(&tv, &ts);
timo = tvtohz(&tv);
} else {
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index e3eb37bce322..e55290df7852 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -1847,7 +1847,7 @@ pps_event(struct pps_state *pps, int event)
*tsp = ts;
if (foff) {
- timespecadd(tsp, osp);
+ timespecadd(tsp, osp, tsp);
if (tsp->tv_nsec < 0) {
tsp->tv_nsec += 1000000000;
tsp->tv_sec -= 1;
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index be9e5c830ab0..3b6b42b64b31 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -543,7 +543,7 @@ kern_clock_nanosleep(struct thread *td, clockid_t clock_id, int flags,
atomic_load_acq_int(&rtc_generation);
error = kern_clock_gettime(td, clock_id, &now);
KASSERT(error == 0, ("kern_clock_gettime: %d", error));
- timespecsub(&ts, &now);
+ timespecsub(&ts, &now, &ts);
}
if (ts.tv_sec < 0 || (ts.tv_sec == 0 && ts.tv_nsec == 0)) {
error = EWOULDBLOCK;
@@ -1520,7 +1520,7 @@ realtimer_gettime(struct itimer *it, struct itimerspec *ovalue)
realtimer_clocktime(it->it_clockid, &cts);
*ovalue = it->it_time;
if (ovalue->it_value.tv_sec != 0 || ovalue->it_value.tv_nsec != 0) {
- timespecsub(&ovalue->it_value, &cts);
+ timespecsub(&ovalue->it_value, &cts, &ovalue->it_value);
if (ovalue->it_value.tv_sec < 0 ||
(ovalue->it_value.tv_sec == 0 &&
ovalue->it_value.tv_nsec == 0)) {
@@ -1561,9 +1561,10 @@ realtimer_settime(struct itimer *it, int flags,
ts = val.it_value;
if ((flags & TIMER_ABSTIME) == 0) {
/* Convert to absolute time. */
- timespecadd(&it->it_time.it_value, &cts);
+ timespecadd(&it->it_time.it_value, &cts,
+ &it->it_time.it_value);
} else {
- timespecsub(&ts, &cts);
+ timespecsub(&ts, &cts, &ts);
/*
* We don't care if ts is negative, tztohz will
* fix it.
@@ -1631,22 +1632,23 @@ realtimer_expire(void *arg)
if (timespeccmp(&cts, &it->it_time.it_value, >=)) {
if (timespecisset(&it->it_time.it_interval)) {
timespecadd(&it->it_time.it_value,
- &it->it_time.it_interval);
+ &it->it_time.it_interval,
+ &it->it_time.it_value);
while (timespeccmp(&cts, &it->it_time.it_value, >=)) {
if (it->it_overrun < INT_MAX)
it->it_overrun++;
else
it->it_ksi.ksi_errno = ERANGE;
timespecadd(&it->it_time.it_value,
- &it->it_time.it_interval);
+ &it->it_time.it_interval,
+ &it->it_time.it_value);
}
} else {
/* single shot timer ? */
timespecclear(&it->it_time.it_value);
}
if (timespecisset(&it->it_time.it_value)) {
- ts = it->it_time.it_value;
- timespecsub(&ts, &cts);
+ timespecsub(&it->it_time.it_value, &cts, &ts);
TIMESPEC_TO_TIMEVAL(&tv, &ts);
callout_reset(&it->it_callout, tvtohz(&tv),
realtimer_expire, it);
@@ -1658,7 +1660,7 @@ realtimer_expire(void *arg)
itimer_leave(it);
} else if (timespecisset(&it->it_time.it_value)) {
ts = it->it_time.it_value;
- timespecsub(&ts, &cts);
+ timespecsub(&ts, &cts, &ts);
TIMESPEC_TO_TIMEVAL(&tv, &ts);
callout_reset(&it->it_callout, tvtohz(&tv), realtimer_expire,
it);
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 63e394eafe7a..8beea32666a6 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -772,8 +772,7 @@ abs_timeout_init(struct abs_timeout *timo, int clockid, int absolute,
if (!absolute) {
timo->is_abs_real = false;
abs_timeout_update(timo);
- timo->end = timo->cur;
- timespecadd(&timo->end, timeout);
+ timespecadd(&timo->cur, timeout, &timo->end);
} else {
timo->end = *timeout;
timo->is_abs_real = clockid == CLOCK_REALTIME ||
@@ -811,8 +810,7 @@ abs_timeout_gethz(struct abs_timeout *timo)
if (timespeccmp(&timo->end, &timo->cur, <=))
return (-1);
- tts = timo->end;
- timespecsub(&tts, &timo->cur);
+ timespecsub(&timo->end, &timo->cur, &tts);
return (tstohz(&tts));
}
@@ -3247,8 +3245,8 @@ do_sem2_wait(struct thread *td, struct _usem2 *sem, struct _umtx_time *timeout)
error = EINTR;
if (error == EINTR) {
abs_timeout_update(&timo);
- timeout->_timeout = timo.end;
- timespecsub(&timeout->_timeout, &timo.cur);
+ timespecsub(&timo.end, &timo.cur,
+ &timeout->_timeout);
}
}
}
diff --git a/sys/kern/subr_rtc.c b/sys/kern/subr_rtc.c
index 66cde8fb2e07..82c276f210a2 100644
--- a/sys/kern/subr_rtc.c
+++ b/sys/kern/subr_rtc.c
@@ -144,7 +144,7 @@ settime_task_func(void *arg, int pending)
getnanotime(&ts);
if (!(rtc->flags & CLOCKF_SETTIME_NO_ADJ)) {
ts.tv_sec -= utc_offset();
- timespecadd(&ts, &rtc->resadj);
+ timespecadd(&ts, &rtc->resadj, &ts);
}
} else {
ts.tv_sec = 0;
@@ -301,7 +301,7 @@ read_clocks(struct timespec *ts, bool debug_read)
continue;
}
if (!(rtc->flags & CLOCKF_GETTIME_NO_ADJ)) {
- timespecadd(ts, &rtc->resadj);
+ timespecadd(ts, &rtc->resadj, ts);
ts->tv_sec += utc_offset();
}
if (!debug_read) {
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index 26c9dee23796..4751635e2aee 100644
--- a/sys/kern/uipc_mqueue.c
+++ b/sys/kern/uipc_mqueue.c
@@ -1735,9 +1735,8 @@ mqueue_send(struct mqueue *mq, const char *msg_ptr,
goto bad;
}
for (;;) {
- ts2 = *abs_timeout;
getnanotime(&ts);
- timespecsub(&ts2, &ts);
+ timespecsub(abs_timeout, &ts, &ts2);
if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) {
error = ETIMEDOUT;
break;
@@ -1887,9 +1886,8 @@ mqueue_receive(struct mqueue *mq, char *msg_ptr,
}
for (;;) {
- ts2 = *abs_timeout;
getnanotime(&ts);
- timespecsub(&ts2, &ts);
+ timespecsub(abs_timeout, &ts, &ts2);
if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) {
error = ETIMEDOUT;
return (error);
diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c
index f4e36026a90c..faa61bfea352 100644
--- a/sys/kern/uipc_sem.c
+++ b/sys/kern/uipc_sem.c
@@ -843,7 +843,7 @@ kern_sem_wait(struct thread *td, semid_t id, int tryflag,
for (;;) {
ts1 = *abstime;
getnanotime(&ts2);
- timespecsub(&ts1, &ts2);
+ timespecsub(&ts1, &ts2, &ts1);
TIMESPEC_TO_TIMEVAL(&tv, &ts1);
if (tv.tv_sec < 0) {
error = ETIMEDOUT;