mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-23 07:51:52 +08:00
Update due to <sys/time.h> API changes
Changes correspond to FreeBSD commit: "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" Update #3472.
This commit is contained in:
parent
8e35aaa9df
commit
12a885cd18
@ -552,7 +552,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;
|
||||
@ -1532,7 +1532,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)) {
|
||||
@ -1573,9 +1573,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.
|
||||
@ -1643,22 +1644,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);
|
||||
@ -1669,8 +1671,7 @@ realtimer_expire(void *arg)
|
||||
ITIMER_LOCK(it);
|
||||
itimer_leave(it);
|
||||
} else 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);
|
||||
|
@ -1031,7 +1031,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, >))
|
||||
|
@ -70,9 +70,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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user