From 00c88b5bd2f2eeae679cda2dc49caf8763fd0b17 Mon Sep 17 00:00:00 2001 From: LIU Hao Date: Wed, 13 Nov 2024 19:05:31 +0800 Subject: [PATCH] xglobals: Make main thread joinable, partially Reference: https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html --- mcfgthread/xglobals.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mcfgthread/xglobals.c b/mcfgthread/xglobals.c index b38faa69c..69a461349 100644 --- a/mcfgthread/xglobals.c +++ b/mcfgthread/xglobals.c @@ -229,9 +229,10 @@ __MCF_gthread_initialize_globals(void) __MCF_G_SET_LAZY(__MCF_crt_kernelbase, GetSystemTimePreciseAsFileTime); /* win8 */ __MCF_G_SET_LAZY(__MCF_crt_kernelbase, QueryInterruptTime); /* win10 */ - /* Attach the main thread. The structure should be all zeroes so no - * initialization is necessary. */ + /* Attach the main thread and make it joinable. The structure should + * be all zeroes so no initialization is necessary. */ __MCF_thread_attach_foreign(__MCF_g->__main_thread); + _MCF_atomic_store_32_rel(__MCF_g->__main_thread->__nref, 2); } __MCF_DLLEXPORT