@@ -163,13 +163,13 @@ mi_decl_cache_align const mi_theap_t _mi_theap_empty_wrong = {
163163
164164// Heap for the main thread
165165
166- #define MI_THREADID_UNINIT ((mi_threadid_t)(~0))
166+ #define MI_THREADID_INVALID ((mi_threadid_t)(~0))
167167
168168extern mi_decl_hidden mi_decl_cache_align mi_theap_t theap_main ;
169169extern mi_decl_hidden mi_decl_cache_align mi_heap_t heap_main ;
170170
171171static mi_decl_cache_align mi_tld_t tld_main = {
172- MI_THREADID_UNINIT , // thread_id
172+ 0 , // thread_id
173173 0 , // thread_seq
174174 0 , // numa node
175175 & subproc_main , // subproc
@@ -300,7 +300,7 @@ static void mi_subproc_main_init(void) {
300300
301301// Initialize main tld
302302static void mi_tld_main_init (void ) {
303- if (tld_main .thread_id == MI_THREADID_UNINIT ) {
303+ if (tld_main .thread_id == 0 ) {
304304 tld_main .thread_id = _mi_prim_thread_id ();
305305 mi_lock_init (& tld_main .theaps_lock );
306306 }
@@ -383,7 +383,7 @@ static mi_tld_t* mi_tld_alloc(void) {
383383mi_decl_noinline static void mi_tld_free (mi_tld_t * tld ) {
384384 if (tld == NULL || tld == MI_TLD_INVALID ) return ;
385385 mi_atomic_decrement_relaxed (& tld -> subproc -> thread_count );
386- tld -> thread_id = 0 ;
386+ tld -> thread_id = MI_THREADID_INVALID ; // note: not 0 as that would re-initialize tld_main
387387 mi_lock_done (& tld -> theaps_lock );
388388 _mi_meta_free (tld , sizeof (mi_tld_t ), tld -> memid ); // note: safe for static tld_main
389389}
@@ -700,7 +700,7 @@ static void mi_process_setup_auto_thread_done(void) {
700700
701701
702702bool _mi_is_main_thread (void ) {
703- return (tld_main .thread_id == MI_THREADID_UNINIT || tld_main .thread_id == _mi_thread_id ());
703+ return (tld_main .thread_id == 0 || tld_main .thread_id == _mi_thread_id ());
704704}
705705
706706
0 commit comments