From 848a0b198760aed3c80002264ebe394cb7b338d2 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 22 Jun 2008 14:57:29 +0200 Subject: [PATCH] add {un,}likely macros Signed-off-by: Pierre Habouzit --- common/util.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/util.h b/common/util.h index 466e077bf..deeb16817 100644 --- a/common/util.h +++ b/common/util.h @@ -26,6 +26,7 @@ #include #include #include +#include /** A list of possible position, not sex related */ typedef enum @@ -91,6 +92,9 @@ typedef struct *__ptr = NULL; \ } while(0) +#define likely(expr) __builtin_expect(!!(expr), 1) +#define unlikely(expr) __builtin_expect((expr), 0) + #else #define p_delete(mem_p) \ @@ -100,6 +104,9 @@ typedef struct *(void **)__ptr = NULL; \ } while (0) +#define likely(expr) expr +#define unlikely(expr) expr + #endif static inline void * __attribute__ ((malloc)) xmalloc(ssize_t size)