]> arthur.barton.de Git - netdata.git/commitdiff
fix for gcc < 4.9
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 26 Sep 2016 23:22:19 +0000 (02:22 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 26 Sep 2016 23:22:19 +0000 (02:22 +0300)
src/common.h
src/log.c

index f94565f1b7b9166451df3b852db01cdf2b7a9c5a..7d6d9a026c577096c9ef327eaaea4571491dd10c 100644 (file)
 #endif
 
 #ifdef __GNUC__
-#define GCC_VERSION (__GNUC__ * 10000 \
-                               + __GNUC_MINOR__ * 100 \
-                               + __GNUC_PATCHLEVEL__)
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+
+#if GCC_VERSION < 40900
+#define WITHOUT_C11_GENERIC 1
+#endif
 
 #if __x86_64__ || __ppc64__
 #define ENVIRONMENT64
index f22ec4d37b3bd80a6980e9359e40eb0c90f137ea..ee3c66dee3ba465853cd77627b57e6301acf1155 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -266,6 +266,18 @@ void info_int( const char *file, const char *function, const unsigned long line,
 // ----------------------------------------------------------------------------
 // error log
 
+#ifdef WITHOUT_C11_GENERIC
+
+#ifdef STRERROR_R_POSIX
+// POSIX version of strerror_r
+static const char *strerror_result(int a, const char *b) { (void)a; return b; }
+#else
+// GLIBC version of strerror_r
+static const char *strerror_result(const char *a, const char *b) { (void)b; return a; }
+#endif
+
+#else /* ! WITHOUT_C11_GENERIC */
+
 // what a trick!
 // http://stackoverflow.com/questions/479207/function-overloading-in-c
 static const char *strerror_result_int(int a, const char *b) { (void)a; return b; }
@@ -276,6 +288,8 @@ static const char *strerror_result_string(const char *a, const char *b) { (void)
     char *: strerror_result_string \
     )(a, b)
 
+#endif /* ! WITHOUT_C11_GENERIC */
+
 void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... )
 {
     va_list args;