mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
* 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
This commit is contained in:
parent
25bec8c8dc
commit
ff4949eeee
19 changed files with 382 additions and 150 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue