summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-02-16 14:49:13 (GMT)
committerGitHub <noreply@github.com>2024-02-16 14:49:13 (GMT)
commit144eb5605b445d22729db6c416d03cc24947ba56 (patch)
treed79f0e3dc243c91c44eb7306dd4b583c67f368ae /Include
parentb178eae3a676473e1c2287a46b4941fc0bcd193f (diff)
downloadcpython-144eb5605b445d22729db6c416d03cc24947ba56.zip
cpython-144eb5605b445d22729db6c416d03cc24947ba56.tar.gz
cpython-144eb5605b445d22729db6c416d03cc24947ba56.tar.bz2
gh-102013: Move PyUnstable_GC_VisitObjects() to Include/cpython/objimpl.h (#115560)
Include/objimpl.h must only contain the limited C API, whereas PyUnstable_GC_VisitObjects() is excluded from the limited C API.
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/objimpl.h17
-rw-r--r--Include/objimpl.h19
2 files changed, 17 insertions, 19 deletions
diff --git a/Include/cpython/objimpl.h b/Include/cpython/objimpl.h
index 58a30ae..e0c2ce2 100644
--- a/Include/cpython/objimpl.h
+++ b/Include/cpython/objimpl.h
@@ -85,3 +85,20 @@ PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op);
PyAPI_FUNC(PyObject *) PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *,
size_t);
+
+
+/* Visit all live GC-capable objects, similar to gc.get_objects(None). The
+ * supplied callback is called on every such object with the void* arg set
+ * to the supplied arg. Returning 0 from the callback ends iteration, returning
+ * 1 allows iteration to continue. Returning any other value may result in
+ * undefined behaviour.
+ *
+ * If new objects are (de)allocated by the callback it is undefined if they
+ * will be visited.
+
+ * Garbage collection is disabled during operation. Explicitly running a
+ * collection in the callback may lead to undefined behaviour e.g. visiting the
+ * same objects multiple times or not at all.
+ */
+typedef int (*gcvisitobjects_t)(PyObject*, void*);
+PyAPI_FUNC(void) PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void* arg);
diff --git a/Include/objimpl.h b/Include/objimpl.h
index ff5fa7a..56472a7 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -153,25 +153,6 @@ PyAPI_FUNC(int) PyGC_Enable(void);
PyAPI_FUNC(int) PyGC_Disable(void);
PyAPI_FUNC(int) PyGC_IsEnabled(void);
-
-#if !defined(Py_LIMITED_API)
-/* Visit all live GC-capable objects, similar to gc.get_objects(None). The
- * supplied callback is called on every such object with the void* arg set
- * to the supplied arg. Returning 0 from the callback ends iteration, returning
- * 1 allows iteration to continue. Returning any other value may result in
- * undefined behaviour.
- *
- * If new objects are (de)allocated by the callback it is undefined if they
- * will be visited.
-
- * Garbage collection is disabled during operation. Explicitly running a
- * collection in the callback may lead to undefined behaviour e.g. visiting the
- * same objects multiple times or not at all.
- */
-typedef int (*gcvisitobjects_t)(PyObject*, void*);
-PyAPI_FUNC(void) PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void* arg);
-#endif
-
/* Test if a type has a GC head */
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)