Skip to content

Commit 8e05c44

Browse files
devnexennikic
authored andcommitted
Opcache JIT, code simplification for Haiku.
More straightforward approach to get the path of the current PHP process. Closes GH-6082.
1 parent e0c9467 commit 8e05c44

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

ext/opcache/jit/zend_elf.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#if defined(__FreeBSD__)
2323
#include <sys/sysctl.h>
2424
#elif defined(__HAIKU__)
25-
#include <kernel/image.h>
25+
#include <FindDirectory.h>
2626
#endif
2727
#include <fcntl.h>
2828
#include <unistd.h>
@@ -67,20 +67,13 @@ void zend_elf_load_symbols(void)
6767
const char *path = getexecname();
6868
int fd = open(path, O_RDONLY);
6969
#elif defined(__HAIKU__)
70-
image_info ii;
71-
int32_t ic = 0;
72-
73-
while (get_next_image_info(0, &ic, &ii) == B_OK) {
74-
if (ii.type == B_APP_IMAGE) {
75-
break;
76-
}
77-
}
78-
79-
if (ii.type != B_APP_IMAGE) {
70+
char path[PATH_MAX];
71+
if (find_path(B_APP_IMAGE_SYMBOL, B_FIND_PATH_IMAGE_PATH,
72+
NULL, path, sizeof(path)) != B_OK) {
8073
return;
8174
}
8275

83-
int fd = open(ii.name, O_RDONLY);
76+
int fd = open(path, O_RDONLY);
8477
#else
8578
// To complete eventually for other ELF platforms.
8679
// Otherwise APPLE is Mach-O

ext/opcache/jit/zend_jit_perf_dump.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// avoiding thread.h inclusion as it conflicts with vtunes types.
3737
extern unsigned int thr_self(void);
3838
#elif defined(__HAIKU__)
39-
#include <kernel/image.h>
39+
#include <FindDirectory.h>
4040
#endif
4141

4242
#include "zend_elf.h"
@@ -136,20 +136,13 @@ static void zend_jit_perf_jitdump_open(void)
136136
const char *path = getexecname();
137137
fd = open(path, O_RDONLY);
138138
#elif defined(__HAIKU__)
139-
image_info ii;
140-
int32_t ic = 0;
141-
142-
while (get_next_image_info(0, &ic, &ii) == B_OK) {
143-
if (ii.type == B_APP_IMAGE) {
144-
break;
145-
}
146-
}
147-
148-
if (ii.type != B_APP_IMAGE) {
139+
char path[PATH_MAX];
140+
if (find_path(B_APP_IMAGE_SYMBOL, B_FIND_PATH_IMAGE_PATH,
141+
NULL, path, sizeof(path)) != B_OK) {
149142
return;
150143
}
151144

152-
fd = open(ii.name, O_RDONLY);
145+
fd = open(path, O_RDONLY);
153146
#else
154147
fd = -1;
155148
#endif

0 commit comments

Comments
 (0)