mirror of
https://github.com/python/cpython.git
synced 2025-11-08 21:52:45 +00:00
Patch #504225: add plan9 ifdef to timemodule floatsleep.
This commit is contained in:
parent
1f803f782c
commit
02af964924
1 changed files with 25 additions and 23 deletions
|
|
@ -778,8 +778,7 @@ floatsleep(double secs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
#else /* !HAVE_SELECT || __BEOS__ */
|
#elif defined(macintosh)
|
||||||
#ifdef macintosh
|
|
||||||
#define MacTicks (* (long *)0x16A)
|
#define MacTicks (* (long *)0x16A)
|
||||||
long deadline;
|
long deadline;
|
||||||
deadline = MacTicks + (long)(secs * 60.0);
|
deadline = MacTicks + (long)(secs * 60.0);
|
||||||
|
|
@ -788,14 +787,12 @@ floatsleep(double secs)
|
||||||
if (PyErr_CheckSignals())
|
if (PyErr_CheckSignals())
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else /* !macintosh */
|
#elif defined(__WATCOMC__) && !defined(__QNX__)
|
||||||
#if defined(__WATCOMC__) && !defined(__QNX__)
|
|
||||||
/* XXX Can't interrupt this sleep */
|
/* XXX Can't interrupt this sleep */
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */
|
delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
#else /* !__WATCOMC__ || __QNX__ */
|
#elif defined(MSDOS)
|
||||||
#ifdef MSDOS
|
|
||||||
struct timeb t1, t2;
|
struct timeb t1, t2;
|
||||||
double frac;
|
double frac;
|
||||||
extern double fmod(double, double);
|
extern double fmod(double, double);
|
||||||
|
|
@ -824,8 +821,7 @@ floatsleep(double secs)
|
||||||
t1.time == t2.time && t1.millitm >= t2.millitm)
|
t1.time == t2.time && t1.millitm >= t2.millitm)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else /* !MSDOS */
|
#elif defined(MS_WIN32)
|
||||||
#ifdef MS_WIN32
|
|
||||||
{
|
{
|
||||||
double millisecs = secs * 1000.0;
|
double millisecs = secs * 1000.0;
|
||||||
if (millisecs > (double)ULONG_MAX) {
|
if (millisecs > (double)ULONG_MAX) {
|
||||||
|
|
@ -837,8 +833,7 @@ floatsleep(double secs)
|
||||||
Sleep((unsigned long)millisecs);
|
Sleep((unsigned long)millisecs);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
}
|
}
|
||||||
#else /* !MS_WIN32 */
|
#elif defined(PYOS_OS2)
|
||||||
#ifdef PYOS_OS2
|
|
||||||
/* This Sleep *IS* Interruptable by Exceptions */
|
/* This Sleep *IS* Interruptable by Exceptions */
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
if (DosSleep(secs * 1000) != NO_ERROR) {
|
if (DosSleep(secs * 1000) != NO_ERROR) {
|
||||||
|
|
@ -847,8 +842,7 @@ floatsleep(double secs)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
#else /* !PYOS_OS2 */
|
#elif defined(__BEOS__)
|
||||||
#ifdef __BEOS__
|
|
||||||
/* This sleep *CAN BE* interrupted. */
|
/* This sleep *CAN BE* interrupted. */
|
||||||
{
|
{
|
||||||
if( secs <= 0.0 ) {
|
if( secs <= 0.0 ) {
|
||||||
|
|
@ -864,8 +858,7 @@ floatsleep(double secs)
|
||||||
}
|
}
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
}
|
}
|
||||||
#else /* !__BEOS__ */
|
#elif defined(RISCOS)
|
||||||
#ifdef RISCOS
|
|
||||||
if (secs <= 0.0)
|
if (secs <= 0.0)
|
||||||
return 0;
|
return 0;
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
|
@ -873,19 +866,28 @@ floatsleep(double secs)
|
||||||
if ( sleep(secs) )
|
if ( sleep(secs) )
|
||||||
return -1;
|
return -1;
|
||||||
Py_END_ALLOW_THREADS
|
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 */
|
/* XXX Can't interrupt this sleep */
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
sleep((int)secs);
|
sleep((int)secs);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
#endif /* !RISCOS */
|
#endif
|
||||||
#endif /* !__BEOS__ */
|
|
||||||
#endif /* !PYOS_OS2 */
|
|
||||||
#endif /* !MS_WIN32 */
|
|
||||||
#endif /* !MSDOS */
|
|
||||||
#endif /* !__WATCOMC__ || __QNX__ */
|
|
||||||
#endif /* !macintosh */
|
|
||||||
#endif /* !HAVE_SELECT */
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue