diff options
author | Mark Kettenis <kettenis@gnu.org> | 2000-01-23 10:10:02 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2000-01-23 10:10:02 +0000 |
commit | abf7fd42256cd1bf76d1ec702c8460da3e3d8a68 (patch) | |
tree | 77495e71a56782ed4e6d5abb2bf85770e236b7b4 /sysdeps/mach/hurd/setitimer.c | |
parent | 786731fc3c71df6dff871c14a28d1a8e997d3f2d (diff) | |
download | glibc-abf7fd42256cd1bf76d1ec702c8460da3e3d8a68.tar.gz glibc-abf7fd42256cd1bf76d1ec702c8460da3e3d8a68.tar.xz glibc-abf7fd42256cd1bf76d1ec702c8460da3e3d8a68.zip |
2000-01-08 Mark Kettenis <kettenis@gnu.org>
* sysdeps/mach/hurd/setitimer.c (quantize_timeval): New function. (setitimer_locked): Use it to quantize the timer values. Use quantized timer values to check if the timeout changed.
Diffstat (limited to 'sysdeps/mach/hurd/setitimer.c')
-rw-r--r-- | sysdeps/mach/hurd/setitimer.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c index b0e70e89f9..df7c69f4f9 100644 --- a/sysdeps/mach/hurd/setitimer.c +++ b/sysdeps/mach/hurd/setitimer.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -36,6 +36,22 @@ vm_address_t _hurd_itimer_thread_stack_base; /* Base of its stack. */ vm_address_t _hurd_itimer_thread_stack_size; /* Size of its stack. */ struct timeval _hurd_itimer_started; /* Time the thread started waiting. */ +static void +quantize_timeval (struct timeval *tv) +{ + static time_t quantum = -1; + + if (quantum == -1) + quantum = 1000000 / __libc_clk_tck (); + + tv->tv_usec = ((tv->tv_usec + (quantum - 1)) / quantum) * quantum; + if (tv->tv_usec >= 1000000) + { + ++tv->tv_sec; + tv->tv_usec -= 1000000; + } +} + static inline void subtract_timeval (struct timeval *from, const struct timeval *subtract) { @@ -165,6 +181,8 @@ setitimer_locked (const struct itimerval *new, struct itimerval *old, } newval = *new; + quantize_timeval (&newval.it_interval); + quantize_timeval (&newval.it_value); if ((newval.it_value.tv_sec | newval.it_value.tv_usec) != 0) { /* Make sure the itimer thread is set up. */ @@ -267,8 +285,8 @@ setitimer_locked (const struct itimerval *new, struct itimerval *old, } } /* See if the timeout changed. If so, we must alert the itimer thread. */ - else if (remaining.tv_sec != new->it_value.tv_sec || - remaining.tv_usec != new->it_value.tv_usec) + else if (remaining.tv_sec != newval.it_value.tv_sec || + remaining.tv_usec != newval.it_value.tv_usec) { /* The timeout value is changing. Tell the itimer thread to reexamine it and start counting down. If the itimer thread is |