summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_pystate.h
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2019-02-23 18:35:52 (GMT)
committerGitHub <noreply@github.com>2019-02-23 18:35:52 (GMT)
commitbe3b295838547bba267eb08434b418ef0df87ee0 (patch)
tree8daa92ecd7088d6ace08833f64ba2251be9b310f /Include/internal/pycore_pystate.h
parent175421b58cc97a2555e474f479f30a6c5d2250b0 (diff)
downloadcpython-be3b295838547bba267eb08434b418ef0df87ee0.zip
cpython-be3b295838547bba267eb08434b418ef0df87ee0.tar.gz
cpython-be3b295838547bba267eb08434b418ef0df87ee0.tar.bz2
bpo-35886: Make PyInterpreterState an opaque type in the public API. (GH-11731)
Move PyInterpreterState into the "internal" header files.
Diffstat (limited to 'Include/internal/pycore_pystate.h')
-rw-r--r--Include/internal/pycore_pystate.h109
1 files changed, 85 insertions, 24 deletions
diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h
index 4f5545a..7796223 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -17,37 +17,74 @@ extern "C" {
#include "pycore_warnings.h"
-/* GIL state */
+/* interpreter state */
-struct _gilstate_runtime_state {
- int check_enabled;
- /* Assuming the current thread holds the GIL, this is the
- PyThreadState for the current thread. */
- _Py_atomic_address tstate_current;
- PyThreadFrameGetter getframe;
- /* The single PyInterpreterState used by this process'
- GILState implementation
- */
- /* TODO: Given interp_main, it may be possible to kill this ref */
- PyInterpreterState *autoInterpreterState;
- Py_tss_t autoTSSkey;
-};
+typedef PyObject* (*_PyFrameEvalFunction)(struct _frame *, int);
+
+// The PyInterpreterState typedef is in Include/pystate.h.
+struct _is {
+
+ struct _is *next;
+ struct _ts *tstate_head;
+
+ int64_t id;
+ int64_t id_refcount;
+ PyThread_type_lock id_mutex;
+
+ PyObject *modules;
+ PyObject *modules_by_index;
+ PyObject *sysdict;
+ PyObject *builtins;
+ PyObject *importlib;
+
+ /* Used in Python/sysmodule.c. */
+ int check_interval;
+
+ /* Used in Modules/_threadmodule.c. */
+ long num_threads;
+ /* Support for runtime thread stack size tuning.
+ A value of 0 means using the platform's default stack size
+ or the size specified by the THREAD_STACK_SIZE macro. */
+ /* Used in Python/thread.c. */
+ size_t pythread_stacksize;
+
+ PyObject *codec_search_path;
+ PyObject *codec_search_cache;
+ PyObject *codec_error_registry;
+ int codecs_initialized;
+ int fscodec_initialized;
+
+ _PyCoreConfig core_config;
+ _PyMainInterpreterConfig config;
+#ifdef HAVE_DLOPEN
+ int dlopenflags;
+#endif
-/* hook for PyEval_GetFrame(), requested for Psyco */
-#define _PyThreadState_GetFrame _PyRuntime.gilstate.getframe
+ PyObject *builtins_copy;
+ PyObject *import_func;
+ /* Initialized to PyEval_EvalFrameDefault(). */
+ _PyFrameEvalFunction eval_frame;
-/* Issue #26558: Flag to disable PyGILState_Check().
- If set to non-zero, PyGILState_Check() always return 1. */
-#define _PyGILState_check_enabled _PyRuntime.gilstate.check_enabled
+ Py_ssize_t co_extra_user_count;
+ freefunc co_extra_freefuncs[MAX_CO_EXTRA_USERS];
+#ifdef HAVE_FORK
+ PyObject *before_forkers;
+ PyObject *after_forkers_parent;
+ PyObject *after_forkers_child;
+#endif
+ /* AtExit module */
+ void (*pyexitfunc)(PyObject *);
+ PyObject *pyexitmodule;
-/* interpreter state */
+ uint64_t tstate_next_unique_id;
+};
-PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpID(PY_INT64_T);
+PyAPI_FUNC(struct _is*) _PyInterpreterState_LookUpID(PY_INT64_T);
-PyAPI_FUNC(int) _PyInterpreterState_IDInitref(PyInterpreterState *);
-PyAPI_FUNC(void) _PyInterpreterState_IDIncref(PyInterpreterState *);
-PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *);
+PyAPI_FUNC(int) _PyInterpreterState_IDInitref(struct _is *);
+PyAPI_FUNC(void) _PyInterpreterState_IDIncref(struct _is *);
+PyAPI_FUNC(void) _PyInterpreterState_IDDecref(struct _is *);
/* cross-interpreter data */
@@ -119,6 +156,30 @@ struct _xidregitem {
};
+/* GIL state */
+
+struct _gilstate_runtime_state {
+ int check_enabled;
+ /* Assuming the current thread holds the GIL, this is the
+ PyThreadState for the current thread. */
+ _Py_atomic_address tstate_current;
+ PyThreadFrameGetter getframe;
+ /* The single PyInterpreterState used by this process'
+ GILState implementation
+ */
+ /* TODO: Given interp_main, it may be possible to kill this ref */
+ PyInterpreterState *autoInterpreterState;
+ Py_tss_t autoTSSkey;
+};
+
+/* hook for PyEval_GetFrame(), requested for Psyco */
+#define _PyThreadState_GetFrame _PyRuntime.gilstate.getframe
+
+/* Issue #26558: Flag to disable PyGILState_Check().
+ If set to non-zero, PyGILState_Check() always return 1. */
+#define _PyGILState_check_enabled _PyRuntime.gilstate.check_enabled
+
+
/* Full Python runtime state */
typedef struct pyruntimestate {