comparison Python/pythonrun.c @ 926:c156d4960c2b legacy-trunk

* 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
author Guido van Rossum <guido@python.org>
date Wed, 05 Aug 1992 19:58:53 +0000
parents 72aceed365d4
children cd40e3eebb49
comparison
equal deleted inserted replaced
925:61143bf03b44 926:c156d4960c2b
31 #include "parsetok.h" 31 #include "parsetok.h"
32 #include "graminit.h" 32 #include "graminit.h"
33 #include "errcode.h" 33 #include "errcode.h"
34 #include "sysmodule.h" 34 #include "sysmodule.h"
35 #include "compile.h" 35 #include "compile.h"
36 #include "eval.h"
36 #include "ceval.h" 37 #include "ceval.h"
37 #include "pythonrun.h" 38 #include "pythonrun.h"
38 #include "import.h" 39 #include "import.h"
39
40 #ifdef USE_THREAD
41 extern void *save_thread();
42 #endif
43 40
44 extern char *getpythonpath(); 41 extern char *getpythonpath();
45 42
46 extern grammar gram; /* From graminit.c */ 43 extern grammar gram; /* From graminit.c */
47 44
125 int 122 int
126 run_tty_1(fp, filename) 123 run_tty_1(fp, filename)
127 FILE *fp; 124 FILE *fp;
128 char *filename; 125 char *filename;
129 { 126 {
130 void *save, *save_thread(), restore_thread();
131 object *m, *d, *v, *w; 127 object *m, *d, *v, *w;
132 node *n; 128 node *n;
133 char *ps1, *ps2; 129 char *ps1, *ps2;
134 int err; 130 int err;
135 v = sysget("ps1"); 131 v = sysget("ps1");
148 } 144 }
149 else { 145 else {
150 w = NULL; 146 w = NULL;
151 ps2 = ""; 147 ps2 = "";
152 } 148 }
153 save = save_thread(); 149 BGN_SAVE
154 err = parsefile(fp, filename, &gram, single_input, ps1, ps2, &n); 150 err = parsefile(fp, filename, &gram, single_input, ps1, ps2, &n);
155 restore_thread(save); 151 END_SAVE
156 XDECREF(v); 152 XDECREF(v);
157 XDECREF(w); 153 XDECREF(w);
158 if (err == E_EOF) 154 if (err == E_EOF)
159 return E_EOF; 155 return E_EOF;
160 if (err != E_DONE) { 156 if (err != E_DONE) {
328 FILE *fp; 324 FILE *fp;
329 char *filename; 325 char *filename;
330 int start; 326 int start;
331 node **n_ret; 327 node **n_ret;
332 { 328 {
333 return parsefile(fp, filename, &gram, start, 329 int ret;
330 BGN_SAVE
331 ret = parsefile(fp, filename, &gram, start,
334 (char *)0, (char *)0, n_ret); 332 (char *)0, (char *)0, n_ret);
333 END_SAVE
334 return ret;
335 } 335 }
336 336
337 /* Simplified interface to parsestring */ 337 /* Simplified interface to parsestring */
338 338
339 int 339 int
364 void 364 void
365 goaway(sts) 365 goaway(sts)
366 int sts; 366 int sts;
367 { 367 {
368 flushline(); 368 flushline();
369
370 #ifdef USE_THREAD
371
372 /* Other threads may still be active, so skip most of the
373 cleanup actions usually done (these are mostly for
374 debugging anyway). */
375
376 (void *) save_thread();
377 donecalls();
378 exit_prog(sts);
379
380 #else /* USE_THREAD */
369 381
370 /* XXX Call doneimport() before donecalls(), since donecalls() 382 /* XXX Call doneimport() before donecalls(), since donecalls()
371 calls wdone(), and doneimport() may close windows */ 383 calls wdone(), and doneimport() may close windows */
372 doneimport(); 384 doneimport();
373 donecalls(); 385 donecalls();
382 if (askyesno("Print left references?")) { 394 if (askyesno("Print left references?")) {
383 printrefs(stderr); 395 printrefs(stderr);
384 } 396 }
385 #endif /* TRACE_REFS */ 397 #endif /* TRACE_REFS */
386 398
387 #ifdef USE_THREAD
388 (void) save_thread();
389 exit_prog(sts);
390 #else
391 exit(sts); 399 exit(sts);
392 #endif 400 #endif /* USE_THREAD */
393 /*NOTREACHED*/ 401 /*NOTREACHED*/
394 } 402 }
395 403
396 #ifdef TRACE_REFS 404 #ifdef TRACE_REFS
397 /* Ask a yes/no question */ 405 /* Ask a yes/no question */