summaryrefslogtreecommitdiffstats
path: root/Include/cpython/pystate.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-02-24 16:51:59 (GMT)
committerGitHub <noreply@github.com>2022-02-24 16:51:59 (GMT)
commit042f31da552c19054acd3ef7bb6cfd857bce172b (patch)
treed1aa8f20f873c89adebbac7072d80dceb19d32c4 /Include/cpython/pystate.h
parentec091bd47e2f968b0d1631b9a8104283a7beeb1b (diff)
downloadcpython-042f31da552c19054acd3ef7bb6cfd857bce172b.zip
cpython-042f31da552c19054acd3ef7bb6cfd857bce172b.tar.gz
cpython-042f31da552c19054acd3ef7bb6cfd857bce172b.tar.bz2
bpo-45459: C API uses type names rather than structure names (GH-31528)
Thanks to the new pytypedefs.h, it becomes to use type names like PyObject rather like structure names like "struct _object".
Diffstat (limited to 'Include/cpython/pystate.h')
-rw-r--r--Include/cpython/pystate.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 74dd44d..8150d50 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -79,12 +79,11 @@ typedef struct _stack_chunk {
PyObject * data[1]; /* Variable sized */
} _PyStackChunk;
-// The PyThreadState typedef is in Include/pystate.h.
struct _ts {
/* See Python/ceval.c for comments explaining most fields */
- struct _ts *prev;
- struct _ts *next;
+ PyThreadState *prev;
+ PyThreadState *next;
PyInterpreterState *interp;
/* Has been initialized to a safe state.
@@ -308,12 +307,12 @@ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
/* cross-interpreter data */
-struct _xid;
-
// _PyCrossInterpreterData is similar to Py_buffer as an effectively
// opaque struct that holds data outside the object machinery. This
// is necessary to pass safely between interpreters in the same process.
-typedef struct _xid {
+typedef struct _xid _PyCrossInterpreterData;
+
+struct _xid {
// data is the cross-interpreter-safe derivation of a Python object
// (see _PyObject_GetCrossInterpreterData). It will be NULL if the
// new_object func (below) encodes the data.
@@ -339,7 +338,7 @@ typedef 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)(struct _xid *);
+ PyObject *(*new_object)(_PyCrossInterpreterData *);
// 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
@@ -350,7 +349,7 @@ typedef struct _xid {
// to PyMem_RawFree (the default if not explicitly set to NULL).
// The call will happen with the original interpreter activated.
void (*free)(void *);
-} _PyCrossInterpreterData;
+};
PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
@@ -360,7 +359,7 @@ PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *);
/* cross-interpreter data registry */
-typedef int (*crossinterpdatafunc)(PyObject *, struct _xid *);
+typedef int (*crossinterpdatafunc)(PyObject *, _PyCrossInterpreterData *);
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);