#include "common.h"
+#ifdef __FreeBSD__
+# include <sys/thr.h>
+# define O_NOATIME 0
+# define MADV_DONTFORK INHERIT_NONE
+#endif /* __FreeBSD__ */
+
char *global_host_prefix = "";
int enable_ksm = 1;
}
pid_t gettid(void) {
+#ifdef __FreeBSD__
+ long pid;
+ thr_self( &pid );
+ return (unsigned) pid;
+#else /* __FreeBSD__ */
return (pid_t)syscall(SYS_gettid);
+#endif /* __FreeBSD__ */
}
char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len) {
#else /* !defined(ENABLE_JEMALLOC) && !defined(ENABLE_TCMALLOC) */
+#ifndef __FreeBSD__
#include <malloc.h>
+#endif /* __FreeBSD__ */
#endif
#include <signal.h>
#include <syslog.h>
#include <sys/mman.h>
+
+#ifndef __FreeBSD__
#include <sys/prctl.h>
+#endif /* __FreeBSD__ */
+
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
* tells us to define it ourselves, but until recently Linux include files
* would also define it.
*/
+#ifndef __FreeBSD__
#ifndef HAVE_UNION_SEMUN
/* according to X/OPEN we have to define it ourselves */
union semun {
struct seminfo *__buf;
};
#endif
+#else /* __FreeBSD__ */
+struct seminfo {
+ int semmni, /* # of semaphore identifiers */
+ semmns, /* # of semaphores in system */
+ semmnu, /* # of undo structures in system */
+ semmsl, /* max # of semaphores per id */
+ semopm, /* max # of operations per semop call */
+ semume, /* max # of undo entries per process */
+ semusz, /* size in bytes of undo structure */
+ semvmx, /* semaphore maximum value */
+ semaem; /* adjust on exit max value */
+};
+#endif /* __FreeBSD__ */
static inline int ipc_sem_get_limits(struct ipc_limits *lim) {
static procfile *ff = NULL;
debug_flags = strtoull(flags, NULL, 0);
debug(D_OPTIONS, "Debug flags set to '0x%8llx'.", debug_flags);
+#ifndef __FreeBSD__
if(debug_flags != 0) {
struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
if(setrlimit(RLIMIT_CORE, &rl) != 0)
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
}
+#endif /* __FreeBSD__ */
// --------------------------------------------------------------------
// initialize the log files
open_all_log_files();
+#ifndef __FreeBSD__
#ifdef NETDATA_INTERNAL_CHECKS
if(debug_flags != 0) {
struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
}
#endif /* NETDATA_INTERNAL_CHECKS */
+#endif /* __FreeBSD__ */
// fork, switch user, create pid file, set process priority
if(become_daemon(dont_fork, user) == -1)