@@ -174,7 +174,7 @@ static size_t _real_page_size = ZEND_MM_PAGE_SIZE;
174174#endif
175175
176176typedef uint32_t zend_mm_page_info ; /* 4-byte integer */
177- typedef zend_ulong zend_mm_bitset ; /* 4-byte or 8-byte integer */
177+ typedef size_t zend_mm_bitset ; /* 4-byte or 8-byte integer */
178178
179179#define ZEND_MM_ALIGNED_OFFSET (size , alignment ) \
180180 (((size_t)(size)) & ((alignment) - 1))
@@ -571,7 +571,7 @@ static void *zend_mm_mmap(size_t size)
571571/* number of trailing set (1) bits */
572572ZEND_ATTRIBUTE_CONST static zend_always_inline int zend_mm_bitset_nts (zend_mm_bitset bitset )
573573{
574- #if (defined(__GNUC__ ) || __has_builtin (__builtin_ctzl )) && SIZEOF_ZEND_LONG == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CTZL )
574+ #if (defined(__GNUC__ ) || __has_builtin (__builtin_ctzl )) && SIZEOF_SIZE_T == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CTZL )
575575 return __builtin_ctzl (~bitset );
576576#elif (defined(__GNUC__ ) || __has_builtin (__builtin_ctzll )) && defined(PHP_HAVE_BUILTIN_CTZLL )
577577 return __builtin_ctzll (~bitset );
@@ -594,7 +594,7 @@ ZEND_ATTRIBUTE_CONST static zend_always_inline int zend_mm_bitset_nts(zend_mm_bi
594594 if (bitset == (zend_mm_bitset )- 1 ) return ZEND_MM_BITSET_LEN ;
595595
596596 n = 0 ;
597- #if SIZEOF_ZEND_LONG == 8
597+ #if SIZEOF_SIZE_T == 8
598598 if (sizeof (zend_mm_bitset ) == 8 ) {
599599 if ((bitset & 0xffffffff ) == 0xffffffff ) {n += 32 ; bitset = bitset >> Z_UL (32 );}
600600 }
@@ -614,12 +614,12 @@ static zend_always_inline int zend_mm_bitset_is_set(zend_mm_bitset *bitset, int
614614
615615static zend_always_inline void zend_mm_bitset_set_bit (zend_mm_bitset * bitset , int bit )
616616{
617- bitset [bit / ZEND_MM_BITSET_LEN ] |= (Z_UL ( 1 ) << (bit & (ZEND_MM_BITSET_LEN - 1 )));
617+ bitset [bit / ZEND_MM_BITSET_LEN ] |= (( zend_mm_bitset ) 1 << (bit & (ZEND_MM_BITSET_LEN - 1 )));
618618}
619619
620620static zend_always_inline void zend_mm_bitset_reset_bit (zend_mm_bitset * bitset , int bit )
621621{
622- bitset [bit / ZEND_MM_BITSET_LEN ] &= ~(Z_UL ( 1 ) << (bit & (ZEND_MM_BITSET_LEN - 1 )));
622+ bitset [bit / ZEND_MM_BITSET_LEN ] &= ~(( zend_mm_bitset ) 1 << (bit & (ZEND_MM_BITSET_LEN - 1 )));
623623}
624624
625625static zend_always_inline void zend_mm_bitset_set_range (zend_mm_bitset * bitset , int start , int len )
@@ -2082,7 +2082,7 @@ static zend_mm_heap *zend_mm_init(void)
20822082#endif
20832083 zend_mm_init_key (heap );
20842084#if ZEND_MM_LIMIT
2085- heap -> limit = (size_t )Z_L ( -1 ) >> 1 ;
2085+ heap -> limit = (size_t )-1 >> 1 ;
20862086 heap -> overflow = 0 ;
20872087#endif
20882088#if ZEND_MM_CUSTOM
@@ -2334,7 +2334,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap)
23342334 repeated = zend_mm_find_leaks_huge (heap , list );
23352335 total += 1 + repeated ;
23362336 if (repeated ) {
2337- zend_message_dispatcher (ZMSG_MEMORY_LEAK_REPEATED , ( void * )( uintptr_t ) repeated );
2337+ zend_message_dispatcher (ZMSG_MEMORY_LEAK_REPEATED , ZEND_ULONG2PTR ( repeated ) );
23382338 }
23392339
23402340 heap -> huge_list = list = list -> next ;
@@ -2373,7 +2373,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap)
23732373 zend_mm_find_leaks (heap , p , i + bin_pages [bin_num ], & leak );
23742374 total += 1 + repeated ;
23752375 if (repeated ) {
2376- zend_message_dispatcher (ZMSG_MEMORY_LEAK_REPEATED , ( void * )( uintptr_t ) repeated );
2376+ zend_message_dispatcher (ZMSG_MEMORY_LEAK_REPEATED , ZEND_ULONG2PTR ( repeated ) );
23772377 }
23782378 }
23792379 dbg = (zend_mm_debug_info * )((char * )dbg + bin_data_size [bin_num ]);
@@ -2399,7 +2399,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap)
23992399 repeated = zend_mm_find_leaks (heap , p , i + pages_count , & leak );
24002400 total += 1 + repeated ;
24012401 if (repeated ) {
2402- zend_message_dispatcher (ZMSG_MEMORY_LEAK_REPEATED , ( void * )( uintptr_t ) repeated );
2402+ zend_message_dispatcher (ZMSG_MEMORY_LEAK_REPEATED , ZEND_ULONG2PTR ( repeated ) );
24032403 }
24042404 i += pages_count ;
24052405 }
@@ -2981,14 +2981,14 @@ static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)
29812981#if ZEND_MM_CUSTOM
29822982static zend_always_inline void tracked_add (zend_mm_heap * heap , void * ptr , size_t size ) {
29832983 zval size_zv ;
2984- zend_ulong h = (( uintptr_t ) ptr ) >> ZEND_MM_ALIGNMENT_LOG2 ;
2985- ZEND_ASSERT (( void * ) ( uintptr_t ) (h << ZEND_MM_ALIGNMENT_LOG2 ) == ptr );
2984+ zend_ulong h = ZEND_PTR2ULONG ( ptr ) >> ZEND_MM_ALIGNMENT_LOG2 ;
2985+ ZEND_ASSERT (ZEND_ULONG2PTR (h << ZEND_MM_ALIGNMENT_LOG2 ) == ptr );
29862986 ZVAL_LONG (& size_zv , size );
29872987 zend_hash_index_add_new (heap -> tracked_allocs , h , & size_zv );
29882988}
29892989
29902990static zend_always_inline zval * tracked_get_size_zv (zend_mm_heap * heap , void * ptr ) {
2991- zend_ulong h = (( uintptr_t ) ptr ) >> ZEND_MM_ALIGNMENT_LOG2 ;
2991+ zend_ulong h = ZEND_PTR2ULONG ( ptr ) >> ZEND_MM_ALIGNMENT_LOG2 ;
29922992 zval * size_zv = zend_hash_index_find (heap -> tracked_allocs , h );
29932993 ZEND_ASSERT (size_zv && "Trying to free pointer not allocated through ZendMM" );
29942994 return size_zv ;
@@ -3074,7 +3074,7 @@ static void tracked_free_all(zend_mm_heap *heap) {
30743074 HashTable * tracked_allocs = heap -> tracked_allocs ;
30753075 zend_ulong h ;
30763076 ZEND_HASH_FOREACH_NUM_KEY (tracked_allocs , h ) {
3077- void * ptr = ( void * ) ( uintptr_t ) (h << ZEND_MM_ALIGNMENT_LOG2 );
3077+ void * ptr = ZEND_ULONG2PTR (h << ZEND_MM_ALIGNMENT_LOG2 );
30783078 free (ptr );
30793079 } ZEND_HASH_FOREACH_END ();
30803080}
@@ -3285,7 +3285,7 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
32853285 zend_mm_heap * mm_heap = alloc_globals -> mm_heap = malloc (sizeof (zend_mm_heap ));
32863286 memset (mm_heap , 0 , sizeof (zend_mm_heap ));
32873287 mm_heap -> use_custom_heap = ZEND_MM_CUSTOM_HEAP_STD ;
3288- mm_heap -> limit = (size_t )Z_L ( -1 ) >> 1 ;
3288+ mm_heap -> limit = (size_t )-1 >> 1 ;
32893289 mm_heap -> overflow = 0 ;
32903290
32913291 if (!tracked ) {
@@ -3506,7 +3506,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
35063506#endif
35073507 zend_mm_init_key (heap );
35083508#if ZEND_MM_LIMIT
3509- heap -> limit = (size_t )Z_L ( -1 ) >> 1 ;
3509+ heap -> limit = (size_t )-1 >> 1 ;
35103510 heap -> overflow = 0 ;
35113511#endif
35123512#if ZEND_MM_CUSTOM
0 commit comments