admin
2022-11-05 3680049029e6a193eae069596be04ce0fb2b1303
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifdef JEMALLOC_INTERNAL_TSD_MALLOC_THREAD_CLEANUP_H
#error This file should be included only once, by tsd.h.
#endif
#define JEMALLOC_INTERNAL_TSD_MALLOC_THREAD_CLEANUP_H
 
#define JEMALLOC_TSD_TYPE_ATTR(type) __thread type JEMALLOC_TLS_MODEL
 
extern JEMALLOC_TSD_TYPE_ATTR(tsd_t) tsd_tls;
extern JEMALLOC_TSD_TYPE_ATTR(bool) tsd_initialized;
extern bool tsd_booted;
 
/* Initialization/cleanup. */
JEMALLOC_ALWAYS_INLINE bool
tsd_cleanup_wrapper(void) {
    if (tsd_initialized) {
        tsd_initialized = false;
        tsd_cleanup(&tsd_tls);
    }
    return tsd_initialized;
}
 
JEMALLOC_ALWAYS_INLINE bool
tsd_boot0(void) {
    malloc_tsd_cleanup_register(&tsd_cleanup_wrapper);
    tsd_booted = true;
    return false;
}
 
JEMALLOC_ALWAYS_INLINE void
tsd_boot1(void) {
    /* Do nothing. */
}
 
JEMALLOC_ALWAYS_INLINE bool
tsd_boot(void) {
    return tsd_boot0();
}
 
JEMALLOC_ALWAYS_INLINE bool
tsd_booted_get(void) {
    return tsd_booted;
}
 
JEMALLOC_ALWAYS_INLINE bool
tsd_get_allocates(void) {
    return false;
}
 
/* Get/set. */
JEMALLOC_ALWAYS_INLINE tsd_t *
tsd_get(bool init) {
    return &tsd_tls;
}
JEMALLOC_ALWAYS_INLINE void
tsd_set(tsd_t *val) {
    assert(tsd_booted);
    if (likely(&tsd_tls != val)) {
        tsd_tls = (*val);
    }
    tsd_initialized = true;
}