diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | grammar/rainerscript.c | 4 | ||||
-rw-r--r-- | plugins/ommongodb/ommongodb.c | 5 | ||||
-rw-r--r-- | runtime/msg.c | 8 | ||||
-rw-r--r-- | runtime/rsyslog.h | 7 | ||||
-rw-r--r-- | tools/syslogd.c | 5 |
7 files changed, 45 insertions, 2 deletions
@@ -2,6 +2,12 @@ var was given --------------------------------------------------------------------------- Version 7.5.6 [devel] 2013-10-?? +- RainerScript: make use of 64 bit for numbers where available + Thanks to Pavel Levshin for enhancement. +- 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..30c4559b 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,10 @@ PKG_CHECK_MODULES([JSON_C], [json],, [ PKG_CHECK_MODULES([JSON_C], [json-c]) ]) +# if int64 is supported, use it +AC_CHECK_LIB(json-c, json_object_new_object,,) +AC_CHECK_FUNCS(json_object_new_int64,,) + case "${host}" in *-*-linux*) AC_DEFINE([OS_LINUX], [1], [Indicator for a Linux OS]) @@ -153,6 +157,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/grammar/rainerscript.c b/grammar/rainerscript.c index e41efa04..abf9dd34 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -1192,7 +1192,11 @@ var2Number(struct var *r, int *bSuccess) n = es_str2num(r->d.estr, bSuccess); } else { if(r->datatype == 'J') { +#ifdef HAVE_JSON_OBJECT_NEW_INT64 + n = (r->d.json == NULL) ? 0 : json_object_get_int64(r->d.json); +#else /* HAVE_JSON_OBJECT_NEW_INT64 */ n = (r->d.json == NULL) ? 0 : json_object_get_int(r->d.json); +#endif /* HAVE_JSON_OBJECT_NEW_INT64 */ } else { n = r->d.n; } diff --git a/plugins/ommongodb/ommongodb.c b/plugins/ommongodb/ommongodb.c index 78781c08..af1f5a37 100644 --- a/plugins/ommongodb/ommongodb.c +++ b/plugins/ommongodb/ommongodb.c @@ -317,8 +317,11 @@ BSONAppendJSONObject(bson *doc, const gchar *name, struct json_object *json) case json_type_int: { int64_t i; - /* FIXME: the future version will have get_int64 */ +#ifdef HAVE_JSON_OBJECT_NEW_INT64 + i = json_object_get_int64(json); +#else /* HAVE_JSON_OBJECT_NEW_INT64 */ i = json_object_get_int(json); +#endif /* HAVE_JSON_OBJECT_NEW_INT64 */ if (i >= INT32_MIN && i <= INT32_MAX) return bson_append_int32(doc, name, i); else diff --git a/runtime/msg.c b/runtime/msg.c index f634329f..907000c4 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -4048,7 +4048,11 @@ jsonDeepCopy(struct json_object *src) dst = json_object_new_double(json_object_get_double(src)); break; case json_type_int: +#ifdef HAVE_JSON_OBJECT_NEW_INT64 + dst = json_object_new_int64(json_object_get_int64(src)); +#else /* HAVE_JSON_OBJECT_NEW_INT64 */ dst = json_object_new_int(json_object_get_int(src)); +#endif /* HAVE_JSON_OBJECT_NEW_INT64 */ break; case json_type_string: dst = json_object_new_string(json_object_get_string(src)); @@ -4091,7 +4095,11 @@ msgSetJSONFromVar(msg_t *pMsg, uchar *varname, struct var *v) free(cstr); break; case 'N':/* number (integer) */ +#ifdef HAVE_JSON_OBJECT_NEW_INT64 + json = json_object_new_int64(v->d.n); +#else /* HAVE_JSON_OBJECT_NEW_INT64 */ json = json_object_new_int((int) v->d.n); +#endif /* HAVE_JSON_OBJECT_NEW_INT64 */ break; case 'J':/* native JSON */ json = jsonDeepCopy(v->d.json); diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index 5f0401df..edf0c593 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -399,7 +399,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... */ diff --git a/tools/syslogd.c b/tools/syslogd.c index fba60df5..aaeb9866 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -1343,6 +1343,11 @@ static void printVersion(void) #else printf("\tuuid support:\t\t\t\tNo\n"); #endif +#ifdef HAVE_JSON_OBJECT_NEW_INT64 + printf("\tNumber of Bits in RainerScript integers: 64\n"); +#else + printf("\tNumber of Bits in RainerScript integers: 32 (due to too-old json-c lib)\n"); +#endif printf("\nSee http://www.rsyslog.com for more information.\n"); } |