summaryrefslogtreecommitdiffstats
path: root/include/jemalloc
diff options
context:
space:
mode:
authorDavid Goldblatt <davidgoldblatt@fb.com>2017-04-17 23:35:04 (GMT)
committerDavid Goldblatt <davidtgoldblatt@gmail.com>2017-04-19 01:35:03 (GMT)
commit38e847c1c594fb9ad4862233f3602ade85da4e7f (patch)
tree1920fb2efb6dd1c767c6c75949e6c821b90bb933 /include/jemalloc
parent418d96a86ce95e36f3dbd3dd700a30b5b7cdbcfd (diff)
downloadjemalloc-38e847c1c594fb9ad4862233f3602ade85da4e7f.zip
jemalloc-38e847c1c594fb9ad4862233f3602ade85da4e7f.tar.gz
jemalloc-38e847c1c594fb9ad4862233f3602ade85da4e7f.tar.bz2
Header refactoring: unify spin.h and move it out of the catch-all.
Diffstat (limited to 'include/jemalloc')
-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
6 files changed, 38 insertions, 48 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 */