summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/jemalloc/internal/jemalloc_internal_includes.h3
-rw-r--r--include/jemalloc/internal/rtree_inlines.h2
-rw-r--r--include/jemalloc/internal/spin.h36
-rw-r--r--include/jemalloc/internal/spin_inlines.h29
-rw-r--r--include/jemalloc/internal/spin_structs.h8
-rw-r--r--include/jemalloc/internal/spin_types.h8
-rw-r--r--src/extent_dss.c1
-rw-r--r--src/jemalloc.c1
-rw-r--r--src/spin.c3
9 files changed, 42 insertions, 49 deletions
diff --git a/include/jemalloc/internal/jemalloc_internal_includes.h b/include/jemalloc/internal/jemalloc_internal_includes.h
index f31fed6..669194d 100644
--- a/include/jemalloc/internal/jemalloc_internal_includes.h
+++ b/include/jemalloc/internal/jemalloc_internal_includes.h
@@ -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"
diff --git a/include/jemalloc/internal/rtree_inlines.h b/include/jemalloc/internal/rtree_inlines.h
index 6791f50..030e578 100644
--- a/include/jemalloc/internal/rtree_inlines.h
+++ b/include/jemalloc/internal/rtree_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);
diff --git a/include/jemalloc/internal/spin.h b/include/jemalloc/internal/spin.h
new file mode 100644
index 0000000..e2afc98
--- /dev/null
+++ b/include/jemalloc/internal/spin.h
@@ -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 */
diff --git a/include/jemalloc/internal/spin_inlines.h b/include/jemalloc/internal/spin_inlines.h
deleted file mode 100644
index 1657326..0000000
--- a/include/jemalloc/internal/spin_inlines.h
+++ /dev/null
@@ -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 */
diff --git a/include/jemalloc/internal/spin_structs.h b/include/jemalloc/internal/spin_structs.h
deleted file mode 100644
index ef71a76..0000000
--- a/include/jemalloc/internal/spin_structs.h
+++ /dev/null
@@ -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 */
diff --git a/include/jemalloc/internal/spin_types.h b/include/jemalloc/internal/spin_types.h
deleted file mode 100644
index 222e069..0000000
--- a/include/jemalloc/internal/spin_types.h
+++ /dev/null
@@ -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 */
diff --git a/src/extent_dss.c b/src/extent_dss.c
index 06bccc8..6b5d066 100644
--- a/src/extent_dss.c
+++ b/src/extent_dss.c
@@ -3,6 +3,7 @@
#include "jemalloc/internal/jemalloc_internal_includes.h"
#include "jemalloc/internal/assert.h"
+#include "jemalloc/internal/spin.h"
/******************************************************************************/
/* Data. */
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 3dad726..0297cf5 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -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"
/******************************************************************************/
diff --git a/src/spin.c b/src/spin.c
index d2d3941..24372c2 100644
--- a/src/spin.c
+++ b/src/spin.c
@@ -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"