Cygwin: timerfd: implement TFD_IOC_SET_TICKS ioctl
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
0e8c7b8689
commit
173e067a31
|
@ -176,15 +176,29 @@ 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;
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case TFD_IOC_SET_TICKS:
|
case TFD_IOC_SET_TICKS:
|
||||||
/* TODO */
|
__try
|
||||||
|
{
|
||||||
|
timer_tracker *tt = (timer_tracker *) timerid;
|
||||||
|
|
||||||
|
ov_cnt = *(uint64_t *) p;
|
||||||
|
if (!ov_cnt)
|
||||||
|
{
|
||||||
|
set_errno (EINVAL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tt->set_event (ov_cnt);
|
||||||
|
}
|
||||||
|
__except (EFAULT) {}
|
||||||
|
__endtry
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
set_errno (EINVAL);
|
ret = fhandler_base::ioctl (cmd, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
syscall_printf ("%d = ioctl_timerfd(%x, %p)", ret, cmd, p);
|
syscall_printf ("%d = ioctl_timerfd(%x, %p)", ret, cmd, p);
|
||||||
|
|
|
@ -132,6 +132,22 @@ timer_tracker::arm_event ()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
timer_tracker::set_event (uint64_t ov_cnt)
|
||||||
|
{
|
||||||
|
LONG ret;
|
||||||
|
|
||||||
|
while ((ret = InterlockedCompareExchange (&event_running, EVENT_LOCK,
|
||||||
|
EVENT_DISARMED)) == EVENT_LOCK)
|
||||||
|
yield ();
|
||||||
|
InterlockedExchange64 (&overrun_count, ov_cnt);
|
||||||
|
if (ret == EVENT_DISARMED)
|
||||||
|
{
|
||||||
|
SetEvent (get_timerfd_handle ());
|
||||||
|
InterlockedExchange (&event_running, EVENT_ARMED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LONG64
|
LONG64
|
||||||
timer_tracker::_disarm_event ()
|
timer_tracker::_disarm_event ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,9 @@ class timer_tracker
|
||||||
|
|
||||||
void gettime (itimerspec *);
|
void gettime (itimerspec *);
|
||||||
int settime (int, const itimerspec *, itimerspec *);
|
int settime (int, const itimerspec *, itimerspec *);
|
||||||
|
|
||||||
LONG arm_event ();
|
LONG arm_event ();
|
||||||
|
void set_event (uint64_t ov_cnt);
|
||||||
unsigned int disarm_event ();
|
unsigned int disarm_event ();
|
||||||
|
|
||||||
DWORD thread_func ();
|
DWORD thread_func ();
|
||||||
|
|
Loading…
Reference in New Issue