]> arthur.ath.cx Git - netdata.git/commitdiff
Get rid of compilation errors on FreeBSD
authorVladimir Kobal <vlad@prokk.net>
Tue, 29 Nov 2016 21:42:46 +0000 (23:42 +0200)
committerVladimir Kobal <vlad@prokk.net>
Tue, 29 Nov 2016 21:42:46 +0000 (23:42 +0200)
src/common.c
src/common.h
src/ipc.c
src/main.c

index fa69bff8568d719c765fa1452bca7940b95663e6..29669d9309ea06412694db6b1d46fcb73523b7d9 100644 (file)
@@ -1,5 +1,11 @@
 #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;
 
@@ -1025,7 +1031,13 @@ int fd_is_valid(int fd) {
 }
 
 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) {
index 7b95daa8ff3a70563365477b965fff03cb0027c4..abcdfcfe27d402e3842b5d1a950bc88bbfd2aa7a 100644 (file)
@@ -20,7 +20,9 @@
 
 #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>
index 3cf76513dce8b27bbf46367fce5d9f54a7451adf..54ebe81749aec4e36984009d75e6695e0e70f168 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -41,6 +41,7 @@ struct ipc_status {
  *  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 {
@@ -50,6 +51,19 @@ 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;
index 5fe9e636952babd54dd4fe6b1ce1c3f0af1cb659..6f3efb1fe699fe869fb8b9e945fbc3946aa80a9f 100644 (file)
@@ -458,6 +458,7 @@ int main(int argc, char **argv)
         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)
@@ -465,6 +466,7 @@ int main(int argc, char **argv)
 
             prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
         }
+#endif /* __FreeBSD__ */
 
         // --------------------------------------------------------------------
 
@@ -633,6 +635,7 @@ int main(int argc, char **argv)
     // 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 };
@@ -641,6 +644,7 @@ int main(int argc, char **argv)
         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)