diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 7 | ||||
-rw-r--r-- | Python/ceval.c | 35 | ||||
-rw-r--r-- | Python/import.c | 2 | ||||
-rw-r--r-- | Python/pythonmain.c | 2 | ||||
-rw-r--r-- | Python/pythonrun.c | 34 | ||||
-rw-r--r-- | Python/thread.c | 8 |
6 files changed, 40 insertions, 48 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index d6ae46f..ca5043d 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -33,7 +33,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "bltinmodule.h" #include "import.h" #include "pythonrun.h" -#include "compile.h" /* For ceval.h */ #include "ceval.h" #include "modsupport.h" @@ -218,13 +217,17 @@ builtin_execfile(self, v) "execfile arguments must be filename[,dict[,dict]]"); return NULL; } + BGN_SAVE fp = fopen(getstringvalue(str), "r"); + END_SAVE if (fp == NULL) { err_setstr(IOError, "execfile cannot open the file argument"); return NULL; } w = run_file(fp, getstringvalue(str), file_input, globals, locals); + BGN_SAVE fclose(fp); + END_SAVE return w; } @@ -324,9 +327,11 @@ builtin_input(self, v) } m = add_module("__main__"); d = getmoduledict(m); + BGN_SAVE while ((c = getc(in)) != EOF && (c == ' ' || c == '\t')) ; ungetc(c, in); + END_SAVE return run_file(in, "<stdin>", expr_input, d, d); } diff --git a/Python/ceval.c b/Python/ceval.c index 32c52c7..252b1dc 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -30,6 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "sysmodule.h" #include "compile.h" #include "frameobject.h" +#include "eval.h" #include "ceval.h" #include "opcode.h" #include "bltinmodule.h" @@ -83,48 +84,28 @@ static object *build_class PROTO((object *, object *)); static frameobject *current_frame; - -/* Interface for threads. - - A module that plans to do a blocking system call (or something else - that lasts a long time and doesn't touch Python data) can allow other - threads to run as follows: - - void *x; - - ...preparations here... - x = save_thread(); - ...blocking system call here... - restore_thread(x); - ...interpretr result here... - - For convenience, that the value of 'errno' is restored across the - the call to restore_thread(). - - The function init_save_thread() should be called only from - initthread() in "threadmodule.c". - - Note that not yet all candidates have been converted to use this - mechanism! -*/ - #ifdef USE_THREAD + #include <errno.h> #include "thread.h" + static type_lock interpreter_lock; void init_save_thread() { -#ifdef USE_THREAD if (interpreter_lock) fatal("2nd call to init_save_thread"); interpreter_lock = allocate_lock(); acquire_lock(interpreter_lock, 1); -#endif } + #endif +/* Functions save_thread and restore_thread are always defined so + dynamically loaded modules needn't be compiled separately for use + with and without threads: */ + void * save_thread() { diff --git a/Python/import.c b/Python/import.c index 5667c77..44f6d7b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -35,7 +35,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "pythonrun.h" #include "marshal.h" #include "compile.h" -#include "ceval.h" +#include "eval.h" #include "osdefs.h" extern int verbose; /* Defined in pythonmain.c */ diff --git a/Python/pythonmain.c b/Python/pythonmain.c index 0f76bfd..4344cde 100644 --- a/Python/pythonmain.c +++ b/Python/pythonmain.c @@ -26,8 +26,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "allobjects.h" -extern char *getpythonpath(); - extern int debugging; /* Needed by parser.c */ extern int verbose; /* Needed by import.c */ diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 2a68f24..c8921da 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -33,14 +33,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "errcode.h" #include "sysmodule.h" #include "compile.h" +#include "eval.h" #include "ceval.h" #include "pythonrun.h" #include "import.h" -#ifdef USE_THREAD -extern void *save_thread(); -#endif - extern char *getpythonpath(); extern grammar gram; /* From graminit.c */ @@ -127,7 +124,6 @@ run_tty_1(fp, filename) FILE *fp; char *filename; { - void *save, *save_thread(), restore_thread(); object *m, *d, *v, *w; node *n; char *ps1, *ps2; @@ -150,9 +146,9 @@ run_tty_1(fp, filename) w = NULL; ps2 = ""; } - save = save_thread(); + BGN_SAVE err = parsefile(fp, filename, &gram, single_input, ps1, ps2, &n); - restore_thread(save); + END_SAVE XDECREF(v); XDECREF(w); if (err == E_EOF) @@ -330,8 +326,12 @@ parse_file(fp, filename, start, n_ret) int start; node **n_ret; { - return parsefile(fp, filename, &gram, start, + int ret; + BGN_SAVE + ret = parsefile(fp, filename, &gram, start, (char *)0, (char *)0, n_ret); + END_SAVE + return ret; } /* Simplified interface to parsestring */ @@ -366,6 +366,18 @@ goaway(sts) int sts; { flushline(); + +#ifdef USE_THREAD + + /* Other threads may still be active, so skip most of the + cleanup actions usually done (these are mostly for + debugging anyway). */ + + (void *) save_thread(); + donecalls(); + exit_prog(sts); + +#else /* USE_THREAD */ /* XXX Call doneimport() before donecalls(), since donecalls() calls wdone(), and doneimport() may close windows */ @@ -384,12 +396,8 @@ goaway(sts) } #endif /* TRACE_REFS */ -#ifdef USE_THREAD - (void) save_thread(); - exit_prog(sts); -#else exit(sts); -#endif +#endif /* USE_THREAD */ /*NOTREACHED*/ } diff --git a/Python/thread.c b/Python/thread.c index 1f0633a..4aa06cf 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -17,7 +17,7 @@ static int exiting; #include <lwp/lwp.h> #include <lwp/stackdep.h> -#define STACKSIZE 1000 /* stacksize for a thread */ +#define STACKSIZE 16000 /* stacksize for a thread */ #define NSTACKS 2 /* # stacks to be put in cache initialy */ struct lock { @@ -90,7 +90,7 @@ void exit_thread _P0() exit(0); #ifdef __sgi exiting = 1; - exit(0); + _exit(0); #endif #ifdef SOLARIS thread_exit(); @@ -113,7 +113,7 @@ static void exit_sig _P0() #ifdef DEBUG printf("exiting in exit_sig\n"); #endif - exit(exit_status); + _exit(exit_status); } } #endif @@ -255,7 +255,7 @@ void exit_prog _P1(status, int status) exiting = 1; do_exit = 1; exit_status = status; - exit(status); + _exit(status); #endif #ifdef sun pod_exit(status); |