2001-10-24 17:13:15 -03:00
|
|
|
#include "oslib/osmodule.h"
|
2001-04-10 19:07:43 -03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "kernel.h"
|
|
|
|
#include <limits.h>
|
|
|
|
#include <errno.h>
|
2001-10-24 17:13:15 -03:00
|
|
|
#include "oslib/taskwindow.h"
|
2001-04-10 19:07:43 -03:00
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
|
2003-05-10 04:36:56 -03:00
|
|
|
int riscos_sleep(double delay)
|
2001-04-10 19:07:43 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
os_t starttime, endtime, time; /* monotonic times (centiseconds) */
|
|
|
|
int *pollword, ret;
|
|
|
|
osbool claimed;
|
2001-04-10 19:07:43 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
/* calculate end time */
|
|
|
|
starttime = os_read_monotonic_time();
|
|
|
|
if (starttime + 100.0*delay >INT_MAX)
|
|
|
|
endtime = INT_MAX;
|
|
|
|
else
|
|
|
|
endtime = (os_t)(starttime + 100.0*delay);
|
2001-04-10 19:07:43 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
/* allocate (in RMA) and set pollword for xupcall_sleep */
|
|
|
|
pollword = osmodule_alloc(4);
|
|
|
|
*pollword = 1;
|
2001-04-10 19:07:43 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
time = starttime;
|
|
|
|
ret = 0;
|
|
|
|
while ( time<endtime && time>=starttime ) {
|
|
|
|
xupcall_sleep (pollword, &claimed);
|
|
|
|
if (PyErr_CheckSignals()) {
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
time = os_read_monotonic_time();
|
|
|
|
}
|
2001-04-10 19:07:43 -03:00
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
/* deallocate pollword */
|
|
|
|
osmodule_free(pollword);
|
|
|
|
return ret;
|
2001-04-10 19:07:43 -03:00
|
|
|
}
|