aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUtkarsh Anand <uanand009@gmail.com>2018-03-29 14:07:49 +0530
committerJustin M. Keyes <justinkz@gmail.com>2018-03-29 10:37:49 +0200
commite9cf40f2b658970d37e0b1a8f70b64073464c648 (patch)
tree944b4dddfc76c58dfadf1b85f9246b24e5adc16f
parentbbca3142e878de3000b3c2046b25340e42c014d6 (diff)
downloadrneovim-e9cf40f2b658970d37e0b1a8f70b64073464c648.tar.gz
rneovim-e9cf40f2b658970d37e0b1a8f70b64073464c648.tar.bz2
rneovim-e9cf40f2b658970d37e0b1a8f70b64073464c648.zip
build/NetBSD: use kinfo_proc2; undef uint64_t (#8197)
closes #8196 For historical reasons, uint64_t and friends are defined both as typedefs and macros. Some platforms that do that define the macros as identity (#define uint64_t uint64_t), others like NetBSD define to the backing type (#define uint64_t __uint64_t). This is normally transparent, except when multiple levels of macro expansions are used inconsistently.
-rw-r--r--src/nvim/map.h5
-rw-r--r--src/nvim/os/process.c14
2 files changed, 18 insertions, 1 deletions
diff --git a/src/nvim/map.h b/src/nvim/map.h
index 047aa163ce..ac1239a548 100644
--- a/src/nvim/map.h
+++ b/src/nvim/map.h
@@ -8,6 +8,11 @@
#include "nvim/api/private/dispatch.h"
#include "nvim/bufhl_defs.h"
+#if defined(__NetBSD__)
+# undef uint64_t
+# define uint64_t uint64_t
+#endif
+
#define MAP_DECLS(T, U) \
KHASH_DECLARE(T##_##U##_map, T, U) \
\
diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c
index e23ba8a4ee..60ca890e0e 100644
--- a/src/nvim/os/process.c
+++ b/src/nvim/os/process.c
@@ -12,12 +12,16 @@
# include <tlhelp32.h> // for CreateToolhelp32Snapshot
#endif
-#if defined(__FreeBSD__) // XXX: OpenBSD, NetBSD ?
+#if defined(__FreeBSD__) // XXX: OpenBSD ?
# include <string.h>
# include <sys/types.h>
# include <sys/user.h>
#endif
+#if defined(__NetBSD__)
+# include <sys/param.h>
+#endif
+
#if defined(__APPLE__) || defined(BSD)
# include <sys/sysctl.h>
# include <pwd.h>
@@ -155,7 +159,11 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count)
# define KP_PID(o) o.p_pid
# define KP_PPID(o) o.p_ppid
# endif
+# ifdef __NetBSD__
+ static int name[] = { CTL_KERN, KERN_PROC2, KERN_PROC_ALL, 0, (int)(sizeof(struct kinfo_proc2)), 0 };
+# else
static int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
+# endif
// Get total process count.
size_t len = 0;
@@ -165,7 +173,11 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count)
}
// Get ALL processes.
+# ifdef __NetBSD__
+ struct kinfo_proc2 *p_list = xmalloc(len);
+# else
struct kinfo_proc *p_list = xmalloc(len);
+# endif
rv = sysctl(name, ARRAY_SIZE(name) - 1, p_list, &len, NULL, 0);
if (rv) {
xfree(p_list);