Staging
v0.8.1
https://github.com/python/cpython
Revision 04606fbcbe2af419a2ab59ff0ba75b4fa994cfe1 authored by Ezio Melotti on 20 September 2009, 07:14:47 UTC, committed by Ezio Melotti on 20 September 2009, 07:14:47 UTC
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r74958 | ezio.melotti | 2009-09-20 10:10:39 +0300 (Sun, 20 Sep 2009) | 1 line

  #6881 - fixed wrong return type; improved the formatting
........
1 parent 7e619c0
Raw File
Tip revision: 04606fbcbe2af419a2ab59ff0ba75b4fa994cfe1 authored by Ezio Melotti on 20 September 2009, 07:14:47 UTC
Merged revisions 74958 via svnmerge from
Tip revision: 04606fb
sleep.c
#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;
}
back to top