Module Name: src Committed By: joerg Date: Tue Apr 21 22:22:55 UTC 2020
Modified Files: src/lib/libc/stdlib: jemalloc.c Log Message: Switch to using TLS in old jemalloc for everywhere but VAX and sun2. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/lib/libc/stdlib/jemalloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/stdlib/jemalloc.c diff -u src/lib/libc/stdlib/jemalloc.c:1.48 src/lib/libc/stdlib/jemalloc.c:1.49 --- src/lib/libc/stdlib/jemalloc.c:1.48 Mon Jan 13 19:14:37 2020 +++ src/lib/libc/stdlib/jemalloc.c Tue Apr 21 22:22:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: jemalloc.c,v 1.48 2020/01/13 19:14:37 joerg Exp $ */ +/* $NetBSD: jemalloc.c,v 1.49 2020/04/21 22:22:55 joerg Exp $ */ /*- * Copyright (C) 2006,2007 Jason Evans <jas...@freebsd.org>. @@ -100,7 +100,6 @@ #ifdef __NetBSD__ # define xutrace(a, b) utrace("malloc", (a), (b)) # define __DECONST(x, y) ((x)__UNCONST(y)) -# define NO_TLS #else # define xutrace(a, b) utrace((a), (b)) #endif /* __NetBSD__ */ @@ -118,7 +117,7 @@ #include <sys/cdefs.h> /* __FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.147 2007/06/15 22:00:16 jasone Exp $"); */ -__RCSID("$NetBSD: jemalloc.c,v 1.48 2020/01/13 19:14:37 joerg Exp $"); +__RCSID("$NetBSD: jemalloc.c,v 1.49 2020/04/21 22:22:55 joerg Exp $"); #ifdef __FreeBSD__ #include "libc_private.h" @@ -222,13 +221,11 @@ __RCSID("$NetBSD: jemalloc.c,v 1.48 2020 # define QUANTUM_2POW_MIN 4 # define SIZEOF_PTR_2POW 3 # define TINY_MIN_2POW 3 -# define NO_TLS #endif #ifdef __sparc64__ # define QUANTUM_2POW_MIN 4 # define SIZEOF_PTR_2POW 3 # define TINY_MIN_2POW 3 -# define NO_TLS #endif #ifdef __amd64__ # define QUANTUM_2POW_MIN 4 @@ -242,7 +239,6 @@ __RCSID("$NetBSD: jemalloc.c,v 1.48 2020 # ifdef __ARM_EABI__ # define TINY_MIN_2POW 3 # endif -# define NO_TLS #endif #ifdef __powerpc__ # define QUANTUM_2POW_MIN 4 @@ -264,6 +260,7 @@ __RCSID("$NetBSD: jemalloc.c,v 1.48 2020 # define QUANTUM_2POW_MIN 4 # define SIZEOF_PTR_2POW 2 # define USE_BRK +# define NO_TLS #endif #ifdef __sh__ # define QUANTUM_2POW_MIN 4 @@ -274,6 +271,9 @@ __RCSID("$NetBSD: jemalloc.c,v 1.48 2020 # define QUANTUM_2POW_MIN 4 # define SIZEOF_PTR_2POW 2 # define USE_BRK +# ifdef __mc68000__ +# define NO_TLS +# endif #endif #if defined(__mips__) || defined(__riscv__) # ifdef _LP64 @@ -771,9 +771,11 @@ static malloc_mutex_t arenas_mtx; /* Pro * for allocations. */ #ifndef NO_TLS -static __thread arena_t **arenas_map; +static __attribute__((tls_model("initial-exec"))) +__thread arena_t **arenas_map; #else static arena_t **arenas_map; +static thread_key_t arenas_map_key = -1; #endif #if !defined(NO_TLS) || !defined(_REENTRANT) @@ -781,7 +783,6 @@ static arena_t **arenas_map; # define set_arenas_map(x) (arenas_map = x) #else -static thread_key_t arenas_map_key = -1; static inline arena_t ** get_arenas_map(void) @@ -809,14 +810,18 @@ set_arenas_map(arena_t **a) } if (arenas_map_key == -1) { +#ifndef NO_TLS (void)thr_keycreate(&arenas_map_key, NULL); +#endif if (arenas_map != NULL) { _DIAGASSERT(arenas_map == a); arenas_map = NULL; } } +#ifndef NO_TLS thr_setspecific(arenas_map_key, a); +#endif } #endif