diff --git a/CMakeLists.txt b/CMakeLists.txt index 3929e00a..657fa4d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ project(Neko C) include(GNUInstallDirs) include(CheckCCompilerFlag) include(CheckIncludeFile) +include(CheckSymbolExists) include(TestBigEndian) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) @@ -88,6 +89,8 @@ endif() check_include_file(xlocale.h NEKO_XLOCALE_H) +check_symbol_exists(getexecpath unistd.h HAVE_GETEXECPATH) + option(NEKO_JIT_DISABLE "Disable Neko JIT." OFF) option(NEKO_JIT_DEBUG "Debug Neko JIT." OFF) diff --git a/vm/main.c b/vm/main.c index 2e209168..5fe755b2 100644 --- a/vm/main.c +++ b/vm/main.c @@ -92,6 +92,11 @@ static char *executable_path() { sysctl(mib, 4, path, &cb, NULL, 0); if (!cb) return NULL; return path; +#elif defined(__OpenBSD__) && defined(HAVE_GETEXECPATH) + static char path[PATH_MAX]; + if (getexecpath(path, sizeof(path)) == -1) + return NULL; + return path; #elif defined(NEKO_LINUX) static char path[PATH_MAX]; int length = readlink("/proc/self/exe", path, sizeof(path)); diff --git a/vm/neko.h.in b/vm/neko.h.in index 4c386094..438b40dc 100644 --- a/vm/neko.h.in +++ b/vm/neko.h.in @@ -96,6 +96,8 @@ # include #endif +#cmakedefine HAVE_GETEXECPATH + #cmakedefine NEKO_XLOCALE_H #cmakedefine NEKO_BIG_ENDIAN