static void * _thrd_wrapper_function(void * aArg) #endif { thrd_start_t fun; void *arg; int res; /* Get thread startup information */ _thread_start_info *ti = (_thread_start_info *) aArg; fun = ti->mFunction; arg = ti->mArg; /* The thread is responsible for freeing the startup information */ free((void *)ti); /* Call the actual client thread function */ res = fun(arg); #if defined(_TTHREAD_WIN32_) if (_tinycthread_tss_head != NULL) { _tinycthread_tss_cleanup(); } return (DWORD)res; #else return (void*)(intptr_t)res; #endif }
static void NTAPI _tinycthread_tss_callback(PVOID h, DWORD dwReason, PVOID pv) { (void)h; (void)pv; if (_tinycthread_tss_head != NULL && (dwReason == DLL_THREAD_DETACH || dwReason == DLL_PROCESS_DETACH)) { _tinycthread_tss_cleanup(); } }
void thrd_exit(int res) { #if defined(_TTHREAD_WIN32_) if (_tinycthread_tss_head != NULL) { _tinycthread_tss_cleanup(); } ExitThread(res); #else pthread_exit((void*)(intptr_t)res); #endif }
void thrd_exit(int res) { #if defined(_TTHREAD_WIN32_) if (_tinycthread_tss_head != NULL) { _tinycthread_tss_cleanup(); } ExitThread(res); #else void *pres = malloc(sizeof(int)); if (pres != NULL) { *(int*)pres = res; } pthread_exit(pres); #endif }
static void * _thrd_wrapper_function(void * aArg) #endif { thrd_start_t fun; void *arg; int res; #if defined(_TTHREAD_POSIX_) void *pres; #endif /* Get thread startup information */ _thread_start_info *ti = (_thread_start_info *) aArg; fun = ti->mFunction; arg = ti->mArg; /* The thread is responsible for freeing the startup information */ free((void *)ti); /* Call the actual client thread function */ res = fun(arg); #if defined(_TTHREAD_WIN32_) if (_tinycthread_tss_head != NULL) { _tinycthread_tss_cleanup(); } return res; #else /* Avoid memory leak for detached threads by not allocating a return val */ if (thrd_is_detached) return NULL; pres = malloc(sizeof(int)); if (pres != NULL) { *(int*)pres = res; } return pres; #endif }