fixed NetBSD support

- assume NetBSD >= 8.0
- for NetBSD < 8.0, define WAI_USE_PROC_SELF_EXE
This commit is contained in:
Jan Beich 2019-01-05 16:51:56 +01:00 committed by Gregory Pakosz
parent e64e8b379b
commit 4414eb5812
2 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,8 @@ Supported platforms:
- Android
- QNX Neutrino
- FreeBSD
- NetBSD
- DragonFly BSD
- SunOS
Just drop `whereami.h` and `whereami.c` into your build and get started. (see

View File

@ -158,7 +158,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
return length;
}
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun)
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(WAI_USE_PROC_SELF_EXE)
#include <stdio.h>
#include <stdlib.h>
@ -581,7 +581,11 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
for (;;)
{
#if defined(__NetBSD__)
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
#else
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
#endif
size_t size = sizeof(buffer1);
if (sysctl(mib, (u_int)(sizeof(mib) / sizeof(mib[0])), path, &size, NULL, 0) != 0)