diff options
author | bde <bde@FreeBSD.org> | 1998-08-05 16:44:30 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-08-05 16:44:30 +0000 |
commit | 67ea95908f26241d56397d8abd7609c53f54f017 (patch) | |
tree | 0468da32de1e5ed9a5ed272831a1f468ac91f79a /sys/compat/linux/linux_misc.c | |
parent | 300f6fc28ba1143d367641c4d0e67942893505f0 (diff) | |
download | FreeBSD-src-67ea95908f26241d56397d8abd7609c53f54f017.zip FreeBSD-src-67ea95908f26241d56397d8abd7609c53f54f017.tar.gz |
Converted the second last instance of hzto() to tvtohz().
Fixed nearby bugs (in linux_alarm()):
- the itimer for the alarm was relative to the epoch instead of relative
to the boot time. This was harmless because the itimer's interval is 0.
- the seconds arg was not checked for validity before converting it to a
possibly different value.
- printf format errors.
Improvements:
Don't use splclock(). splsoftclock() suffices. Don't complicate things
by micro-optimizing interrupt latency.
Minor improvements:
Various micro-optimizations to exploit the specialness of the alarm itimer
and the value 0.
Diffstat (limited to 'sys/compat/linux/linux_misc.c')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 004cf6c..ec420fa 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_misc.c,v 1.39 1998/07/10 22:30:01 jkh Exp $ + * $Id: linux_misc.c,v 1.40 1998/07/29 16:43:00 bde Exp $ */ #include <sys/param.h> @@ -67,36 +67,31 @@ linux_alarm(struct proc *p, struct linux_alarm_args *args) int s; #ifdef DEBUG - printf("Linux-emul(%d): alarm(%d)\n", p->p_pid, args->secs); + printf("Linux-emul(%ld): alarm(%u)\n", (long)p->p_pid, args->secs); #endif + if (args->secs > 100000000) + return EINVAL; it.it_value.tv_sec = (long)args->secs; it.it_value.tv_usec = 0; it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 0; - s = splclock(); /* XXX Still needed ? */ + s = splsoftclock(); old_it = p->p_realtimer; - getmicrotime(&tv); + getmicrouptime(&tv); if (timevalisset(&old_it.it_value)) - if (timevalcmp(&old_it.it_value, &tv, <)) - timevalclear(&old_it.it_value); - else - timevalsub(&old_it.it_value, &tv); - splx(s); - if (itimerfix(&it.it_value) || itimerfix(&it.it_interval)) - return EINVAL; - s = splclock(); /* XXX Still needed ? */ - if (timevalisset(&p->p_realtimer.it_value)) - untimeout(realitexpire, (caddr_t)p, p->p_ithandle); - getmicrotime(&tv); - if (timevalisset(&it.it_value)) { + untimeout(realitexpire, (caddr_t)p, p->p_ithandle); + if (it.it_value.tv_sec != 0) { + p->p_ithandle = timeout(realitexpire, (caddr_t)p, tvtohz(&it.it_value)); timevaladd(&it.it_value, &tv); - p->p_ithandle = timeout(realitexpire, (caddr_t)p, hzto(&it.it_value)); } p->p_realtimer = it; splx(s); - if (old_it.it_value.tv_usec) - old_it.it_value.tv_sec++; - p->p_retval[0] = old_it.it_value.tv_sec; + if (timevalcmp(&old_it.it_value, &tv, >)) { + timevalsub(&old_it.it_value, &tv); + if (old_it.it_value.tv_usec != 0) + old_it.it_value.tv_sec++; + p->p_retval[0] = old_it.it_value.tv_sec; + } return 0; } |