symbian-qemu-0.9.1-12/python-2.6.1/RISCOS/sleep.c
author Mike Kinghan <mikek@symbian.org>
Wed, 04 Aug 2010 15:41:26 +0100
branchGCC_SURGE
changeset 95 285922d13199
parent 1 2fb8b9db1c86
permissions -rw-r--r--
Correction for the fix for Bug 3508 - Persistent storage support breaks Linux compatibility. A 2nd `make install' will fail attempting to create symlink libnvmemmory.so already created by 1st install. Install should pre-emptively delete it.

#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;
	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;
}