diff options
author | Guido van Rossum <guido@python.org> | 1992-08-05 19:58:53 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-08-05 19:58:53 (GMT) |
commit | ff4949eeee7f86117d4a69599777ff5564315e39 (patch) | |
tree | 551b1b2d53d665fb81d10dd1d51e433be0512604 /Modules/timemodule.c | |
parent | 25bec8c8dc0de55694cc573ef6d213ee5babd306 (diff) | |
download | cpython-ff4949eeee7f86117d4a69599777ff5564315e39.zip cpython-ff4949eeee7f86117d4a69599777ff5564315e39.tar.gz cpython-ff4949eeee7f86117d4a69599777ff5564315e39.tar.bz2 |
* Makefile: cosmetics
* socketmodule.c: get rid of makepair(); fix makesocketaddr to fix
broken recvfrom()
* socketmodule: get rid of getStrarg()
* ceval.h: move eval_code() to new file eval.h, so compile.h is no
longer needed.
* ceval.c: move thread comments to ceval.h; always make save/restore
thread functions available (for dynloaded modules)
* cdmodule.c, listobject.c: don't include compile.h
* flmodule.c: include ceval.h
* import.c: include eval.h instead of ceval.h
* cgen.py: add forground(); noport(); winopen(""); to initgl().
* bltinmodule.c, socketmodule.c, fileobject.c, posixmodule.c,
selectmodule.c:
adapt to threads (add BGN/END SAVE macros)
* stdwinmodule.c: adapt to threads and use a special stdwin lock.
* pythonmain.c: don't include getpythonpath().
* pythonrun.c: use BGN/END SAVE instead of direct calls; also more
BGN/END SAVE calls etc.
* thread.c: bigger stack size for sun; change exit() to _exit()
* threadmodule.c: use BGN/END SAVE macros where possible
* timemodule.c: adapt better to threads; use BGN/END SAVE; add
longsleep internal function if BSD_TIME; cosmetics
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 5a278a9bd..4d13611 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -25,8 +25,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* Time module */ #include "allobjects.h" - #include "modsupport.h" +#include "ceval.h" #include "sigtype.h" @@ -104,14 +104,13 @@ time_sleep(self, args) object *self; object *args; { - void *save, *save_thread(), restore_thread(); - int secs; + long secs; SIGTYPE (*sigsave)() = 0; /* Initialized to shut lint up */ - if (!getintarg(args, &secs)) + if (!getargs(args, "l", &secs)) return NULL; - save = save_thread(); + BGN_SAVE if (setjmp(sleep_intr)) { - restore_thread(save); + RET_SAVE signal(SIGINT, sigsave); err_set(KeyboardInterrupt); return NULL; @@ -119,8 +118,12 @@ time_sleep(self, args) sigsave = signal(SIGINT, SIG_IGN); if (sigsave != (SIGTYPE (*)()) SIG_IGN) signal(SIGINT, sleep_catcher); - sleep(secs); - restore_thread(save); +#ifdef BSD_TIME + longsleep(secs); +#else + sleep((int)secs); +#endif + END_SAVE signal(SIGINT, sigsave); INCREF(None); return None; @@ -151,14 +154,13 @@ time_millisleep(self, args) object *self; object *args; { - void *save, *save_thread(), restore_thread(); long msecs; SIGTYPE (*sigsave)(); if (!getlongarg(args, &msecs)) return NULL; - save = save_thread(); + BGN_SAVE if (setjmp(sleep_intr)) { - restore_thread(save); + RET_SAVE signal(SIGINT, sigsave); err_set(KeyboardInterrupt); return NULL; @@ -167,7 +169,7 @@ time_millisleep(self, args) if (sigsave != (SIGTYPE (*)()) SIG_IGN) signal(SIGINT, sleep_catcher); millisleep(msecs); - restore_thread(save); + END_SAVE signal(SIGINT, sigsave); INCREF(None); return None; @@ -249,12 +251,12 @@ inittime() #define MacTicks (* (long *)0x16A) #ifdef THINK_C_3_0 -sleep(msecs) - int msecs; +sleep(secs) + int secs; { register long deadline; - deadline = MacTicks + msecs * 60; + deadline = MacTicks + mecs * 60; while (MacTicks < deadline) { if (intrcheck()) sleep_catcher(SIGINT); @@ -295,7 +297,6 @@ millitimer() if (gettimeofday(&t, &tz) != 0) return -1; return t.tv_sec*1000 + t.tv_usec/1000; - } millisleep(msecs) @@ -307,6 +308,15 @@ millisleep(msecs) (void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t); } +longsleep(secs) + long secs; +{ + struct timeval t; + t.tv_sec = secs; + t.tv_usec = 0; + (void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t); +} + #endif /* BSD_TIME */ |