diff options
| author | jackpoz <giacomopoz@gmail.com> | 2017-11-19 11:23:41 +0100 | 
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2017-11-19 19:22:41 +0100 | 
| commit | cc6dec72863a771da0c0f3ab3d32f75d7ce863bd (patch) | |
| tree | 5386204cdcc3ed9844b38986e3a45bf5613748c5 /dep/jemalloc/src/tsd.c | |
| parent | 11beb4b6e1e63156774a42e5cfc63f17bdccc3ad (diff) | |
Dep/Jemalloc: Update to Jemalloc 4.0.4
Diffstat (limited to 'dep/jemalloc/src/tsd.c')
| -rw-r--r-- | dep/jemalloc/src/tsd.c | 62 | 
1 files changed, 57 insertions, 5 deletions
| diff --git a/dep/jemalloc/src/tsd.c b/dep/jemalloc/src/tsd.c index 700caabfe47..9ffe9afef7a 100644 --- a/dep/jemalloc/src/tsd.c +++ b/dep/jemalloc/src/tsd.c @@ -7,21 +7,22 @@  static unsigned ncleanups;  static malloc_tsd_cleanup_t cleanups[MALLOC_TSD_CLEANUPS_MAX]; +malloc_tsd_data(, , tsd_t, TSD_INITIALIZER) +  /******************************************************************************/  void *  malloc_tsd_malloc(size_t size)  { -	/* Avoid choose_arena() in order to dodge bootstrapping issues. */ -	return (arena_malloc(arenas[0], size, false, false)); +	return (a0malloc(CACHELINE_CEILING(size)));  }  void  malloc_tsd_dalloc(void *wrapper)  { -	idalloct(wrapper, false); +	a0dalloc(wrapper);  }  void @@ -67,10 +68,61 @@ malloc_tsd_cleanup_register(bool (*f)(void))  }  void -malloc_tsd_boot(void) +tsd_cleanup(void *arg) +{ +	tsd_t *tsd = (tsd_t *)arg; + +	switch (tsd->state) { +	case tsd_state_uninitialized: +		/* Do nothing. */ +		break; +	case tsd_state_nominal: +#define O(n, t)								\ +		n##_cleanup(tsd); +MALLOC_TSD +#undef O +		tsd->state = tsd_state_purgatory; +		tsd_set(tsd); +		break; +	case tsd_state_purgatory: +		/* +		 * The previous time this destructor was called, we set the +		 * state to tsd_state_purgatory so that other destructors +		 * wouldn't cause re-creation of the tsd.  This time, do +		 * nothing, and do not request another callback. +		 */ +		break; +	case tsd_state_reincarnated: +		/* +		 * Another destructor deallocated memory after this destructor +		 * was called.  Reset state to tsd_state_purgatory and request +		 * another callback. +		 */ +		tsd->state = tsd_state_purgatory; +		tsd_set(tsd); +		break; +	default: +		not_reached(); +	} +} + +bool +malloc_tsd_boot0(void)  {  	ncleanups = 0; +	if (tsd_boot0()) +		return (true); +	*tsd_arenas_cache_bypassp_get(tsd_fetch()) = true; +	return (false); +} + +void +malloc_tsd_boot1(void) +{ + +	tsd_boot1(); +	*tsd_arenas_cache_bypassp_get(tsd_fetch()) = false;  }  #ifdef _WIN32 @@ -102,7 +154,7 @@ _tls_callback(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)  #  pragma section(".CRT$XLY",long,read)  #endif  JEMALLOC_SECTION(".CRT$XLY") JEMALLOC_ATTR(used) -static const BOOL	(WINAPI *tls_callback)(HINSTANCE hinstDLL, +static BOOL	(WINAPI *const tls_callback)(HINSTANCE hinstDLL,      DWORD fdwReason, LPVOID lpvReserved) = _tls_callback;  #endif | 
