aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2020-07-13 14:36:10 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-07-13 14:36:10 +0100
commit2b9b9e701041dfbe5efd9af2205b21b35a49f971 (patch)
treef7616cda6c41614d392842f2e86c4d334255e7fb /util
parent81b7b1e21d5da37faef1dbb5404f3adae7e68ac2 (diff)
util/oslib-posix.c: Implement qemu_init_exec_dir() for Haiku
The qemu_init_exec_dir() function is inherently non-portable; provide an implementation for Haiku hosts. Signed-off-by: David Carlier <devnexen@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20200703145614.16684-9-peter.maydell@linaro.org [PMM: Expanded commit message] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/oslib-posix.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 7ad9195c44..72907d4d7f 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -60,6 +60,10 @@
#include <mach-o/dyld.h>
#endif
+#ifdef __HAIKU__
+#include <kernel/image.h>
+#endif
+
#include "qemu/mmap-alloc.h"
#ifdef CONFIG_DEBUG_STACK_USAGE
@@ -389,6 +393,21 @@ void qemu_init_exec_dir(const char *argv0)
}
}
}
+#elif defined(__HAIKU__)
+ {
+ image_info ii;
+ int32_t c = 0;
+
+ *buf = '\0';
+ while (get_next_image_info(0, &c, &ii) == B_OK) {
+ if (ii.type == B_APP_IMAGE) {
+ strncpy(buf, ii.name, sizeof(buf));
+ buf[sizeof(buf) - 1] = 0;
+ p = buf;
+ break;
+ }
+ }
+ }
#endif
/* If we don't have any way of figuring out the actual executable
location then try argv[0]. */