blob: 0d24d34f2bf1e7204ee6c043e072997daa7b7afb [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From b2fb725dc404d471371731b663234e87cb0fca84 Mon Sep 17 00:00:00 2001
2From: Anuj Mittal <anuj.mittal@intel.com>
3Date: Mon, 2 Apr 2018 17:54:52 +0800
4Subject: [PATCH] opcache/config.m4: enable opcache
5
6We can't use AC_TRY_RUN to run programs in a cross compile environment. Set
7the variables directly instead since we know that we'd be running on latest
8enough linux kernel.
9
10Upstream-Status: Inappropriate [Configuration]
11
12Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
13---
14 ext/opcache/config.m4 | 349 ++------------------------------------------------
15 1 file changed, 8 insertions(+), 341 deletions(-)
16
17diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
18index 7b500f0..10bb99a 100644
19--- a/ext/opcache/config.m4
20+++ b/ext/opcache/config.m4
21@@ -28,353 +28,20 @@ if test "$PHP_OPCACHE" != "no"; then
22
23 AC_CHECK_HEADERS([unistd.h sys/uio.h])
24
25- AC_MSG_CHECKING(for sysvipc shared memory support)
26- AC_TRY_RUN([
27-#include <sys/types.h>
28-#include <sys/wait.h>
29-#include <sys/ipc.h>
30-#include <sys/shm.h>
31-#include <unistd.h>
32-#include <string.h>
33+ AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
34
35-int main() {
36- pid_t pid;
37- int status;
38- int ipc_id;
39- char *shm;
40- struct shmid_ds shmbuf;
41+ AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
42
43- ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
44- if (ipc_id == -1) {
45- return 1;
46- }
47+ AC_DEFINE(HAVE_SHM_MMAP_ZERO, 1, [Define if you have mmap("/dev/zero") SHM support])
48
49- shm = shmat(ipc_id, NULL, 0);
50- if (shm == (void *)-1) {
51- shmctl(ipc_id, IPC_RMID, NULL);
52- return 2;
53- }
54-
55- if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
56- shmdt(shm);
57- shmctl(ipc_id, IPC_RMID, NULL);
58- return 3;
59- }
60-
61- shmbuf.shm_perm.uid = getuid();
62- shmbuf.shm_perm.gid = getgid();
63- shmbuf.shm_perm.mode = 0600;
64-
65- if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
66- shmdt(shm);
67- shmctl(ipc_id, IPC_RMID, NULL);
68- return 4;
69- }
70-
71- shmctl(ipc_id, IPC_RMID, NULL);
72-
73- strcpy(shm, "hello");
74-
75- pid = fork();
76- if (pid < 0) {
77- return 5;
78- } else if (pid == 0) {
79- strcpy(shm, "bye");
80- return 6;
81- }
82- if (wait(&status) != pid) {
83- return 7;
84- }
85- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
86- return 8;
87- }
88- if (strcmp(shm, "bye") != 0) {
89- return 9;
90- }
91- return 0;
92-}
93-],dnl
94- AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
95- msg=yes,msg=no,msg=no)
96- AC_MSG_RESULT([$msg])
97-
98- AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
99- AC_TRY_RUN([
100-#include <sys/types.h>
101-#include <sys/wait.h>
102-#include <sys/mman.h>
103-#include <unistd.h>
104-#include <string.h>
105-
106-#ifndef MAP_ANON
107-# ifdef MAP_ANONYMOUS
108-# define MAP_ANON MAP_ANONYMOUS
109-# endif
110-#endif
111-#ifndef MAP_FAILED
112-# define MAP_FAILED ((void*)-1)
113-#endif
114-
115-int main() {
116- pid_t pid;
117- int status;
118- char *shm;
119-
120- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
121- if (shm == MAP_FAILED) {
122- return 1;
123- }
124-
125- strcpy(shm, "hello");
126-
127- pid = fork();
128- if (pid < 0) {
129- return 5;
130- } else if (pid == 0) {
131- strcpy(shm, "bye");
132- return 6;
133- }
134- if (wait(&status) != pid) {
135- return 7;
136- }
137- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
138- return 8;
139- }
140- if (strcmp(shm, "bye") != 0) {
141- return 9;
142- }
143- return 0;
144-}
145-],dnl
146- AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
147- msg=yes,msg=no,msg=no)
148- AC_MSG_RESULT([$msg])
149-
150- AC_MSG_CHECKING(for mmap() using /dev/zero shared memory support)
151- AC_TRY_RUN([
152-#include <sys/types.h>
153-#include <sys/wait.h>
154-#include <sys/mman.h>
155-#include <sys/stat.h>
156-#include <fcntl.h>
157-#include <unistd.h>
158-#include <string.h>
159-
160-#ifndef MAP_FAILED
161-# define MAP_FAILED ((void*)-1)
162-#endif
163-
164-int main() {
165- pid_t pid;
166- int status;
167- int fd;
168- char *shm;
169-
170- fd = open("/dev/zero", O_RDWR, S_IRUSR | S_IWUSR);
171- if (fd == -1) {
172- return 1;
173- }
174-
175- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
176- if (shm == MAP_FAILED) {
177- return 2;
178- }
179-
180- strcpy(shm, "hello");
181-
182- pid = fork();
183- if (pid < 0) {
184- return 5;
185- } else if (pid == 0) {
186- strcpy(shm, "bye");
187- return 6;
188- }
189- if (wait(&status) != pid) {
190- return 7;
191- }
192- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
193- return 8;
194- }
195- if (strcmp(shm, "bye") != 0) {
196- return 9;
197- }
198- return 0;
199-}
200-],dnl
201- AC_DEFINE(HAVE_SHM_MMAP_ZERO, 1, [Define if you have mmap("/dev/zero") SHM support])
202- msg=yes,msg=no,msg=no)
203- AC_MSG_RESULT([$msg])
204-
205- AC_MSG_CHECKING(for mmap() using shm_open() shared memory support)
206- AC_TRY_RUN([
207-#include <sys/types.h>
208-#include <sys/wait.h>
209-#include <sys/mman.h>
210-#include <sys/stat.h>
211-#include <fcntl.h>
212-#include <unistd.h>
213-#include <string.h>
214-#include <stdlib.h>
215-#include <stdio.h>
216-
217-#ifndef MAP_FAILED
218-# define MAP_FAILED ((void*)-1)
219-#endif
220-
221-int main() {
222- pid_t pid;
223- int status;
224- int fd;
225- char *shm;
226- char tmpname[4096];
227-
228- sprintf(tmpname,"test.shm.%dXXXXXX", getpid());
229- if (mktemp(tmpname) == NULL) {
230- return 1;
231- }
232- fd = shm_open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
233- if (fd == -1) {
234- return 2;
235- }
236- if (ftruncate(fd, 4096) < 0) {
237- close(fd);
238- shm_unlink(tmpname);
239- return 3;
240- }
241-
242- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
243- if (shm == MAP_FAILED) {
244- return 4;
245- }
246- shm_unlink(tmpname);
247- close(fd);
248-
249- strcpy(shm, "hello");
250-
251- pid = fork();
252- if (pid < 0) {
253- return 5;
254- } else if (pid == 0) {
255- strcpy(shm, "bye");
256- return 6;
257- }
258- if (wait(&status) != pid) {
259- return 7;
260- }
261- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
262- return 8;
263- }
264- if (strcmp(shm, "bye") != 0) {
265- return 9;
266- }
267- return 0;
268-}
269-],dnl
270- AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
271- msg=yes,msg=no,msg=no)
272- AC_MSG_RESULT([$msg])
273+ AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
274
275 AC_MSG_CHECKING(for mmap() using regular file shared memory support)
276- AC_TRY_RUN([
277-#include <sys/types.h>
278-#include <sys/wait.h>
279-#include <sys/mman.h>
280-#include <sys/stat.h>
281-#include <fcntl.h>
282-#include <unistd.h>
283-#include <string.h>
284-#include <stdlib.h>
285-#include <stdio.h>
286-
287-#ifndef MAP_FAILED
288-# define MAP_FAILED ((void*)-1)
289-#endif
290-
291-int main() {
292- pid_t pid;
293- int status;
294- int fd;
295- char *shm;
296- char tmpname[4096];
297-
298- sprintf(tmpname,"test.shm.%dXXXXXX", getpid());
299- if (mktemp(tmpname) == NULL) {
300- return 1;
301- }
302- fd = open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
303- if (fd == -1) {
304- return 2;
305- }
306- if (ftruncate(fd, 4096) < 0) {
307- close(fd);
308- unlink(tmpname);
309- return 3;
310- }
311-
312- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
313- if (shm == MAP_FAILED) {
314- return 4;
315- }
316- unlink(tmpname);
317- close(fd);
318-
319- strcpy(shm, "hello");
320-
321- pid = fork();
322- if (pid < 0) {
323- return 5;
324- } else if (pid == 0) {
325- strcpy(shm, "bye");
326- return 6;
327- }
328- if (wait(&status) != pid) {
329- return 7;
330- }
331- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
332- return 8;
333- }
334- if (strcmp(shm, "bye") != 0) {
335- return 9;
336- }
337- return 0;
338-}
339-],dnl
340- AC_DEFINE(HAVE_SHM_MMAP_FILE, 1, [Define if you have mmap() SHM support])
341- msg=yes,msg=no,msg=no)
342- AC_MSG_RESULT([$msg])
343-
344-flock_type=unknown
345-AC_MSG_CHECKING("whether flock struct is linux ordered")
346-AC_TRY_RUN([
347- #include <fcntl.h>
348- struct flock lock = { 1, 2, 3, 4, 5 };
349- int main() {
350- if(lock.l_type == 1 && lock.l_whence == 2 && lock.l_start == 3 && lock.l_len == 4) {
351- return 0;
352- }
353- return 1;
354- }
355-], [
356- flock_type=linux
357- AC_DEFINE([HAVE_FLOCK_LINUX], [], [Struct flock is Linux-type])
358- AC_MSG_RESULT("yes")
359-], AC_MSG_RESULT("no") )
360+
361+ AC_DEFINE(HAVE_SHM_MMAP_FILE, 1, [Define if you have mmap() SHM support])
362
363-AC_MSG_CHECKING("whether flock struct is BSD ordered")
364-AC_TRY_RUN([
365- #include <fcntl.h>
366- struct flock lock = { 1, 2, 3, 4, 5 };
367- int main() {
368- if(lock.l_start == 1 && lock.l_len == 2 && lock.l_type == 4 && lock.l_whence == 5) {
369- return 0;
370- }
371- return 1;
372- }
373-], [
374- flock_type=bsd
375- AC_DEFINE([HAVE_FLOCK_BSD], [], [Struct flock is BSD-type])
376- AC_MSG_RESULT("yes")
377-], AC_MSG_RESULT("no") )
378+ flock_type=linux
379+ AC_DEFINE([HAVE_FLOCK_LINUX], [], [Struct flock is Linux-type])
380
381 if test "$flock_type" = "unknown"; then
382 AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])
383--
3842.7.4
385