From 5f118307543b128e1ad6298ec2ab1acd71140095 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Sun, 5 Feb 2017 23:57:16 -0800 Subject: [PATCH] Replace spin_init() with SPIN_INITIALIZER. --- include/jemalloc/internal/private_symbols.txt | 1 - include/jemalloc/internal/spin_inlines.h | 6 ------ include/jemalloc/internal/spin_types.h | 2 ++ src/extent_dss.c | 3 +-- src/jemalloc.c | 4 +--- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt index 3f29d3fe..2c824541 100644 --- a/include/jemalloc/internal/private_symbols.txt +++ b/include/jemalloc/internal/private_symbols.txt @@ -445,7 +445,6 @@ size2index_compute size2index_lookup size2index_tab spin_adaptive -spin_init stats_print tcache_alloc_easy tcache_alloc_large diff --git a/include/jemalloc/internal/spin_inlines.h b/include/jemalloc/internal/spin_inlines.h index 1ffc4232..03beeada 100644 --- a/include/jemalloc/internal/spin_inlines.h +++ b/include/jemalloc/internal/spin_inlines.h @@ -2,16 +2,10 @@ #define JEMALLOC_INTERNAL_SPIN_INLINES_H #ifndef JEMALLOC_ENABLE_INLINE -void spin_init(spin_t *spin); void spin_adaptive(spin_t *spin); #endif #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_SPIN_C_)) -JEMALLOC_INLINE void -spin_init(spin_t *spin) { - spin->iteration = 0; -} - JEMALLOC_INLINE void spin_adaptive(spin_t *spin) { volatile uint64_t i; diff --git a/include/jemalloc/internal/spin_types.h b/include/jemalloc/internal/spin_types.h index 52ee4cc1..222e0698 100644 --- a/include/jemalloc/internal/spin_types.h +++ b/include/jemalloc/internal/spin_types.h @@ -3,4 +3,6 @@ typedef struct spin_s spin_t; +#define SPIN_INITIALIZER {0U} + #endif /* JEMALLOC_INTERNAL_SPIN_TYPES_H */ diff --git a/src/extent_dss.c b/src/extent_dss.c index a3cfab26..0b4e1fe3 100644 --- a/src/extent_dss.c +++ b/src/extent_dss.c @@ -62,13 +62,12 @@ extent_dss_prec_set(dss_prec_t dss_prec) { static void * extent_dss_max_update(void *new_addr) { void *max_cur; - spin_t spinner; /* * Get the current end of the DSS as max_cur and assure that dss_max is * up to date. */ - spin_init(&spinner); + spin_t spinner = SPIN_INITIALIZER; while (true) { void *max_prev = atomic_read_p(&dss_max); diff --git a/src/jemalloc.c b/src/jemalloc.c index 48be4a3f..d2c33bbc 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1153,10 +1153,8 @@ malloc_init_hard_needed(void) { } #ifdef JEMALLOC_THREADED_INIT if (malloc_initializer != NO_INITIALIZER && !IS_INITIALIZER) { - spin_t spinner; - /* Busy-wait until the initializing thread completes. */ - spin_init(&spinner); + spin_t spinner = SPIN_INITIALIZER; do { malloc_mutex_unlock(TSDN_NULL, &init_lock); spin_adaptive(&spinner);