diff options
author | Guido van Rossum <guido@python.org> | 1998-08-04 22:53:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-08-04 22:53:56 (GMT) |
commit | bcc207484a0f8f27a684e11194e7430c0710f66d (patch) | |
tree | 506ce2d793a619a92e78faa89032878ea4a43461 /Modules/timemodule.c | |
parent | 1a8791e0b875df8e9428c2d9969f64e5967ac0b4 (diff) | |
download | cpython-bcc207484a0f8f27a684e11194e7430c0710f66d.zip cpython-bcc207484a0f8f27a684e11194e7430c0710f66d.tar.gz cpython-bcc207484a0f8f27a684e11194e7430c0710f66d.tar.bz2 |
Changes for BeOS, QNX and long long, by Chris Herborth.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 43b247f..7feefbc 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -53,14 +53,17 @@ PERFORMANCE OF THIS SOFTWARE. #include <unistd.h> #endif -#ifdef HAVE_SELECT +#if defined(HAVE_SELECT) && !defined(__BEOS__) #include "myselect.h" #else #include "mytime.h" #endif #ifdef HAVE_FTIME +#ifndef __BEOS__ +/* We have ftime(), but not in the headers (PR2). - [cjh] */ #include <sys/timeb.h> +#endif #if !defined(MS_WINDOWS) && !defined(PYOS_OS2) extern int ftime(); #endif /* MS_WINDOWS */ @@ -99,6 +102,12 @@ extern int ftime(); #define timezone _timezone #endif +#ifdef __BEOS__ +/* For bigtime_t, snooze(). - [cjh] */ +#include <support/SupportDefs.h> +#include <kernel/OS.h> +#endif + /* Forward declarations */ static int floatsleep Py_PROTO((double)); static double floattime Py_PROTO(()); @@ -670,7 +679,7 @@ floattime() } #endif /* !HAVE_GETTIMEOFDAY */ { -#ifdef HAVE_FTIME +#if defined(HAVE_FTIME) && !defined(__BEOS__) struct timeb t; ftime(&t); return (double)t.time + (double)t.millitm * (double)0.001; @@ -696,7 +705,7 @@ floatsleep(double secs) #endif /* MPW */ { /* XXX Should test for MS_WIN32 first! */ -#ifdef HAVE_SELECT +#if defined(HAVE_SELECT) && !defined(__BEOS__) struct timeval t; double frac; frac = fmod(secs, 1.0); @@ -710,7 +719,7 @@ floatsleep(double secs) return -1; } Py_END_ALLOW_THREADS -#else /* !HAVE_SELECT */ +#else /* !HAVE_SELECT || __BEOS__ */ #ifdef macintosh #define MacTicks (* (long *)0x16A) long deadline; @@ -773,10 +782,35 @@ floatsleep(double secs) } Py_END_ALLOW_THREADS #else /* !PYOS_OS2 */ +#ifdef __BEOS__ + /* This sleep *CAN BE* interrupted. */ + { + bigtime_t frac, seconds; + + extern double fmod Py_PROTO((double,double)); + extern double floor Py_PROTO((double)); + + if( secs <= 0.0 ) { + return; + } + + frac = (bigtime_t)fmod( secs, 1.0 ); + seconds = (bigtime_t)floor( secs ); + + Py_BEGIN_ALLOW_THREADS + if( snooze( seconds * (bigtime_t)1000 + frac ) == B_INTERRUPTED ) { + Py_BLOCK_THREADS + PyErr_SetFromErrno( PyExc_IOError ); + return -1; + } + Py_END_ALLOW_THREADS + } +#else /* !__BEOS__ */ /* XXX Can't interrupt this sleep */ Py_BEGIN_ALLOW_THREADS sleep((int)secs); Py_END_ALLOW_THREADS +#endif /* !__BEOS__ */ #endif /* !PYOS_OS2 */ #endif /* !MS_WIN32 */ #endif /* !MSDOS */ |