summaryrefslogtreecommitdiffstats
path: root/Include/cpython/pystate.h
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-12-05 20:40:20 (GMT)
committerGitHub <noreply@github.com>2022-12-05 20:40:20 (GMT)
commit530cc9dbb61df55b83f0219d2282980c9cb1cbd8 (patch)
treed40fb85821f901b3e8abe91f266f4367f1f579ac /Include/cpython/pystate.h
parent51ee0a29e9b20c3e4a94a675e73a894ee2fe447b (diff)
downloadcpython-530cc9dbb61df55b83f0219d2282980c9cb1cbd8.zip
cpython-530cc9dbb61df55b83f0219d2282980c9cb1cbd8.tar.gz
cpython-530cc9dbb61df55b83f0219d2282980c9cb1cbd8.tar.bz2
gh-99741: Implement Multi-Phase Init for the _xxsubinterpreters Module (gh-99742)
_xxsubinterpreters is an internal module used for testing. https://github.com/python/cpython/issues/99741
Diffstat (limited to 'Include/cpython/pystate.h')
-rw-r--r--Include/cpython/pystate.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 0f56b1f..0117c23 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -353,6 +353,9 @@ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
// is necessary to pass safely between interpreters in the same process.
typedef struct _xid _PyCrossInterpreterData;
+typedef PyObject *(*xid_newobjectfunc)(_PyCrossInterpreterData *);
+typedef void (*xid_freefunc)(void *);
+
struct _xid {
// data is the cross-interpreter-safe derivation of a Python object
// (see _PyObject_GetCrossInterpreterData). It will be NULL if the
@@ -379,7 +382,7 @@ struct _xid {
// interpreter given the data. The resulting object (a new
// reference) will be equivalent to the original object. This field
// is required.
- PyObject *(*new_object)(_PyCrossInterpreterData *);
+ xid_newobjectfunc new_object;
// free is called when the data is released. If it is NULL then
// nothing will be done to free the data. For some types this is
// okay (e.g. bytes) and for those types this field should be set
@@ -389,9 +392,20 @@ struct _xid {
// leak. In that case, at the very least this field should be set
// to PyMem_RawFree (the default if not explicitly set to NULL).
// The call will happen with the original interpreter activated.
- void (*free)(void *);
+ xid_freefunc free;
};
+PyAPI_FUNC(void) _PyCrossInterpreterData_Init(
+ _PyCrossInterpreterData *data,
+ PyInterpreterState *interp, void *shared, PyObject *obj,
+ xid_newobjectfunc new_object);
+PyAPI_FUNC(int) _PyCrossInterpreterData_InitWithSize(
+ _PyCrossInterpreterData *,
+ PyInterpreterState *interp, const size_t, PyObject *,
+ xid_newobjectfunc);
+PyAPI_FUNC(void) _PyCrossInterpreterData_Clear(
+ PyInterpreterState *, _PyCrossInterpreterData *);
+
PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
PyAPI_FUNC(int) _PyCrossInterpreterData_Release(_PyCrossInterpreterData *);
@@ -400,7 +414,8 @@ PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *);
/* cross-interpreter data registry */
-typedef int (*crossinterpdatafunc)(PyObject *, _PyCrossInterpreterData *);
+typedef int (*crossinterpdatafunc)(PyThreadState *tstate, PyObject *,
+ _PyCrossInterpreterData *);
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
PyAPI_FUNC(int) _PyCrossInterpreterData_UnregisterClass(PyTypeObject *);