Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 2 | Copyright (c) 2000, BeOpen.com. |
| 3 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 4 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 5 | All rights reserved. |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 7 | See the file "Misc/COPYRIGHT" for information on usage and |
| 8 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 9 | ******************************************************************/ |
| 10 | |
| 11 | /* Thread and interpreter state structures and their interfaces */ |
| 12 | |
| 13 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 14 | #ifndef Py_PYSTATE_H |
| 15 | #define Py_PYSTATE_H |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 20 | /* State shared between threads */ |
| 21 | |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 22 | struct _ts; /* Forward */ |
| 23 | struct _is; /* Forward */ |
| 24 | |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 25 | typedef struct _is { |
| 26 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 27 | struct _is *next; |
| 28 | struct _ts *tstate_head; |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 29 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 30 | PyObject *modules; |
| 31 | PyObject *sysdict; |
| 32 | PyObject *builtins; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 33 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 34 | int checkinterval; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 35 | |
| 36 | } PyInterpreterState; |
| 37 | |
| 38 | |
| 39 | /* State unique per thread */ |
| 40 | |
| 41 | struct _frame; /* Avoid including frameobject.h */ |
| 42 | |
| 43 | typedef struct _ts { |
| 44 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 45 | struct _ts *next; |
| 46 | PyInterpreterState *interp; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 47 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 48 | struct _frame *frame; |
| 49 | int recursion_depth; |
| 50 | int ticker; |
| 51 | int tracing; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 52 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 53 | PyObject *sys_profilefunc; |
| 54 | PyObject *sys_tracefunc; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 55 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 56 | PyObject *curexc_type; |
| 57 | PyObject *curexc_value; |
| 58 | PyObject *curexc_traceback; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 59 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 60 | PyObject *exc_type; |
| 61 | PyObject *exc_value; |
| 62 | PyObject *exc_traceback; |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 63 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 64 | PyObject *dict; |
Guido van Rossum | ee0a63b | 1998-04-13 20:24:05 +0000 | [diff] [blame] | 65 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 66 | /* XXX signal handlers should also be here */ |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 67 | |
| 68 | } PyThreadState; |
| 69 | |
| 70 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 71 | DL_IMPORT(PyInterpreterState *) PyInterpreterState_New(void); |
| 72 | DL_IMPORT(void) PyInterpreterState_Clear(PyInterpreterState *); |
| 73 | DL_IMPORT(void) PyInterpreterState_Delete(PyInterpreterState *); |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 74 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 75 | DL_IMPORT(PyThreadState *) PyThreadState_New(PyInterpreterState *); |
| 76 | DL_IMPORT(void) PyThreadState_Clear(PyThreadState *); |
| 77 | DL_IMPORT(void) PyThreadState_Delete(PyThreadState *); |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 78 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 79 | DL_IMPORT(PyThreadState *) PyThreadState_Get(void); |
| 80 | DL_IMPORT(PyThreadState *) PyThreadState_Swap(PyThreadState *); |
| 81 | DL_IMPORT(PyObject *) PyThreadState_GetDict(void); |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 82 | |
Guido van Rossum | 275ea67 | 1998-12-21 18:28:10 +0000 | [diff] [blame] | 83 | |
| 84 | /* Variable and macro for in-line access to current thread state */ |
| 85 | |
Guido van Rossum | a8b47fe | 1998-12-21 20:21:19 +0000 | [diff] [blame] | 86 | extern DL_IMPORT(PyThreadState *) _PyThreadState_Current; |
Guido van Rossum | 275ea67 | 1998-12-21 18:28:10 +0000 | [diff] [blame] | 87 | |
| 88 | #ifdef Py_DEBUG |
| 89 | #define PyThreadState_GET() PyThreadState_Get() |
| 90 | #else |
| 91 | #define PyThreadState_GET() (_PyThreadState_Current) |
| 92 | #endif |
| 93 | |
Guido van Rossum | a027efa | 1997-05-05 20:56:21 +0000 | [diff] [blame] | 94 | #ifdef __cplusplus |
| 95 | } |
| 96 | #endif |
| 97 | #endif /* !Py_PYSTATE_H */ |