@cryptotaxi247 / netdata-1 / commits / 8875982fa

Get rid of compilation errors on FreeBSD

Vladimir Kobal committed Nov 29, 2016 at 23:42 UTC 8875982faa9cd761f4415ae5d912c085ed4b095d
4 files changed +36
src/common.c
+12
@@ -1,5 +1,11 @@
1 #include "common.h"
2
3 +#ifdef __FreeBSD__
4 +# include <sys/thr.h>
5 +# define O_NOATIME 0
6 +# define MADV_DONTFORK INHERIT_NONE
7 +#endif /* __FreeBSD__ */
8 +
9 char *global_host_prefix = "";
10 int enable_ksm = 1;
11
@@ -1025,7 +1031,13 @@ int fd_is_valid(int fd) {
1031 }
1032
1033 pid_t gettid(void) {
1034 +#ifdef __FreeBSD__
1035 + long pid;
1036 + thr_self( &pid );
1037 + return (unsigned) pid;
1038 +#else /* __FreeBSD__ */
1039 return (pid_t)syscall(SYS_gettid);
1040 +#endif /* __FreeBSD__ */
1041 }
1042
1043 char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len) {
src/common.h
+6
@@ -20,7 +20,9 @@
20
21 #else /* !defined(ENABLE_JEMALLOC) && !defined(ENABLE_TCMALLOC) */
22
23 +#ifndef __FreeBSD__
24 #include <malloc.h>
25 +#endif /* __FreeBSD__ */
26
27 #endif
28
@@ -52,7 +54,11 @@
54 #include <signal.h>
55 #include <syslog.h>
56 #include <sys/mman.h>
57 +
58 +#ifndef __FreeBSD__
59 #include <sys/prctl.h>
60 +#endif /* __FreeBSD__ */
61 +
62 #include <sys/resource.h>
63 #include <sys/socket.h>
64 #include <sys/stat.h>
src/ipc.c
+14
@@ -41,6 +41,7 @@ struct ipc_status {
41 * tells us to define it ourselves, but until recently Linux include files
42 * would also define it.
43 */
44 +#ifndef __FreeBSD__
45 #ifndef HAVE_UNION_SEMUN
46 /* according to X/OPEN we have to define it ourselves */
47 union semun {
@@ -50,6 +51,19 @@ union semun {
51 struct seminfo *__buf;
52 };
53 #endif
54 +#else /* __FreeBSD__ */
55 +struct seminfo {
56 + int semmni, /* # of semaphore identifiers */
57 + semmns, /* # of semaphores in system */
58 + semmnu, /* # of undo structures in system */
59 + semmsl, /* max # of semaphores per id */
60 + semopm, /* max # of operations per semop call */
61 + semume, /* max # of undo entries per process */
62 + semusz, /* size in bytes of undo structure */
63 + semvmx, /* semaphore maximum value */
64 + semaem; /* adjust on exit max value */
65 +};
66 +#endif /* __FreeBSD__ */
67
68 static inline int ipc_sem_get_limits(struct ipc_limits *lim) {
69 static procfile *ff = NULL;
src/main.c
+4
@@ -458,6 +458,7 @@ int main(int argc, char **argv)
458 debug_flags = strtoull(flags, NULL, 0);
459 debug(D_OPTIONS, "Debug flags set to '0x%8llx'.", debug_flags);
460
461 +#ifndef __FreeBSD__
462 if(debug_flags != 0) {
463 struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
464 if(setrlimit(RLIMIT_CORE, &rl) != 0)
@@ -465,6 +466,7 @@ int main(int argc, char **argv)
466
467 prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
468 }
469 +#endif /* __FreeBSD__ */
470
471 // --------------------------------------------------------------------
472
@@ -633,6 +635,7 @@ int main(int argc, char **argv)
635 // initialize the log files
636 open_all_log_files();
637
638 +#ifndef __FreeBSD__
639 #ifdef NETDATA_INTERNAL_CHECKS
640 if(debug_flags != 0) {
641 struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
@@ -641,6 +644,7 @@ int main(int argc, char **argv)
644 prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
645 }
646 #endif /* NETDATA_INTERNAL_CHECKS */
647 +#endif /* __FreeBSD__ */
648
649 // fork, switch user, create pid file, set process priority
650 if(become_daemon(dont_fork, user) == -1)