From: Marek VavruĊĦa Date: Mon, 29 Jun 2015 23:08:44 +0000 (+0200) Subject: lib: helping compiler with early returns X-Git-Tag: v1.0.0-beta1~95^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87ad66eea0824af26afde2c15a2d288989c908e5;p=thirdparty%2Fknot-resolver.git lib: helping compiler with early returns --- diff --git a/lib/defines.h b/lib/defines.h index 017a14087..9709380c9 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -25,7 +25,10 @@ * Error codes. */ #define kr_ok() 0 -#define kr_error(x) -abs(x) +/* Mark as cold to mark all branches as unlikely. */ +static inline int __attribute__((__cold__)) kr_error(int x) { + return -abs(x); +} #define kr_strerror(x) strerror(abs(x)) /*