Date: Mon, 30 Jul 2018 15:46:41 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336914 - in head: lib/libnetbsd/sys sbin/fsck_ffs share/man/man3 sys/compat/linux sys/compat/linuxkpi/common/include/linux sys/dev/acpica sys/dev/drm2/i915 sys/dev/efidev sys/dev/isp s... Message-ID: <201807301546.w6UFkf5V020458@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Mon Jul 30 15:46:40 2018 New Revision: 336914 URL: https://svnweb.freebsd.org/changeset/base/336914 Log: 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 Deleted: head/lib/libnetbsd/sys/time.h Modified: head/sbin/fsck_ffs/fsutil.c head/share/man/man3/Makefile head/share/man/man3/timeradd.3 head/sys/compat/linux/linux_event.c head/sys/compat/linux/linux_futex.c head/sys/compat/linux/linux_misc.c head/sys/compat/linux/linux_socket.c head/sys/compat/linuxkpi/common/include/linux/time.h head/sys/dev/acpica/acpi_cmbat.c head/sys/dev/acpica/acpi_smbat.c head/sys/dev/acpica/acpi_thermal.c head/sys/dev/drm2/i915/i915_gem.c head/sys/dev/drm2/i915/intel_pm.c head/sys/dev/efidev/efirtc.c head/sys/dev/isp/isp_freebsd.c head/sys/dev/joy/joy.c head/sys/dev/xen/timer/timer.c head/sys/kern/kern_sig.c head/sys/kern/kern_tc.c head/sys/kern/kern_time.c head/sys/kern/kern_umtx.c head/sys/kern/subr_rtc.c head/sys/kern/uipc_mqueue.c head/sys/kern/uipc_sem.c head/sys/mips/ingenic/jz4780_smb.c head/sys/netinet/ip_input.c head/sys/netinet6/ip6_input.c head/sys/netsmb/smb_iod.c head/sys/netsmb/smb_trantcp.c head/sys/opencrypto/crypto.c head/sys/sys/param.h head/sys/sys/time.h head/sys/ufs/ffs/ffs_snapshot.c head/sys/x86/iommu/intel_dmar.h head/tools/regression/posixsem/posixsem.c head/tools/regression/sockets/udp_pingpong/udp_pingpong.c head/tools/regression/sockets/unix_cmsg/uc_check_time.c head/tools/tools/netrate/juggle/juggle.c head/tools/tools/netrate/tcpp/tcpp_client.c head/tools/tools/syscall_timing/syscall_timing.c head/usr.bin/truss/setup.c head/usr.bin/truss/syscalls.c head/usr.bin/truss/truss.h head/usr.sbin/camdd/camdd.c Modified: head/sbin/fsck_ffs/fsutil.c ============================================================================== --- head/sbin/fsck_ffs/fsutil.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sbin/fsck_ffs/fsutil.c Mon Jul 30 15:46:40 2018 (r336914) @@ -297,28 +297,6 @@ foundit: return (bp); } -/* - * Timespec operations (from <sys/time.h>). - */ -#define timespecsub(vvp, uvp) \ - 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; \ - } \ - } while (0) -#define timespecadd(vvp, uvp) \ - 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; \ - } \ - } while (0) - void getblk(struct bufarea *bp, ufs2_daddr_t blk, long size) { @@ -337,8 +315,9 @@ getblk(struct bufarea *bp, ufs2_daddr_t blk, long size bp->b_errs = blread(fsreadfd, bp->b_un.b_buf, dblk, size); if (debug) { clock_gettime(CLOCK_REALTIME_PRECISE, &finish); - timespecsub(&finish, &start); - timespecadd(&readtime[bp->b_type], &finish); + timespecsub(&finish, &start, &finish); + timespecadd(&readtime[bp->b_type], &finish, + &readtime[bp->b_type]); } bp->b_bno = dblk; bp->b_size = size; @@ -509,7 +488,7 @@ IOstats(char *what) totaldiskreads += diskreads; diskreads = 0; for (i = 0; i < BT_NUMBUFTYPES; i++) { - timespecadd(&totalreadtime[i], &readtime[i]); + timespecadd(&totalreadtime[i], &readtime[i], &totalreadtime[i]); totalreadcnt[i] += readcnt[i]; readtime[i].tv_sec = readtime[i].tv_nsec = 0; readcnt[i] = 0; @@ -529,7 +508,7 @@ finalIOstats(void) diskreads = totaldiskreads; startpass = startprog; for (i = 0; i < BT_NUMBUFTYPES; i++) { - timespecadd(&totalreadtime[i], &readtime[i]); + timespecadd(&totalreadtime[i], &readtime[i], &totalreadtime[i]); totalreadcnt[i] += readcnt[i]; readtime[i] = totalreadtime[i]; readcnt[i] = totalreadcnt[i]; @@ -543,7 +522,7 @@ static void printIOstats(void) int i; clock_gettime(CLOCK_REALTIME_PRECISE, &finishpass); - timespecsub(&finishpass, &startpass); + timespecsub(&finishpass, &startpass, &finishpass); printf("Running time: %jd.%03ld sec\n", (intmax_t)finishpass.tv_sec, finishpass.tv_nsec / 1000000); printf("buffer reads by type:\n"); Modified: head/share/man/man3/Makefile ============================================================================== --- head/share/man/man3/Makefile Mon Jul 30 15:46:24 2018 (r336913) +++ head/share/man/man3/Makefile Mon Jul 30 15:46:40 2018 (r336914) @@ -164,7 +164,12 @@ MLINKS+= stdarg.3 va_arg.3 \ MLINKS+= timeradd.3 timerclear.3 \ timeradd.3 timercmp.3 \ timeradd.3 timerisset.3 \ - timeradd.3 timersub.3 + timeradd.3 timersub.3 \ + timeradd.3 timespecadd.3 \ + timeradd.3 timespecsub.3 \ + timeradd.3 timespecclear.3 \ + timeradd.3 timespecisset.3 \ + timeradd.3 timespeccmp.3 MLINKS+= tree.3 RB_EMPTY.3 \ tree.3 RB_ENTRY.3 \ tree.3 RB_FIND.3 \ Modified: head/share/man/man3/timeradd.3 ============================================================================== --- head/share/man/man3/timeradd.3 Mon Jul 30 15:46:24 2018 (r336913) +++ head/share/man/man3/timeradd.3 Mon Jul 30 15:46:40 2018 (r336914) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 11, 1999 +.Dd July 30, 2018 .Dt TIMERADD 3 .Os .Sh NAME @@ -35,8 +35,13 @@ .Nm timersub , .Nm timerclear , .Nm timerisset , -.Nm timercmp -.Nd operations on timevals +.Nm timercmp , +.Nm timespecadd , +.Nm timespecsub , +.Nm timespecclear , +.Nm timespecisset , +.Nm timespeccmp +.Nd operations on timevals and timespecs .Sh SYNOPSIS .In sys/time.h .Ft void @@ -49,15 +54,31 @@ .Fn timerisset "struct timeval *tvp" .Ft int .Fn timercmp "struct timeval *a" "struct timeval *b" CMP +.Ft void +.Fn timespecadd "struct timespec *a" "struct timespec *b" "struct timespec *res" +.Ft void +.Fn timespecsub "struct timespec *a" "struct timespec *b" "struct timespec *res" +.Ft void +.Fn timespecclear "struct timespec *ts" +.Ft int +.Fn timespecisset "struct timespec *ts" +.Ft int +.Fn timespeccmp "struct timespec *a" "struct timespec *b" CMP .Sh DESCRIPTION These macros are provided for manipulating .Fa timeval +and +.Fa timespec structures for use with the +.Xr clock_gettime 2 , +.Xr clock_settime 2 , .Xr gettimeofday 2 and .Xr settimeofday 2 calls. -The structure is defined in +The +.Fa timeval +structure is defined in .In sys/time.h as: .Bd -literal @@ -66,50 +87,67 @@ struct timeval { long tv_usec; /* and microseconds */ }; .Ed +And the +.Fa timespec +structure is defined in +.In time.h +as: +.Bd -literal +struct timespec { + time_t tv_nsec; /* seconds */ + long tv_nsec; /* and nanoseconds */ +}; +.Ed .Pp .Fn timeradd -adds the time information stored in +and +.Fn timespecadd +add the time information stored in .Fa a to .Fa b -and stores the resulting -.Vt timeval -in +and store the result in .Fa res . The results are simplified such that the value of .Fa res->tv_usec -is always less than 1,000,000 (1 second). +or +.Fa res->tv_nsec +is always less than 1 second. .Pp .Fn timersub -subtracts the time information stored in +and +.Fn timespecsub +subtract the time information stored in .Fa b from .Fa a -and stores the resulting -.Vt timeval +and store the result in .Fa res . .Pp .Fn timerclear -initializes -.Fa tvp -to midnight (0 hour) January 1st, 1970 (the Epoch). +and +.Fn timespecclear +initialize their argument to midnight (0 hour) January 1st, 1970 (the Epoch). .Pp .Fn timerisset -returns true if -.Fa tvp -is set to any time value other than the Epoch. +and +.Fn timespecisset +return true if their argument is set to any time value other than the Epoch. .Pp .Fn timercmp -compares +and +.Fn timespeccmp +compare .Fa a to .Fa b using the comparison operator given in .Fa CMP , -and returns the result of that comparison. +and return the result of that comparison. .Sh SEE ALSO -.Xr gettimeofday 2 +.Xr gettimeofday 2 , +.Xr clock_gettime 2 .Sh HISTORY The .Fn timeradd @@ -117,3 +155,11 @@ family of macros were imported from .Nx 1.1 , and appeared in .Fx 2.2.6 . +The +.Fn timespecadd +family of macros were imported from +.Nx 1.3 +into +.Fx 3.0 , +though they were not exposed to userland until +.Fx 12.0 . Modified: head/sys/compat/linux/linux_event.c ============================================================================== --- head/sys/compat/linux/linux_event.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/compat/linux/linux_event.c Mon Jul 30 15:46:40 2018 (r336914) @@ -1183,7 +1183,7 @@ linux_timerfd_curval(struct timerfd *tfd, struct itime 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_ 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); Modified: head/sys/compat/linux/linux_futex.c ============================================================================== --- head/sys/compat/linux/linux_futex.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/compat/linux/linux_futex.c Mon Jul 30 15:46:40 2018 (r336914) @@ -290,10 +290,10 @@ futex_copyin_timeout(int op, struct l_timespec *luts, 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); } Modified: head/sys/compat/linux/linux_misc.c ============================================================================== --- head/sys/compat/linux/linux_misc.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/compat/linux/linux_misc.c Mon Jul 30 15:46:40 2018 (r336914) @@ -2382,8 +2382,8 @@ linux_ppoll(struct thread *td, struct linux_ppoll_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 Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/compat/linux/linux_socket.c Mon Jul 30 15:46:40 2018 (r336914) @@ -1463,7 +1463,7 @@ linux_recvmmsg(struct thread *td, struct linux_recvmms 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_recvmms */ if (args->timeout) { getnanotime(&ts); - timespecsub(&ts, &tts); + timespecsub(&ts, &tts, &ts); if (!timespecisset(&ts) || ts.tv_sec > 0) break; } Modified: head/sys/compat/linuxkpi/common/include/linux/time.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/time.h Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/compat/linuxkpi/common/include/linux/time.h Mon Jul 30 15:46:40 2018 (r336914) @@ -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; } Modified: head/sys/dev/acpica/acpi_cmbat.c ============================================================================== --- head/sys/dev/acpica/acpi_cmbat.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/acpica/acpi_cmbat.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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()); } Modified: head/sys/dev/acpica/acpi_smbat.c ============================================================================== --- head/sys/dev/acpica/acpi_smbat.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/acpica/acpi_smbat.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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()); } Modified: head/sys/dev/acpica/acpi_thermal.c ============================================================================== --- head/sys/dev/acpica/acpi_thermal.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/acpica/acpi_thermal.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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; } Modified: head/sys/dev/drm2/i915/i915_gem.c ============================================================================== --- head/sys/dev/drm2/i915/i915_gem.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/drm2/i915/i915_gem.c Mon Jul 30 15:46:40 2018 (r336914) @@ -1135,8 +1135,8 @@ static int __wait_seqno(struct intel_ring_buffer *ring #undef EXIT_COND if (timeout) { - timespecsub(&now, &before); - timespecsub(timeout, &now); + timespecsub(&now, &before, &now); + timespecsub(timeout, &now, timeout); } switch (end) { Modified: head/sys/dev/drm2/i915/intel_pm.c ============================================================================== --- head/sys/dev/drm2/i915/intel_pm.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/drm2/i915/intel_pm.c Mon Jul 30 15:46:40 2018 (r336914) @@ -3102,8 +3102,7 @@ static void __i915_update_gfx_val(struct drm_i915_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; Modified: head/sys/dev/efidev/efirtc.c ============================================================================== --- head/sys/dev/efidev/efirtc.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/efidev/efirtc.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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); Modified: head/sys/dev/isp/isp_freebsd.c ============================================================================== --- head/sys/dev/isp/isp_freebsd.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/isp/isp_freebsd.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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++; Modified: head/sys/dev/joy/joy.c ============================================================================== --- head/sys/dev/joy/joy.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/joy/joy.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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; Modified: head/sys/dev/xen/timer/timer.c ============================================================================== --- head/sys/dev/xen/timer/timer.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/dev/xen/timer/timer.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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); } Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/kern/kern_sig.c Mon Jul 30 15:46:40 2018 (r336914) @@ -1261,8 +1261,7 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, 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, error = EAGAIN; break; } - ts = ets; - timespecsub(&ts, &rts); + timespecsub(&ets, &rts, &ts); TIMESPEC_TO_TIMEVAL(&tv, &ts); timo = tvtohz(&tv); } else { Modified: head/sys/kern/kern_tc.c ============================================================================== --- head/sys/kern/kern_tc.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/kern/kern_tc.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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; Modified: head/sys/kern/kern_time.c ============================================================================== --- head/sys/kern/kern_time.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/kern/kern_time.c Mon Jul 30 15:46:40 2018 (r336914) @@ -543,7 +543,7 @@ kern_clock_nanosleep(struct thread *td, clockid_t cloc 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 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); Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/kern/kern_umtx.c Mon Jul 30 15:46:40 2018 (r336914) @@ -772,8 +772,7 @@ abs_timeout_init(struct abs_timeout *timo, int clockid 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, st 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); } } } Modified: head/sys/kern/subr_rtc.c ============================================================================== --- head/sys/kern/subr_rtc.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/kern/subr_rtc.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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) { Modified: head/sys/kern/uipc_mqueue.c ============================================================================== --- head/sys/kern/uipc_mqueue.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/kern/uipc_mqueue.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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); Modified: head/sys/kern/uipc_sem.c ============================================================================== --- head/sys/kern/uipc_sem.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/kern/uipc_sem.c Mon Jul 30 15:46:40 2018 (r336914) @@ -843,7 +843,7 @@ kern_sem_wait(struct thread *td, semid_t id, int tryfl for (;;) { ts1 = *abstime; getnanotime(&ts2); - timespecsub(&ts1, &ts2); + timespecsub(&ts1, &ts2, &ts1); TIMESPEC_TO_TIMEVAL(&tv, &ts1); if (tv.tv_sec < 0) { error = ETIMEDOUT; Modified: head/sys/mips/ingenic/jz4780_smb.c ============================================================================== --- head/sys/mips/ingenic/jz4780_smb.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/mips/ingenic/jz4780_smb.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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 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]); Modified: head/sys/netinet/ip_input.c ============================================================================== --- head/sys/netinet/ip_input.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/netinet/ip_input.c Mon Jul 30 15:46:40 2018 (r336914) @@ -1193,7 +1193,7 @@ ip_savecontrol(struct inpcb *inp, struct mbuf **mp, st mbuf_tstmp2timespec(m, &ts); getboottimebin(&boottimebin); bintime2timespec(&boottimebin, &ts1); - timespecadd(&ts, &ts1); + timespecadd(&ts, &ts1, &ts); } else { nanotime(&ts); } Modified: head/sys/netinet6/ip6_input.c ============================================================================== --- head/sys/netinet6/ip6_input.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/netinet6/ip6_input.c Mon Jul 30 15:46:40 2018 (r336914) @@ -1267,7 +1267,7 @@ ip6_savecontrol_v4(struct inpcb *inp, struct mbuf *m, mbuf_tstmp2timespec(m, &t.ts); getboottimebin(&boottimebin); bintime2timespec(&boottimebin, &ts1); - timespecadd(&t.ts, &ts1); + timespecadd(&t.ts, &ts1, &t.ts); } else { nanotime(&t.ts); } Modified: head/sys/netsmb/smb_iod.c ============================================================================== --- head/sys/netsmb/smb_iod.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/netsmb/smb_iod.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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); } Modified: head/sys/netsmb/smb_trantcp.c ============================================================================== --- head/sys/netsmb/smb_trantcp.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/netsmb/smb_trantcp.c Mon Jul 30 15:46:40 2018 (r336914) @@ -546,15 +546,14 @@ smb_nbst_connect(struct smb_vc *vcp, struct sockaddr * 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); Modified: head/sys/opencrypto/crypto.c ============================================================================== --- head/sys/opencrypto/crypto.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/opencrypto/crypto.c Mon Jul 30 15:46:40 2018 (r336914) @@ -1188,7 +1188,7 @@ crypto_tstat(struct cryptotstat *ts, struct bintime *b 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, >)) Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/sys/param.h Mon Jul 30 15:46:40 2018 (r336914) @@ -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, Modified: head/sys/sys/time.h ============================================================================== --- head/sys/sys/time.h Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/sys/time.h Mon Jul 30 15:46:40 2018 (r336914) @@ -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,24 +314,27 @@ 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. */ Modified: head/sys/ufs/ffs/ffs_snapshot.c ============================================================================== --- head/sys/ufs/ffs/ffs_snapshot.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/ufs/ffs/ffs_snapshot.c Mon Jul 30 15:46:40 2018 (r336914) @@ -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); Modified: head/sys/x86/iommu/intel_dmar.h ============================================================================== --- head/sys/x86/iommu/intel_dmar.h Mon Jul 30 15:46:24 2018 (r336913) +++ head/sys/x86/iommu/intel_dmar.h Mon Jul 30 15:46:40 2018 (r336914) @@ -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) { \ Modified: head/tools/regression/posixsem/posixsem.c ============================================================================== --- head/tools/regression/posixsem/posixsem.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/tools/regression/posixsem/posixsem.c Mon Jul 30 15:46:40 2018 (r336914) @@ -55,35 +55,6 @@ __FBSDID("$FreeBSD$"); #include "test.h" -/* Cut and pasted from kernel header, bah! */ - -/* Operations on timespecs */ -#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) -#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) -#define timespeccmp(tvp, uvp, cmp) \ - (((tvp)->tv_sec == (uvp)->tv_sec) ? \ - ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ - ((tvp)->tv_sec cmp (uvp)->tv_sec)) -#define timespecadd(vvp, uvp) \ - 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; \ - } \ - } while (0) -#define timespecsub(vvp, uvp) \ - 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; \ - } \ - } while (0) - - #define TEST_PATH "/tmp/posixsem_regression_test" #define ELAPSED(elapsed, limit) (abs((elapsed) - (limit)) < 100) @@ -791,7 +762,7 @@ timedwait(semid_t id, u_int msec, u_int *delta, int er } end.tv_sec = msec / 1000; end.tv_nsec = msec % 1000 * 1000000; - timespecadd(&end, &start); + timespecadd(&end, &start, &end); if (ksem_timedwait(id, &end) < 0) { if (errno != error) { fail_errno("ksem_timedwait"); @@ -805,7 +776,7 @@ timedwait(semid_t id, u_int msec, u_int *delta, int er fail_errno("clock_gettime(CLOCK_REALTIME)"); return (-1); } - timespecsub(&end, &start); + timespecsub(&end, &start, &end); *delta = end.tv_nsec / 1000000; *delta += end.tv_sec * 1000; return (0); @@ -944,7 +915,7 @@ testwait(semid_t id, u_int *delta) fail_errno("clock_gettime(CLOCK_REALTIME)"); return (-1); } - timespecsub(&end, &start); + timespecsub(&end, &start, &end); *delta = end.tv_nsec / 1000000; *delta += end.tv_sec * 1000; return (0); Modified: head/tools/regression/sockets/udp_pingpong/udp_pingpong.c ============================================================================== --- head/tools/regression/sockets/udp_pingpong/udp_pingpong.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/tools/regression/sockets/udp_pingpong/udp_pingpong.c Mon Jul 30 15:46:40 2018 (r336914) @@ -106,31 +106,6 @@ struct rtt { #define NSEC_MAX 1000000000L #define NSEC_IN_USEC 1000L -#define timespecsub2(r, v, u) \ - do { \ - SEC(r) = SEC(v) - SEC(u); \ - NSEC(r) = NSEC(v) - NSEC(u); \ - if (NSEC(r) < 0 && (SEC(r) > 0 || NSEC(r) <= -NSEC_MAX)) { \ - SEC(r)--; \ - NSEC(r) += NSEC_MAX; \ - } \ - } while (0); - -#define timespecadd2(r, v, u) \ - do { \ - SEC(r) = SEC(v) + SEC(u); \ - NSEC(r) = NSEC(v) + NSEC(u); \ - if (NSEC(r) >= NSEC_MAX) { \ - SEC(r)++; \ - NSEC(r) -= NSEC_MAX; \ - } \ - } while (0); - -#define timespeccmp(t, c, u) \ - ((SEC(t) == SEC(u)) ? \ - (NSEC(t) c NSEC(u)) : \ - (SEC(t) c SEC(u))) - #define timeval2timespec(tv, ts) \ do { \ SEC(ts) = (tv)->tv_sec; \ @@ -536,10 +511,10 @@ static void calc_rtt(struct test_pkt *tpp, struct rtt *rttp) { - timespecsub2(&rttp->a2b, &tpp->tss[1].recvd, &tpp->tss[0].sent); - timespecsub2(&rttp->b2a, &tpp->tss[0].recvd, &tpp->tss[1].sent); - timespecadd2(&rttp->a2b_b2a, &rttp->a2b, &rttp->b2a); - timespecsub2(&rttp->e2e, &tpp->tss[0].recvd, &tpp->tss[0].sent); + timespecsub(&tpp->tss[1].recvd, &tpp->tss[0].sent, &rttp->a2b); + timespecsub(&tpp->tss[0].recvd, &tpp->tss[1].sent, &rttp->b2a); + timespecadd(&rttp->a2b, &rttp->b2a, &rttp->a2b_b2a); + timespecsub(&tpp->tss[0].recvd, &tpp->tss[0].sent, &rttp->e2e); } static void @@ -604,13 +579,13 @@ test_run(int ts_type, int use_ipv6, int use_recvmsg, c continue; } calc_rtt(&test_ctx.test_pkts[i], &rtt); - if (!timespeccmp(&rtt.e2e, >, &rtt.a2b_b2a)) + if (!timespeccmp(&rtt.e2e, &rtt.a2b_b2a, >)) errx(1, "end-to-end trip time is too small"); - if (!timespeccmp(&rtt.e2e, <, &max_ts)) + if (!timespeccmp(&rtt.e2e, &max_ts, <)) errx(1, "end-to-end trip time is too large"); - if (!timespeccmp(&rtt.a2b, >, &zero_ts)) + if (!timespeccmp(&rtt.a2b, &zero_ts, >)) errx(1, "A2B trip time is not positive"); - if (!timespeccmp(&rtt.b2a, >, &zero_ts)) + if (!timespeccmp(&rtt.b2a, &zero_ts, >)) errx(1, "B2A trip time is not positive"); } teardown_udp(&test_ctx); Modified: head/tools/regression/sockets/unix_cmsg/uc_check_time.c ============================================================================== --- head/tools/regression/sockets/unix_cmsg/uc_check_time.c Mon Jul 30 15:46:24 2018 (r336913) +++ head/tools/regression/sockets/unix_cmsg/uc_check_time.c Mon Jul 30 15:46:40 2018 (r336914) @@ -35,20 +35,6 @@ __FBSDID("$FreeBSD$"); static const struct timeval max_diff_tv = {.tv_sec = 1, .tv_usec = 0}; static const struct timespec max_diff_ts = {.tv_sec = 1, .tv_nsec = 0}; -#define timespeccmp(tvp, uvp, cmp) \ - (((tvp)->tv_sec == (uvp)->tv_sec) ? \ - ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ - ((tvp)->tv_sec cmp (uvp)->tv_sec)) -#define timespecsub(vvp, uvp) \ - do { \ *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807301546.w6UFkf5V020458>