diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | runtime/rsyslog.h | 7 |
3 files changed, 18 insertions, 1 deletions
@@ -1,5 +1,9 @@ --------------------------------------------------------------------------- Version 7.5.6 [devel] 2013-10-?? +- 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. - removed global variable support The original idea was not well thought out and global variables, as implemented, worked far different from what anybody would expect. As diff --git a/configure.ac b/configure.ac index 2f23147b..ebf35190 100644 --- a/configure.ac +++ b/configure.ac @@ -153,6 +153,14 @@ AC_TRY_COMPILE([ AC_MSG_RESULT(no; defined as 64) ) +# Check for __builtin_expect() +AC_MSG_CHECKING([for __builtin_expect()]) +AC_LINK_IFELSE([AC_LANG_PROGRAM(, return __builtin_expect(main != 0, 1))], + [AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, + Define to 1 if compiler supports __builtin_expect) + AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) + # check for availability of atomic operations RS_ATOMIC_OPERATIONS RS_ATOMIC_OPERATIONS_64BIT 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... */ |