Skip to content

Commit

Permalink
lib: helping compiler with early returns
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Vavruša committed Jun 29, 2015
1 parent 46122a5 commit 87ad66e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/defines.h
Expand Up @@ -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))

/*
Expand Down

0 comments on commit 87ad66e

Please sign in to comment.