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 /include/jemalloc | |
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 'include/jemalloc')
-rw-r--r-- | include/jemalloc/internal/extent_inlines.h | 2 | ||||
-rw-r--r-- | include/jemalloc/internal/jemalloc_internal.h.in | 7 |
2 files changed, 4 insertions, 5 deletions
diff --git a/include/jemalloc/internal/extent_inlines.h b/include/jemalloc/internal/extent_inlines.h index e6e447c..f1b9477 100644 --- a/include/jemalloc/internal/extent_inlines.h +++ b/include/jemalloc/internal/extent_inlines.h @@ -63,7 +63,7 @@ extent_arena_get(const extent_t *extent) { return NULL; } assert(arena_ind <= MALLOCX_ARENA_MAX); - return arenas[arena_ind]; + return (arena_t *)atomic_load_p(&arenas[arena_ind], ATOMIC_ACQUIRE); } JEMALLOC_INLINE szind_t diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in index 4255b63..04f91c0 100644 --- a/include/jemalloc/internal/jemalloc_internal.h.in +++ b/include/jemalloc/internal/jemalloc_internal.h.in @@ -469,7 +469,7 @@ extern unsigned narenas_auto; * Arenas that are used to service external requests. Not all elements of the * arenas array are necessarily used; arenas are created lazily as needed. */ -extern arena_t *arenas[]; +extern atomic_p_t arenas[]; /* * pind2sz_tab encodes the same information as could be computed by @@ -909,10 +909,9 @@ arena_get(tsdn_t *tsdn, unsigned ind, bool init_if_missing) { assert(ind <= MALLOCX_ARENA_MAX); - ret = arenas[ind]; + ret = (arena_t *)atomic_load_p(&arenas[ind], ATOMIC_ACQUIRE); if (unlikely(ret == NULL)) { - ret = (arena_t *)atomic_read_p((void **)&arenas[ind]); - if (init_if_missing && unlikely(ret == NULL)) { + if (init_if_missing) { ret = arena_init(tsdn, ind, (extent_hooks_t *)&extent_hooks_default); } |