diff options
author | Alan Somers <asomers@FreeBSD.org> | 2018-07-30 15:46:40 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2018-07-30 15:46:40 +0000 |
commit | 6040822c4e20fb46638ecaaad543fc56f6ec2b0f (patch) | |
tree | 133352663bf8c98c65abf581f6a4a8769325ca09 /sys | |
parent | 19fe43f796f3d962b3bf023a4484a82d7b2a5711 (diff) | |
download | src-6040822c4e20fb46638ecaaad543fc56f6ec2b0f.tar.gz src-6040822c4e20fb46638ecaaad543fc56f6ec2b0f.zip |
Make timespecadd(3) and friends public
The timespecadd(3) family of macros were imported from NetBSD back in
r35029. However, they were initially guarded by #ifdef _KERNEL. In the
meantime, we have grown at least 28 syscalls that use timespecs in some
way, leading many programs both inside and outside of the base system to
redefine those macros. It's better just to make the definitions public.
Our kernel currently defines two-argument versions of timespecadd and
timespecsub. NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define
three-argument versions. Solaris also defines a three-argument version, but
only in its kernel. This revision changes our definition to match the
common three-argument version.
Bump _FreeBSD_version due to the breaking KPI change.
Discussed with: cem, jilles, ian, bde
Differential Revision: https://reviews.freebsd.org/D14725
Notes
Notes:
svn path=/head/; revision=336914
Diffstat (limited to 'sys')
31 files changed, 84 insertions, 88 deletions
diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index ae6cb83c9e7a..bb4825574ed5 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -1183,7 +1183,7 @@ linux_timerfd_curval(struct timerfd *tfd, struct itimerspec *ots) linux_timerfd_clocktime(tfd, &cts); *ots = tfd->tfd_time; if (ots->it_value.tv_sec != 0 || ots->it_value.tv_nsec != 0) { - timespecsub(&ots->it_value, &cts); + timespecsub(&ots->it_value, &cts, &ots->it_value); if (ots->it_value.tv_sec < 0 || (ots->it_value.tv_sec == 0 && ots->it_value.tv_nsec == 0)) { @@ -1265,9 +1265,10 @@ linux_timerfd_settime(struct thread *td, struct linux_timerfd_settime_args *args linux_timerfd_clocktime(tfd, &cts); ts = nts.it_value; if ((args->flags & LINUX_TFD_TIMER_ABSTIME) == 0) { - timespecadd(&tfd->tfd_time.it_value, &cts); + timespecadd(&tfd->tfd_time.it_value, &cts, + &tfd->tfd_time.it_value); } else { - timespecsub(&ts, &cts); + timespecsub(&ts, &cts, &ts); } TIMESPEC_TO_TIMEVAL(&tv, &ts); callout_reset(&tfd->tfd_callout, tvtohz(&tv), @@ -1303,13 +1304,13 @@ linux_timerfd_expire(void *arg) if (timespeccmp(&cts, &tfd->tfd_time.it_value, >=)) { if (timespecisset(&tfd->tfd_time.it_interval)) timespecadd(&tfd->tfd_time.it_value, - &tfd->tfd_time.it_interval); + &tfd->tfd_time.it_interval, + &tfd->tfd_time.it_value); else /* single shot timer */ timespecclear(&tfd->tfd_time.it_value); if (timespecisset(&tfd->tfd_time.it_value)) { - ts = tfd->tfd_time.it_value; - timespecsub(&ts, &cts); + timespecsub(&tfd->tfd_time.it_value, &cts, &ts); TIMESPEC_TO_TIMEVAL(&tv, &ts); callout_reset(&tfd->tfd_callout, tvtohz(&tv), linux_timerfd_expire, tfd); @@ -1319,8 +1320,7 @@ linux_timerfd_expire(void *arg) selwakeup(&tfd->tfd_sel); wakeup(&tfd->tfd_count); } else if (timespecisset(&tfd->tfd_time.it_value)) { - ts = tfd->tfd_time.it_value; - timespecsub(&ts, &cts); + timespecsub(&tfd->tfd_time.it_value, &cts, &ts); TIMESPEC_TO_TIMEVAL(&tv, &ts); callout_reset(&tfd->tfd_callout, tvtohz(&tv), linux_timerfd_expire, tfd); diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index a82672eaa4f1..7c15af2d89c2 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -290,10 +290,10 @@ futex_copyin_timeout(int op, struct l_timespec *luts, int clockrt, return (error); if (clockrt) { nanotime(&kts); - timespecsub(ts, &kts); + timespecsub(ts, &kts, ts); } else if (op == LINUX_FUTEX_WAIT_BITSET) { nanouptime(&kts); - timespecsub(ts, &kts); + timespecsub(ts, &kts, ts); } return (error); } diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 95a8ab174e9d..516952fac490 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -2382,8 +2382,8 @@ linux_ppoll(struct thread *td, struct linux_ppoll_args *args) if (error == 0 && args->tsp != NULL) { if (td->td_retval[0]) { nanotime(&ts1); - timespecsub(&ts1, &ts0); - timespecsub(&uts, &ts1); + timespecsub(&ts1, &ts0, &ts1); + timespecsub(&uts, &ts1, &uts); if (uts.tv_sec < 0) timespecclear(&uts); } else diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 604627048ed0..d4f567b5192f 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1463,7 +1463,7 @@ linux_recvmmsg(struct thread *td, struct linux_recvmmsg_args *args) if (error != 0) return (error); getnanotime(&tts); - timespecadd(&tts, &ts); + timespecadd(&tts, &ts, &tts); } msg = PTRIN(args->msg); @@ -1492,7 +1492,7 @@ linux_recvmmsg(struct thread *td, struct linux_recvmmsg_args *args) */ if (args->timeout) { getnanotime(&ts); - timespecsub(&ts, &tts); + timespecsub(&ts, &tts, &ts); if (!timespecisset(&ts) || ts.tv_sec > 0) break; } diff --git a/sys/compat/linuxkpi/common/include/linux/time.h b/sys/compat/linuxkpi/common/include/linux/time.h index 9f69e95f6bf5..1c07c69a67a6 100644 --- a/sys/compat/linuxkpi/common/include/linux/time.h +++ b/sys/compat/linuxkpi/common/include/linux/time.h @@ -76,9 +76,7 @@ timespec_sub(struct timespec lhs, struct timespec rhs) { struct timespec ts; - ts.tv_sec = lhs.tv_sec; - ts.tv_nsec = lhs.tv_nsec; - timespecsub(&ts, &rhs); + timespecsub(&lhs, &rhs, &ts); return ts; } diff --git a/sys/dev/acpica/acpi_cmbat.c b/sys/dev/acpica/acpi_cmbat.c index 7dbfa0334559..b4835bb66cda 100644 --- a/sys/dev/acpica/acpi_cmbat.c +++ b/sys/dev/acpica/acpi_cmbat.c @@ -229,7 +229,7 @@ acpi_cmbat_info_expired(struct timespec *lastupdated) return (TRUE); getnanotime(&curtime); - timespecsub(&curtime, lastupdated); + timespecsub(&curtime, lastupdated, &curtime); return (curtime.tv_sec < 0 || curtime.tv_sec > acpi_battery_get_info_expire()); } diff --git a/sys/dev/acpica/acpi_smbat.c b/sys/dev/acpica/acpi_smbat.c index dfc9938e0302..af09f383b843 100644 --- a/sys/dev/acpica/acpi_smbat.c +++ b/sys/dev/acpica/acpi_smbat.c @@ -170,7 +170,7 @@ acpi_smbat_info_expired(struct timespec *lastupdated) return (TRUE); getnanotime(&curtime); - timespecsub(&curtime, lastupdated); + timespecsub(&curtime, lastupdated, &curtime); return (curtime.tv_sec < 0 || curtime.tv_sec > acpi_battery_get_info_expire()); } diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c index b2b2a13aa889..f3ff8242591a 100644 --- a/sys/dev/acpica/acpi_thermal.c +++ b/sys/dev/acpica/acpi_thermal.c @@ -535,7 +535,7 @@ acpi_tz_monitor(void *Context) (newactive == TZ_ACTIVE_NONE || newactive > sc->tz_active)) { getnanotime(&curtime); - timespecsub(&curtime, &sc->tz_cooling_started); + timespecsub(&curtime, &sc->tz_cooling_started, &curtime); if (curtime.tv_sec < acpi_tz_min_runtime) newactive = sc->tz_active; } diff --git a/sys/dev/drm2/i915/i915_gem.c b/sys/dev/drm2/i915/i915_gem.c index 33f0d9953ecd..4dfb90753b6c 100644 --- a/sys/dev/drm2/i915/i915_gem.c +++ b/sys/dev/drm2/i915/i915_gem.c @@ -1135,8 +1135,8 @@ static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno, #undef EXIT_COND if (timeout) { - timespecsub(&now, &before); - timespecsub(timeout, &now); + timespecsub(&now, &before, &now); + timespecsub(timeout, &now, timeout); } switch (end) { diff --git a/sys/dev/drm2/i915/intel_pm.c b/sys/dev/drm2/i915/intel_pm.c index 143c92a97200..a2c409f15dfe 100644 --- a/sys/dev/drm2/i915/intel_pm.c +++ b/sys/dev/drm2/i915/intel_pm.c @@ -3102,8 +3102,7 @@ static void __i915_update_gfx_val(struct drm_i915_private *dev_priv) mtx_assert(&mchdev_lock, MA_OWNED); nanotime(&now); - diff1 = now; - timespecsub(&diff1, &dev_priv->ips.last_time2); + timespecsub(&now, &dev_priv->ips.last_time2, &diff1); /* Don't divide by 0 */ diffms = diff1.tv_sec * 1000 + diff1.tv_nsec / 1000000; diff --git a/sys/dev/efidev/efirtc.c b/sys/dev/efidev/efirtc.c index 1e5784b19263..b9e06bcc362e 100644 --- a/sys/dev/efidev/efirtc.c +++ b/sys/dev/efidev/efirtc.c @@ -163,7 +163,7 @@ efirtc_settime(device_t dev, struct timespec *ts) */ ts->tv_sec -= utc_offset(); if (!efirtc_zeroes_subseconds) - timespecadd(ts, &efirtc_resadj); + timespecadd(ts, &efirtc_resadj, ts); clock_ts_to_ct(ts, &ct); clock_dbgprint_ct(dev, CLOCK_DBG_WRITE, &ct); diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index 3f7850829b91..693df8f66463 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -4083,8 +4083,9 @@ uint64_t isp_nanotime_sub(struct timespec *b, struct timespec *a) { uint64_t elapsed; - struct timespec x = *b; - timespecsub(&x, a); + struct timespec x; + + timespecsub(b, a, &x); elapsed = GET_NANOSEC(&x); if (elapsed == 0) elapsed++; diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c index 6b8811f4faef..15f4f8e221a3 100644 --- a/sys/dev/joy/joy.c +++ b/sys/dev/joy/joy.c @@ -171,14 +171,14 @@ joyread(struct cdev *dev, struct uio *uio, int flag) nanotime(&t); end.tv_sec = 0; end.tv_nsec = joy->timeout[joypart(dev)] * 1000; - timespecadd(&end, &t); + timespecadd(&end, &t, &end); for (; timespeccmp(&t, &end, <) && (bus_space_read_1(bt, port, 0) & 0x0f); nanotime(&t)) ; /* nothing */ bus_space_write_1 (bt, port, 0, 0xff); nanotime(&start); end.tv_sec = 0; end.tv_nsec = joy->timeout[joypart(dev)] * 1000; - timespecadd(&end, &start); + timespecadd(&end, &start, &end); t = start; timespecclear(&x); timespecclear(&y); @@ -200,12 +200,12 @@ joyread(struct cdev *dev, struct uio *uio, int flag) enable_intr (); #endif if (timespecisset(&x)) { - timespecsub(&x, &start); + timespecsub(&x, &start, &x); c.x = joy->x_off[joypart(dev)] + x.tv_nsec / 1000; } else c.x = 0x80000000; if (timespecisset(&y)) { - timespecsub(&y, &start); + timespecsub(&y, &start, &y); c.y = joy->y_off[joypart(dev)] + y.tv_nsec / 1000; } else c.y = 0x80000000; diff --git a/sys/dev/xen/timer/timer.c b/sys/dev/xen/timer/timer.c index 465d978fbbb9..ecd4e0990652 100644 --- a/sys/dev/xen/timer/timer.c +++ b/sys/dev/xen/timer/timer.c @@ -262,7 +262,7 @@ xentimer_gettime(device_t dev, struct timespec *ts) timespecclear(ts); xen_fetch_wallclock(ts); xen_fetch_uptime(&u_ts); - timespecadd(ts, &u_ts); + timespecadd(ts, &u_ts, ts); return (0); } 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; diff --git a/sys/mips/ingenic/jz4780_smb.c b/sys/mips/ingenic/jz4780_smb.c index c910b05bd683..a69b6cbd198c 100644 --- a/sys/mips/ingenic/jz4780_smb.c +++ b/sys/mips/ingenic/jz4780_smb.c @@ -248,7 +248,7 @@ jzsmb_transfer_read(device_t dev, struct iic_msg *msg) SMB_WRITE(sc, SMBDC, SMBDC_CMD); for (;;) { getnanouptime(&diff); - timespecsub(&diff, &start); + timespecsub(&diff, &start, &diff); if ((SMB_READ(sc, SMBST) & SMBST_RFNE) != 0) { msg->buf[msg->len - resid] = SMB_READ(sc, SMBDC) & SMBDC_DAT; @@ -293,7 +293,7 @@ jzsmb_transfer_write(device_t dev, struct iic_msg *msg, int stop_hold) for (resid = msg->len; resid > 0; resid--) { for (;;) { getnanouptime(&diff); - timespecsub(&diff, &start); + timespecsub(&diff, &start, &diff); if ((SMB_READ(sc, SMBST) & SMBST_TFNF) != 0) { SMB_WRITE(sc, SMBDC, msg->buf[msg->len - resid]); diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index fcdeff9cb338..882b2aea119a 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1193,7 +1193,7 @@ ip_savecontrol(struct inpcb *inp, struct mbuf **mp, struct ip *ip, mbuf_tstmp2timespec(m, &ts); getboottimebin(&boottimebin); bintime2timespec(&boottimebin, &ts1); - timespecadd(&ts, &ts1); + timespecadd(&ts, &ts1, &ts); } else { nanotime(&ts); } diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 87788cb3b6d0..84bf56fc3ac2 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1267,7 +1267,7 @@ ip6_savecontrol_v4(struct inpcb *inp, struct mbuf *m, struct mbuf **mp, mbuf_tstmp2timespec(m, &t.ts); getboottimebin(&boottimebin); bintime2timespec(&boottimebin, &ts1); - timespecadd(&t.ts, &ts1); + timespecadd(&t.ts, &ts1, &t.ts); } else { nanotime(&t.ts); } diff --git a/sys/netsmb/smb_iod.c b/sys/netsmb/smb_iod.c index 29407b7a0567..e93787c3bb1d 100644 --- a/sys/netsmb/smb_iod.c +++ b/sys/netsmb/smb_iod.c @@ -557,9 +557,9 @@ smb_iod_sendall(struct smbiod *iod) break; case SMBRQ_SENT: SMB_TRAN_GETPARAM(vcp, SMBTP_TIMEOUT, &tstimeout); - timespecadd(&tstimeout, &tstimeout); + timespecadd(&tstimeout, &tstimeout, &tstimeout); getnanotime(&ts); - timespecsub(&ts, &tstimeout); + timespecsub(&ts, &tstimeout, &ts); if (timespeccmp(&ts, &rqp->sr_timesent, >)) { smb_iod_rqprocessed(rqp, ETIMEDOUT); } @@ -630,7 +630,7 @@ smb_iod_main(struct smbiod *iod) #if 0 if (iod->iod_state == SMBIOD_ST_VCACTIVE) { getnanotime(&tsnow); - timespecsub(&tsnow, &iod->iod_pingtimo); + timespecsub(&tsnow, &iod->iod_pingtimo, &tsnow); if (timespeccmp(&tsnow, &iod->iod_lastrqsent, >)) { smb_smb_echo(vcp, &iod->iod_scred); } diff --git a/sys/netsmb/smb_trantcp.c b/sys/netsmb/smb_trantcp.c index 2c2f7ed19908..8101993277a3 100644 --- a/sys/netsmb/smb_trantcp.c +++ b/sys/netsmb/smb_trantcp.c @@ -546,15 +546,14 @@ smb_nbst_connect(struct smb_vc *vcp, struct sockaddr *sap, struct thread *td) if (error) return error; getnanotime(&ts2); - timespecsub(&ts2, &ts1); + timespecsub(&ts2, &ts1, &ts2); if (ts2.tv_sec == 0) { ts2.tv_sec = 1; ts2.tv_nsec = 0; } - nbp->nbp_timo = ts2; - timespecadd(&nbp->nbp_timo, &ts2); - timespecadd(&nbp->nbp_timo, &ts2); - timespecadd(&nbp->nbp_timo, &ts2); /* * 4 */ + timespecadd(&ts2, &ts2, &nbp->nbp_timo); + timespecadd(&nbp->nbp_timo, &ts2, &nbp->nbp_timo); + timespecadd(&nbp->nbp_timo, &ts2, &nbp->nbp_timo); /* * 4 */ error = nbssn_rq_request(nbp, td); if (error) smb_nbst_disconnect(vcp, td); diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index a6c5920eb857..f3a3bba2e59b 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -1188,7 +1188,7 @@ crypto_tstat(struct cryptotstat *ts, struct bintime *bt) if (u < delta.frac) delta.sec--; bintime2timespec(&delta, &t); - timespecadd(&ts->acc, &t); + timespecadd(&ts->acc, &t, &ts->acc); if (timespeccmp(&t, &ts->min, <)) ts->min = t; if (timespeccmp(&t, &ts->max, >)) diff --git a/sys/sys/param.h b/sys/sys/param.h index 4798ac50e04a..fc8650e5abb7 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200075 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200076 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/time.h b/sys/sys/time.h index cd517d856d76..6fea11c680b5 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -306,6 +306,7 @@ tvtosbt(struct timeval _tv) #define USEC_2_TICKS(u) max(1, (uint32_t)((hz == 1000) ? \ ((u) / 1000) : ((uint64_t)(u) * (uint64_t)hz)/(uint64_t)1000000)) +#endif /* Operations on timespecs */ #define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) #define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) @@ -313,25 +314,28 @@ tvtosbt(struct timeval _tv) (((tvp)->tv_sec == (uvp)->tv_sec) ? \ ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ ((tvp)->tv_sec cmp (uvp)->tv_sec)) -#define timespecadd(vvp, uvp) \ + +#define timespecadd(tsp, usp, vsp) \ do { \ - (vvp)->tv_sec += (uvp)->tv_sec; \ - (vvp)->tv_nsec += (uvp)->tv_nsec; \ - if ((vvp)->tv_nsec >= 1000000000) { \ - (vvp)->tv_sec++; \ - (vvp)->tv_nsec -= 1000000000; \ + (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ + if ((vsp)->tv_nsec >= 1000000000L) { \ + (vsp)->tv_sec++; \ + (vsp)->tv_nsec -= 1000000000L; \ } \ } while (0) -#define timespecsub(vvp, uvp) \ +#define timespecsub(tsp, usp, vsp) \ do { \ - (vvp)->tv_sec -= (uvp)->tv_sec; \ - (vvp)->tv_nsec -= (uvp)->tv_nsec; \ - if ((vvp)->tv_nsec < 0) { \ - (vvp)->tv_sec--; \ - (vvp)->tv_nsec += 1000000000; \ + (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ + if ((vsp)->tv_nsec < 0) { \ + (vsp)->tv_sec--; \ + (vsp)->tv_nsec += 1000000000L; \ } \ } while (0) +#ifdef _KERNEL + /* Operations on timevals. */ #define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 43829e869d4c..fed0456b13cb 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -694,7 +694,7 @@ out1: vfs_write_resume(vp->v_mount, VR_START_WRITE | VR_NO_SUSPCLR); if (collectsnapstats && starttime.tv_sec > 0) { nanotime(&endtime); - timespecsub(&endtime, &starttime); + timespecsub(&endtime, &starttime, &endtime); printf("%s: suspended %ld.%03ld sec, redo %ld of %d\n", vp->v_mount->mnt_stat.f_mntonname, (long)endtime.tv_sec, endtime.tv_nsec / 1000000, redo, fs->fs_ncg); diff --git a/sys/x86/iommu/intel_dmar.h b/sys/x86/iommu/intel_dmar.h index 6d25ac3644e6..af151aa6f91f 100644 --- a/sys/x86/iommu/intel_dmar.h +++ b/sys/x86/iommu/intel_dmar.h @@ -524,8 +524,7 @@ extern struct timespec dmar_hw_timeout; } else { \ forever = false; \ nanouptime(&curr); \ - last = curr; \ - timespecadd(&last, &dmar_hw_timeout); \ + timespecadd(&curr, &dmar_hw_timeout, &last); \ } \ for (;;) { \ if (cond) { \ |