diff mbox series

[5/5] haiku build fix

Message ID CA+XhMqxcvPwakFCC2Qy-S3FZ1NdVJ2rojsZGg5S7KK-feZ-BnA@mail.gmail.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

David CARLIER June 26, 2020, 12:54 p.m. UTC
From 6fa7a4108236f513201192654e07c7044a3d7e58 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Fri, 26 Jun 2020 13:51:37 +0000
Subject: [PATCH 3/3] qemu_init_exec_dir Haiku implementation

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 util/oslib-posix.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Eric Blake June 26, 2020, 2:31 p.m. UTC | #1
On 6/26/20 7:54 AM, David CARLIER wrote:
>>From 6fa7a4108236f513201192654e07c7044a3d7e58 Mon Sep 17 00:00:00 2001
> From: David Carlier <devnexen@gmail.com>
> Date: Fri, 26 Jun 2020 13:51:37 +0000
> Subject: [PATCH 3/3] qemu_init_exec_dir Haiku implementation

meta-comment: the original subject line says 5/5, while this line says 
3/3, which adds to the confusion of which patches are actually doing 
what, as well as which iteration of the patches we are on.  Also, the 
original subject line "haiku build fix" has been repeated for multiple 
distinct emails; better is to have the subject line come from the patch 
itself (the contents of this line would have been better as the overall 
patch subject).
diff mbox series

Patch

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 7ad9195c44..459e3f8093 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].  */