annotate Include/pystate.h @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 3ce0102e4c1f
children
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;
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 71770
diff changeset
28 PyObject *importlib;
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
76303
2dd046be2c88 Issue #2377: Make importlib the implementation of __import__().
Brett Cannon <brett@python.org>
parents: 71770
diff changeset
36
18689
064de84385ca Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents: 18374
diff changeset
37 #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
38 int dlopenflags;
064de84385ca Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents: 18374
diff changeset
39 #endif
32301
41c59d80bbc5 Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents: 31836
diff changeset
40 #ifdef WITH_TSC
41c59d80bbc5 Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents: 31836
diff changeset
41 int tscdump;
41c59d80bbc5 Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents: 31836
diff changeset
42 #endif
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 } PyInterpreterState;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
45 #endif
5405
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
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 /* State unique per thread */
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 struct _frame; /* Avoid including frameobject.h */
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
52 #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
53 /* 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
54 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
55
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
56 /* 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
57 #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
58 #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
59 #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
60 #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
61 #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
62 #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
63 #define PyTrace_C_RETURN 6
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
64 #endif
18325
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
65
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
66 #ifdef Py_LIMITED_API
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
67 typedef struct _ts PyThreadState;
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
68 #else
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 typedef struct _ts {
35125
cdec978b916c Add comments about PyThreadState and the usage of its fields.
Brett Cannon <bcannon@gmail.com>
parents: 32301
diff changeset
70 /* 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
71
83690
375d4fed4cf2 Issue #17912: Use a doubly linked-list for thread states.
Charles-Francois Natali <cf.natali@gmail.com>
parents: 83630
diff changeset
72 struct _ts *prev;
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
73 struct _ts *next;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
74 PyInterpreterState *interp;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
75
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
76 struct _frame *frame;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
77 int recursion_depth;
42013
cd125fe83051 Make identifiers str (not str8) objects throughout.
Martin v. Löwis <martin@v.loewis.de>
parents: 41128
diff changeset
78 char overflowed; /* The stack has overflowed. Allow 50 more calls
69584
75503c26a17f PyGILState_Ensure(), PyGILState_Release(), PyGILState_GetThisThreadState() are
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257
diff changeset
79 to handle the runtime error. */
75503c26a17f PyGILState_Ensure(), PyGILState_Release(), PyGILState_GetThisThreadState() are
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257
diff changeset
80 char recursion_critical; /* The current calls must not cause
75503c26a17f PyGILState_Ensure(), PyGILState_Release(), PyGILState_GetThisThreadState() are
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257
diff changeset
81 a stack overflow. */
35125
cdec978b916c Add comments about PyThreadState and the usage of its fields.
Brett Cannon <bcannon@gmail.com>
parents: 32301
diff changeset
82 /* '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
83 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
84 the trace/profile. */
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
85 int tracing;
18374
3b295ce2705f This change adjusts the profiling/tracing support so that the common
Fred Drake <fdrake@acm.org>
parents: 18325
diff changeset
86 int use_tracing;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
87
18325
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
88 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
89 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
90 PyObject *c_profileobj;
fb35b3a22604 Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents: 16139
diff changeset
91 PyObject *c_traceobj;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
93 PyObject *curexc_type;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
94 PyObject *curexc_value;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
95 PyObject *curexc_traceback;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
96
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
97 PyObject *exc_type;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
98 PyObject *exc_value;
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
99 PyObject *exc_traceback;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100
35125
cdec978b916c Add comments about PyThreadState and the usage of its fields.
Brett Cannon <bcannon@gmail.com>
parents: 32301
diff changeset
101 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
102
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
103 int gilstate_counter;
26109
e61b946474df Assorted patches from Armin Rigo:
Michael W. Hudson <mwh@python.net>
parents: 25108
diff changeset
104
29643
fa97293533a9 Add PyThreadState_SetAsyncExc(long, PyObject *).
Guido van Rossum <guido@python.org>
parents: 28694
diff changeset
105 PyObject *async_exc; /* Asynchronous exception to raise */
fa97293533a9 Add PyThreadState_SetAsyncExc(long, PyObject *).
Guido van Rossum <guido@python.org>
parents: 28694
diff changeset
106 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
107
78912
5aa1bc2f00ad Issue #13992: The trashcan mechanism is now thread-safe. This eliminates
Antoine Pitrou <solipsis@pitrou.net>
parents: 77564
diff changeset
108 int trash_delete_nesting;
5aa1bc2f00ad Issue #13992: The trashcan mechanism is now thread-safe. This eliminates
Antoine Pitrou <solipsis@pitrou.net>
parents: 77564
diff changeset
109 PyObject *trash_delete_later;
5aa1bc2f00ad Issue #13992: The trashcan mechanism is now thread-safe. This eliminates
Antoine Pitrou <solipsis@pitrou.net>
parents: 77564
diff changeset
110
85598
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
111 /* Called when a thread state is deleted normally, but not when it
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
112 * is destroyed after fork().
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
113 * Pain: to prevent rare but fatal shutdown errors (issue 18808),
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
114 * Thread.join() must wait for the join'ed thread's tstate to be unlinked
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
115 * from the tstate chain. That happens at the end of a thread's life,
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
116 * in pystate.c.
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
117 * The obvious way doesn't quite work: create a lock which the tstate
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
118 * unlinking code releases, and have Thread.join() wait to acquire that
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
119 * lock. The problem is that we _are_ at the end of the thread's life:
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
120 * if the thread holds the last reference to the lock, decref'ing the
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
121 * lock will delete the lock, and that may trigger arbitrary Python code
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
122 * if there's a weakref, with a callback, to the lock. But by this time
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
123 * _PyThreadState_Current is already NULL, so only the simplest of C code
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
124 * can be allowed to run (in particular it must not be possible to
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
125 * release the GIL).
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
126 * So instead of holding the lock directly, the tstate holds a weakref to
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
127 * the lock: that's the value of on_delete_data below. Decref'ing a
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
128 * weakref is harmless.
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
129 * on_delete points to _threadmodule.c's static release_sentinel() function.
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
130 * After the tstate is unlinked, release_sentinel is called with the
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
131 * weakref-to-lock (on_delete_data) argument, and release_sentinel releases
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
132 * the indirectly held lock.
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
133 */
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
134 void (*on_delete)(void *);
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
135 void *on_delete_data;
d52b68edbca6 Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
Antoine Pitrou <solipsis@pitrou.net>
parents: 85112
diff changeset
136
13443
7e58c060d534 ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
137 /* 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
138
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
139 } PyThreadState;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
140 #endif
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
142
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
143 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
144 PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
145 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
146 PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*);
77564
55e8cba34b11 Issue #15042: Add PyState_AddModule and PyState_RemoveModule.
Martin v. Löwis <martin@v.loewis.de>
parents: 76640
diff changeset
147 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
55e8cba34b11 Issue #15042: Add PyState_AddModule and PyState_RemoveModule.
Martin v. Löwis <martin@v.loewis.de>
parents: 76640
diff changeset
148 /* New in 3.3 */
55e8cba34b11 Issue #15042: Add PyState_AddModule and PyState_RemoveModule.
Martin v. Löwis <martin@v.loewis.de>
parents: 76640
diff changeset
149 PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*);
55e8cba34b11 Issue #15042: Add PyState_AddModule and PyState_RemoveModule.
Martin v. Löwis <martin@v.loewis.de>
parents: 76640
diff changeset
150 PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*);
55e8cba34b11 Issue #15042: Add PyState_AddModule and PyState_RemoveModule.
Martin v. Löwis <martin@v.loewis.de>
parents: 76640
diff changeset
151 #endif
47580
94f64f11fdd0 Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents: 42013
diff changeset
152 PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
85112
1edff836c954 Issue #10241: Clear extension module dict copies at interpreter shutdown.
Antoine Pitrou <solipsis@pitrou.net>
parents: 84979
diff changeset
153 #ifndef Py_LIMITED_API
1edff836c954 Issue #10241: Clear extension module dict copies at interpreter shutdown.
Antoine Pitrou <solipsis@pitrou.net>
parents: 84979
diff changeset
154 PyAPI_FUNC(void) _PyState_ClearModules(void);
1edff836c954 Issue #10241: Clear extension module dict copies at interpreter shutdown.
Antoine Pitrou <solipsis@pitrou.net>
parents: 84979
diff changeset
155 #endif
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
156
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
157 PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
59317
d7a62c16505b Merged revisions 78639 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 49613
diff changeset
158 PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
d7a62c16505b Merged revisions 78639 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 49613
diff changeset
159 PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
160 PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
161 PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
83630
847692b9902a Issue #17094: Clear stale thread states after fork().
Antoine Pitrou <solipsis@pitrou.net>
parents: 82889
diff changeset
162 PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);
16139
d96ce9708c00 Add a new API, PyThreadState_DeleteCurrent() that combines
Guido van Rossum <guido@python.org>
parents: 14375
diff changeset
163 #ifdef WITH_THREAD
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
164 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
165 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
166 #endif
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
167
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
168 PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
169 PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
170 PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
29643
fa97293533a9 Add PyThreadState_SetAsyncExc(long, PyObject *).
Guido van Rossum <guido@python.org>
parents: 28694
diff changeset
171 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
172
9668
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
173
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
174 /* 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
175
61184
4fd3ab5fa71d Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 59316
diff changeset
176 /* 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
177 PyThreadState for the current thread. */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
178 #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
179 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
180 #endif
9668
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
181
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
182 #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
183 #define PyThreadState_GET() PyThreadState_Get()
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
184 #else
61184
4fd3ab5fa71d Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 59316
diff changeset
185 #define PyThreadState_GET() \
4fd3ab5fa71d Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents: 59316
diff changeset
186 ((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
187 #endif
40858ab23568 Add macro version of PyThreadState_GET(). This uses
Guido van Rossum <guido@python.org>
parents: 9586
diff changeset
188
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
189 typedef
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
190 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
191 PyGILState_STATE;
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
192
69584
75503c26a17f PyGILState_Ensure(), PyGILState_Release(), PyGILState_GetThisThreadState() are
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257
diff changeset
193 #ifdef WITH_THREAD
75503c26a17f PyGILState_Ensure(), PyGILState_Release(), PyGILState_GetThisThreadState() are
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257
diff changeset
194
28694
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
195 /* 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
196 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
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
205 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
206 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
207 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
208 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
209 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
210 call to PyGILState_Release.
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
211
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
212 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
213
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
214 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
215 */
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
216 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
217
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
218 /* 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
219 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
220 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
221 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
222
31836
e42cbaff8027 Added a comment about the unreferenced PyThreadState.tick_counter
Tim Peters <tim.peters@gmail.com>
parents: 31796
diff changeset
223 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
224 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
225 */
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
226 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
227
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
228 /* 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
229 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
230 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
231 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
232 on the main thread.
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
233 */
a4154dd5939a New PyGILState_ API - implements pep 311, from patch 684256.
Mark Hammond <mhammond@skippinet.com.au>
parents: 28325
diff changeset
234 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
235
82889
2e92d1567ad7 Issue #17522: Add the PyGILState_Check() API.
Kristján Valur Jónsson <sweskman@gmail.com>
parents: 78921
diff changeset
236 /* Helper/diagnostic function - return 1 if the current thread
2e92d1567ad7 Issue #17522: Add the PyGILState_Check() API.
Kristján Valur Jónsson <sweskman@gmail.com>
parents: 78921
diff changeset
237 * currently holds the GIL, 0 otherwise
2e92d1567ad7 Issue #17522: Add the PyGILState_Check() API.
Kristján Valur Jónsson <sweskman@gmail.com>
parents: 78921
diff changeset
238 */
2e92d1567ad7 Issue #17522: Add the PyGILState_Check() API.
Kristján Valur Jónsson <sweskman@gmail.com>
parents: 78921
diff changeset
239 PyAPI_FUNC(int) PyGILState_Check(void);
2e92d1567ad7 Issue #17522: Add the PyGILState_Check() API.
Kristján Valur Jónsson <sweskman@gmail.com>
parents: 78921
diff changeset
240
69584
75503c26a17f PyGILState_Ensure(), PyGILState_Release(), PyGILState_GetThisThreadState() are
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257
diff changeset
241 #endif /* #ifdef WITH_THREAD */
75503c26a17f PyGILState_Ensure(), PyGILState_Release(), PyGILState_GetThisThreadState() are
Victor Stinner <victor.stinner@haypocalc.com>
parents: 68257
diff changeset
242
39056
b6fd499e4343 After approval from Anthony, merge the tim-current_frames
Tim Peters <tim.peters@gmail.com>
parents: 35125
diff changeset
243 /* The implementation of sys._current_frames() Returns a dict mapping
b6fd499e4343 After approval from Anthony, merge the tim-current_frames
Tim Peters <tim.peters@gmail.com>
parents: 35125
diff changeset
244 thread id to that thread's current frame.
b6fd499e4343 After approval from Anthony, merge the tim-current_frames
Tim Peters <tim.peters@gmail.com>
parents: 35125
diff changeset
245 */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
246 #ifndef Py_LIMITED_API
39056
b6fd499e4343 After approval from Anthony, merge the tim-current_frames
Tim Peters <tim.peters@gmail.com>
parents: 35125
diff changeset
247 PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
248 #endif
39056
b6fd499e4343 After approval from Anthony, merge the tim-current_frames
Tim Peters <tim.peters@gmail.com>
parents: 35125
diff changeset
249
18733
b0329649b8cf Add a low-level API to access interpreters, for David Beazley.
Guido van Rossum <guido@python.org>
parents: 18689
diff changeset
250 /* 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
251 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
252 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
253 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
254 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
255 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 18733
diff changeset
256 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
257
27978
4b99a701defe - PyEval_GetFrame() is now declared to return a PyFrameObject *
Guido van Rossum <guido@python.org>
parents: 26109
diff changeset
258 typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
259 #endif
27978
4b99a701defe - PyEval_GetFrame() is now declared to return a PyFrameObject *
Guido van Rossum <guido@python.org>
parents: 26109
diff changeset
260
26109
e61b946474df Assorted patches from Armin Rigo:
Michael W. Hudson <mwh@python.net>
parents: 25108
diff changeset
261 /* 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
262 #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
263 PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 61184
diff changeset
264 #endif
26109
e61b946474df Assorted patches from Armin Rigo:
Michael W. Hudson <mwh@python.net>
parents: 25108
diff changeset
265
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
266 #ifdef __cplusplus
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
267 }
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
268 #endif
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
diff changeset
269 #endif /* !Py_PYSTATE_H */