1 #define JEMALLOC_TSD_C_
2 #include "jemalloc/internal/jemalloc_internal.h"
4 /******************************************************************************/
7 static unsigned ncleanups;
8 static malloc_tsd_cleanup_t cleanups[MALLOC_TSD_CLEANUPS_MAX];
10 /******************************************************************************/
13 malloc_tsd_malloc(size_t size)
16 /* Avoid choose_arena() in order to dodge bootstrapping issues. */
17 return (arena_malloc(arenas[0], size, false, false));
21 malloc_tsd_dalloc(void *wrapper)
28 malloc_tsd_no_cleanup(void *arg)
34 #if defined(JEMALLOC_MALLOC_THREAD_CLEANUP) || defined(_WIN32)
39 _malloc_thread_cleanup(void)
41 bool pending[MALLOC_TSD_CLEANUPS_MAX], again;
44 for (i = 0; i < ncleanups; i++)
49 for (i = 0; i < ncleanups; i++) {
51 pending[i] = cleanups[i]();
61 malloc_tsd_cleanup_register(bool (*f)(void))
64 assert(ncleanups < MALLOC_TSD_CLEANUPS_MAX);
65 cleanups[ncleanups] = f;
78 _tls_callback(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
82 #ifdef JEMALLOC_LAZY_LOCK
83 case DLL_THREAD_ATTACH:
87 case DLL_THREAD_DETACH:
88 _malloc_thread_cleanup();
98 # pragma comment(linker, "/INCLUDE:__tls_used")
100 # pragma comment(linker, "/INCLUDE:_tls_used")
102 # pragma section(".CRT$XLY",long,read)
104 JEMALLOC_SECTION(".CRT$XLY") JEMALLOC_ATTR(used)
105 static const BOOL (WINAPI *tls_callback)(HINSTANCE hinstDLL,
106 DWORD fdwReason, LPVOID lpvReserved) = _tls_callback;