Cygwin: timerfd: rename overrun_count to expiration_count
The value returned by reading from a timerfd is not an overrun count in the same sense as for posix timers, it's an expiry counter. Reflect that in the name. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
ea99e9fdda
commit
528f4d4938
@ -218,7 +218,7 @@ int
|
|||||||
fhandler_timerfd::ioctl (unsigned int cmd, void *p)
|
fhandler_timerfd::ioctl (unsigned int cmd, void *p)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
uint64_t ov_cnt;
|
uint64_t exp_cnt;
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
@ -227,13 +227,13 @@ fhandler_timerfd::ioctl (unsigned int cmd, void *p)
|
|||||||
{
|
{
|
||||||
timerfd_tracker *tfd = (timerfd_tracker *) timerid;
|
timerfd_tracker *tfd = (timerfd_tracker *) timerid;
|
||||||
|
|
||||||
ov_cnt = *(uint64_t *) p;
|
exp_cnt = *(uint64_t *) p;
|
||||||
if (!ov_cnt)
|
if (!exp_cnt)
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tfd->ioctl_set_ticks (ov_cnt);
|
tfd->ioctl_set_ticks (exp_cnt);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
__except (EFAULT) {}
|
__except (EFAULT) {}
|
||||||
|
@ -70,7 +70,7 @@ timerfd_tracker::handle_timechange_window ()
|
|||||||
/* make sure to handle each WM_TIMECHANGE only once! */
|
/* make sure to handle each WM_TIMECHANGE only once! */
|
||||||
if (msg.time != tc_time ())
|
if (msg.time != tc_time ())
|
||||||
{
|
{
|
||||||
set_overrun_count (-1LL);
|
set_expiration_count (-1LL);
|
||||||
disarm_timer ();
|
disarm_timer ();
|
||||||
timer_expired ();
|
timer_expired ();
|
||||||
set_tc_time (msg.time);
|
set_tc_time (msg.time);
|
||||||
@ -133,7 +133,7 @@ timerfd_tracker::thread_func ()
|
|||||||
continue;
|
continue;
|
||||||
/* Make sure we haven't been abandoned and/or disarmed
|
/* Make sure we haven't been abandoned and/or disarmed
|
||||||
in the meantime */
|
in the meantime */
|
||||||
if (overrun_count () == -1LL
|
if (expiration_count () == -1LL
|
||||||
|| IsEventSignalled (tfd_shared->disarm_evt ()))
|
|| IsEventSignalled (tfd_shared->disarm_evt ()))
|
||||||
{
|
{
|
||||||
leave_critical_section ();
|
leave_critical_section ();
|
||||||
@ -142,29 +142,29 @@ timerfd_tracker::thread_func ()
|
|||||||
/* One-shot timer? */
|
/* One-shot timer? */
|
||||||
if (!get_interval ())
|
if (!get_interval ())
|
||||||
{
|
{
|
||||||
/* Set overrun count, disarm timer */
|
/* Set expiration count, disarm timer */
|
||||||
increment_overrun_count (1);
|
increment_expiration_count (1);
|
||||||
disarm_timer ();
|
disarm_timer ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Compute overrun count. */
|
/* Compute expiration count. */
|
||||||
LONG64 now = get_clock_now ();
|
LONG64 now = get_clock_now ();
|
||||||
LONG64 ts = get_exp_ts ();
|
LONG64 ts = get_exp_ts ();
|
||||||
|
LONG64 exp_cnt;
|
||||||
|
|
||||||
/* Make concessions for unexact realtime clock */
|
/* Make concessions for unexact realtime clock */
|
||||||
if (ts > now)
|
if (ts > now)
|
||||||
ts = now - 1;
|
ts = now - 1;
|
||||||
LONG64 ov_cnt = (now - ts + get_interval () - 1)
|
exp_cnt = (now - ts + get_interval () - 1) / get_interval ();
|
||||||
/ get_interval ();
|
increment_expiration_count (exp_cnt);
|
||||||
increment_overrun_count (ov_cnt);
|
ts += get_interval () * exp_cnt;
|
||||||
ts += get_interval () * ov_cnt;
|
|
||||||
/* Set exp_ts to current timestamp. Make sure exp_ts ends up
|
/* Set exp_ts to current timestamp. Make sure exp_ts ends up
|
||||||
bigger than "now" and fix overrun count as required */
|
bigger than "now" and fix expiration count as required */
|
||||||
while (ts <= (now = get_clock_now ()))
|
while (ts <= (now = get_clock_now ()))
|
||||||
{
|
{
|
||||||
increment_overrun_count ((now - ts + get_interval () - 1)
|
increment_expiration_count ((now - ts + get_interval () - 1)
|
||||||
/ get_interval ());
|
/ get_interval ());
|
||||||
ts += get_interval ();
|
ts += get_interval ();
|
||||||
}
|
}
|
||||||
set_exp_ts (ts);
|
set_exp_ts (ts);
|
||||||
@ -395,9 +395,9 @@ timerfd_tracker::close ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
timerfd_tracker::ioctl_set_ticks (uint64_t ov_cnt)
|
timerfd_tracker::ioctl_set_ticks (uint64_t exp_cnt)
|
||||||
{
|
{
|
||||||
set_overrun_count (ov_cnt);
|
set_expiration_count (exp_cnt);
|
||||||
timer_expired ();
|
timer_expired ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +449,7 @@ repeat:
|
|||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = read_and_reset_overrun_count ();
|
ret = read_and_reset_expiration_count ();
|
||||||
leave_critical_section ();
|
leave_critical_section ();
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
@ -461,7 +461,7 @@ repeat:
|
|||||||
goto repeat;
|
goto repeat;
|
||||||
ret = -EAGAIN;
|
ret = -EAGAIN;
|
||||||
break;
|
break;
|
||||||
default: /* Return (positive) overrun count. */
|
default: /* Return (positive) expiration count. */
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
ret = INT64_MAX;
|
ret = INT64_MAX;
|
||||||
break;
|
break;
|
||||||
@ -539,7 +539,7 @@ timerfd_shared::arm_timer (int flags, const struct itimerspec *new_value)
|
|||||||
{
|
{
|
||||||
DueTime.QuadPart = get_clock_now () - ts;
|
DueTime.QuadPart = get_clock_now () - ts;
|
||||||
/* If the timestamp was earlier than now, compute number
|
/* If the timestamp was earlier than now, compute number
|
||||||
of overruns and offset DueTime to expire immediately. */
|
of expirations and offset DueTime to expire immediately. */
|
||||||
if (DueTime.QuadPart >= 0)
|
if (DueTime.QuadPart >= 0)
|
||||||
DueTime.QuadPart = -1LL;
|
DueTime.QuadPart = -1LL;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class timerfd_shared
|
|||||||
LONG64 _exp_ts; /* start timestamp or next expire timestamp
|
LONG64 _exp_ts; /* start timestamp or next expire timestamp
|
||||||
in 100ns */
|
in 100ns */
|
||||||
LONG64 _interval; /* timer interval in 100ns */
|
LONG64 _interval; /* timer interval in 100ns */
|
||||||
LONG64 _overrun_count; /* expiry counter */
|
LONG64 _expiration_count; /* expiry counter */
|
||||||
int _flags; /* settime flags */
|
int _flags; /* settime flags */
|
||||||
DWORD _tc_time; /* timestamp of the last WM_TIMECHANGE msg */
|
DWORD _tc_time; /* timestamp of the last WM_TIMECHANGE msg */
|
||||||
|
|
||||||
@ -46,13 +46,13 @@ class timerfd_shared
|
|||||||
int flags () const { return _flags; }
|
int flags () const { return _flags; }
|
||||||
|
|
||||||
/* write access methods */
|
/* write access methods */
|
||||||
void increment_overrun_count (LONG64 add)
|
void increment_expiration_count (LONG64 add)
|
||||||
{ InterlockedAdd64 (&_overrun_count, add); }
|
{ InterlockedAdd64 (&_expiration_count, add); }
|
||||||
void set_overrun_count (LONG64 newval)
|
void set_expiration_count (LONG64 newval)
|
||||||
{ InterlockedExchange64 (&_overrun_count, newval); }
|
{ InterlockedExchange64 (&_expiration_count, newval); }
|
||||||
LONG64 read_and_reset_overrun_count ()
|
LONG64 read_and_reset_expiration_count ()
|
||||||
{
|
{
|
||||||
LONG64 ret = InterlockedExchange64 (&_overrun_count, 0);
|
LONG64 ret = InterlockedExchange64 (&_expiration_count, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
ResetEvent (_expired_evt);
|
ResetEvent (_expired_evt);
|
||||||
return ret;
|
return ret;
|
||||||
@ -113,13 +113,13 @@ class timerfd_tracker /* cygheap! */
|
|||||||
int disarm_timer () const { return tfd_shared->disarm_timer (); }
|
int disarm_timer () const { return tfd_shared->disarm_timer (); }
|
||||||
void timer_expired () const { tfd_shared->timer_expired (); }
|
void timer_expired () const { tfd_shared->timer_expired (); }
|
||||||
|
|
||||||
LONG64 overrun_count () const { return tfd_shared->_overrun_count; }
|
LONG64 expiration_count () const { return tfd_shared->_expiration_count; }
|
||||||
void increment_overrun_count (LONG64 add) const
|
void increment_expiration_count (LONG64 add) const
|
||||||
{ tfd_shared->increment_overrun_count (add); }
|
{ tfd_shared->increment_expiration_count (add); }
|
||||||
void set_overrun_count (LONG64 ov_cnt) const
|
void set_expiration_count (LONG64 exp_cnt) const
|
||||||
{ tfd_shared->set_overrun_count ((LONG64) ov_cnt); }
|
{ tfd_shared->set_expiration_count ((LONG64) exp_cnt); }
|
||||||
LONG64 read_and_reset_overrun_count () const
|
LONG64 read_and_reset_expiration_count () const
|
||||||
{ return tfd_shared->read_and_reset_overrun_count (); }
|
{ return tfd_shared->read_and_reset_expiration_count (); }
|
||||||
|
|
||||||
struct timespec it_value () const
|
struct timespec it_value () const
|
||||||
{ return tfd_shared->time_spec ().it_value; }
|
{ return tfd_shared->time_spec ().it_value; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user