@@ -164,14 +164,6 @@ static void __pthread_exit(void *result)
164164 self -> prev -> next = self -> next ;
165165 self -> prev = self -> next = self ;
166166
167- #ifndef __wasilibc_unmodified_upstream
168- /* On Linux, the thread is created with CLONE_CHILD_CLEARTID,
169- * and this lock will unlock by kernel when this thread terminates.
170- * So we should unlock it here in WebAssembly.
171- * See also set_tid_address(2) */
172- __tl_unlock ();
173- #endif
174-
175167#ifdef __wasilibc_unmodified_upstream
176168 if (state == DT_DETACHED && self -> map_base ) {
177169 /* Detached threads must block even implementation-internal
@@ -190,9 +182,6 @@ static void __pthread_exit(void *result)
190182 }
191183#else
192184 if (state == DT_DETACHED && self -> map_base ) {
193- // __syscall(SYS_exit) would unlock the thread, list
194- // do it manually here
195- __tl_unlock ();
196185 free (self -> map_base );
197186 // Can't use `exit()` here, because it is too high level
198187 return ;
@@ -212,10 +201,15 @@ static void __pthread_exit(void *result)
212201#ifdef __wasilibc_unmodified_upstream
213202 for (;;) __syscall (SYS_exit , 0 );
214203#else
215- // __syscall(SYS_exit) would unlock the thread, list
216- // do it manually here
217- __tl_unlock ();
218204 // Can't use `exit()` here, because it is too high level
205+
206+ /* On Linux, the thread is created with CLONE_CHILD_CLEARTID,
207+ * and the lock (__thread_list_lock) will be unlocked by kernel when
208+ * this thread terminates.
209+ * See also set_tid_address(2)
210+ *
211+ * In WebAssembly, we leave it to wasi_thread_start instead.
212+ */
219213#endif
220214}
221215
0 commit comments