summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bfs.h11
-rw-r--r--src/ioq.c5
2 files changed, 15 insertions, 1 deletions
diff --git a/src/bfs.h b/src/bfs.h
index af4cf9f..6c930ad 100644
--- a/src/bfs.h
+++ b/src/bfs.h
@@ -218,4 +218,15 @@ extern const char bfs_ldlibs[];
# define _target_clones(...)
#endif
+/**
+ * Optimization hint to not unroll a loop.
+ */
+#if __clang__
+# define _nounroll _Pragma("nounroll")
+#elif __GNUC__
+# define _nounroll _Pragma("GCC unroll 0")
+#else
+# define _nounroll
+#endif
+
#endif // BFS_H
diff --git a/src/ioq.c b/src/ioq.c
index 8050c9e..dd5d31e 100644
--- a/src/ioq.c
+++ b/src/ioq.c
@@ -277,10 +277,13 @@ static struct ioq_monitor *ioq_slot_monitor(struct ioqq *ioqq, ioq_slot *slot) {
/** Atomically wait for a slot to change. */
_noinline
static uintptr_t ioq_slot_wait(struct ioqq *ioqq, ioq_slot *slot, uintptr_t value) {
- // Try spinning a few times before blocking
uintptr_t ret;
+
+ // Try spinning a few times before blocking
+ _nounroll
for (int i = 0; i < 10; ++i) {
// Exponential backoff
+ _nounroll
for (int j = 0; j < (1 << i); ++j) {
spin_loop();
}