long get_system_cpus(void) {
processors = 1;
+ #ifdef __APPLE__
+ int32_t tmp_processors;
+
+ if (unlikely(GETSYSCTL("hw.logicalcpu", tmp_processors))) {
+ error("Assuming system has %d processors.", processors);
+ } else {
+ processors = tmp_processors;
+ }
+
+ return processors;
+ #else
+
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/stat", global_host_prefix);
debug(D_SYSTEM, "System has %d processors.", processors);
return processors;
+
+ #endif /* __APPLE__ */
}
pid_t pid_max = 32768;
pid_t get_system_pid_max(void) {
+ #ifdef __APPLE__
+ // 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;
+ #else
+
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s/proc/sys/kernel/pid_max", global_host_prefix);
procfile *ff = procfile_open(filename, NULL, PROCFILE_FLAG_DEFAULT);
procfile_close(ff);
debug(D_SYSTEM, "System supports %d pids.", pid_max);
return pid_max;
+
+ #endif /* __APPLE__ */
}
unsigned int hz;
// NEEDED BY do_uptime
#include <time.h>
-#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
-
// MacOS calculates load averages once every 5 seconds
#define MIN_LOADAVG_UPDATE_EVERY 5
-int getsysctl(const char *name, void *ptr, size_t len);
-
int do_macos_sysctl(int update_every, usec_t dt) {
(void)dt;
void *macos_main(void *ptr);
+#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
+
+extern int getsysctl(const char *name, void *ptr, size_t len);
+
extern int do_macos_sysctl(int update_every, usec_t dt);
extern int do_macos_mach_smi(int update_every, usec_t dt);
extern int do_macos_iokit(int update_every, usec_t dt);