diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-26 13:09:59 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-26 13:09:59 +0200 |
commit | a000bd661e0459524bd146a803e17df813350d92 (patch) | |
tree | f737c83b8d532490590011fef17f4220157e2b60 /runtime/rsyslog.h | |
parent | 244e4571849aef4ea0c26c398ba056ea7d641592 (diff) | |
download | rsyslog-a000bd661e0459524bd146a803e17df813350d92.tar.gz rsyslog-a000bd661e0459524bd146a803e17df813350d92.tar.bz2 rsyslog-a000bd661e0459524bd146a803e17df813350d92.zip |
slight performance optimization if GCC is used
We give branch prediction hints for the frequent RETiRet macro which is
used for error handling. Some slight performance gain is to be expected
from that.
Diffstat (limited to 'runtime/rsyslog.h')
-rw-r--r-- | runtime/rsyslog.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index 71849bec..85381b8d 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -445,7 +445,12 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth * Be sure to call the to-be-returned variable always "iRet" and * the function finalizer always "finalize_it". */ -#define CHKiRet(code) if((iRet = code) != RS_RET_OK) goto finalize_it +#if HAVE_BUILTIN_EXCEPT +# define CHKiRet(code) if(__builtin_expect(((iRet = code) != RS_RET_OK), 0)) goto finalize_it +#else +# define CHKiRet(code) if((iRet = code) != RS_RET_OK) goto finalize_it +#endif + /* macro below is to be used if we need our own handling, eg for cleanup */ #define CHKiRet_Hdlr(code) if((iRet = code) != RS_RET_OK) /* macro below is to handle failing malloc/calloc/strdup... which we almost always handle in the same way... */ |