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);
242
242
243
243
#define Py_INT_TAG 3
244
244
#define Py_TAG_REFCNT 1
245
+ #define Py_TAG_BITS 3
245
246
246
247
static inline bool
247
248
PyStackRef_IsTaggedInt (_PyStackRef i )
@@ -268,7 +269,8 @@ PyStackRef_UntagInt(_PyStackRef i)
268
269
static inline _PyStackRef
269
270
PyStackRef_IncrementTaggedIntNoOverflow (_PyStackRef ref )
270
271
{
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
272
274
return (_PyStackRef ){ .bits = ref .bits + 4 };
273
275
}
274
276
@@ -278,7 +280,6 @@ PyStackRef_IncrementTaggedIntNoOverflow(_PyStackRef ref)
278
280
#define Py_TAG_DEFERRED Py_TAG_REFCNT
279
281
280
282
#define Py_TAG_PTR ((uintptr_t)0)
281
- #define Py_TAG_BITS ((uintptr_t)1)
282
283
283
284
284
285
static const _PyStackRef PyStackRef_NULL = { .bits = Py_TAG_DEFERRED };
@@ -453,7 +454,6 @@ PyStackRef_AsStrongReference(_PyStackRef stackref)
453
454
/* References to immortal objects always have their tag bit set to Py_TAG_REFCNT
454
455
* as they can (must) have their reclamation deferred */
455
456
456
- #define Py_TAG_BITS 3
457
457
#if _Py_IMMORTAL_FLAGS != Py_TAG_REFCNT
458
458
# error "_Py_IMMORTAL_FLAGS != Py_TAG_REFCNT"
459
459
#endif
You can’t perform that action at this time.
0 commit comments