diff options
author | Guido van Rossum <guido@python.org> | 1993-01-21 16:07:51 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-01-21 16:07:51 (GMT) |
commit | 0b0db8e3a07c92786fde60bf53bd1d5aa32e0aae (patch) | |
tree | 8750daf2aeb5be8cdb034755f883c1c3557ea809 /Modules/timemodule.c | |
parent | 80530ce8754956c8d5349d4644dc83113a63cfc1 (diff) | |
download | cpython-0b0db8e3a07c92786fde60bf53bd1d5aa32e0aae.zip cpython-0b0db8e3a07c92786fde60bf53bd1d5aa32e0aae.tar.gz cpython-0b0db8e3a07c92786fde60bf53bd1d5aa32e0aae.tar.bz2 |
Added separate main program for the Mac: macmain.c
stdwinmodule.c: wsetfont can now return an error
Makefile: add CL_USE and CL_LIB*S; config.c: move CL part around
New things in imgfile; also in Makefile.
longobject.c: fix comparison of negative long ints... [REAL BUG!]
marshal.c: add dumps() and loads() to read/write strings
timemodule.c: make sure there's always a floatsleep()
posixmodule.c: rationalize struct returned by times()
Makefile: add test target, disable imgfile by default
thread.c: Improved coexistance with dl module (sjoerd)
stdwinmodule.c: Change include stdwin.h if macintosh
rotormodule.c: added missing last argument to RTR_?_region calls
confic.c: merged with configmac.c, added 1993 to copyright message
fileobject.c: int compared to NULL in writestring(); change fopenRF ifdef
timemodule.c: simplify times() using mkvalue; include myselect.h
earlier (for sequent).
posixmodule: for sequent, include unistd.h instead of explicit
extern definitions and don't define rename()
Makefile: change misleading/wrong MD5 comments
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 89d889c..b8b22e3 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -35,6 +35,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifdef BSD_TIME #define HAVE_GETTIMEOFDAY +#include "myselect.h" /* Implies <sys/types.h>, <sys/time.h>, <sys/param.h> */ #endif #ifdef macintosh @@ -70,6 +71,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <time.h> #endif /* !unix */ +/* XXX This is bogus -- times() is defined in posixmodule.c */ #ifdef DO_TIMES #include <sys/times.h> #include <sys/param.h> @@ -215,7 +217,6 @@ time_times(self, args) { struct tms t; clock_t c; - object *tuple; if (!getnoarg(args)) return NULL; errno = 0; @@ -224,18 +225,11 @@ time_times(self, args) err_errno(IOError); return NULL; } - tuple = newtupleobject(4); - if (tuple == NULL) - return NULL; - settupleitem(tuple, 0, newfloatobject((double)t.tms_utime / HZ)); - settupleitem(tuple, 1, newfloatobject((double)t.tms_stime / HZ)); - settupleitem(tuple, 2, newfloatobject((double)t.tms_cutime / HZ)); - settupleitem(tuple, 3, newfloatobject((double)t.tms_cstime / HZ)); - if (err_occurred()) { - DECREF(tuple); - return NULL; - } - return tuple; + return mkvalue("dddd", + (double)t.tms_utime / HZ, + (double)t.tms_stime / HZ, + (double)t.tms_cutime / HZ, + (double)t.tms_cstime / HZ); } #endif @@ -285,7 +279,7 @@ floatsleep(secs) { register long deadline; - deadline = MacTicks + long(secs * 60.0); + deadline = MacTicks + (long)(secs * 60.0); while (MacTicks < deadline) { if (intrcheck()) sleep_catcher(SIGINT); @@ -301,9 +295,9 @@ millitimer() #endif /* macintosh */ -#ifdef BSD_TIME +#ifdef unix -#include "myselect.h" /* Implies <sys/types.h>, <sys/time.h>, <sys/param.h> */ +#ifdef BSD_TIME long millitimer() @@ -329,7 +323,17 @@ floatsleep(secs) (void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t); } -#endif /* BSD_TIME */ +#else /* !BSD_TIME */ + +floatsleep(secs) + double secs; +{ + sleep((int)secs); +} + +#endif /* !BSD_TIME */ + +#endif /* unix */ #ifdef TURBO_C /* Maybe also for MS-DOS? */ @@ -338,14 +342,13 @@ floatsleep(secs) #define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */ #endif -static floatsleep(secs) double secs; { delay(long(secs/1000.0)); } -static long +long millitimer() { clock_t ticks; |