1 #ifndef JEMALLOC_INTERNAL_SPIN_INLINES_H
2 #define JEMALLOC_INTERNAL_SPIN_INLINES_H
3 
4 #ifndef JEMALLOC_ENABLE_INLINE
5 void	spin_init(spin_t *spin);
6 void	spin_adaptive(spin_t *spin);
7 #endif
8 
9 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_SPIN_C_))
10 JEMALLOC_INLINE void
spin_init(spin_t * spin)11 spin_init(spin_t *spin)
12 {
13 	spin->iteration = 0;
14 }
15 
16 JEMALLOC_INLINE void
spin_adaptive(spin_t * spin)17 spin_adaptive(spin_t *spin)
18 {
19 	volatile uint64_t i;
20 
21 	for (i = 0; i < (KQU(1) << spin->iteration); i++)
22 		CPU_SPINWAIT;
23 
24 	if (spin->iteration < 63)
25 		spin->iteration++;
26 }
27 
28 #endif
29 
30 #endif /* JEMALLOC_INTERNAL_SPIN_INLINES_H */
31