cpython-withatomic / RISCOS / sleep.c

The branch 'legacy-trunk' does not exist.
#include "oslib/osmodule.h"
#include <stdio.h>
#include "kernel.h"
#include <limits.h>
#include <errno.h>
#include "oslib/taskwindow.h"
#include "Python.h"

int riscos_sleep(double delay)
    os_t starttime, endtime, time; /* monotonic times (centiseconds) */
    int *pollword, ret;
    osbool claimed;

    /* calculate end time */
    starttime = os_read_monotonic_time();
    if (starttime + 100.0*delay >INT_MAX)
        endtime = INT_MAX;
        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;
        time = os_read_monotonic_time();

    /* deallocate pollword */
    return ret;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.