]> arthur.barton.de Git - netdata.git/blobdiff - src/common.h
Separate macOS plugin
[netdata.git] / src / common.h
index 407dd4859dda2815d3fb3d81c3d87f9a9a257624..baa95dcb07e92a7505d11f9e1204a87cc519f13d 100644 (file)
@@ -5,18 +5,27 @@
 #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) */
+
+#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#include <malloc.h>
+#endif /* __FreeBSD__ || __APPLE__ */
+
+#endif
+
 #include <pthread.h>
 #include <errno.h>
 
 #include <strings.h>
 
 #include <arpa/inet.h>
-#include <netinet/in.h>
 #include <netinet/tcp.h>
 
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+
 #include <dirent.h>
 #include <fcntl.h>
 #include <getopt.h>
 #include <pwd.h>
 #include <locale.h>
 
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
+
+#include <net/if.h>
+
 #include <poll.h>
 #include <signal.h>
 #include <syslog.h>
 #include <sys/mman.h>
+#if !(defined(__FreeBSD__) || defined(__APPLE__))
 #include <sys/prctl.h>
+#endif /* __FreeBSD__ || __APPLE__*/
 #include <sys/resource.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <uuid/uuid.h>
 
+// #1408
+#ifdef MAJOR_IN_MKDEV
+#include <sys/mkdev.h>
+#endif
+#ifdef MAJOR_IN_SYSMACROS
+#include <sys/sysmacros.h>
+#endif
+
+/*
+#include <mntent.h>
+*/
+
 #ifdef STORAGE_WITH_MATH
 #include <math.h>
 #endif
 #endif // __GNUC__
 
 #include "avl.h"
+#include "clocks.h"
 #include "log.h"
 #include "global_statistics.h"
 #include "storage_number.h"
 #include "plugin_checks.h"
 #include "plugin_idlejitter.h"
 #include "plugin_nfacct.h"
+#if defined(__FreeBSD__)
+#include "plugin_freebsd.h"
+#elif defined(__APPLE__)
+#include "plugin_macos.h"
+#else
 #include "plugin_proc.h"
+#endif /* __FreeBSD__, __APPLE__*/
 #include "plugin_tc.h"
 #include "plugins_d.h"
 
+#include "socket.h"
+
 #include "eval.h"
 #include "health.h"
 
 #include "main.h"
 #include "unit_test.h"
 
+#include "ipc.h"
+#include "backends.h"
+
 #ifdef abs
 #undef abs
 #endif
 #define abs(x) ((x < 0)? -x : x)
 
-extern unsigned long long usec_dt(struct timeval *now, struct timeval *old);
-extern unsigned long long timeval_usec(struct timeval *tv);
-
-// #define usec_dt(now, last) (((((now)->tv_sec * 1000000ULL) + (now)->tv_usec) - (((last)->tv_sec * 1000000ULL) + (last)->tv_usec)))
-
 extern void netdata_fix_chart_id(char *s);
 extern void netdata_fix_chart_name(char *s);
 
@@ -163,6 +205,8 @@ extern void *reallocz(void *ptr, size_t size);
 extern void freez(void *ptr);
 #endif
 
+extern void json_escape_string(char *dst, const char *src, size_t size);
+
 extern void *mymmap(const char *filename, size_t size, int flags, int ksm);
 extern int savememory(const char *filename, void *mem, size_t size);
 
@@ -173,8 +217,7 @@ extern int enable_ksm;
 
 extern pid_t gettid(void);
 
-extern unsigned long long time_usec(void);
-extern int sleep_usec(unsigned long long usec);
+extern int sleep_usec(usec_t usec);
 
 extern char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len);