From e9cf40f2b658970d37e0b1a8f70b64073464c648 Mon Sep 17 00:00:00 2001 From: Utkarsh Anand Date: Thu, 29 Mar 2018 14:07:49 +0530 Subject: [PATCH] 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. --- src/nvim/map.h | 5 +++++ src/nvim/os/process.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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 // for CreateToolhelp32Snapshot #endif -#if defined(__FreeBSD__) // XXX: OpenBSD, NetBSD ? +#if defined(__FreeBSD__) // XXX: OpenBSD ? # include # include # include #endif +#if defined(__NetBSD__) +# include +#endif + #if defined(__APPLE__) || defined(BSD) # include # include @@ -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);