From a02d4e78531550b4ff658aa6fff8806f05715330 Mon Sep 17 00:00:00 2001 From: Jason Thorpe Date: Sun, 3 Mar 2024 07:54:39 -0800 Subject: [PATCH] Tweak the FreeBSD version of proc_self_dirname() to work on NetBSD use it. --- kernel/yosys.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 20f9791c6..57433d0d9 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -55,7 +55,7 @@ # include #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__NetBSD__) # include #endif @@ -901,10 +901,14 @@ std::string proc_self_dirname() buflen--; return std::string(path, buflen); } -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__NetBSD__) std::string proc_self_dirname() { +#ifdef __NetBSD__ + int mib[4] = {CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_PATHNAME}; +#else int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; +#endif size_t buflen; char *buffer; std::string path;