#else /* !defined(ENABLE_JEMALLOC) && !defined(ENABLE_TCMALLOC) */
-#ifndef __FreeBSD__
+#if !(defined(__FreeBSD__) || defined(__APPLE__))
#include <malloc.h>
-#endif /* __FreeBSD__ */
+#endif /* __FreeBSD__ || __APPLE__ */
#endif
#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>
-#ifndef __FreeBSD__
+#if !(defined(__FreeBSD__) || defined(__APPLE__))
#include <sys/prctl.h>
-#endif /* __FreeBSD__ */
+#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>
*/
#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"
-#ifndef __FreeBSD__
-#include "plugin_proc.h"
-#else
+#if defined(__FreeBSD__)
#include "plugin_freebsd.h"
-#endif /* __FreeBSD__ */
+#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"
#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);
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);
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);