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 /tools/regression/sockets/unix_cmsg | |
parent | 19fe43f796f3d962b3bf023a4484a82d7b2a5711 (diff) |
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 'tools/regression/sockets/unix_cmsg')
-rw-r--r-- | tools/regression/sockets/unix_cmsg/uc_check_time.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/tools/regression/sockets/unix_cmsg/uc_check_time.c b/tools/regression/sockets/unix_cmsg/uc_check_time.c index 5b7dfe11bb89..682cd442077d 100644 --- a/tools/regression/sockets/unix_cmsg/uc_check_time.c +++ b/tools/regression/sockets/unix_cmsg/uc_check_time.c @@ -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 { \ - (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) - int uc_check_bintime(const struct bintime *mt) { @@ -79,7 +65,7 @@ uc_check_timespec_real(const struct timespec *bt) if (clock_gettime(CLOCK_REALTIME, &ct) < 0) return (-1); - timespecsub(&ct, bt); + timespecsub(&ct, bt, &ct); if (!timespeccmp(&ct, &max_diff_ts, <)) return (-1); @@ -93,7 +79,7 @@ uc_check_timespec_mono(const struct timespec *bt) if (clock_gettime(CLOCK_MONOTONIC, &ct) < 0) return (-1); - timespecsub(&ct, bt); + timespecsub(&ct, bt, &ct); if (!timespeccmp(&ct, &max_diff_ts, <)) return (-1); |