]> granicus.if.org Git - php/commitdiff
Opcache JIT, code simplification for Haiku.
authorDavid Carlier <devnexen@gmail.com>
Sat, 5 Sep 2020 14:04:01 +0000 (14:04 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 7 Sep 2020 08:15:28 +0000 (10:15 +0200)
More straightforward approach to get the path of the
 current PHP process.

Closes GH-6082.

ext/opcache/jit/zend_elf.c
ext/opcache/jit/zend_jit_perf_dump.c

index 2618f5a488d2d2ea8db4a79a4443584ec26d4c05..58d6fdd72cc6a6107f7e664bbe2173b25a5a72b3 100644 (file)
@@ -22,7 +22,7 @@
 #if defined(__FreeBSD__)
 #include <sys/sysctl.h>
 #elif defined(__HAIKU__)
-#include <kernel/image.h>
+#include <FindDirectory.h>
 #endif
 #include <fcntl.h>
 #include <unistd.h>
@@ -67,20 +67,13 @@ void zend_elf_load_symbols(void)
        const char *path = getexecname();
        int fd = open(path, O_RDONLY);
 #elif defined(__HAIKU__)
-       image_info ii;
-       int32_t ic = 0;
-
-       while (get_next_image_info(0, &ic, &ii) == B_OK) {
-               if (ii.type == B_APP_IMAGE) {
-                       break;
-               }
-       }
-
-       if (ii.type != B_APP_IMAGE) {
+       char path[PATH_MAX];
+       if (find_path(B_APP_IMAGE_SYMBOL, B_FIND_PATH_IMAGE_PATH,
+               NULL, path, sizeof(path)) != B_OK) {
                return;
        }
 
-       int fd = open(ii.name, O_RDONLY);
+       int fd = open(path, O_RDONLY);
 #else
        // To complete eventually for other ELF platforms.
        // Otherwise APPLE is Mach-O
index 94feba1f07d8c9a4a118a1314f7d5181e67a7ae1..613280c2179d2c9975e62605574de85146f542f5 100644 (file)
@@ -36,7 +36,7 @@
 // avoiding thread.h inclusion as it conflicts with vtunes types.
 extern unsigned int thr_self(void);
 #elif defined(__HAIKU__)
-#include <kernel/image.h>
+#include <FindDirectory.h>
 #endif
 
 #include "zend_elf.h"
@@ -136,20 +136,13 @@ static void zend_jit_perf_jitdump_open(void)
        const char *path = getexecname();
        fd = open(path, O_RDONLY);
 #elif defined(__HAIKU__)
-       image_info ii;
-       int32_t ic = 0;
-
-       while (get_next_image_info(0, &ic, &ii) == B_OK) {
-               if (ii.type == B_APP_IMAGE) {
-                       break;
-               }
-       }
-
-       if (ii.type != B_APP_IMAGE) {
+       char path[PATH_MAX];
+       if (find_path(B_APP_IMAGE_SYMBOL, B_FIND_PATH_IMAGE_PATH,
+               NULL, path, sizeof(path)) != B_OK) {
                return;
        }
 
-       fd = open(ii.name, O_RDONLY);
+       fd = open(path, O_RDONLY);
 #else
        fd = -1;
 #endif