Add GNU likely/unlikely support

This commit is contained in:
c9s 2015-11-10 20:41:52 +08:00
parent 4ce9068963
commit cd430968ef

View file

@ -13,6 +13,13 @@
#include "slug.h" #include "slug.h"
#include "zmalloc.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; #define CHECK_PTR(ptr) if (ptr == NULL) return NULL;