Merge pull request #16 from marcIhm/master

fixed NetBSD support
This commit is contained in:
Gregory Pakosz 2019-01-07 10:49:40 +01:00
commit f3a86fdf17
2 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,8 @@ Supported platforms:
- Android - Android
- QNX Neutrino - QNX Neutrino
- FreeBSD - FreeBSD
- NetBSD
- DragonFly BSD
- SunOS - SunOS
Just drop `whereami.h` and `whereami.c` into your build and get started. (see 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; 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 <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -581,7 +581,11 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
for (;;) 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 }; int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
#endif
size_t size = sizeof(buffer1); size_t size = sizeof(buffer1);
if (sysctl(mib, (u_int)(sizeof(mib) / sizeof(mib[0])), path, &size, NULL, 0) != 0) if (sysctl(mib, (u_int)(sizeof(mib) / sizeof(mib[0])), path, &size, NULL, 0) != 0)