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)
29402940{
29412941 uintptr_t full = (uintptr_t )ptr ;
29422942 assert ((full & 3 ) == 0 );
2943+ #if SIZEOF_VOID_P > 4
29432944 uint32_t refcnt = (uint32_t )full ;
29442945 if (refcnt >= (uint32_t )_Py_IMMORTAL_MINIMUM_REFCNT ) {
29452946 full = full - ((uintptr_t )_Py_IMMORTAL_MINIMUM_REFCNT ) + 1 ;
29462947 }
29472948 return full + 2 ;
2949+ #else
2950+ // Make the top two bits 0, so it appears mortal.
2951+ return (full >> 2 ) + 1 ;
2952+ #endif
29482953}
29492954
29502955static void *
29512956safe_refcount_to_pointer (uintptr_t refcnt )
29522957{
2958+ #if SIZEOF_VOID_P > 4
29532959 if (refcnt & 1 ) {
29542960 refcnt += _Py_IMMORTAL_MINIMUM_REFCNT - 1 ;
29552961 }
29562962 return (void * )(refcnt - 2 );
2963+ #else
2964+ return (void * )((refcnt - 1 ) << 2 );
2965+ #endif
29572966}
29582967#endif
29592968
You can’t perform that action at this time.
0 commit comments