Fix compilation errors for macOS 10.5
Vladimir Kobal committed
Oct 12, 2017 at 15:30 UTC
584e7f6b9af433ad2d2033cd2406a80a12fafc7f
2 files changed
+25
src/macos_mach_smi.c
+19
@@ -25,7 +25,11 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
25
natural_t cp_time[CPU_STATE_MAX];
26
27
// NEEDED BY: do_ram, do_swapio, do_pgfaults
28
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED > 1050)
29
vm_statistics64_data_t vm_statistics;
30
+#else
31
+ vm_statistics_data_t vm_statistics;
32
+#endif
33
34
host = mach_host_self();
35
kr = host_page_size(host, &system_pagesize);
@@ -73,8 +77,13 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
77
// --------------------------------------------------------------------
78
79
if (likely(do_ram || do_swapio || do_pgfaults)) {
80
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED > 1050)
81
count = sizeof(vm_statistics64_data_t);
82
kr = host_statistics64(host, HOST_VM_INFO64, (host_info64_t)&vm_statistics, &count);
83
+#else
84
+ count = sizeof(vm_statistics_data_t);
85
+ kr = host_statistics(host, HOST_VM_INFO, (host_info_t)&vm_statistics, &count);
86
+#endif
87
if (unlikely(kr != KERN_SUCCESS)) {
88
error("MACOS: host_statistics64() failed: %s", mach_error_string(kr));
89
do_ram = 0;
@@ -92,8 +101,10 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
101
102
rrddim_add(st, "active", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE);
103
rrddim_add(st, "wired", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE);
104
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080)
105
rrddim_add(st, "throttled", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE);
106
rrddim_add(st, "compressor", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE);
107
+#endif
108
rrddim_add(st, "inactive", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE);
109
rrddim_add(st, "purgeable", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE);
110
rrddim_add(st, "speculative", NULL, system_pagesize, 1048576, RRD_ALGORITHM_ABSOLUTE);
@@ -103,8 +114,10 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
114
115
rrddim_set(st, "active", vm_statistics.active_count);
116
rrddim_set(st, "wired", vm_statistics.wire_count);
117
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080)
118
rrddim_set(st, "throttled", vm_statistics.throttled_count);
119
rrddim_set(st, "compressor", vm_statistics.compressor_page_count);
120
+#endif
121
rrddim_set(st, "inactive", vm_statistics.inactive_count);
122
rrddim_set(st, "purgeable", vm_statistics.purgeable_count);
123
rrddim_set(st, "speculative", vm_statistics.speculative_count);
@@ -112,6 +125,7 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
125
rrdset_done(st);
126
}
127
128
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080)
129
// --------------------------------------------------------------------
130
131
if (likely(do_swapio)) {
@@ -129,6 +143,7 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
143
rrddim_set(st, "out", vm_statistics.swapouts);
144
rrdset_done(st);
145
}
146
+#endif
147
148
// --------------------------------------------------------------------
149
@@ -143,8 +158,10 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
158
rrddim_add(st, "cow", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
159
rrddim_add(st, "pagein", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
160
rrddim_add(st, "pageout", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
161
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080)
162
rrddim_add(st, "compress", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
163
rrddim_add(st, "decompress", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
164
+#endif
165
rrddim_add(st, "zero_fill", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
166
rrddim_add(st, "reactivate", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
167
rrddim_add(st, "purge", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -155,8 +172,10 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
172
rrddim_set(st, "cow", vm_statistics.cow_faults);
173
rrddim_set(st, "pagein", vm_statistics.pageins);
174
rrddim_set(st, "pageout", vm_statistics.pageouts);
175
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED > 1080)
176
rrddim_set(st, "compress", vm_statistics.compressions);
177
rrddim_set(st, "decompress", vm_statistics.decompressions);
178
+#endif
179
rrddim_set(st, "zero_fill", vm_statistics.zero_fill_count);
180
rrddim_set(st, "reactivate", vm_statistics.reactivations);
181
rrddim_set(st, "purge", vm_statistics.purges);
src/macos_sysctl.c
+6
@@ -531,15 +531,21 @@ int do_macos_sysctl(int update_every, usec_t dt) {
531
rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
532
rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
533
rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
534
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
535
rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
536
+#endif
537
} else
538
rrdset_next(st);
539
540
rrddim_set(st, "InErrors", udpstat.udps_hdrops + udpstat.udps_badlen);
541
rrddim_set(st, "NoPorts", udpstat.udps_noport);
542
rrddim_set(st, "RcvbufErrors", udpstat.udps_fullsock);
543
+#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
544
rrddim_set(st, "InCsumErrors", udpstat.udps_badsum + udpstat.udps_nosum);
545
rrddim_set(st, "IgnoredMulti", udpstat.udps_filtermcast);
546
+#else
547
+ rrddim_set(st, "InCsumErrors", udpstat.udps_badsum);
548
+#endif
549
rrdset_done(st);
550
}
551
}