summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Goldblatt <davidgoldblatt@fb.com>2017-04-05 01:34:01 (GMT)
committerDavid Goldblatt <davidtgoldblatt@gmail.com>2017-04-05 23:25:37 (GMT)
commit5dcc13b342b3ffb38a1215ab2584b8cb12c46030 (patch)
treea5e745a7ca93bf0c24674fb054f9bae0881746a0 /src
parent492a941f493f77f60062039b60040f426aa7ee45 (diff)
downloadjemalloc-5dcc13b342b3ffb38a1215ab2584b8cb12c46030.zip
jemalloc-5dcc13b342b3ffb38a1215ab2584b8cb12c46030.tar.gz
jemalloc-5dcc13b342b3ffb38a1215ab2584b8cb12c46030.tar.bz2
Make the mutex n_waiting_thds field a C11-style atomic
Diffstat (limited to 'src')
-rw-r--r--src/mutex.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mutex.c b/src/mutex.c
index fa2770a..8c59310 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -93,10 +93,11 @@ label_spin_done:
/* Copy before to after to avoid clock skews. */
nstime_t after;
nstime_copy(&after, &before);
- uint32_t n_thds = atomic_add_u32(&data->n_waiting_thds, 1);
+ uint32_t n_thds = atomic_fetch_add_u32(&data->n_waiting_thds, 1,
+ ATOMIC_RELAXED) + 1;
/* One last try as above two calls may take quite some cycles. */
if (!malloc_mutex_trylock(mutex)) {
- atomic_sub_u32(&data->n_waiting_thds, 1);
+ atomic_fetch_sub_u32(&data->n_waiting_thds, 1, ATOMIC_RELAXED);
data->n_spin_acquired++;
return;
}
@@ -104,7 +105,7 @@ label_spin_done:
/* True slow path. */
malloc_mutex_lock_final(mutex);
/* Update more slow-path only counters. */
- atomic_sub_u32(&data->n_waiting_thds, 1);
+ atomic_fetch_sub_u32(&data->n_waiting_thds, 1, ATOMIC_RELAXED);
nstime_update(&after);
nstime_t delta;