summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/stdlib/malloc/heap.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/libc/stdlib/malloc/heap.h b/libc/stdlib/malloc/heap.h
index 38451f091..da63b4341 100644
--- a/libc/stdlib/malloc/heap.h
+++ b/libc/stdlib/malloc/heap.h
@@ -68,6 +68,18 @@ struct heap_free_area
HEAP_ADJUST_SIZE (sizeof (struct heap_free_area) + 32)
+/* branch-prediction macros; they may already be defined by libc. */
+#ifndef likely
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+#define likely(cond) __builtin_expect(!!(int)(cond), 1)
+#define unlikely(cond) __builtin_expect((int)(cond), 0)
+#else
+#define likely(cond) (cond)
+#define unlikely(cond) (cond)
+#endif
+#endif /* !likely */
+
+
/* Define HEAP_DEBUGGING to cause the heap routines to emit debugging info
to stderr. */
#ifdef HEAP_DEBUGGING