summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Include/cpython/objimpl.h
diff options
context:
space:
mode:
authorAlexSm <[email protected]>2024-02-16 11:51:30 +0100
committerGitHub <[email protected]>2024-02-16 11:51:30 +0100
commit506ecaee93b52cc12c2e2f97c3d42e3ca2a7f59e (patch)
treed096fb9eb988fbb0ca1ba970041773207ce3aa70 /contrib/tools/python3/src/Include/cpython/objimpl.h
parent4749b9e5d260714490997e6f5ee1ee8c1c8fc46c (diff)
parentf200f72c9d7a89c1018e3dc6b46c49fe2ecf84fb (diff)
Merge pull request #1940 from dcherednik/importlib
Library import 14
Diffstat (limited to 'contrib/tools/python3/src/Include/cpython/objimpl.h')
-rw-r--r--contrib/tools/python3/src/Include/cpython/objimpl.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/contrib/tools/python3/src/Include/cpython/objimpl.h b/contrib/tools/python3/src/Include/cpython/objimpl.h
index d7c76eab5c7..5a8cdd57c78 100644
--- a/contrib/tools/python3/src/Include/cpython/objimpl.h
+++ b/contrib/tools/python3/src/Include/cpython/objimpl.h
@@ -2,7 +2,9 @@
# error "this header file must not be included directly"
#endif
-#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
+static inline size_t _PyObject_SIZE(PyTypeObject *type) {
+ return _Py_STATIC_CAST(size_t, type->tp_basicsize);
+}
/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a
vrbl-size object with nitems items, exclusive of gc overhead (if any). The
@@ -18,10 +20,11 @@
# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2"
#endif
-#define _PyObject_VAR_SIZE(typeobj, nitems) \
- _Py_SIZE_ROUND_UP((typeobj)->tp_basicsize + \
- (nitems)*(typeobj)->tp_itemsize, \
- SIZEOF_VOID_P)
+static inline size_t _PyObject_VAR_SIZE(PyTypeObject *type, Py_ssize_t nitems) {
+ size_t size = _Py_STATIC_CAST(size_t, type->tp_basicsize);
+ size += _Py_STATIC_CAST(size_t, nitems) * _Py_STATIC_CAST(size_t, type->tp_itemsize);
+ return _Py_SIZE_ROUND_UP(size, SIZEOF_VOID_P);
+}
/* This example code implements an object constructor with a custom
@@ -87,3 +90,6 @@ PyAPI_FUNC(int) PyObject_IS_GC(PyObject *obj);
PyAPI_FUNC(int) PyType_SUPPORTS_WEAKREFS(PyTypeObject *type);
PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op);
+
+PyAPI_FUNC(PyObject *) PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *,
+ size_t);