Skip to content

Commit 5a00f82

Browse files
Do not re-declare _PyObject_IsImmortal.
1 parent d272218 commit 5a00f82

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Include/object.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,6 @@ typedef struct {
121121
#define _PyVarObject_CAST(op) ((PyVarObject*)(op))
122122
#define _PyVarObject_CAST_CONST(op) ((const PyVarObject*)(op))
123123

124-
// This is a static version of _PyObject_IsImmortal(), for the sake
125-
// of other static functions, like _Py_SET_REFCNT() and _Py_INCREF().
126-
static inline int _py_is_immortal(PyObject *op)
127-
{
128-
#ifdef Py_IMMORTAL_CONST_REFCOUNTS
129-
#ifndef _PyObject_IMMORTAL_BIT
130-
// This is duplicated as-is from the internal API.
131-
#define _PyObject_IMMORTAL_BIT (1LL << (8 * sizeof(Py_ssize_t) - 4))
132-
#endif
133-
return (op->ob_refcnt & _PyObject_IMMORTAL_BIT) != 0;
134-
#else
135-
extern int _PyObject_IsImmortal(PyObject *);
136-
return _PyObject_IsImmortal(op);
137-
#endif
138-
}
139-
140124
static inline Py_ssize_t _Py_REFCNT(const PyObject *ob) {
141125
return ob->ob_refcnt;
142126
}
@@ -156,6 +140,8 @@ static inline int _Py_IS_TYPE(const PyObject *ob, const PyTypeObject *type) {
156140
#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST_CONST(ob), type)
157141

158142

143+
static inline int _py_is_immortal(PyObject *); // forward
144+
159145
static inline void _Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
160146
if (_py_is_immortal((PyObject *)ob)) {
161147
return;
@@ -708,6 +694,20 @@ times.
708694
#error "the immortal objects API is not available in the limited API"
709695
#endif
710696

697+
// This is a static version of _PyObject_IsImmortal(), for the sake
698+
// of other static functions, like _Py_SET_REFCNT() and _Py_INCREF().
699+
static inline int _py_is_immortal(PyObject *op)
700+
{
701+
#ifdef Py_IMMORTAL_CONST_REFCOUNTS
702+
return (op->ob_refcnt & _PyObject_IMMORTAL_BIT) != 0;
703+
#else
704+
#ifndef _Py_IMMORTAL_OBJECTS
705+
extern int _PyObject_IsImmortal(PyObject *);
706+
#endif
707+
return _PyObject_IsImmortal(op);
708+
#endif
709+
}
710+
711711

712712
static inline int
713713
PyType_HasFeature(PyTypeObject *type, unsigned long feature)

0 commit comments

Comments
 (0)