From 0f66c96633b67370be9c490491f993c29536a4d7 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Fri, 30 Aug 2002 05:14:26 +0000 Subject: (likely, unlikely): New macros. --- libc/stdlib/malloc/heap.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libc') 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 -- cgit v1.2.3