[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V4] util/oslib-posix : qemu_init_exec_dir implementation for Mac
From: |
David CARLIER |
Subject: |
[PATCH V4] util/oslib-posix : qemu_init_exec_dir implementation for Mac |
Date: |
Tue, 16 Jun 2020 17:10:56 +0100 |
>From 7eef8b803cdb0e7148fdf894d2992052695c1ff8 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Tue, 26 May 2020 21:35:27 +0100
Subject: [PATCH] util/oslib-posix : qemu_init_exec_dir implementation for Mac
Using dyld API to get the full path of the current process.
Signed-off-by: David Carlier <devnexen@gmail.com>
---
util/oslib-posix.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 916f1be224..3612c2c80e 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -57,6 +57,10 @@
#include <lwp.h>
#endif
+#ifdef __APPLE__
+#include <mach-o/dyld.h>
+#endif
+
#include "qemu/mmap-alloc.h"
#ifdef CONFIG_DEBUG_STACK_USAGE
@@ -375,6 +379,16 @@ void qemu_init_exec_dir(const char *argv0)
p = buf;
}
}
+#elif defined(__APPLE__)
+ {
+ uint32_t len = sizeof(buf);
+ if (_NSGetExecutablePath(buf, &len) == 0) {
+ char fpath[PATH_MAX];
+ buf[len - 1] = 0;
+ realpath(buf, fpath);
+ p = fpath;
+ }
+ }
#endif
/* If we don't have any way of figuring out the actual executable
location then try argv[0]. */
--
2.27.0
- [PATCH V4] util/oslib-posix : qemu_init_exec_dir implementation for Mac,
David CARLIER <=