Skip to content

Commit 2b9b9e7

Browse files
devnexenpm215
authored andcommitted
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 <[email protected]> Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Peter Maydell <[email protected]> Message-id: [email protected] [PMM: Expanded commit message] Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Peter Maydell <[email protected]>
1 parent 81b7b1e commit 2b9b9e7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

util/oslib-posix.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
#include <mach-o/dyld.h>
6161
#endif
6262

63+
#ifdef __HAIKU__
64+
#include <kernel/image.h>
65+
#endif
66+
6367
#include "qemu/mmap-alloc.h"
6468

6569
#ifdef CONFIG_DEBUG_STACK_USAGE
@@ -389,6 +393,21 @@ void qemu_init_exec_dir(const char *argv0)
389393
}
390394
}
391395
}
396+
#elif defined(__HAIKU__)
397+
{
398+
image_info ii;
399+
int32_t c = 0;
400+
401+
*buf = '\0';
402+
while (get_next_image_info(0, &c, &ii) == B_OK) {
403+
if (ii.type == B_APP_IMAGE) {
404+
strncpy(buf, ii.name, sizeof(buf));
405+
buf[sizeof(buf) - 1] = 0;
406+
p = buf;
407+
break;
408+
}
409+
}
410+
}
392411
#endif
393412
/* If we don't have any way of figuring out the actual executable
394413
location then try argv[0]. */

0 commit comments

Comments
 (0)