Browse Source

(likely, unlikely): New macros.

Miles Bader 22 years ago
parent
commit
0f66c96633
1 changed files with 12 additions and 0 deletions
  1. 12 0
      libc/stdlib/malloc/heap.h

+ 12 - 0
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