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/stdwinmodule.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/stdwinmodule.c')
-rw-r--r-- | Modules/stdwinmodule.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c index 537777e..e33610d 100644 --- a/Modules/stdwinmodule.c +++ b/Modules/stdwinmodule.c @@ -63,11 +63,29 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "allobjects.h" - #include "modsupport.h" +#include "ceval.h" #include "stdwin.h" +#ifdef USE_THREAD + +#include "thread.h" + +static type_lock StdwinLock; /* Lock held when interpreter not locked */ + +#define BGN_STDWIN BGN_SAVE acquire_lock(StdwinLock, 1); +#define RET_STDWIN release_lock(StdwinLock); RET_SAVE +#define END_STDWIN release_lock(StdwinLock); END_SAVE + +#else + +#define BGN_STDWIN BGN_SAVE +#define RET_STDWIN RET_SAVE +#define END_STDWIN END_SAVE + +#endif + static object *StdwinError; /* Exception stdwin.error */ /* Window and menu object types declared here because of forward references */ @@ -1727,14 +1745,17 @@ stdwin_get_poll_event(poll, args) return NULL; } again: + BGN_STDWIN if (poll) { if (!wpollevent(&e)) { + RET_STDWIN INCREF(None); return None; } } else wgetevent(&e); + END_STDWIN if (e.type == WE_COMMAND && e.u.command == WC_CANCEL) { /* Turn keyboard interrupts into exceptions */ err_set(KeyboardInterrupt); @@ -1919,7 +1940,9 @@ stdwin_askfile(self, args) return NULL; strncpy(buf, dflt, sizeof buf); buf[sizeof buf - 1] = '\0'; + BGN_STDWIN ret = waskfile(prompt, buf, sizeof buf, new); + END_STDWIN if (!ret) { err_set(KeyboardInterrupt); return NULL; @@ -1936,7 +1959,9 @@ stdwin_askync(self, args) int new, ret; if (!getstrintarg(args, &prompt, &new)) return NULL; + BGN_STDWIN ret = waskync(prompt, new); + END_STDWIN if (ret < 0) { err_set(KeyboardInterrupt); return NULL; @@ -1956,7 +1981,9 @@ stdwin_askstr(self, args) return NULL; strncpy(buf, dflt, sizeof buf); buf[sizeof buf - 1] = '\0'; + BGN_STDWIN ret = waskstr(prompt, buf, sizeof buf); + END_STDWIN if (!ret) { err_set(KeyboardInterrupt); return NULL; @@ -1972,7 +1999,9 @@ stdwin_message(self, args) char *msg; if (!getstrarg(args, &msg)) return NULL; + BGN_STDWIN wmessage(msg); + END_STDWIN INCREF(None); return None; } @@ -2185,4 +2214,9 @@ initstdwin() StdwinError = newstringobject("stdwin.error"); if (StdwinError == NULL || dictinsert(d, "error", StdwinError) != 0) fatal("can't define stdwin.error"); +#ifdef USE_THREAD + StdwinLock = allocate_lock(); + if (StdwinLock == NULL) + fatal("can't allocate stdwin lock"); +#endif } |