]> arthur.barton.de Git - netdata.git/commitdiff
jemalloc and tcmalloc configure best practices applied
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 2 Oct 2016 09:51:14 +0000 (12:51 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 2 Oct 2016 09:51:14 +0000 (12:51 +0300)
configure.ac
src/common.h
src/main.c

index 1c0dfda1d1b2203a87e8c1c1ccd10edfe0354f4d..6b543b9f8bda342dd14ec759ea4f45e0d89dfb3f 100644 (file)
@@ -85,13 +85,18 @@ CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
 CC="${PTHREAD_CC}"
 
 TS_CHECK_JEMALLOC
-if test "$has_jemalloc" = "0"; then
+if test "$has_jemalloc" = "1"; then
+       AC_DEFINE([ENABLE_JEMALLOC], [1], [compile and link with jemalloc])
+else
        TS_CHECK_TCMALLOC
+       if test "$has_tcmalloc" = "1"; then
+               AC_DEFINE([ENABLE_TCMALLOC], [1], [compile and link with tcmalloc])
+       else
+               AC_C_MALLOPT
+               AC_C_MALLINFO
+       fi
 fi
-if test "$has_jemalloc$has_tcmalloc" = "00"; then
-       AC_C_MALLOPT
-       AC_C_MALLINFO
-fi
+
 AC_TYPE_UINT8_T
 AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
index 407dd4859dda2815d3fb3d81c3d87f9a9a257624..9ffa8c8bc4efb7b43de058a0cae064c183f43145 100644 (file)
@@ -5,18 +5,25 @@
 #include <config.h>
 #endif
 
-#ifdef has_jemalloc
+/* select the memory allocator, based on autoconf findings */
+#if defined(ENABLE_JEMALLOC)
+
+#if defined(HAVE_JEMALLOC_JEMALLOC_H)
 #include <jemalloc/jemalloc.h>
-#undef HAVE_C_MALLOPT
-#undef HAVE_C_MALLINFO
-#elif has_tcmalloc
-#include <google/tcmalloc.h>
-#undef HAVE_C_MALLOPT
-#undef HAVE_C_MALLINFO
 #else
 #include <malloc.h>
 #endif
 
+#elif defined(ENABLE_TCMALLOC)
+
+#include <google/tcmalloc.h>
+
+#else /* !defined(ENABLE_JEMALLOC) && !defined(ENABLE_TCMALLOC) */
+
+#include <malloc.h>
+
+#endif
+
 #include <pthread.h>
 #include <errno.h>
 
index 533292cf1dcccd18e66f4ce7e98fe10c9c620fd1..3e6aa5046845b29fbf552c01c2364829c060db24 100644 (file)
@@ -374,7 +374,7 @@ int main(int argc, char **argv)
                     break;
                 case 'v':
                     // TODO: Outsource version to makefile which can compute version from git.
-                    printf("netdata " VERSION "\n");
+                    printf("netdata %s\n", VERSION);
                     return 0;
                 case 'W':
                     {