1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
From dc8bb6a53bfdfe42d9ae81d4e78c6155ad4bfd6e Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Sun, 17 May 2015 16:50:50 +0200
Subject: [PATCH] ext/opcache: fix detection of shm/mmap
The detection of sysvipc and mmap doesn't work well when cross-compiling,
so I decided to only check for the availability of the functions involved.
This is not a clean solution, but works for now(tm) :-)
It should be discussed with upstream to find a better solution.
This solves the issue reported at
https://github.com/openwrt/packages/issues/1010
and makes opcache usable on OpenWrt.
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
ext/opcache/config.m4 | 122 ++-----------------------------------------------
1 file changed, 4 insertions(+), 118 deletions(-)
diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
index b7e4835..7b6c0aa 100644
--- a/ext/opcache/config.m4
+++ b/ext/opcache/config.m4
@@ -11,127 +11,13 @@ if test "$PHP_OPCACHE" != "no"; then
AC_DEFINE(HAVE_MPROTECT, 1, [Define if you have mprotect() function])
])
- AC_MSG_CHECKING(for sysvipc shared memory support)
- AC_TRY_RUN([
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <unistd.h>
-#include <string.h>
-
-int main() {
- pid_t pid;
- int status;
- int ipc_id;
- char *shm;
- struct shmid_ds shmbuf;
-
- ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
- if (ipc_id == -1) {
- return 1;
- }
-
- shm = shmat(ipc_id, NULL, 0);
- if (shm == (void *)-1) {
- shmctl(ipc_id, IPC_RMID, NULL);
- return 2;
- }
-
- if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
- shmdt(shm);
- shmctl(ipc_id, IPC_RMID, NULL);
- return 3;
- }
-
- shmbuf.shm_perm.uid = getuid();
- shmbuf.shm_perm.gid = getgid();
- shmbuf.shm_perm.mode = 0600;
-
- if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
- shmdt(shm);
- shmctl(ipc_id, IPC_RMID, NULL);
- return 4;
- }
-
- shmctl(ipc_id, IPC_RMID, NULL);
-
- strcpy(shm, "hello");
-
- pid = fork();
- if (pid < 0) {
- return 5;
- } else if (pid == 0) {
- strcpy(shm, "bye");
- return 6;
- }
- if (wait(&status) != pid) {
- return 7;
- }
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
- return 8;
- }
- if (strcmp(shm, "bye") != 0) {
- return 9;
- }
- return 0;
-}
-],dnl
+ AC_CHECK_FUNC(shmget,[
AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
- msg=yes,msg=no,msg=no)
- AC_MSG_RESULT([$msg])
-
- AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
- AC_TRY_RUN([
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <string.h>
-
-#ifndef MAP_ANON
-# ifdef MAP_ANONYMOUS
-# define MAP_ANON MAP_ANONYMOUS
-# endif
-#endif
-#ifndef MAP_FAILED
-# define MAP_FAILED ((void*)-1)
-#endif
-
-int main() {
- pid_t pid;
- int status;
- char *shm;
-
- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
- if (shm == MAP_FAILED) {
- return 1;
- }
-
- strcpy(shm, "hello");
+ ])
- pid = fork();
- if (pid < 0) {
- return 5;
- } else if (pid == 0) {
- strcpy(shm, "bye");
- return 6;
- }
- if (wait(&status) != pid) {
- return 7;
- }
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
- return 8;
- }
- if (strcmp(shm, "bye") != 0) {
- return 9;
- }
- return 0;
-}
-],dnl
+ AC_CHECK_FUNC(mmap,[
AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
- msg=yes,msg=no,msg=no)
- AC_MSG_RESULT([$msg])
+ ])
AC_MSG_CHECKING(for mmap() using /dev/zero shared memory support)
AC_TRY_RUN([
--
1.7.10.4
|