svn commit: r244192 - in projects/calloutng/sys: kern sys
Alexander Motin
mav at FreeBSD.org
Thu Dec 13 21:40:00 UTC 2012
Author: mav
Date: Thu Dec 13 21:39:59 2012
New Revision: 244192
URL: http://svnweb.freebsd.org/changeset/base/244192
Log:
- Fix bug in TIMESEL() macro, incorrectly using (get)binuptime() functions.
- Make TIMESEL() macro return flag reporting which of functions was used.
- Use the above flag to simplify the code.
- Make some minor optimizations.
Reviewed by: davide
Modified:
projects/calloutng/sys/kern/kern_time.c
projects/calloutng/sys/kern/kern_timeout.c
projects/calloutng/sys/kern/sys_generic.c
projects/calloutng/sys/sys/time.h
Modified: projects/calloutng/sys/kern/kern_time.c
==============================================================================
--- projects/calloutng/sys/kern/kern_time.c Thu Dec 13 21:27:20 2012 (r244191)
+++ projects/calloutng/sys/kern/kern_time.c Thu Dec 13 21:39:59 2012 (r244192)
@@ -491,15 +491,11 @@ kern_nanosleep(struct thread *td, struct
if (rqt->tv_sec < 0 || (rqt->tv_sec == 0 && rqt->tv_nsec == 0))
return (0);
timespec2bintime(rqt, &tmp);
- TIMESEL(&bt, &tmp);
- bintime_add(&bt, &tmp);
bt_prec = tmp;
bintime_divpow2(&bt_prec, tc_timeexp);
- if (rqt->tv_nsec > tc_timethreshold) {
+ if (TIMESEL(&bt, &tmp))
bintime_add(&bt, &tick_bt);
- if (bintime_cmp(&bt_prec, &halftick_bt, <))
- bt_prec = halftick_bt;
- }
+ bintime_add(&bt, &tmp);
bintime_add(&bt, &bt_prec);
error = tsleep_bt(&nanowait, PWAIT | PCATCH, "nanslp", &bt, &bt_prec);
TIMESEL(&btt, &tmp);
Modified: projects/calloutng/sys/kern/kern_timeout.c
==============================================================================
--- projects/calloutng/sys/kern/kern_timeout.c Thu Dec 13 21:27:20 2012 (r244191)
+++ projects/calloutng/sys/kern/kern_timeout.c Thu Dec 13 21:39:59 2012 (r244192)
@@ -935,7 +935,7 @@ _callout_reset_on(struct callout *c, str
if (bt == NULL) {
pr = to_bt = tick_bt;
getbinuptime(&now);
- if (to_ticks > 0)
+ if (to_ticks > 1)
bintime_mul(&to_bt, to_ticks);
bintime_add(&to_bt, &now);
to_ticks >>= C_PRELGET(flags);
Modified: projects/calloutng/sys/kern/sys_generic.c
==============================================================================
--- projects/calloutng/sys/kern/sys_generic.c Thu Dec 13 21:27:20 2012 (r244191)
+++ projects/calloutng/sys/kern/sys_generic.c Thu Dec 13 21:39:59 2012 (r244192)
@@ -1005,15 +1005,11 @@ kern_select(struct thread *td, int nd, f
goto done;
}
timeval2bintime(&atv, &abt);
- TIMESEL(&rbt, &abt);
- bintime_add(&abt, &rbt);
precision = abt;
bintime_divpow2(&precision, tc_timeexp);
- if (bintime_cmp(&tick_bt, &precision, >)) {
+ if (TIMESEL(&rbt, &abt))
bintime_add(&abt, &tick_bt);
- if (bintime_cmp(&precision, &halftick_bt, <))
- precision = halftick_bt;
- }
+ bintime_add(&abt, &rbt);
bintime_add(&abt, &precision);
} else {
abt.sec = 0;
@@ -1292,15 +1288,11 @@ sys_poll(td, uap)
goto done;
}
timeval2bintime(&atv, &abt);
- TIMESEL(&rbt, &abt);
precision = abt;
- bintime_add(&abt, &rbt);
bintime_divpow2(&precision, tc_timeexp);
- if (atv.tv_usec * 1000 > tc_timethreshold) {
+ if (TIMESEL(&rbt, &abt))
bintime_add(&abt, &tick_bt);
- if (bintime_cmp(&precision, &halftick_bt, <))
- precision = halftick_bt;
- }
+ bintime_add(&abt, &rbt);
bintime_add(&abt, &precision);
} else {
abt.sec = 0;
Modified: projects/calloutng/sys/sys/time.h
==============================================================================
--- projects/calloutng/sys/sys/time.h Thu Dec 13 21:27:20 2012 (r244191)
+++ projects/calloutng/sys/sys/time.h Thu Dec 13 21:39:59 2012 (r244192)
@@ -367,7 +367,7 @@ int tvtohz(struct timeval *tv);
#define TIMESEL(bt, bt2) \
((bintime_cmp((bt2), (&bt_timethreshold), >=)) ? \
- binuptime((bt)) : getbinuptime((bt)))
+ (getbinuptime(bt), 1) : (binuptime(bt), 0))
#else /* !_KERNEL */
#include <time.h>
More information about the svn-src-projects
mailing list