summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorMiles Bader <miles@lsi.nec.co.jp>2002-08-30 05:14:26 +0000
committerMiles Bader <miles@lsi.nec.co.jp>2002-08-30 05:14:26 +0000
commit0f66c96633b67370be9c490491f993c29536a4d7 (patch)
tree8f381b8e807cace05d2b550f221d46841e088d07 /libc
parent8879afda8b95340b8e2263e4862d02bfe6aa54f1 (diff)
(likely, unlikely): New macros.
Diffstat (limited to 'libc')
-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