Spaces:
Running
Running
yuri@FreeBSD
commited on
Commit
·
83b02bc
1
Parent(s):
f1e76ce
ggml : fix run-time on FreeBSD in get_executable_path() (llama/10948)
Browse files
ggml/src/ggml-backend-reg.cpp
CHANGED
|
@@ -402,12 +402,16 @@ static std::string get_executable_path() {
|
|
| 402 |
base_path = base_path.substr(0, last_slash);
|
| 403 |
}
|
| 404 |
return base_path + "/";
|
| 405 |
-
#elif defined(__linux__)
|
| 406 |
std::string base_path = ".";
|
| 407 |
std::vector<char> path(1024);
|
| 408 |
while (true) {
|
| 409 |
// get executable path
|
|
|
|
| 410 |
ssize_t len = readlink("/proc/self/exe", path.data(), path.size());
|
|
|
|
|
|
|
|
|
|
| 411 |
if (len == -1) {
|
| 412 |
break;
|
| 413 |
}
|
|
|
|
| 402 |
base_path = base_path.substr(0, last_slash);
|
| 403 |
}
|
| 404 |
return base_path + "/";
|
| 405 |
+
#elif defined(__linux__) || defined(__FreeBSD__)
|
| 406 |
std::string base_path = ".";
|
| 407 |
std::vector<char> path(1024);
|
| 408 |
while (true) {
|
| 409 |
// get executable path
|
| 410 |
+
# if defined(__linux__)
|
| 411 |
ssize_t len = readlink("/proc/self/exe", path.data(), path.size());
|
| 412 |
+
# elif defined(__FreeBSD__)
|
| 413 |
+
ssize_t len = readlink("/proc/curproc/file", path.data(), path.size());
|
| 414 |
+
# endif
|
| 415 |
if (len == -1) {
|
| 416 |
break;
|
| 417 |
}
|