Merge pull request #4254 from thorpej/dev/pkgsrc-patch-NetBSD-1

Add NetBSD support
This commit is contained in:
Martin Povišer 2024-03-04 11:22:34 +01:00 committed by GitHub
commit 8d004661dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -55,7 +55,7 @@
# include <glob.h> # include <glob.h>
#endif #endif
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__NetBSD__)
# include <sys/sysctl.h> # include <sys/sysctl.h>
#endif #endif
@ -901,10 +901,14 @@ std::string proc_self_dirname()
buflen--; buflen--;
return std::string(path, buflen); return std::string(path, buflen);
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined(__NetBSD__)
std::string proc_self_dirname() 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}; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
#endif
size_t buflen; size_t buflen;
char *buffer; char *buffer;
std::string path; std::string path;