aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux
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/compat/linux
parent19fe43f796f3d962b3bf023a4484a82d7b2a5711 (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 'sys/compat/linux')
-rw-r--r--sys/compat/linux/linux_event.c16
-rw-r--r--sys/compat/linux/linux_futex.c4
-rw-r--r--sys/compat/linux/linux_misc.c4
-rw-r--r--sys/compat/linux/linux_socket.c4
4 files changed, 14 insertions, 14 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;
}