summaryrefslogtreecommitdiffstats
path: root/RISCOS/sleep.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-04-10 22:07:43 (GMT)
committerGuido van Rossum <guido@python.org>2001-04-10 22:07:43 (GMT)
commitbceccf5f43b51d166951ea97cff086c8828b745b (patch)
tree051a8711efadb0a2c114debc509946507e65469e /RISCOS/sleep.c
parent13aa70679ef504a7517261d5c4a3a27ee9aa30c7 (diff)
downloadcpython-bceccf5f43b51d166951ea97cff086c8828b745b.zip
cpython-bceccf5f43b51d166951ea97cff086c8828b745b.tar.gz
cpython-bceccf5f43b51d166951ea97cff086c8828b745b.tar.bz2
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Diffstat (limited to 'RISCOS/sleep.c')
-rw-r--r--RISCOS/sleep.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/RISCOS/sleep.c b/RISCOS/sleep.c
new file mode 100644
index 0000000..0aeba55
--- /dev/null
+++ b/RISCOS/sleep.c
@@ -0,0 +1,41 @@
+#include "osmodule.h"
+#include <stdio.h>
+#include "kernel.h"
+#include <limits.h>
+#include <errno.h>
+#include "taskwindow.h"
+#include "Python.h"
+
+
+int sleep(double delay)
+{
+ os_t starttime, endtime, time; /* monotonic times (centiseconds) */
+ int *pollword, ret;
+ bool claimed;
+
+ /* 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);
+
+ /* allocate (in RMA) and set pollword for xupcall_sleep */
+ pollword = osmodule_alloc(4);
+ *pollword = 1;
+
+ time = starttime;
+ ret = 0;
+ while ( time<endtime && time>=starttime ) {
+ xupcall_sleep (pollword, &claimed);
+ if (PyErr_CheckSignals()) {
+ ret = 1;
+ break;
+ }
+ time = os_read_monotonic_time();
+ }
+
+ /* deallocate pollword */
+ osmodule_free(pollword);
+ return ret;
+}