diff --git a/README.md b/README.md index 350bf76..98c7a3b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/whereami.c b/src/whereami.c index 7441823..48d9af3 100644 --- a/src/whereami.c +++ b/src/whereami.c @@ -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 #include @@ -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)