* 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
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 @@
*/
#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 @@
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 @@
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 @@
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 @@
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 @@
char *msg;
if (!getstrarg(args, &msg))
return NULL;
+ BGN_STDWIN
wmessage(msg);
+ END_STDWIN
INCREF(None);
return None;
}
@@ -2185,4 +2214,9 @@
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
}