blob: d9708a2d32c5da833d2f757d3f49ea8d8d5a48d0 [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001/***********************************************************
Guido van Rossum5113f5f1992-04-05 14:20:22 +00002Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The
Guido van Rossumf70e43a1991-02-19 12:39:46 +00003Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
Guido van Rossumff4949e1992-08-05 19:58:53 +000025/* Interface to random parts in ceval.c */
Guido van Rossum3f5da241990-12-20 15:06:42 +000026
Guido van Rossuma0490311991-07-27 21:33:03 +000027object *call_object PROTO((object *, object *));
28
Guido van Rossum3f5da241990-12-20 15:06:42 +000029object *getglobals PROTO((void));
30object *getlocals PROTO((void));
31
32void printtraceback PROTO((FILE *));
Guido van Rossum704a26c1992-03-27 17:29:31 +000033void flushline PROTO((void));
Guido van Rossumff4949e1992-08-05 19:58:53 +000034
35
36/* Interface for threads.
37
38 A module that plans to do a blocking system call (or something else
39 that lasts a long time and doesn't touch Python data) can allow other
40 threads to run as follows:
41
42 ...preparations here...
43 BGN_SAVE
44 ...blocking system call here...
45 END_SAVE
46 ...interpretr result here...
47
48 The BGN_SAVE/END_SAVE pair expands to a {}-surrounded block.
49 To leave the block in the middle (e.g., with return), you must insert
50 a line containing RET_SAVE before the return, e.g.
51
52 if (...premature_exit...) {
53 RET_SAVE
54 err_errno(IOError);
55 return NULL;
56 }
57
58 An alternative is:
59
60 RET_SAVE
61 if (...premature_exit...) {
62 err_errno(IOError);
63 return NULL;
64 }
65 RES_SAVE
66
67 For convenience, that the value of 'errno' is restored across
68 END_SAVE and RET_SAVE.
69
70 WARNING: NEVER NEST CALLS TO BGN_SAVE AND END_SAVE!!!
71
72 The function init_save_thread() should be called only from
73 initthread() in "threadmodule.c".
74
75 Note that not yet all candidates have been converted to use this
76 mechanism!
77*/
78
79extern void init_save_thread PROTO((void));
80extern void *save_thread PROTO((void));
81extern void restore_thread PROTO((void *));
82
83#ifdef USE_THREAD
84
85#define BGN_SAVE { \
86 void *_save; \
87 _save = save_thread();
88#define RET_SAVE restore_thread(_save);
89#define RES_SAVE _save = save_thread();
90#define END_SAVE restore_thread(_save); \
91 }
92
93#else /* !USE_THREAD */
94
95#define BGN_SAVE {
96#define RET_SAVE
97#define RES_SAVE
98#define END_SAVE }
99
100#endif /* !USE_THREAD */