@@ -5,6 +5,7 @@ extern "C" {
55#endif
66
77
8+ #if !defined(_Py_OPAQUE_PYOBJECT )
89/*
910Immortalization:
1011
@@ -90,14 +91,16 @@ check by comparing the reference count field to the minimum immortality refcount
9091# define _Py_REF_SHARED (refcnt , flags ) \
9192 (((refcnt) << _Py_REF_SHARED_SHIFT) + (flags))
9293#endif // Py_GIL_DISABLED
93-
94+ #endif // _Py_OPAQUE_PYOBJECT
9495
9596// Py_REFCNT() implementation for the stable ABI
9697PyAPI_FUNC (Py_ssize_t ) Py_REFCNT (PyObject * ob );
9798
9899#if defined(Py_LIMITED_API ) && Py_LIMITED_API + 0 >= 0x030e0000
99100 // Stable ABI implements Py_REFCNT() as a function call
100- // on limited C API version 3.14 and newer.
101+ // on limited C API version 3.14 and newer, and on abi3t.
102+ #elif defined(_Py_OPAQUE_PYOBJECT )
103+ // Py_REFCNT() is also a function call in abi3t.
101104#else
102105 static inline Py_ssize_t _Py_REFCNT (PyObject * ob ) {
103106 #if !defined(Py_GIL_DISABLED )
@@ -150,9 +153,10 @@ PyAPI_FUNC(void) _Py_SetRefcnt(PyObject *ob, Py_ssize_t refcnt);
150153
151154static inline void Py_SET_REFCNT (PyObject * ob , Py_ssize_t refcnt ) {
152155 assert (refcnt >= 0 );
153- #if defined(Py_LIMITED_API ) && Py_LIMITED_API + 0 >= 0x030d0000
156+ #if (defined(Py_LIMITED_API ) && Py_LIMITED_API + 0 >= 0x030d0000 ) \
157+ || defined(_Py_OPAQUE_PYOBJECT )
154158 // Stable ABI implements Py_SET_REFCNT() as a function call
155- // on limited C API version 3.13 and newer.
159+ // on limited C API version 3.13 and newer, and abi3t .
156160 _Py_SetRefcnt (ob , refcnt );
157161#else
158162 // This immortal check is for code that is unaware of immortal objects.
@@ -191,7 +195,7 @@ static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
191195 ob -> ob_ref_shared = _Py_REF_SHARED (refcnt , _Py_REF_MERGED );
192196 }
193197#endif // Py_GIL_DISABLED
194- #endif // Py_LIMITED_API+0 < 0x030d0000
198+ #endif // Py_LIMITED_API
195199}
196200#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
197201# define Py_SET_REFCNT (ob , refcnt ) Py_SET_REFCNT(_PyObject_CAST(ob), (refcnt))
@@ -250,10 +254,11 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);
250254
251255static inline Py_ALWAYS_INLINE void Py_INCREF (PyObject * op )
252256{
253- #if defined(Py_LIMITED_API ) && (Py_LIMITED_API + 0 >= 0x030c0000 || defined(Py_REF_DEBUG ))
257+ #if (defined(Py_LIMITED_API ) && (Py_LIMITED_API + 0 >= 0x030c0000 || defined(Py_REF_DEBUG ))) \
258+ || defined(_Py_OPAQUE_PYOBJECT )
254259 // Stable ABI implements Py_INCREF() as a function call on limited C API
255- // version 3.12 and newer, and on Python built in debug mode. _Py_IncRef()
256- // was added to Python 3.10.0a7, use Py_IncRef() on older Python versions.
260+ // version 3.12 and newer, abi3t, and on Python built in debug mode.
261+ // _Py_IncRef() was added to Python 3.10.0a7, use Py_IncRef() on older versions.
257262 // Py_IncRef() accepts NULL whereas _Py_IncRef() doesn't.
258263# if Py_LIMITED_API + 0 >= 0x030a00A7
259264 _Py_IncRef (op );
@@ -305,8 +310,8 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
305310# define Py_INCREF (op ) Py_INCREF(_PyObject_CAST(op))
306311#endif
307312
308-
309- #if !defined( Py_LIMITED_API ) && defined(Py_GIL_DISABLED )
313+ #if !defined( Py_LIMITED_API )
314+ #if defined(Py_GIL_DISABLED )
310315// Implements Py_DECREF on objects not owned by the current thread.
311316PyAPI_FUNC (void ) _Py_DecRefShared (PyObject * );
312317PyAPI_FUNC (void ) _Py_DecRefSharedDebug (PyObject * , const char * , int );
@@ -316,12 +321,14 @@ PyAPI_FUNC(void) _Py_DecRefSharedDebug(PyObject *, const char *, int);
316321// zero. Otherwise, the thread gives up ownership and merges the reference
317322// count fields.
318323PyAPI_FUNC (void ) _Py_MergeZeroLocalRefcount (PyObject * );
319- #endif
324+ #endif // Py_GIL_DISABLED
325+ #endif // Py_LIMITED_API
320326
321- #if defined(Py_LIMITED_API ) && (Py_LIMITED_API + 0 >= 0x030c0000 || defined(Py_REF_DEBUG ))
327+ #if (defined(Py_LIMITED_API ) && (Py_LIMITED_API + 0 >= 0x030c0000 || defined(Py_REF_DEBUG ))) \
328+ || defined(_Py_OPAQUE_PYOBJECT )
322329// Stable ABI implements Py_DECREF() as a function call on limited C API
323- // version 3.12 and newer, and on Python built in debug mode. _Py_DecRef() was
324- // added to Python 3.10.0a7, use Py_DecRef() on older Python versions.
330+ // version 3.12 and newer, abi3t, and on Python built in debug mode.
331+ // _Py_DecRef() was added to Python 3.10.0a7, use Py_DecRef() on older versions.
325332// Py_DecRef() accepts NULL whereas _Py_DecRef() doesn't.
326333static inline void Py_DECREF (PyObject * op ) {
327334# if Py_LIMITED_API + 0 >= 0x030a00A7
0 commit comments