Make prof's cum_gctx a C11-style atomic
This commit is contained in:
parent
5dcc13b342
commit
074f2256ca
@ -63,7 +63,7 @@ size_t lg_prof_sample;
|
|||||||
* creating/destroying mutexes.
|
* creating/destroying mutexes.
|
||||||
*/
|
*/
|
||||||
static malloc_mutex_t *gctx_locks;
|
static malloc_mutex_t *gctx_locks;
|
||||||
static unsigned cum_gctxs; /* Atomic counter. */
|
static atomic_u_t cum_gctxs; /* Atomic counter. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Table of mutexes that are shared among tdata's. No operations require
|
* Table of mutexes that are shared among tdata's. No operations require
|
||||||
@ -524,7 +524,7 @@ prof_backtrace(prof_bt_t *bt) {
|
|||||||
|
|
||||||
static malloc_mutex_t *
|
static malloc_mutex_t *
|
||||||
prof_gctx_mutex_choose(void) {
|
prof_gctx_mutex_choose(void) {
|
||||||
unsigned ngctxs = atomic_add_u(&cum_gctxs, 1);
|
unsigned ngctxs = atomic_fetch_add_u(&cum_gctxs, 1, ATOMIC_RELAXED);
|
||||||
|
|
||||||
return &gctx_locks[(ngctxs - 1) % PROF_NCTX_LOCKS];
|
return &gctx_locks[(ngctxs - 1) % PROF_NCTX_LOCKS];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user