blob: e3aecfd4dfededb75ec55b5f4aee0f17af671af2 [file]
/* This is simple DLL library which uses CRT dtor TLS callback */
#include <corecrt_startup.h>
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
static int *process_or_thread_detach_var = NULL;
__attribute__((dllexport))
void set_process_or_thread_detach_var(int *var)
{
process_or_thread_detach_var = var;
}
static void __cdecl oneshot_dtor_tls_callback(void)
{
if (process_or_thread_detach_var)
(*process_or_thread_detach_var)++;
}
/* Register oneshot_dtor_tls_callback as oneshot CRT dtor TLS callback */
extern int __cdecl __tlregdtor(_PVFV func);
__attribute__((dllexport))
int register_thread_detach_for_current_thread(void)
{
return __tlregdtor(&oneshot_dtor_tls_callback);
}