annotate Include/pystate.h @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents 53b8260b9ea7
children 6adfeec8c482 e72cda3f40a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* Thread and interpreter state structures and their interfaces */
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
5 #ifndef Py_PYSTATE_H
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
6 #define Py_PYSTATE_H
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
7 #ifdef __cplusplus
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
8 extern "C" {
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
9 #endif
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
10
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 /* State shared between threads */
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
5919
5da18e002b1a Mass checkin (more to follow for other directories).
Guido van Rossum <guido@python.org>
parents: 5564
diff changeset
13 struct _ts; /* Forward */
5da18e002b1a Mass checkin (more to follow for other directories).
Guido van Rossum <guido@python.org>
parents: 5564
diff changeset
14 struct _is; /* Forward */
5da18e002b1a Mass checkin (more to follow for other directories).
Guido van Rossum <guido@python.org>
parents: 5564
diff changeset
15
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
16 #ifdef Py_LIMITED_API
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
17 typedef struct _is PyInterpreterState;
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
18 #else
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 typedef struct _is {
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
21 struct _is *next;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
22 struct _ts *tstate_head;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
24 PyObject *modules;
47580
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 42013
diff changeset
25 PyObject *modules_by_index;
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
26 PyObject *sysdict;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
27 PyObject *builtins;
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
28 PyObject *modules_reloading;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
28325
850626d47574 Fixed SF bug #663074. The codec system was using global static
Gustavo Niemeyer <gustavo@niemeyer.net>
parents: 27978
diff changeset
30 PyObject *codec_search_path;
850626d47574 Fixed SF bug #663074. The codec system was using global static
Gustavo Niemeyer <gustavo@niemeyer.net>
parents: 27978
diff changeset
31 PyObject *codec_search_cache;
850626d47574 Fixed SF bug #663074. The codec system was using global static
Gustavo Niemeyer <gustavo@niemeyer.net>
parents: 27978
diff changeset
32 PyObject *codec_error_registry;
49613
efef5fc45a9a Issue 3723: Fixed initialization of subinterpreters
Christian Heimes <christian@cheimes.de>
parents: 47580
diff changeset
33 int codecs_initialized;
69708
2caf82aee7a4 Issue #10914: Initialize correctly the filesystem codec when creating a new
Victor Stinner <victor.stinner@haypocalc.com>
parents: 69637
diff changeset
34 int fscodec_initialized;
28325
850626d47574 Fixed SF bug #663074. The codec system was using global static
Gustavo Niemeyer <gustavo@niemeyer.net>
parents: 27978
diff changeset
35
18689
064de84385ca Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents: 18374
diff changeset
36 #ifdef HAVE_DLOPEN
064de84385ca Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents: 18374
diff changeset
37 int dlopenflags;
064de84385ca Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents: 18374
diff changeset
38 #endif
32301
41c59d80bbc5 Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents: 31836
diff changeset
39 #ifdef WITH_TSC
41c59d80bbc5 Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents: 31836
diff changeset
40 int tscdump;
41c59d80bbc5 Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents: 31836
diff changeset
41 #endif
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
42
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 } PyInterpreterState;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
44 #endif
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
45
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 /* State unique per thread */
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 struct _frame; /* Avoid including frameobject.h */
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
51 #ifndef Py_LIMITED_API
18325
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
52 /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
53 typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
54
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
55 /* The following values are used for 'what' for tracefunc functions: */
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
56 #define PyTrace_CALL 0
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
57 #define PyTrace_EXCEPTION 1
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
58 #define PyTrace_LINE 2
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
59 #define PyTrace_RETURN 3
31796
1c117dbb2def Enable the profiling of C functions (builtins and extensions)
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31654
diff changeset
60 #define PyTrace_C_CALL 4
1c117dbb2def Enable the profiling of C functions (builtins and extensions)
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31654
diff changeset
61 #define PyTrace_C_EXCEPTION 5
1c117dbb2def Enable the profiling of C functions (builtins and extensions)
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31654
diff changeset
62 #define PyTrace_C_RETURN 6
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
63 #endif
18325
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
64
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
65 #ifdef Py_LIMITED_API
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
66 typedef struct _ts PyThreadState;
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
67 #else
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 typedef struct _ts {
35125
cdec978b916c Add comments about PyThreadState and the usage of its fields.
Brett Cannon <bcannon@gmail.com>
parents: 32301
diff changeset
69 /* See Python/ceval.c for comments explaining most fields */
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
70
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
71 struct _ts *next;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
72 PyInterpreterState *interp;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
73
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
74 struct _frame *frame;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
75 int recursion_depth;
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41554
diff changeset
76 char overflowed; /* The stack has overflowed. Allow 50 more calls
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41554
diff changeset
77 to handle the runtime error. */
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41554
diff changeset
78 char recursion_critical; /* The current calls must not cause
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41554
diff changeset
79 a stack overflow. */
35125
cdec978b916c Add comments about PyThreadState and the usage of its fields.
Brett Cannon <bcannon@gmail.com>
parents: 32301
diff changeset
80 /* 'tracing' keeps track of the execution depth when tracing/profiling.
cdec978b916c Add comments about PyThreadState and the usage of its fields.
Brett Cannon <bcannon@gmail.com>
parents: 32301
diff changeset
81 This is to prevent the actual trace/profile code from being recorded in
cdec978b916c Add comments about PyThreadState and the usage of its fields.
Brett Cannon <bcannon@gmail.com>
parents: 32301
diff changeset
82 the trace/profile. */
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
83 int tracing;
18374
3b295ce2705f This change adjusts the profiling/tracing support so that the common
Fred Drake <fdrake@acm.org>
parents: 18325
diff changeset
84 int use_tracing;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
85
18325
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
86 Py_tracefunc c_profilefunc;
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
87 Py_tracefunc c_tracefunc;
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
88 PyObject *c_profileobj;
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
89 PyObject *c_traceobj;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
90
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
91 PyObject *curexc_type;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
92 PyObject *curexc_value;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
93 PyObject *curexc_traceback;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
94
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
95 PyObject *exc_type;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
96 PyObject *exc_value;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
97 PyObject *exc_traceback;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
98
35125
cdec978b916c Add comments about PyThreadState and the usage of its fields.
Brett Cannon <bcannon@gmail.com>
parents: 32301
diff changeset
99 PyObject *dict; /* Stores per-thread state */
8043
b8e8ace79cf0 Move 'dict' struct member to end of struct. This ensures binary
Guido van Rossum <guido@python.org>
parents: 7971
diff changeset
100
57175
fdd6484f1210 Merge in the new GIL.
Antoine Pitrou <solipsis@pitrou.net>
parents: 49613
diff changeset
101 /* XXX doesn't mean anything anymore (the comment below is obsolete)
fdd6484f1210 Merge in the new GIL.
Antoine Pitrou <solipsis@pitrou.net>
parents: 49613
diff changeset
102 => deprecate or remove? */
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
103 /* tick_counter is incremented whenever the check_interval ticker
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
104 * reaches zero. The purpose is to give a useful measure of the number
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
105 * of interpreted bytecode instructions in a given thread. This
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
106 * extremely lightweight statistic collector may be of interest to
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
107 * profilers (like psyco.jit()), although nothing in the core uses it.
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
108 */
26109
e61b946474df Assorted patches from Armin Rigo:
Michael W. Hudson <mwh@python.net>
parents: 25108
diff changeset
109 int tick_counter;
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
110
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
111 int gilstate_counter;
26109
e61b946474df Assorted patches from Armin Rigo:
Michael W. Hudson <mwh@python.net>
parents: 25108
diff changeset
112
29643
fa97293533a9 Add PyThreadState_SetAsyncExc(long, PyObject *).
Guido van Rossum <guido@python.org>
parents: 28694
diff changeset
113 PyObject *async_exc; /* Asynchronous exception to raise */
fa97293533a9 Add PyThreadState_SetAsyncExc(long, PyObject *).
Guido van Rossum <guido@python.org>
parents: 28694
diff changeset
114 long thread_id; /* Thread id where this tstate was created */
fa97293533a9 Add PyThreadState_SetAsyncExc(long, PyObject *).
Guido van Rossum <guido@python.org>
parents: 28694
diff changeset
115
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
116 /* XXX signal handlers should also be here */
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 } PyThreadState;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
119 #endif
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
120
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
121
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
122 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
123 PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
124 PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
47580
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 42013
diff changeset
125 PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*);
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 42013
diff changeset
126 PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
127
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
128 PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
59317
d7a62c16505b Merged revisions 78639 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 49613
diff changeset
129 PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
d7a62c16505b Merged revisions 78639 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 49613
diff changeset
130 PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
131 PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
132 PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
16139
d96ce9708c00 Add a new API, PyThreadState_DeleteCurrent() that combines
Guido van Rossum <guido@python.org>
parents: 14375
diff changeset
133 #ifdef WITH_THREAD
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
134 PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
69637
7b7ad9a88451 Issue #10517: After fork(), reinitialize the TLS used by the PyGILState_*
Antoine Pitrou <solipsis@pitrou.net>
parents: 68257
diff changeset
135 PyAPI_FUNC(void) _PyGILState_Reinit(void);
16139
d96ce9708c00 Add a new API, PyThreadState_DeleteCurrent() that combines
Guido van Rossum <guido@python.org>
parents: 14375
diff changeset
136 #endif
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
137
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
138 PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
139 PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
140 PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
29643
fa97293533a9 Add PyThreadState_SetAsyncExc(long, PyObject *).
Guido van Rossum <guido@python.org>
parents: 28694
diff changeset
141 PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
142
9668
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
143
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
144 /* Variable and macro for in-line access to current thread state */
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
145
61184
4fd3ab5fa71d Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 59316
diff changeset
146 /* Assuming the current thread holds the GIL, this is the
4fd3ab5fa71d Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 59316
diff changeset
147 PyThreadState for the current thread. */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
148 #ifndef Py_LIMITED_API
61184
4fd3ab5fa71d Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 59316
diff changeset
149 PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
150 #endif
9668
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
151
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
152 #if defined(Py_DEBUG) || defined(Py_LIMITED_API)
9668
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
153 #define PyThreadState_GET() PyThreadState_Get()
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
154 #else
61184
4fd3ab5fa71d Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 59316
diff changeset
155 #define PyThreadState_GET() \
4fd3ab5fa71d Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 59316
diff changeset
156 ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
9668
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
157 #endif
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
158
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
159 typedef
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
160 enum {PyGILState_LOCKED, PyGILState_UNLOCKED}
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
161 PyGILState_STATE;
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
162
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
163 /* Ensure that the current thread is ready to call the Python
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
164 C API, regardless of the current state of Python, or of its
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
165 thread lock. This may be called as many times as desired
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
166 by a thread so long as each call is matched with a call to
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
167 PyGILState_Release(). In general, other thread-state APIs may
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
168 be used between _Ensure() and _Release() calls, so long as the
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
169 thread-state is restored to its previous state before the Release().
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
170 For example, normal use of the Py_BEGIN_ALLOW_THREADS/
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
171 Py_END_ALLOW_THREADS macros are acceptable.
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
172
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
173 The return value is an opaque "handle" to the thread state when
31654
7fffdb94a172 SF patch #906501: Fix typos in pystate.h comments
Raymond Hettinger <python@rcn.com>
parents: 29643
diff changeset
174 PyGILState_Ensure() was called, and must be passed to
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
175 PyGILState_Release() to ensure Python is left in the same state. Even
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
176 though recursive calls are allowed, these handles can *not* be shared -
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
177 each unique call to PyGILState_Ensure must save the handle for its
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
178 call to PyGILState_Release.
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
179
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
180 When the function returns, the current thread will hold the GIL.
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
181
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
182 Failure is a fatal error.
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
183 */
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
184 PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
185
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
186 /* Release any resources previously acquired. After this call, Python's
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
187 state will be the same as it was prior to the corresponding
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
188 PyGILState_Ensure() call (but generally this state will be unknown to
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
189 the caller, hence the use of the GILState API.)
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
190
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
191 Every call to PyGILState_Ensure must be matched by a call to
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
192 PyGILState_Release on the same thread.
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
193 */
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
194 PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
195
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
196 /* Helper/diagnostic function - get the current thread state for
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
197 this thread. May return NULL if no GILState API has been used
71769
53b8260b9ea7 #10741: add documentation for PyGILState_GetThisThreadState()
Sandro Tosi <sandro.tosi@gmail.com>
parents: 69708
diff changeset
198 on the current thread. Note that the main thread always has such a
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
199 thread-state, even if no auto-thread-state call has been made
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
200 on the main thread.
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
201 */
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
202 PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
203
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35125
diff changeset
204 /* The implementation of sys._current_frames() Returns a dict mapping
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35125
diff changeset
205 thread id to that thread's current frame.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35125
diff changeset
206 */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
207 #ifndef Py_LIMITED_API
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35125
diff changeset
208 PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
209 #endif
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35125
diff changeset
210
18733
b0329649b8cf Add a low-level API to access interpreters, for David Beazley.
Guido van Rossum <guido@python.org>
parents: 18689
diff changeset
211 /* Routines for advanced debuggers, requested by David Beazley.
b0329649b8cf Add a low-level API to access interpreters, for David Beazley.
Guido van Rossum <guido@python.org>
parents: 18689
diff changeset
212 Don't use unless you know what you are doing! */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
213 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
214 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
215 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
216 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
217 PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
18733
b0329649b8cf Add a low-level API to access interpreters, for David Beazley.
Guido van Rossum <guido@python.org>
parents: 18689
diff changeset
218
27978
4b99a701defe - PyEval_GetFrame() is now declared to return a PyFrameObject *
Guido van Rossum <guido@python.org>
parents: 26109
diff changeset
219 typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
220 #endif
27978
4b99a701defe - PyEval_GetFrame() is now declared to return a PyFrameObject *
Guido van Rossum <guido@python.org>
parents: 26109
diff changeset
221
26109
e61b946474df Assorted patches from Armin Rigo:
Michael W. Hudson <mwh@python.net>
parents: 25108
diff changeset
222 /* hook for PyEval_GetFrame(), requested for Psyco */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
223 #ifndef Py_LIMITED_API
27978
4b99a701defe - PyEval_GetFrame() is now declared to return a PyFrameObject *
Guido van Rossum <guido@python.org>
parents: 26109
diff changeset
224 PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
225 #endif
26109
e61b946474df Assorted patches from Armin Rigo:
Michael W. Hudson <mwh@python.net>
parents: 25108
diff changeset
226
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
227 #ifdef __cplusplus
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
228 }
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
229 #endif
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
230 #endif /* !Py_PYSTATE_H */