Skip to content

Commit 2fd9d34

Browse files
committed
Set flags properly for all objects
1 parent 5d7e1c0 commit 2fd9d34

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Include/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ whose size is determined when the object is allocated.
8181
#else
8282
#define PyObject_HEAD_INIT(type) \
8383
{ \
84-
{ _Py_IMMORTAL_INITIAL_REFCNT }, \
84+
{ _Py_STATIC_IMMORTAL_INITIAL_REFCNT }, \
8585
(type) \
8686
},
8787
#endif

Include/refcount.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ immortal. The latter should be the only instances that require
1919
cleanup during runtime finalization.
2020
*/
2121

22+
/* Leave the low bits for refcount overflow for old stable ABI code */
23+
#define _Py_STATICALLY_ALLOCATED_FLAG (1 << 7)
24+
2225
#if SIZEOF_VOID_P > 4
2326
/*
2427
In 64+ bit systems, any object whose 32 bit reference count is >= 2**31
@@ -39,7 +42,8 @@ beyond the refcount limit. Immortality checks for reference count decreases will
3942
be done by checking the bit sign flag in the lower 32 bits.
4043
4144
*/
42-
#define _Py_IMMORTAL_INITIAL_REFCNT ((Py_ssize_t)(3UL << 30))
45+
#define _Py_IMMORTAL_INITIAL_REFCNT (3UL << 30)
46+
#define _Py_STATIC_IMMORTAL_INITIAL_REFCNT ((Py_ssize_t)(_Py_IMMORTAL_INITIAL_REFCNT | (((Py_ssize_t)_Py_STATICALLY_ALLOCATED_FLAG) << 32)))
4347

4448
#else
4549
/*
@@ -60,9 +64,6 @@ check by comparing the reference count field to the minimum immortality refcount
6064
#define _Py_STATIC_IMMORTAL_MINIMUM_REFCNT ((Py_ssize_t)(6L << 28))
6165
#endif
6266

63-
/* Leave the low bits for refcount overflow for old stable ABI code */
64-
#define _Py_STATICALLY_ALLOCATED_FLAG (1 << 7)
65-
6667
// Py_GIL_DISABLED builds indicate immortal objects using `ob_ref_local`, which is
6768
// always 32-bits.
6869
#ifdef Py_GIL_DISABLED

0 commit comments

Comments
 (0)