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