22
22
23
23
// See musl's pthread_create.c
24
24
25
- extern int __pthread_create_js (pthread_t thread , const pthread_attr_t * attr , void * (* start_routine ) (void * ), void * arg );
25
+ extern int __pthread_create_js (struct pthread * thread , const pthread_attr_t * attr , void * (* start_routine ) (void * ), void * arg );
26
26
extern void _emscripten_thread_init (int , int , int );
27
27
extern int _emscripten_default_pthread_stack_size ();
28
28
extern void __pthread_detached_exit ();
@@ -76,7 +76,7 @@ int __pthread_create(pthread_t* restrict res,
76
76
void * (* entry )(void * ),
77
77
void * restrict arg ) {
78
78
// Note on LSAN: lsan intercepts/wraps calls to pthread_create so any
79
- // allocation we do here should be considered as leak .
79
+ // allocation we we do here should be considered leaks .
80
80
// See: lsan_interceptors.cpp.
81
81
if (!res ) {
82
82
return EINVAL ;
@@ -188,11 +188,11 @@ static void free_tls_data() {
188
188
}
189
189
190
190
void _emscripten_thread_exit (void * result ) {
191
- pthread_t self = __pthread_self ();
191
+ struct pthread * self = __pthread_self ();
192
192
assert (self );
193
193
194
- self -> canceldisable = 1 ;
195
- self -> cancelasync = 0 ;
194
+ self -> canceldisable = PTHREAD_CANCEL_DISABLE ;
195
+ self -> cancelasync = PTHREAD_CANCEL_DEFERRED ;
196
196
self -> result = result ;
197
197
198
198
// Run any handlers registered with pthread_cleanup_push
@@ -219,16 +219,16 @@ void _emscripten_thread_exit(void* result) {
219
219
return ;
220
220
}
221
221
222
- // We have the call the builtin free here since lsan handling for this thread
222
+ // We have the call the buildin free here since lsan handling for this thread
223
223
// gets shut down during __pthread_tsd_run_dtors.
224
224
emscripten_builtin_free (self -> tsd );
225
225
self -> tsd = NULL ;
226
226
227
227
// Not hosting a pthread anymore in this worker set __pthread_self to NULL
228
228
_emscripten_thread_init (0 , 0 , 0 );
229
229
230
- // This atomic potentially competes with a concurrent pthread_detach
231
- // call; the loser is responsible for freeing thread resources.
230
+ /* This atomic potentially competes with a concurrent pthread_detach
231
+ * call; the loser is responsible for freeing thread resources. */
232
232
int state = a_cas (& self -> detach_state , DT_JOINABLE , DT_EXITING );
233
233
234
234
// Mark the thread as no longer running.
@@ -244,7 +244,7 @@ void _emscripten_thread_exit(void* result) {
244
244
}
245
245
}
246
246
247
- // Mark as `no_sanitize("address") ` since emscripten_pthread_exit destroys
247
+ // Mark as `no_sanitize("address"` since emscripten_pthread_exit destroys
248
248
// the current thread and runs its exit handlers. Without this asan injects
249
249
// a call to __asan_handle_no_return before emscripten_unwind_to_js_event_loop
250
250
// which seem to cause a crash later down the line.
0 commit comments