Replace spin_init() with SPIN_INITIALIZER.

This commit is contained in:
Jason Evans 2017-02-05 23:57:16 -08:00
parent 650c070e10
commit 5f11830754
5 changed files with 4 additions and 12 deletions

View File

@ -445,7 +445,6 @@ size2index_compute
size2index_lookup size2index_lookup
size2index_tab size2index_tab
spin_adaptive spin_adaptive
spin_init
stats_print stats_print
tcache_alloc_easy tcache_alloc_easy
tcache_alloc_large tcache_alloc_large

View File

@ -2,16 +2,10 @@
#define JEMALLOC_INTERNAL_SPIN_INLINES_H #define JEMALLOC_INTERNAL_SPIN_INLINES_H
#ifndef JEMALLOC_ENABLE_INLINE #ifndef JEMALLOC_ENABLE_INLINE
void spin_init(spin_t *spin);
void spin_adaptive(spin_t *spin); void spin_adaptive(spin_t *spin);
#endif #endif
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_SPIN_C_)) #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_SPIN_C_))
JEMALLOC_INLINE void
spin_init(spin_t *spin) {
spin->iteration = 0;
}
JEMALLOC_INLINE void JEMALLOC_INLINE void
spin_adaptive(spin_t *spin) { spin_adaptive(spin_t *spin) {
volatile uint64_t i; volatile uint64_t i;

View File

@ -3,4 +3,6 @@
typedef struct spin_s spin_t; typedef struct spin_s spin_t;
#define SPIN_INITIALIZER {0U}
#endif /* JEMALLOC_INTERNAL_SPIN_TYPES_H */ #endif /* JEMALLOC_INTERNAL_SPIN_TYPES_H */

View File

@ -62,13 +62,12 @@ extent_dss_prec_set(dss_prec_t dss_prec) {
static void * static void *
extent_dss_max_update(void *new_addr) { extent_dss_max_update(void *new_addr) {
void *max_cur; void *max_cur;
spin_t spinner;
/* /*
* Get the current end of the DSS as max_cur and assure that dss_max is * Get the current end of the DSS as max_cur and assure that dss_max is
* up to date. * up to date.
*/ */
spin_init(&spinner); spin_t spinner = SPIN_INITIALIZER;
while (true) { while (true) {
void *max_prev = atomic_read_p(&dss_max); void *max_prev = atomic_read_p(&dss_max);

View File

@ -1153,10 +1153,8 @@ malloc_init_hard_needed(void) {
} }
#ifdef JEMALLOC_THREADED_INIT #ifdef JEMALLOC_THREADED_INIT
if (malloc_initializer != NO_INITIALIZER && !IS_INITIALIZER) { if (malloc_initializer != NO_INITIALIZER && !IS_INITIALIZER) {
spin_t spinner;
/* Busy-wait until the initializing thread completes. */ /* Busy-wait until the initializing thread completes. */
spin_init(&spinner); spin_t spinner = SPIN_INITIALIZER;
do { do {
malloc_mutex_unlock(TSDN_NULL, &init_lock); malloc_mutex_unlock(TSDN_NULL, &init_lock);
spin_adaptive(&spinner); spin_adaptive(&spinner);