1use libc::size_t;
2use std::os::raw::{c_int, c_void};
3
4use crate::object::*;
5use crate::pyport::Py_ssize_t;
6
7extern "C" {
8 #[cfg_attr(PyPy, link_name = "PyPyObject_Malloc")]
9 pub fn PyObject_Malloc(size: size_t) -> *mut c_void;
10 #[cfg_attr(PyPy, link_name = "PyPyObject_Calloc")]
11 pub fn PyObject_Calloc(nelem: size_t, elsize: size_t) -> *mut c_void;
12 #[cfg_attr(PyPy, link_name = "PyPyObject_Realloc")]
13 pub fn PyObject_Realloc(ptr: *mut c_void, new_size: size_t) -> *mut c_void;
14 #[cfg_attr(PyPy, link_name = "PyPyObject_Free")]
15 pub fn PyObject_Free(ptr: *mut c_void);
16
17 // skipped PyObject_MALLOC
18 // skipped PyObject_REALLOC
19 // skipped PyObject_FREE
20 // skipped PyObject_Del
21 // skipped PyObject_DEL
22
23 #[cfg_attr(PyPy, link_name = "PyPyObject_Init")]
24 pub fn PyObject_Init(arg1: *mut PyObject, arg2: *mut PyTypeObject) -> *mut PyObject;
25 #[cfg_attr(PyPy, link_name = "PyPyObject_InitVar")]
26 pub fn PyObject_InitVar(
27 arg1: *mut PyVarObject,
28 arg2: *mut PyTypeObject,
29 arg3: Py_ssize_t,
30 ) -> *mut PyVarObject;
31
32 // skipped PyObject_INIT
33 // skipped PyObject_INIT_VAR
34
35 #[cfg_attr(PyPy, link_name = "_PyPyObject_New")]
36 pub fn _PyObject_New(arg1: *mut PyTypeObject) -> *mut PyObject;
37 #[cfg_attr(PyPy, link_name = "_PyPyObject_NewVar")]
38 pub fn _PyObject_NewVar(arg1: *mut PyTypeObject, arg2: Py_ssize_t) -> *mut PyVarObject;
39
40 // skipped PyObject_New
41 // skipped PyObject_NEW
42 // skipped PyObject_NewVar
43 // skipped PyObject_NEW_VAR
44
45 pub fn PyGC_Collect() -> Py_ssize_t;
46
47 #[cfg(Py_3_10)]
48 #[cfg_attr(PyPy, link_name = "PyPyGC_Enable")]
49 pub fn PyGC_Enable() -> c_int;
50
51 #[cfg(Py_3_10)]
52 #[cfg_attr(PyPy, link_name = "PyPyGC_Disable")]
53 pub fn PyGC_Disable() -> c_int;
54
55 #[cfg(Py_3_10)]
56 #[cfg_attr(PyPy, link_name = "PyPyGC_IsEnabled")]
57 pub fn PyGC_IsEnabled() -> c_int;
58
59 // skipped PyUnstable_GC_VisitObjects
60}
61
62#[inline]
63pub unsafe fn PyType_IS_GC(t: *mut PyTypeObject) -> c_int {
64 PyType_HasFeature(t, Py_TPFLAGS_HAVE_GC)
65}
66
67extern "C" {
68 pub fn _PyObject_GC_Resize(arg1: *mut PyVarObject, arg2: Py_ssize_t) -> *mut PyVarObject;
69
70 // skipped PyObject_GC_Resize
71
72 #[cfg_attr(PyPy, link_name = "_PyPyObject_GC_New")]
73 pub fn _PyObject_GC_New(arg1: *mut PyTypeObject) -> *mut PyObject;
74 #[cfg_attr(PyPy, link_name = "_PyPyObject_GC_NewVar")]
75 pub fn _PyObject_GC_NewVar(arg1: *mut PyTypeObject, arg2: Py_ssize_t) -> *mut PyVarObject;
76 #[cfg(not(PyPy))]
77 pub fn PyObject_GC_Track(arg1: *mut c_void);
78 #[cfg(not(PyPy))]
79 pub fn PyObject_GC_UnTrack(arg1: *mut c_void);
80 #[cfg_attr(PyPy, link_name = "PyPyObject_GC_Del")]
81 pub fn PyObject_GC_Del(arg1: *mut c_void);
82
83 // skipped PyObject_GC_New
84 // skipped PyObject_GC_NewVar
85
86 #[cfg(any(all(Py_3_9, not(PyPy)), Py_3_10))] // added in 3.9, or 3.10 on PyPy
87 #[cfg_attr(PyPy, link_name = "PyPyObject_GC_IsTracked")]
88 pub fn PyObject_GC_IsTracked(arg1: *mut PyObject) -> c_int;
89 #[cfg(any(all(Py_3_9, not(PyPy)), Py_3_10))] // added in 3.9, or 3.10 on PyPy
90 #[cfg_attr(PyPy, link_name = "PyPyObject_GC_IsFinalized")]
91 pub fn PyObject_GC_IsFinalized(arg1: *mut PyObject) -> c_int;
92}
93
94// skipped Py_VISIT
95