File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2940,20 +2940,29 @@ pointer_to_safe_refcount(void *ptr)
2940
2940
{
2941
2941
uintptr_t full = (uintptr_t )ptr ;
2942
2942
assert ((full & 3 ) == 0 );
2943
+ #if SIZEOF_VOID_P > 4
2943
2944
uint32_t refcnt = (uint32_t )full ;
2944
2945
if (refcnt >= (uint32_t )_Py_IMMORTAL_MINIMUM_REFCNT ) {
2945
2946
full = full - ((uintptr_t )_Py_IMMORTAL_MINIMUM_REFCNT ) + 1 ;
2946
2947
}
2947
2948
return full + 2 ;
2949
+ #else
2950
+ // Make the top two bits 0, so it appears mortal.
2951
+ return (full >> 2 ) + 1 ;
2952
+ #endif
2948
2953
}
2949
2954
2950
2955
static void *
2951
2956
safe_refcount_to_pointer (uintptr_t refcnt )
2952
2957
{
2958
+ #if SIZEOF_VOID_P > 4
2953
2959
if (refcnt & 1 ) {
2954
2960
refcnt += _Py_IMMORTAL_MINIMUM_REFCNT - 1 ;
2955
2961
}
2956
2962
return (void * )(refcnt - 2 );
2963
+ #else
2964
+ return (void * )((refcnt - 1 ) << 2 );
2965
+ #endif
2957
2966
}
2958
2967
#endif
2959
2968
You can’t perform that action at this time.
0 commit comments