blob: ee0d5edcdbc8ff9136934e52319166034445c15d [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001opcache/config.m4: enable opcache
Brad Bishop316dfdd2018-06-25 12:45:53 -04002
Andrew Geissler82c905d2020-04-13 13:39:40 -05003We can't use AC_TRY_RUN to run programs in a cross compile environment.
4Set
5the variables directly instead since we know that we'd be running on
6latest
Brad Bishop316dfdd2018-06-25 12:45:53 -04007enough linux kernel.
8
9Upstream-Status: Inappropriate [Configuration]
10
11Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Brad Bishop19323692019-04-05 15:28:33 -040012
Andrew Geissler82c905d2020-04-13 13:39:40 -050013update patch to version 7.4.4
Brad Bishop19323692019-04-05 15:28:33 -040014Signed-off-by: Changqing Li <changqing.li@windriver.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040015---
Andrew Geissler82c905d2020-04-13 13:39:40 -050016 ext/opcache/config.m4 | 194 +-------------------------------------------------
17 1 file changed, 3 insertions(+), 191 deletions(-)
Brad Bishop316dfdd2018-06-25 12:45:53 -040018
19diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
Andrew Geissler82c905d2020-04-13 13:39:40 -050020index 6c40caf..84ddf1e 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040021--- a/ext/opcache/config.m4
22+++ b/ext/opcache/config.m4
Andrew Geissler82c905d2020-04-13 13:39:40 -050023@@ -23,201 +23,13 @@ if test "$PHP_OPCACHE" != "no"; then
24 AC_CHECK_FUNCS([mprotect])
Brad Bishop316dfdd2018-06-25 12:45:53 -040025
Brad Bishop19323692019-04-05 15:28:33 -040026 AC_MSG_CHECKING(for sysvipc shared memory support)
27- AC_RUN_IFELSE([AC_LANG_SOURCE([[
Brad Bishop316dfdd2018-06-25 12:45:53 -040028-#include <sys/types.h>
29-#include <sys/wait.h>
30-#include <sys/ipc.h>
31-#include <sys/shm.h>
32-#include <unistd.h>
33-#include <string.h>
Brad Bishop19323692019-04-05 15:28:33 -040034-
Brad Bishop316dfdd2018-06-25 12:45:53 -040035-int main() {
36- pid_t pid;
37- int status;
38- int ipc_id;
39- char *shm;
40- struct shmid_ds shmbuf;
Brad Bishop19323692019-04-05 15:28:33 -040041-
Brad Bishop316dfdd2018-06-25 12:45:53 -040042- ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
43- if (ipc_id == -1) {
44- return 1;
45- }
Brad Bishop19323692019-04-05 15:28:33 -040046-
Brad Bishop316dfdd2018-06-25 12:45:53 -040047- shm = shmat(ipc_id, NULL, 0);
48- if (shm == (void *)-1) {
49- shmctl(ipc_id, IPC_RMID, NULL);
50- return 2;
51- }
52-
53- if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
54- shmdt(shm);
55- shmctl(ipc_id, IPC_RMID, NULL);
56- return 3;
57- }
58-
59- shmbuf.shm_perm.uid = getuid();
60- shmbuf.shm_perm.gid = getgid();
61- shmbuf.shm_perm.mode = 0600;
62-
63- if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
64- shmdt(shm);
65- shmctl(ipc_id, IPC_RMID, NULL);
66- return 4;
67- }
68-
69- shmctl(ipc_id, IPC_RMID, NULL);
70-
71- strcpy(shm, "hello");
72-
73- pid = fork();
74- if (pid < 0) {
75- return 5;
76- } else if (pid == 0) {
77- strcpy(shm, "bye");
78- return 6;
79- }
80- if (wait(&status) != pid) {
81- return 7;
82- }
83- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
84- return 8;
85- }
86- if (strcmp(shm, "bye") != 0) {
87- return 9;
88- }
89- return 0;
90-}
Brad Bishop19323692019-04-05 15:28:33 -040091-]])],[dnl
Brad Bishop316dfdd2018-06-25 12:45:53 -040092- AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
Brad Bishop19323692019-04-05 15:28:33 -040093- msg=yes],[msg=no],[msg=no])
Brad Bishop316dfdd2018-06-25 12:45:53 -040094- AC_MSG_RESULT([$msg])
Brad Bishop19323692019-04-05 15:28:33 -040095+ AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
Andrew Geissler82c905d2020-04-13 13:39:40 -050096
Brad Bishop19323692019-04-05 15:28:33 -040097 AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
98- AC_RUN_IFELSE([AC_LANG_SOURCE([[
Brad Bishop316dfdd2018-06-25 12:45:53 -040099-#include <sys/types.h>
100-#include <sys/wait.h>
101-#include <sys/mman.h>
102-#include <unistd.h>
103-#include <string.h>
104-
105-#ifndef MAP_ANON
106-# ifdef MAP_ANONYMOUS
107-# define MAP_ANON MAP_ANONYMOUS
108-# endif
109-#endif
110-#ifndef MAP_FAILED
111-# define MAP_FAILED ((void*)-1)
112-#endif
Andrew Geissler82c905d2020-04-13 13:39:40 -0500113+ AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
114
Brad Bishop316dfdd2018-06-25 12:45:53 -0400115-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-}
Brad Bishop19323692019-04-05 15:28:33 -0400145-]])],[dnl
Brad Bishop316dfdd2018-06-25 12:45:53 -0400146- AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
Brad Bishop19323692019-04-05 15:28:33 -0400147- msg=yes],[msg=no],[msg=no])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400148- AC_MSG_RESULT([$msg])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400149-
Andrew Geissler82c905d2020-04-13 13:39:40 -0500150- PHP_CHECK_FUNC_LIB(shm_open, rt)
Brad Bishop19323692019-04-05 15:28:33 -0400151 AC_MSG_CHECKING(for mmap() using shm_open() shared memory support)
152- AC_RUN_IFELSE([AC_LANG_SOURCE([[
Brad Bishop316dfdd2018-06-25 12:45:53 -0400153-#include <sys/types.h>
154-#include <sys/wait.h>
155-#include <sys/mman.h>
156-#include <sys/stat.h>
157-#include <fcntl.h>
158-#include <unistd.h>
159-#include <string.h>
160-#include <stdlib.h>
161-#include <stdio.h>
162-
163-#ifndef MAP_FAILED
164-# define MAP_FAILED ((void*)-1)
165-#endif
166-
167-int main() {
168- pid_t pid;
169- int status;
170- int fd;
171- char *shm;
172- char tmpname[4096];
173-
Andrew Geissler82c905d2020-04-13 13:39:40 -0500174- sprintf(tmpname,"/opcache.test.shm.%dXXXXXX", getpid());
Brad Bishop316dfdd2018-06-25 12:45:53 -0400175- if (mktemp(tmpname) == NULL) {
176- return 1;
177- }
178- fd = shm_open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
179- if (fd == -1) {
180- return 2;
181- }
182- if (ftruncate(fd, 4096) < 0) {
183- close(fd);
184- shm_unlink(tmpname);
185- return 3;
186- }
187-
188- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
189- if (shm == MAP_FAILED) {
190- return 4;
191- }
192- shm_unlink(tmpname);
193- close(fd);
194-
195- strcpy(shm, "hello");
196-
197- pid = fork();
198- if (pid < 0) {
199- return 5;
200- } else if (pid == 0) {
201- strcpy(shm, "bye");
202- return 6;
203- }
204- if (wait(&status) != pid) {
205- return 7;
206- }
207- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
208- return 8;
209- }
210- if (strcmp(shm, "bye") != 0) {
211- return 9;
212- }
213- return 0;
214-}
Brad Bishop19323692019-04-05 15:28:33 -0400215-]])],[dnl
Brad Bishop316dfdd2018-06-25 12:45:53 -0400216- AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
Andrew Geissler82c905d2020-04-13 13:39:40 -0500217- AC_MSG_RESULT([yes])
218- PHP_CHECK_LIBRARY(rt, shm_unlink, [PHP_ADD_LIBRARY(rt,1,OPCACHE_SHARED_LIBADD)])
219- ],[
220- AC_MSG_RESULT([no])
221- ],[
222- AC_MSG_RESULT([no])
223- ])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400224+ AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
225
Brad Bishopc342db32019-05-15 21:57:59 -0400226 PHP_NEW_EXTENSION(opcache,
227 ZendAccelerator.c \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400228--
2292.7.4
230