1#ifndef JEMALLOC_INTERNAL_TCACHE_TYPES_H
2#define JEMALLOC_INTERNAL_TCACHE_TYPES_H
3
4#include "jemalloc/internal/sc.h"
5
6typedef struct tcache_slow_s tcache_slow_t;
7typedef struct tcache_s tcache_t;
8typedef struct tcaches_s tcaches_t;
9
10/*
11 * tcache pointers close to NULL are used to encode state information that is
12 * used for two purposes: preventing thread caching on a per thread basis and
13 * cleaning up during thread shutdown.
14 */
15#define TCACHE_STATE_DISABLED ((tcache_t *)(uintptr_t)1)
16#define TCACHE_STATE_REINCARNATED ((tcache_t *)(uintptr_t)2)
17#define TCACHE_STATE_PURGATORY ((tcache_t *)(uintptr_t)3)
18#define TCACHE_STATE_MAX TCACHE_STATE_PURGATORY
19
20/* Used in TSD static initializer only. Real init in tsd_tcache_data_init(). */
21#define TCACHE_ZERO_INITIALIZER {0}
22#define TCACHE_SLOW_ZERO_INITIALIZER {0}
23
24/* Used in TSD static initializer only. Will be initialized to opt_tcache. */
25#define TCACHE_ENABLED_ZERO_INITIALIZER false
26
27/* Used for explicit tcache only. Means flushed but not destroyed. */
28#define TCACHES_ELM_NEED_REINIT ((tcache_t *)(uintptr_t)1)
29
30#define TCACHE_LG_MAXCLASS_LIMIT 23 /* tcache_maxclass = 8M */
31#define TCACHE_MAXCLASS_LIMIT ((size_t)1 << TCACHE_LG_MAXCLASS_LIMIT)
32#define TCACHE_NBINS_MAX (SC_NBINS + SC_NGROUP * \
33 (TCACHE_LG_MAXCLASS_LIMIT - SC_LG_LARGE_MINCLASS) + 1)
34
35#endif /* JEMALLOC_INTERNAL_TCACHE_TYPES_H */
36