File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,7 @@ PyStackRef_IsNullOrInt(_PyStackRef ref);
242242
243243#define Py_INT_TAG 3
244244#define Py_TAG_REFCNT 1
245+ #define Py_TAG_BITS 3
245246
246247static inline bool
247248PyStackRef_IsTaggedInt (_PyStackRef i )
@@ -268,7 +269,8 @@ PyStackRef_UntagInt(_PyStackRef i)
268269static inline _PyStackRef
269270PyStackRef_IncrementTaggedIntNoOverflow (_PyStackRef ref )
270271{
271- assert (ref .bits != (uintptr_t )-1 ); // Deosn't overflow
272+ assert ((ref .bits & Py_TAG_BITS ) == Py_INT_TAG ); // Is tagged int
273+ assert ((ref .bits & (~Py_TAG_BITS )) != (INT_MAX & (~Py_TAG_BITS ))); // Isn't about to overflow
272274 return (_PyStackRef ){ .bits = ref .bits + 4 };
273275}
274276
@@ -278,7 +280,6 @@ PyStackRef_IncrementTaggedIntNoOverflow(_PyStackRef ref)
278280#define Py_TAG_DEFERRED Py_TAG_REFCNT
279281
280282#define Py_TAG_PTR ((uintptr_t)0)
281- #define Py_TAG_BITS ((uintptr_t)1)
282283
283284
284285static const _PyStackRef PyStackRef_NULL = { .bits = Py_TAG_DEFERRED };
@@ -453,7 +454,6 @@ PyStackRef_AsStrongReference(_PyStackRef stackref)
453454/* References to immortal objects always have their tag bit set to Py_TAG_REFCNT
454455 * as they can (must) have their reclamation deferred */
455456
456- #define Py_TAG_BITS 3
457457#if _Py_IMMORTAL_FLAGS != Py_TAG_REFCNT
458458# error "_Py_IMMORTAL_FLAGS != Py_TAG_REFCNT"
459459#endif
You can’t perform that action at this time.
0 commit comments