summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/os/os-macos-wrappers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnetdata/os/os-macos-wrappers.c')
-rw-r--r--src/libnetdata/os/os-macos-wrappers.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libnetdata/os/os-macos-wrappers.c b/src/libnetdata/os/os-macos-wrappers.c
new file mode 100644
index 000000000..b3d3ee4e6
--- /dev/null
+++ b/src/libnetdata/os/os-macos-wrappers.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "../libnetdata.h"
+
+#if defined(OS_MACOS)
+
+int getsysctl_by_name(const char *name, void *ptr, size_t len) {
+ size_t nlen = len;
+
+ if (unlikely(sysctlbyname(name, ptr, &nlen, NULL, 0) == -1)) {
+ netdata_log_error("MACOS: sysctl(%s...) failed: %s", name, strerror(errno));
+ return 1;
+ }
+ if (unlikely(nlen != len)) {
+ netdata_log_error("MACOS: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
+ return 1;
+ }
+ return 0;
+}
+
+#endif