1 #ifndef JEMALLOC_INTERNAL_TSD_STRUCTS_H
2 #define JEMALLOC_INTERNAL_TSD_STRUCTS_H
3 
4 #if (!defined(JEMALLOC_MALLOC_THREAD_CLEANUP) && !defined(JEMALLOC_TLS) && \
5     !defined(_WIN32))
6 struct tsd_init_block_s {
7 	ql_elm(tsd_init_block_t)	link;
8 	pthread_t			thread;
9 	void				*data;
10 };
11 struct tsd_init_head_s {
12 	ql_head(tsd_init_block_t)	blocks;
13 	malloc_mutex_t			lock;
14 };
15 #endif
16 
17 #define	MALLOC_TSD							\
18 /*  O(name,			type,			cleanup) */	\
19     O(tcache,			tcache_t *,		yes)		\
20     O(thread_allocated,		uint64_t,		no)		\
21     O(thread_deallocated,	uint64_t,		no)		\
22     O(prof_tdata,		prof_tdata_t *,		yes)		\
23     O(iarena,			arena_t *,		yes)		\
24     O(arena,			arena_t *,		yes)		\
25     O(arenas_tdata,		arena_tdata_t *,	yes)		\
26     O(narenas_tdata,		unsigned,		no)		\
27     O(arenas_tdata_bypass,	bool,			no)		\
28     O(tcache_enabled,		tcache_enabled_t,	no)		\
29     O(rtree_ctx,		rtree_ctx_t,		no)		\
30     O(witnesses,		witness_list_t,		yes)		\
31     O(rtree_elm_witnesses,	rtree_elm_witness_tsd_t,no)		\
32     O(witness_fork,		bool,			no)		\
33 
34 #define	TSD_INITIALIZER {						\
35     tsd_state_uninitialized,						\
36     NULL,								\
37     0,									\
38     0,									\
39     NULL,								\
40     NULL,								\
41     NULL,								\
42     NULL,								\
43     0,									\
44     false,								\
45     tcache_enabled_default,						\
46     RTREE_CTX_INITIALIZER,						\
47     ql_head_initializer(witnesses),					\
48     RTREE_ELM_WITNESS_TSD_INITIALIZER,					\
49     false								\
50 }
51 
52 struct tsd_s {
53 	tsd_state_t	state;
54 #define	O(n, t, c)							\
55 	t		n;
56 MALLOC_TSD
57 #undef O
58 };
59 
60 /*
61  * Wrapper around tsd_t that makes it possible to avoid implicit conversion
62  * between tsd_t and tsdn_t, where tsdn_t is "nullable" and has to be
63  * explicitly converted to tsd_t, which is non-nullable.
64  */
65 struct tsdn_s {
66 	tsd_t	tsd;
67 };
68 
69 static const tsd_t tsd_initializer = TSD_INITIALIZER;
70 
71 malloc_tsd_types(, tsd_t)
72 
73 #endif /* JEMALLOC_INTERNAL_TSD_STRUCTS_H */
74