summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-03-09 16:07:23 (GMT)
committerGuido van Rossum <guido@python.org>1999-03-09 16:07:23 (GMT)
commitd3eb5774ad18683aff2a7316242914459e422e26 (patch)
tree2e8119d7e92540575852f5f0dbd665e2eb1fed85 /Modules/timemodule.c
parentd2cd6f8c935425a12c625f7afaabe7c37401b024 (diff)
downloadcpython-d3eb5774ad18683aff2a7316242914459e422e26.zip
cpython-d3eb5774ad18683aff2a7316242914459e422e26.tar.gz
cpython-d3eb5774ad18683aff2a7316242914459e422e26.tar.bz2
Patch by Chris Herborth for BeOS code.
He writes: I had an off-by-1000 error in floatsleep(), and the problem with time.clock() is that it's not implemented properly on QNX... ANSI says it's supposed to return _CPU_ time used by the process, but on QNX it returns the amount of real time used... so I was confused.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index b65bfbc..c6d275a 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -60,10 +60,7 @@ PERFORMANCE OF THIS SOFTWARE.
#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 */
@@ -98,6 +95,10 @@ extern int ftime();
/* For bigtime_t, snooze(). - [cjh] */
#include <support/SupportDefs.h>
#include <kernel/OS.h>
+#ifndef CLOCKS_PER_SEC
+/* C'mon, fix the bloody headers... - [cjh] */
+#define CLOCKS_PER_SEC 1000
+#endif
#endif
/* Forward declarations */
@@ -705,7 +706,7 @@ floattime()
}
#endif /* !HAVE_GETTIMEOFDAY */
{
-#if defined(HAVE_FTIME) && !defined(__BEOS__)
+#if defined(HAVE_FTIME)
struct timeb t;
ftime(&t);
return (double)t.time + (double)t.millitm * (double)0.001;
@@ -811,20 +812,13 @@ floatsleep(double secs)
#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 ) {
+ /* BeOS snooze() is in microseconds... */
+ if( snooze( (bigtime_t)( secs * 1000.0 * 1000.0 ) ) == B_INTERRUPTED ) {
Py_BLOCK_THREADS
PyErr_SetFromErrno( PyExc_IOError );
return -1;