From 7e545159a0800750313849b1e1b83239485f7d18 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 10 Nov 2015 20:41:52 +0800 Subject: [PATCH] Add GNU likely/unlikely support --- src/node.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/node.c b/src/node.c index c209f44..13ddddc 100644 --- a/src/node.c +++ b/src/node.c @@ -13,6 +13,13 @@ #include "slug.h" #include "zmalloc.h" +#ifdef __GNUC__ +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +#else +# define likely(x) !!(x) +# define unlikely(x) !!(x) +#endif #define CHECK_PTR(ptr) if (ptr == NULL) return NULL;