1 #include "jemalloc/internal/jemalloc_preamble.h"
2 #include "jemalloc/internal/jemalloc_internal_includes.h"
3
4 #include "jemalloc/internal/counter.h"
5
6 bool
counter_accum_init(counter_accum_t * counter,uint64_t interval)7 counter_accum_init(counter_accum_t *counter, uint64_t interval) {
8 if (LOCKEDINT_MTX_INIT(counter->mtx, "counter_accum",
9 WITNESS_RANK_COUNTER_ACCUM, malloc_mutex_rank_exclusive)) {
10 return true;
11 }
12 locked_init_u64_unsynchronized(&counter->accumbytes, 0);
13 counter->interval = interval;
14 return false;
15 }
16
17 void
counter_prefork(tsdn_t * tsdn,counter_accum_t * counter)18 counter_prefork(tsdn_t *tsdn, counter_accum_t *counter) {
19 LOCKEDINT_MTX_PREFORK(tsdn, counter->mtx);
20 }
21
22 void
counter_postfork_parent(tsdn_t * tsdn,counter_accum_t * counter)23 counter_postfork_parent(tsdn_t *tsdn, counter_accum_t *counter) {
24 LOCKEDINT_MTX_POSTFORK_PARENT(tsdn, counter->mtx);
25 }
26
27 void
counter_postfork_child(tsdn_t * tsdn,counter_accum_t * counter)28 counter_postfork_child(tsdn_t *tsdn, counter_accum_t *counter) {
29 LOCKEDINT_MTX_POSTFORK_CHILD(tsdn, counter->mtx);
30 }
31