048c6679cd
The external linkage for spin_adaptive was not used, and the inline declaration of spin_adaptive that was used caused a probem on FreeBSD where CPU_SPINWAIT is implemented as a call to a static procedure for x86 architectures.
31 lines
477 B
C
31 lines
477 B
C
#ifndef JEMALLOC_INTERNAL_SPIN_H
|
|
#define JEMALLOC_INTERNAL_SPIN_H
|
|
|
|
#define SPIN_INITIALIZER {0U}
|
|
|
|
typedef struct {
|
|
unsigned iteration;
|
|
} spin_t;
|
|
|
|
static 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 */
|