web_buffer.c web_buffer.h \
$(NULL)
+if FREEBSD
+apps_plugin_SOURCES += \
+ plugin_freebsd.h \
+ $(NULL)
+endif
+
apps_plugin_LDADD = \
$(OPTIONAL_MATH_LIBS) \
$(OPTIONAL_CAP_LIBS) \
processors = tmp_processors;
}
+ return processors;
+ #elif __FreeBSD__
+ int32_t tmp_processors;
+
+ if (unlikely(GETSYSCTL("hw.ncpu", tmp_processors))) {
+ error("Assuming system has %d processors.", processors);
+ } else {
+ processors = tmp_processors;
+ }
+
return processors;
#else
debug(D_SYSTEM, "System has %d processors.", processors);
return processors;
- #endif /* __APPLE__ */
+ #endif /* __APPLE__, __FreeBSD__ */
}
pid_t pid_max = 32768;
// As we currently do not know a solution to query pid_max from the os
// we use the number defined in bsd/sys/proc_internal.h in XNU sources
pid_max = 99999;
+ return pid_max;
+ #elif __FreeBSD__
+ int32_t tmp_pid_max;
+
+ if (unlikely(GETSYSCTL("kern.pid_max", tmp_pid_max))) {
+ pid_max = 99999;
+ error("Assuming system's maximum pid is %d.", pid_max);
+ } else {
+ pid_max = tmp_pid_max;
+ }
+
return pid_max;
#else
pid_max = (pid_t) max;
return pid_max;
- #endif /* __APPLE__ */
+ #endif /* __APPLE__, __FreeBSD__ */
}
unsigned int hz;
pthread_exit(NULL);
return NULL;
}
-
-int getsysctl(const char *name, void *ptr, size_t len)
-{
- size_t nlen = len;
-
- if (unlikely(sysctlbyname(name, ptr, &nlen, NULL, 0) == -1)) {
- error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
- return 1;
- }
- if (unlikely(nlen != len)) {
- error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
- return 1;
- }
- return 0;
-}
void *freebsd_main(void *ptr);
-int getsysctl(const char *name, void *ptr, size_t len);
-
extern int do_freebsd_sysctl(int update_every, usec_t dt);
+static inline int getsysctl(const char *name, void *ptr, size_t len)
+{
+ size_t nlen = len;
+
+ if (unlikely(sysctlbyname(name, ptr, &nlen, NULL, 0) == -1)) {
+ error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
+ return 1;
+ }
+ if (unlikely(nlen != len)) {
+ error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
+ return 1;
+ }
+ return 0;
+}
+
#endif /* NETDATA_PLUGIN_FREEBSD_H */