mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-127705: Move Py_INCREF_MORTAL() to the internal C API (GH-136178)
Rename Py_INCREF_MORTAL() to _Py_INCREF_MORTAL() and move it to pycore_object.h internal header.
This commit is contained in:
parent
ab7196a2f5
commit
fa43a1e0f8
3 changed files with 18 additions and 18 deletions
|
@ -626,7 +626,7 @@ _PyStackRef_FromPyObjectNew(PyObject *obj)
|
|||
if (_Py_IsImmortal(obj)) {
|
||||
return (_PyStackRef){ .bits = ((uintptr_t)obj) | Py_TAG_REFCNT};
|
||||
}
|
||||
Py_INCREF_MORTAL(obj);
|
||||
_Py_INCREF_MORTAL(obj);
|
||||
_PyStackRef ref = (_PyStackRef){ .bits = (uintptr_t)obj };
|
||||
PyStackRef_CheckValid(ref);
|
||||
return ref;
|
||||
|
@ -637,7 +637,7 @@ static inline _PyStackRef
|
|||
_PyStackRef_FromPyObjectNewMortal(PyObject *obj)
|
||||
{
|
||||
assert(obj != NULL);
|
||||
Py_INCREF_MORTAL(obj);
|
||||
_Py_INCREF_MORTAL(obj);
|
||||
_PyStackRef ref = (_PyStackRef){ .bits = (uintptr_t)obj };
|
||||
PyStackRef_CheckValid(ref);
|
||||
return ref;
|
||||
|
@ -654,14 +654,14 @@ PyStackRef_FromPyObjectBorrow(PyObject *obj)
|
|||
/* WARNING: This macro evaluates its argument more than once */
|
||||
#ifdef _WIN32
|
||||
#define PyStackRef_DUP(REF) \
|
||||
(PyStackRef_RefcountOnObject(REF) ? (Py_INCREF_MORTAL(BITS_TO_PTR(REF)), (REF)) : (REF))
|
||||
(PyStackRef_RefcountOnObject(REF) ? (_Py_INCREF_MORTAL(BITS_TO_PTR(REF)), (REF)) : (REF))
|
||||
#else
|
||||
static inline _PyStackRef
|
||||
PyStackRef_DUP(_PyStackRef ref)
|
||||
{
|
||||
assert(!PyStackRef_IsNull(ref));
|
||||
if (PyStackRef_RefcountOnObject(ref)) {
|
||||
Py_INCREF_MORTAL(BITS_TO_PTR(ref));
|
||||
_Py_INCREF_MORTAL(BITS_TO_PTR(ref));
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue