summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-01-16 11:04:06 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-01-16 11:04:06 (GMT)
commit02af964924009c54d3fb872d60f5e384563bd136 (patch)
tree844929821c6b7edb1abce7ceb07de21ae2d6cc3d /Modules/timemodule.c
parent1f803f782c3bb7aa9ff1cb96d4a2c1f2a0facbde (diff)
downloadcpython-02af964924009c54d3fb872d60f5e384563bd136.zip
cpython-02af964924009c54d3fb872d60f5e384563bd136.tar.gz
cpython-02af964924009c54d3fb872d60f5e384563bd136.tar.bz2
Patch #504225: add plan9 ifdef to timemodule floatsleep.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index a5d81fe..6841b0f 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -778,8 +778,7 @@ floatsleep(double secs)
}
}
Py_END_ALLOW_THREADS
-#else /* !HAVE_SELECT || __BEOS__ */
-#ifdef macintosh
+#elif defined(macintosh)
#define MacTicks (* (long *)0x16A)
long deadline;
deadline = MacTicks + (long)(secs * 60.0);
@@ -788,14 +787,12 @@ floatsleep(double secs)
if (PyErr_CheckSignals())
return -1;
}
-#else /* !macintosh */
-#if defined(__WATCOMC__) && !defined(__QNX__)
+#elif defined(__WATCOMC__) && !defined(__QNX__)
/* XXX Can't interrupt this sleep */
Py_BEGIN_ALLOW_THREADS
delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */
Py_END_ALLOW_THREADS
-#else /* !__WATCOMC__ || __QNX__ */
-#ifdef MSDOS
+#elif defined(MSDOS)
struct timeb t1, t2;
double frac;
extern double fmod(double, double);
@@ -824,8 +821,7 @@ floatsleep(double secs)
t1.time == t2.time && t1.millitm >= t2.millitm)
break;
}
-#else /* !MSDOS */
-#ifdef MS_WIN32
+#elif defined(MS_WIN32)
{
double millisecs = secs * 1000.0;
if (millisecs > (double)ULONG_MAX) {
@@ -837,8 +833,7 @@ floatsleep(double secs)
Sleep((unsigned long)millisecs);
Py_END_ALLOW_THREADS
}
-#else /* !MS_WIN32 */
-#ifdef PYOS_OS2
+#elif defined(PYOS_OS2)
/* This Sleep *IS* Interruptable by Exceptions */
Py_BEGIN_ALLOW_THREADS
if (DosSleep(secs * 1000) != NO_ERROR) {
@@ -847,8 +842,7 @@ floatsleep(double secs)
return -1;
}
Py_END_ALLOW_THREADS
-#else /* !PYOS_OS2 */
-#ifdef __BEOS__
+#elif defined(__BEOS__)
/* This sleep *CAN BE* interrupted. */
{
if( secs <= 0.0 ) {
@@ -864,8 +858,7 @@ floatsleep(double secs)
}
Py_END_ALLOW_THREADS
}
-#else /* !__BEOS__ */
-#ifdef RISCOS
+#elif defined(RISCOS)
if (secs <= 0.0)
return 0;
Py_BEGIN_ALLOW_THREADS
@@ -873,19 +866,28 @@ floatsleep(double secs)
if ( sleep(secs) )
return -1;
Py_END_ALLOW_THREADS
-#else /* !RISCOS */
+#elif defined(PLAN9)
+ {
+ double millisecs = secs * 1000.0;
+ if (millisecs > (double)LONG_MAX) {
+ PyErr_SetString(PyExc_OverflowError, "sleep length is too large");
+ return -1;
+ }
+ /* This sleep *CAN BE* interrupted. */
+ Py_BEGIN_ALLOW_THREADS
+ if(sleep((long)millisecs) < 0){
+ Py_BLOCK_THREADS
+ PyErr_SetFromErrno(PyExc_IOError);
+ return -1;
+ }
+ Py_END_ALLOW_THREADS
+ }
+#else
/* XXX Can't interrupt this sleep */
Py_BEGIN_ALLOW_THREADS
sleep((int)secs);
Py_END_ALLOW_THREADS
-#endif /* !RISCOS */
-#endif /* !__BEOS__ */
-#endif /* !PYOS_OS2 */
-#endif /* !MS_WIN32 */
-#endif /* !MSDOS */
-#endif /* !__WATCOMC__ || __QNX__ */
-#endif /* !macintosh */
-#endif /* !HAVE_SELECT */
+#endif
return 0;
}