diff options
author | David Goldblatt <davidgoldblatt@fb.com> | 2017-04-04 22:12:24 (GMT) |
---|---|---|
committer | David Goldblatt <davidtgoldblatt@gmail.com> | 2017-04-05 23:25:37 (GMT) |
commit | bc32ec3503433fae4c737c7ffe6b3822ce98d5d8 (patch) | |
tree | d77e5e422e58e60fff4c5676d25b7b6ee01b11b4 /src | |
parent | 864adb7f4219dc9b920ead049478946f0a42428d (diff) | |
download | jemalloc-bc32ec3503433fae4c737c7ffe6b3822ce98d5d8.zip jemalloc-bc32ec3503433fae4c737c7ffe6b3822ce98d5d8.tar.gz jemalloc-bc32ec3503433fae4c737c7ffe6b3822ce98d5d8.tar.bz2 |
Move arena-tracking atomics in jemalloc.c to C11-style
Diffstat (limited to 'src')
-rw-r--r-- | src/jemalloc.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index 7c8fe9c..94ae030 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -55,10 +55,12 @@ static malloc_mutex_t arenas_lock; * arenas[0..narenas_auto) are used for automatic multiplexing of threads and * arenas. arenas[narenas_auto..narenas_total) are only used if the application * takes some action to create them and allocate from them. + * + * Points to an arena_t. */ JEMALLOC_ALIGNED(CACHELINE) -arena_t *arenas[MALLOCX_ARENA_MAX + 1]; -static unsigned narenas_total; /* Use narenas_total_*(). */ +atomic_p_t arenas[MALLOCX_ARENA_MAX + 1]; +static atomic_u_t narenas_total; /* Use narenas_total_*(). */ static arena_t *a0; /* arenas[0]; read-only after initialization. */ unsigned narenas_auto; /* Read-only after initialization. */ @@ -363,22 +365,22 @@ bootstrap_free(void *ptr) { void arena_set(unsigned ind, arena_t *arena) { - atomic_write_p((void **)&arenas[ind], arena); + atomic_store_p(&arenas[ind], arena, ATOMIC_RELEASE); } static void narenas_total_set(unsigned narenas) { - atomic_write_u(&narenas_total, narenas); + atomic_store_u(&narenas_total, narenas, ATOMIC_RELEASE); } static void narenas_total_inc(void) { - atomic_add_u(&narenas_total, 1); + atomic_fetch_add_u(&narenas_total, 1, ATOMIC_RELEASE); } unsigned narenas_total_get(void) { - return atomic_read_u(&narenas_total); + return atomic_load_u(&narenas_total, ATOMIC_ACQUIRE); } /* Create a new arena and insert it into the arenas array at index ind. */ |