Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 1 | #ifndef Py_PYSTATE_H |
| 2 | #define Py_PYSTATE_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
| 7 | /*********************************************************** |
| 8 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 9 | The Netherlands. |
| 10 | |
| 11 | All Rights Reserved |
| 12 | |
| 13 | Permission to use, copy, modify, and distribute this software and its |
| 14 | documentation for any purpose and without fee is hereby granted, |
| 15 | provided that the above copyright notice appear in all copies and that |
| 16 | both that copyright notice and this permission notice appear in |
| 17 | supporting documentation, and that the names of Stichting Mathematisch |
| 18 | Centrum or CWI or Corporation for National Research Initiatives or |
| 19 | CNRI not be used in advertising or publicity pertaining to |
| 20 | distribution of the software without specific, written prior |
| 21 | permission. |
| 22 | |
| 23 | While CWI is the initial source for this software, a modified version |
| 24 | is made available by the Corporation for National Research Initiatives |
| 25 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 26 | |
| 27 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 28 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 29 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 30 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 31 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 32 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 33 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 34 | PERFORMANCE OF THIS SOFTWARE. |
| 35 | |
| 36 | ******************************************************************/ |
| 37 | |
| 38 | /* Thread and interpreter state structures and their interfaces */ |
| 39 | |
| 40 | |
| 41 | /* State shared between threads */ |
| 42 | |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 43 | struct _ts; /* Forward */ |
| 44 | struct _is; /* Forward */ |
| 45 | |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 46 | typedef struct _is { |
| 47 | |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 48 | struct _is *next; |
| 49 | struct _ts *tstate_head; |
| 50 | |
| 51 | PyObject *modules; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 52 | PyObject *sysdict; |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 53 | PyObject *builtins; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 54 | |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 55 | int checkinterval; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 56 | |
| 57 | } PyInterpreterState; |
| 58 | |
| 59 | |
| 60 | /* State unique per thread */ |
| 61 | |
| 62 | struct _frame; /* Avoid including frameobject.h */ |
| 63 | |
| 64 | typedef struct _ts { |
| 65 | |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 66 | struct _ts *next; |
| 67 | PyInterpreterState *interp; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 68 | |
| 69 | struct _frame *frame; |
| 70 | int recursion_depth; |
| 71 | int ticker; |
| 72 | int tracing; |
| 73 | |
| 74 | PyObject *sys_profilefunc; |
| 75 | PyObject *sys_tracefunc; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 76 | |
| 77 | PyObject *curexc_type; |
| 78 | PyObject *curexc_value; |
| 79 | PyObject *curexc_traceback; |
| 80 | |
| 81 | PyObject *exc_type; |
| 82 | PyObject *exc_value; |
| 83 | PyObject *exc_traceback; |
| 84 | |
Guido van Rossum | ee0a63b | 1998-04-13 20:24:05 +0000 | [diff] [blame] | 85 | PyObject *dict; |
| 86 | |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 87 | /* XXX signal handlers should also be here */ |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 88 | |
| 89 | } PyThreadState; |
| 90 | |
| 91 | |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 92 | DL_IMPORT(PyInterpreterState *) PyInterpreterState_New Py_PROTO((void)); |
| 93 | DL_IMPORT(void) PyInterpreterState_Clear Py_PROTO((PyInterpreterState *)); |
| 94 | DL_IMPORT(void) PyInterpreterState_Delete Py_PROTO((PyInterpreterState *)); |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 95 | |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 96 | DL_IMPORT(PyThreadState *) PyThreadState_New Py_PROTO((PyInterpreterState *)); |
| 97 | DL_IMPORT(void) PyThreadState_Clear Py_PROTO((PyThreadState *)); |
| 98 | DL_IMPORT(void) PyThreadState_Delete Py_PROTO((PyThreadState *)); |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 99 | |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 100 | DL_IMPORT(PyThreadState *) PyThreadState_Get Py_PROTO((void)); |
| 101 | DL_IMPORT(PyThreadState *) PyThreadState_Swap Py_PROTO((PyThreadState *)); |
| 102 | DL_IMPORT(PyObject *) PyThreadState_GetDict Py_PROTO((void)); |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 103 | |
Guido van Rossum | 275ea67 | 1998-12-21 18:28:10 +0000 | [diff] [blame] | 104 | |
| 105 | /* Variable and macro for in-line access to current thread state */ |
| 106 | |
Guido van Rossum | a8b47fe | 1998-12-21 20:21:19 +0000 | [diff] [blame] | 107 | extern DL_IMPORT(PyThreadState *) _PyThreadState_Current; |
Guido van Rossum | 275ea67 | 1998-12-21 18:28:10 +0000 | [diff] [blame] | 108 | |
| 109 | #ifdef Py_DEBUG |
| 110 | #define PyThreadState_GET() PyThreadState_Get() |
| 111 | #else |
| 112 | #define PyThreadState_GET() (_PyThreadState_Current) |
| 113 | #endif |
| 114 | |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 115 | #ifdef __cplusplus |
| 116 | } |
| 117 | #endif |
| 118 | #endif /* !Py_PYSTATE_H */ |