@@ -57,7 +57,7 @@ size_t _mi_os_minimal_purge_size(void) {
5757 if (minsize != 0 ) {
5858 return _mi_align_up (minsize , _mi_os_page_size ());
5959 }
60- else if (mi_os_mem_config .has_transparent_huge_pages && mi_option_is_enabled (mi_option_allow_thp )) {
60+ else if (mi_os_mem_config .has_transparent_huge_pages && mi_option_get (mi_option_allow_thp ) == 2 ) {
6161 return _mi_os_large_page_size ();
6262 }
6363 else {
@@ -131,15 +131,15 @@ void* _mi_os_get_aligned_hint(size_t try_alignment, size_t size)
131131 if (try_alignment <= mi_os_mem_config .alloc_granularity || try_alignment > MI_HINT_ALIGN ) return NULL ;
132132 if (mi_os_mem_config .virtual_address_bits < 46 ) return NULL ; // < 64TiB virtual address space
133133 size = _mi_align_up (size , MI_HINT_ALIGN );
134- if (size > 16 * MI_GiB ) return NULL ; // guarantee the chance of fixed valid address is at least 1/(MI_HINT_AREA / 1<<34)
134+ if (size > 16 * MI_GiB ) return NULL ; // guarantee the chance of fixed valid address is at least 1/(MI_HINT_AREA / 1<<34)
135135 size += MI_HINT_ALIGN ; // put in virtual gaps between hinted blocks; this splits VLA's but increases guarded areas.
136-
136+
137137 uintptr_t hint = mi_atomic_add_acq_rel (& aligned_base , size );
138138 if (hint == 0 || hint > MI_HINT_MAX ) { // wrap or initialize
139139 uintptr_t init = MI_HINT_BASE ;
140140 #if (MI_SECURE >=1 || defined(NDEBUG )) // security: randomize start of aligned allocations unless in debug mode
141141 mi_theap_t * const theap = _mi_theap_default (); // don't use `mi_theap_get_default()` as that can cause allocation recursively (issue #1267)
142- if (!mi_theap_is_initialized (theap )) return NULL ; // no hint as we lack randomness at this point
142+ if (!mi_theap_is_initialized (theap )) return NULL ; // no hint as we lack randomness at this point
143143 const uintptr_t r = _mi_theap_random_next (theap );
144144 init = init + ((MI_HINT_ALIGN * ((r >>17 ) & 0xFFFFF )) % MI_HINT_AREA ); // (randomly 20 bits)*4MiB == 0 to 4TiB
145145 #endif
@@ -157,7 +157,7 @@ void* _mi_os_get_aligned_hint(size_t try_alignment, size_t size) {
157157 return NULL ;
158158}
159159#endif
160-
160+
161161
162162/* -----------------------------------------------------------
163163 Guard page allocation
@@ -298,11 +298,11 @@ static void* mi_os_prim_alloc_at(void* hint_addr, size_t size, size_t try_alignm
298298 if (size == 0 ) return NULL ;
299299 if (!commit ) { allow_large = false; }
300300 if (try_alignment == 0 ) { try_alignment = 1 ; } // avoid 0 to ensure there will be no divide by zero when aligning
301-
301+
302302 // try to align along large OS page size for larger allocations
303303 const size_t large_page_size = mi_os_mem_config .large_page_size ;
304304 if (large_page_size > 0 && hint_addr == NULL && size >= 8 * large_page_size && _mi_is_power_of_two (try_alignment ) && try_alignment < large_page_size ) {
305- try_alignment = large_page_size ;
305+ try_alignment = large_page_size ;
306306 }
307307
308308 * is_zero = false;
@@ -575,7 +575,7 @@ bool _mi_os_commit(void* addr, size_t size, bool* is_zero) {
575575
576576static bool mi_os_decommit_ex (void * addr , size_t size , bool * needs_recommit , size_t stat_size ) {
577577 mi_assert_internal (needs_recommit != NULL );
578-
578+
579579 // page align
580580 size_t csize ;
581581 void * start = mi_os_page_align_area_conservative (addr , size , & csize );
@@ -587,7 +587,7 @@ static bool mi_os_decommit_ex(void* addr, size_t size, bool* needs_recommit, siz
587587 if (err != 0 ) {
588588 _mi_warning_message ("cannot decommit OS memory (error: %d (0x%x), address: %p, size: 0x%zx bytes)\n" , err , err , start , csize );
589589 }
590- else if (* needs_recommit ) {
590+ else if (* needs_recommit ) {
591591 mi_os_stat_decrease (committed , stat_size );
592592 }
593593 mi_assert_internal (err == 0 );
0 commit comments