Header refactoring: unify spin.h and move it out of the catch-all.
This commit is contained in:
parent
418d96a86c
commit
38e847c1c5
@ -40,7 +40,6 @@
|
||||
/* TYPES */
|
||||
/******************************************************************************/
|
||||
|
||||
#include "jemalloc/internal/spin_types.h"
|
||||
#include "jemalloc/internal/prng_types.h"
|
||||
#include "jemalloc/internal/ticker_types.h"
|
||||
#include "jemalloc/internal/ckh_types.h"
|
||||
@ -65,7 +64,6 @@
|
||||
/* STRUCTS */
|
||||
/******************************************************************************/
|
||||
|
||||
#include "jemalloc/internal/spin_structs.h"
|
||||
#include "jemalloc/internal/ticker_structs.h"
|
||||
#include "jemalloc/internal/ckh_structs.h"
|
||||
#include "jemalloc/internal/witness_structs.h"
|
||||
@ -110,7 +108,6 @@
|
||||
/* INLINES */
|
||||
/******************************************************************************/
|
||||
|
||||
#include "jemalloc/internal/spin_inlines.h"
|
||||
#include "jemalloc/internal/prng_inlines.h"
|
||||
#include "jemalloc/internal/ticker_inlines.h"
|
||||
#include "jemalloc/internal/tsd_inlines.h"
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef JEMALLOC_INTERNAL_RTREE_INLINES_H
|
||||
#define JEMALLOC_INTERNAL_RTREE_INLINES_H
|
||||
|
||||
#include "jemalloc/internal/spin.h"
|
||||
|
||||
#ifndef JEMALLOC_ENABLE_INLINE
|
||||
uintptr_t rtree_leafkey(uintptr_t key);
|
||||
uintptr_t rtree_subkey(uintptr_t key, unsigned level);
|
||||
|
36
include/jemalloc/internal/spin.h
Normal file
36
include/jemalloc/internal/spin.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef JEMALLOC_INTERNAL_SPIN_H
|
||||
#define JEMALLOC_INTERNAL_SPIN_H
|
||||
|
||||
#ifdef JEMALLOC_SPIN_C_
|
||||
# define SPIN_INLINE extern inline
|
||||
#else
|
||||
# define SPIN_INLINE inline
|
||||
#endif
|
||||
|
||||
#define SPIN_INITIALIZER {0U}
|
||||
|
||||
typedef struct {
|
||||
unsigned iteration;
|
||||
} spin_t;
|
||||
|
||||
SPIN_INLINE void
|
||||
spin_adaptive(spin_t *spin) {
|
||||
volatile uint32_t i;
|
||||
|
||||
if (spin->iteration < 5) {
|
||||
for (i = 0; i < (1U << spin->iteration); i++) {
|
||||
CPU_SPINWAIT;
|
||||
}
|
||||
spin->iteration++;
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
SwitchToThread();
|
||||
#else
|
||||
sched_yield();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#undef SPIN_INLINE
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_SPIN_H */
|
@ -1,29 +0,0 @@
|
||||
#ifndef JEMALLOC_INTERNAL_SPIN_INLINES_H
|
||||
#define JEMALLOC_INTERNAL_SPIN_INLINES_H
|
||||
|
||||
#ifndef JEMALLOC_ENABLE_INLINE
|
||||
void spin_adaptive(spin_t *spin);
|
||||
#endif
|
||||
|
||||
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_SPIN_C_))
|
||||
JEMALLOC_INLINE void
|
||||
spin_adaptive(spin_t *spin) {
|
||||
volatile uint32_t i;
|
||||
|
||||
if (spin->iteration < 5) {
|
||||
for (i = 0; i < (1U << spin->iteration); i++) {
|
||||
CPU_SPINWAIT;
|
||||
}
|
||||
spin->iteration++;
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
SwitchToThread();
|
||||
#else
|
||||
sched_yield();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_SPIN_INLINES_H */
|
@ -1,8 +0,0 @@
|
||||
#ifndef JEMALLOC_INTERNAL_SPIN_STRUCTS_H
|
||||
#define JEMALLOC_INTERNAL_SPIN_STRUCTS_H
|
||||
|
||||
struct spin_s {
|
||||
unsigned iteration;
|
||||
};
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_SPIN_STRUCTS_H */
|
@ -1,8 +0,0 @@
|
||||
#ifndef JEMALLOC_INTERNAL_SPIN_TYPES_H
|
||||
#define JEMALLOC_INTERNAL_SPIN_TYPES_H
|
||||
|
||||
typedef struct spin_s spin_t;
|
||||
|
||||
#define SPIN_INITIALIZER {0U}
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_SPIN_TYPES_H */
|
@ -3,6 +3,7 @@
|
||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||
|
||||
#include "jemalloc/internal/assert.h"
|
||||
#include "jemalloc/internal/spin.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/* Data. */
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "jemalloc/internal/atomic.h"
|
||||
#include "jemalloc/internal/jemalloc_internal_types.h"
|
||||
#include "jemalloc/internal/malloc_io.h"
|
||||
#include "jemalloc/internal/spin.h"
|
||||
#include "jemalloc/internal/util.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -1,3 +1,4 @@
|
||||
#define JEMALLOC_SPIN_C_
|
||||
#include "jemalloc/internal/jemalloc_preamble.h"
|
||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||
|
||||
#include "jemalloc/internal/spin.h"
|
||||
|
Loading…
Reference in New Issue
Block a user