annotate DEPENDENCIES/mingw32/Python27/include/pystate.h @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2a2c65a20a8b
children
rev   line source
Chris@87 1
Chris@87 2 /* Thread and interpreter state structures and their interfaces */
Chris@87 3
Chris@87 4
Chris@87 5 #ifndef Py_PYSTATE_H
Chris@87 6 #define Py_PYSTATE_H
Chris@87 7 #ifdef __cplusplus
Chris@87 8 extern "C" {
Chris@87 9 #endif
Chris@87 10
Chris@87 11 /* State shared between threads */
Chris@87 12
Chris@87 13 struct _ts; /* Forward */
Chris@87 14 struct _is; /* Forward */
Chris@87 15
Chris@87 16 typedef struct _is {
Chris@87 17
Chris@87 18 struct _is *next;
Chris@87 19 struct _ts *tstate_head;
Chris@87 20
Chris@87 21 PyObject *modules;
Chris@87 22 PyObject *sysdict;
Chris@87 23 PyObject *builtins;
Chris@87 24 PyObject *modules_reloading;
Chris@87 25
Chris@87 26 PyObject *codec_search_path;
Chris@87 27 PyObject *codec_search_cache;
Chris@87 28 PyObject *codec_error_registry;
Chris@87 29
Chris@87 30 #ifdef HAVE_DLOPEN
Chris@87 31 int dlopenflags;
Chris@87 32 #endif
Chris@87 33 #ifdef WITH_TSC
Chris@87 34 int tscdump;
Chris@87 35 #endif
Chris@87 36
Chris@87 37 } PyInterpreterState;
Chris@87 38
Chris@87 39
Chris@87 40 /* State unique per thread */
Chris@87 41
Chris@87 42 struct _frame; /* Avoid including frameobject.h */
Chris@87 43
Chris@87 44 /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
Chris@87 45 typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
Chris@87 46
Chris@87 47 /* The following values are used for 'what' for tracefunc functions: */
Chris@87 48 #define PyTrace_CALL 0
Chris@87 49 #define PyTrace_EXCEPTION 1
Chris@87 50 #define PyTrace_LINE 2
Chris@87 51 #define PyTrace_RETURN 3
Chris@87 52 #define PyTrace_C_CALL 4
Chris@87 53 #define PyTrace_C_EXCEPTION 5
Chris@87 54 #define PyTrace_C_RETURN 6
Chris@87 55
Chris@87 56 typedef struct _ts {
Chris@87 57 /* See Python/ceval.c for comments explaining most fields */
Chris@87 58
Chris@87 59 struct _ts *next;
Chris@87 60 PyInterpreterState *interp;
Chris@87 61
Chris@87 62 struct _frame *frame;
Chris@87 63 int recursion_depth;
Chris@87 64 /* 'tracing' keeps track of the execution depth when tracing/profiling.
Chris@87 65 This is to prevent the actual trace/profile code from being recorded in
Chris@87 66 the trace/profile. */
Chris@87 67 int tracing;
Chris@87 68 int use_tracing;
Chris@87 69
Chris@87 70 Py_tracefunc c_profilefunc;
Chris@87 71 Py_tracefunc c_tracefunc;
Chris@87 72 PyObject *c_profileobj;
Chris@87 73 PyObject *c_traceobj;
Chris@87 74
Chris@87 75 PyObject *curexc_type;
Chris@87 76 PyObject *curexc_value;
Chris@87 77 PyObject *curexc_traceback;
Chris@87 78
Chris@87 79 PyObject *exc_type;
Chris@87 80 PyObject *exc_value;
Chris@87 81 PyObject *exc_traceback;
Chris@87 82
Chris@87 83 PyObject *dict; /* Stores per-thread state */
Chris@87 84
Chris@87 85 /* tick_counter is incremented whenever the check_interval ticker
Chris@87 86 * reaches zero. The purpose is to give a useful measure of the number
Chris@87 87 * of interpreted bytecode instructions in a given thread. This
Chris@87 88 * extremely lightweight statistic collector may be of interest to
Chris@87 89 * profilers (like psyco.jit()), although nothing in the core uses it.
Chris@87 90 */
Chris@87 91 int tick_counter;
Chris@87 92
Chris@87 93 int gilstate_counter;
Chris@87 94
Chris@87 95 PyObject *async_exc; /* Asynchronous exception to raise */
Chris@87 96 long thread_id; /* Thread id where this tstate was created */
Chris@87 97
Chris@87 98 int trash_delete_nesting;
Chris@87 99 PyObject *trash_delete_later;
Chris@87 100
Chris@87 101 /* XXX signal handlers should also be here */
Chris@87 102
Chris@87 103 } PyThreadState;
Chris@87 104
Chris@87 105
Chris@87 106 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
Chris@87 107 PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
Chris@87 108 PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
Chris@87 109
Chris@87 110 PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
Chris@87 111 PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
Chris@87 112 PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);
Chris@87 113 PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
Chris@87 114 PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
Chris@87 115 #ifdef WITH_THREAD
Chris@87 116 PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
Chris@87 117 #endif
Chris@87 118
Chris@87 119 PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
Chris@87 120 PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
Chris@87 121 PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
Chris@87 122 PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
Chris@87 123
Chris@87 124
Chris@87 125 /* Variable and macro for in-line access to current thread state */
Chris@87 126
Chris@87 127 PyAPI_DATA(PyThreadState *) _PyThreadState_Current;
Chris@87 128
Chris@87 129 #ifdef Py_DEBUG
Chris@87 130 #define PyThreadState_GET() PyThreadState_Get()
Chris@87 131 #else
Chris@87 132 #define PyThreadState_GET() (_PyThreadState_Current)
Chris@87 133 #endif
Chris@87 134
Chris@87 135 typedef
Chris@87 136 enum {PyGILState_LOCKED, PyGILState_UNLOCKED}
Chris@87 137 PyGILState_STATE;
Chris@87 138
Chris@87 139 /* Ensure that the current thread is ready to call the Python
Chris@87 140 C API, regardless of the current state of Python, or of its
Chris@87 141 thread lock. This may be called as many times as desired
Chris@87 142 by a thread so long as each call is matched with a call to
Chris@87 143 PyGILState_Release(). In general, other thread-state APIs may
Chris@87 144 be used between _Ensure() and _Release() calls, so long as the
Chris@87 145 thread-state is restored to its previous state before the Release().
Chris@87 146 For example, normal use of the Py_BEGIN_ALLOW_THREADS/
Chris@87 147 Py_END_ALLOW_THREADS macros are acceptable.
Chris@87 148
Chris@87 149 The return value is an opaque "handle" to the thread state when
Chris@87 150 PyGILState_Ensure() was called, and must be passed to
Chris@87 151 PyGILState_Release() to ensure Python is left in the same state. Even
Chris@87 152 though recursive calls are allowed, these handles can *not* be shared -
Chris@87 153 each unique call to PyGILState_Ensure must save the handle for its
Chris@87 154 call to PyGILState_Release.
Chris@87 155
Chris@87 156 When the function returns, the current thread will hold the GIL.
Chris@87 157
Chris@87 158 Failure is a fatal error.
Chris@87 159 */
Chris@87 160 PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
Chris@87 161
Chris@87 162 /* Release any resources previously acquired. After this call, Python's
Chris@87 163 state will be the same as it was prior to the corresponding
Chris@87 164 PyGILState_Ensure() call (but generally this state will be unknown to
Chris@87 165 the caller, hence the use of the GILState API.)
Chris@87 166
Chris@87 167 Every call to PyGILState_Ensure must be matched by a call to
Chris@87 168 PyGILState_Release on the same thread.
Chris@87 169 */
Chris@87 170 PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
Chris@87 171
Chris@87 172 /* Helper/diagnostic function - get the current thread state for
Chris@87 173 this thread. May return NULL if no GILState API has been used
Chris@87 174 on the current thread. Note that the main thread always has such a
Chris@87 175 thread-state, even if no auto-thread-state call has been made
Chris@87 176 on the main thread.
Chris@87 177 */
Chris@87 178 PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
Chris@87 179
Chris@87 180 /* The implementation of sys._current_frames() Returns a dict mapping
Chris@87 181 thread id to that thread's current frame.
Chris@87 182 */
Chris@87 183 PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
Chris@87 184
Chris@87 185 /* Routines for advanced debuggers, requested by David Beazley.
Chris@87 186 Don't use unless you know what you are doing! */
Chris@87 187 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
Chris@87 188 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
Chris@87 189 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
Chris@87 190 PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
Chris@87 191
Chris@87 192 typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
Chris@87 193
Chris@87 194 /* hook for PyEval_GetFrame(), requested for Psyco */
Chris@87 195 PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
Chris@87 196
Chris@87 197 #ifdef __cplusplus
Chris@87 198 }
Chris@87 199 #endif
Chris@87 200 #endif /* !Py_PYSTATE_H */