blob: 1f3e683a0fdccdab01f3f11a175efa0f8b45abb4 [file] [log] [blame]
Andrew Geissler7f40b712020-05-15 14:09:53 -05001From a74b42098aededd296ec6a3cd4cf5a17e59d6f29 Mon Sep 17 00:00:00 2001
2From: Claude Bing <cbing@cybernetics.com>
3Date: Fri, 8 May 2020 10:15:32 -0400
4Subject: [PATCH] opcache/config.m4: enable opcache
Brad Bishop316dfdd2018-06-25 12:45:53 -04005
Andrew Geissler82c905d2020-04-13 13:39:40 -05006We can't use AC_TRY_RUN to run programs in a cross compile environment.
7Set
8the variables directly instead since we know that we'd be running on
9latest
Brad Bishop316dfdd2018-06-25 12:45:53 -040010enough linux kernel.
11
12Upstream-Status: Inappropriate [Configuration]
13
14Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Brad Bishop19323692019-04-05 15:28:33 -040015
Andrew Geissler82c905d2020-04-13 13:39:40 -050016update patch to version 7.4.4
Brad Bishop19323692019-04-05 15:28:33 -040017Signed-off-by: Changqing Li <changqing.li@windriver.com>
Andrew Geissler7f40b712020-05-15 14:09:53 -050018
19fix issue linking with librt
20Signed-off-by: Claude Bing <cbing@cybernetics.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040021---
Andrew Geissler7f40b712020-05-15 14:09:53 -050022 ext/opcache/config.m4 | 195 +-----------------------------------------
23 1 file changed, 4 insertions(+), 191 deletions(-)
Brad Bishop316dfdd2018-06-25 12:45:53 -040024
25diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
Andrew Geissler7f40b712020-05-15 14:09:53 -050026index 6c40cafc1c..6569aa9e1c 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040027--- a/ext/opcache/config.m4
28+++ b/ext/opcache/config.m4
Andrew Geissler7f40b712020-05-15 14:09:53 -050029@@ -23,201 +23,14 @@ if test "$PHP_OPCACHE" != "no"; then
Andrew Geissler82c905d2020-04-13 13:39:40 -050030 AC_CHECK_FUNCS([mprotect])
Brad Bishop316dfdd2018-06-25 12:45:53 -040031
Brad Bishop19323692019-04-05 15:28:33 -040032 AC_MSG_CHECKING(for sysvipc shared memory support)
33- AC_RUN_IFELSE([AC_LANG_SOURCE([[
Brad Bishop316dfdd2018-06-25 12:45:53 -040034-#include <sys/types.h>
35-#include <sys/wait.h>
36-#include <sys/ipc.h>
37-#include <sys/shm.h>
38-#include <unistd.h>
39-#include <string.h>
Brad Bishop19323692019-04-05 15:28:33 -040040-
Brad Bishop316dfdd2018-06-25 12:45:53 -040041-int main() {
42- pid_t pid;
43- int status;
44- int ipc_id;
45- char *shm;
46- struct shmid_ds shmbuf;
Brad Bishop19323692019-04-05 15:28:33 -040047-
Brad Bishop316dfdd2018-06-25 12:45:53 -040048- ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
49- if (ipc_id == -1) {
50- return 1;
51- }
Brad Bishop19323692019-04-05 15:28:33 -040052-
Brad Bishop316dfdd2018-06-25 12:45:53 -040053- shm = shmat(ipc_id, NULL, 0);
54- if (shm == (void *)-1) {
55- shmctl(ipc_id, IPC_RMID, NULL);
56- return 2;
57- }
58-
59- if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
60- shmdt(shm);
61- shmctl(ipc_id, IPC_RMID, NULL);
62- return 3;
63- }
64-
65- shmbuf.shm_perm.uid = getuid();
66- shmbuf.shm_perm.gid = getgid();
67- shmbuf.shm_perm.mode = 0600;
68-
69- if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
70- shmdt(shm);
71- shmctl(ipc_id, IPC_RMID, NULL);
72- return 4;
73- }
74-
75- shmctl(ipc_id, IPC_RMID, NULL);
76-
77- strcpy(shm, "hello");
78-
79- pid = fork();
80- if (pid < 0) {
81- return 5;
82- } else if (pid == 0) {
83- strcpy(shm, "bye");
84- return 6;
85- }
86- if (wait(&status) != pid) {
87- return 7;
88- }
89- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
90- return 8;
91- }
92- if (strcmp(shm, "bye") != 0) {
93- return 9;
94- }
95- return 0;
96-}
Brad Bishop19323692019-04-05 15:28:33 -040097-]])],[dnl
Brad Bishop316dfdd2018-06-25 12:45:53 -040098- AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
Brad Bishop19323692019-04-05 15:28:33 -040099- msg=yes],[msg=no],[msg=no])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400100- AC_MSG_RESULT([$msg])
Brad Bishop19323692019-04-05 15:28:33 -0400101+ AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
Andrew Geissler82c905d2020-04-13 13:39:40 -0500102
Brad Bishop19323692019-04-05 15:28:33 -0400103 AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
104- AC_RUN_IFELSE([AC_LANG_SOURCE([[
Brad Bishop316dfdd2018-06-25 12:45:53 -0400105-#include <sys/types.h>
106-#include <sys/wait.h>
107-#include <sys/mman.h>
108-#include <unistd.h>
109-#include <string.h>
110-
111-#ifndef MAP_ANON
112-# ifdef MAP_ANONYMOUS
113-# define MAP_ANON MAP_ANONYMOUS
114-# endif
115-#endif
116-#ifndef MAP_FAILED
117-# define MAP_FAILED ((void*)-1)
118-#endif
Andrew Geissler82c905d2020-04-13 13:39:40 -0500119+ AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
120
Brad Bishop316dfdd2018-06-25 12:45:53 -0400121-int main() {
122- pid_t pid;
123- int status;
124- char *shm;
125-
126- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
127- if (shm == MAP_FAILED) {
128- return 1;
129- }
130-
131- strcpy(shm, "hello");
132-
133- pid = fork();
134- if (pid < 0) {
135- return 5;
136- } else if (pid == 0) {
137- strcpy(shm, "bye");
138- return 6;
139- }
140- if (wait(&status) != pid) {
141- return 7;
142- }
143- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
144- return 8;
145- }
146- if (strcmp(shm, "bye") != 0) {
147- return 9;
148- }
149- return 0;
150-}
Brad Bishop19323692019-04-05 15:28:33 -0400151-]])],[dnl
Brad Bishop316dfdd2018-06-25 12:45:53 -0400152- AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
Brad Bishop19323692019-04-05 15:28:33 -0400153- msg=yes],[msg=no],[msg=no])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400154- AC_MSG_RESULT([$msg])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400155-
Andrew Geissler82c905d2020-04-13 13:39:40 -0500156- PHP_CHECK_FUNC_LIB(shm_open, rt)
Brad Bishop19323692019-04-05 15:28:33 -0400157 AC_MSG_CHECKING(for mmap() using shm_open() shared memory support)
158- AC_RUN_IFELSE([AC_LANG_SOURCE([[
Brad Bishop316dfdd2018-06-25 12:45:53 -0400159-#include <sys/types.h>
160-#include <sys/wait.h>
161-#include <sys/mman.h>
162-#include <sys/stat.h>
163-#include <fcntl.h>
164-#include <unistd.h>
165-#include <string.h>
166-#include <stdlib.h>
167-#include <stdio.h>
168-
169-#ifndef MAP_FAILED
170-# define MAP_FAILED ((void*)-1)
171-#endif
172-
173-int main() {
174- pid_t pid;
175- int status;
176- int fd;
177- char *shm;
178- char tmpname[4096];
179-
Andrew Geissler82c905d2020-04-13 13:39:40 -0500180- sprintf(tmpname,"/opcache.test.shm.%dXXXXXX", getpid());
Brad Bishop316dfdd2018-06-25 12:45:53 -0400181- if (mktemp(tmpname) == NULL) {
182- return 1;
183- }
184- fd = shm_open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
185- if (fd == -1) {
186- return 2;
187- }
188- if (ftruncate(fd, 4096) < 0) {
189- close(fd);
190- shm_unlink(tmpname);
191- return 3;
192- }
193-
194- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
195- if (shm == MAP_FAILED) {
196- return 4;
197- }
198- shm_unlink(tmpname);
199- close(fd);
200-
201- strcpy(shm, "hello");
202-
203- pid = fork();
204- if (pid < 0) {
205- return 5;
206- } else if (pid == 0) {
207- strcpy(shm, "bye");
208- return 6;
209- }
210- if (wait(&status) != pid) {
211- return 7;
212- }
213- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
214- return 8;
215- }
216- if (strcmp(shm, "bye") != 0) {
217- return 9;
218- }
219- return 0;
220-}
Brad Bishop19323692019-04-05 15:28:33 -0400221-]])],[dnl
Brad Bishop316dfdd2018-06-25 12:45:53 -0400222- AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
Andrew Geissler82c905d2020-04-13 13:39:40 -0500223- AC_MSG_RESULT([yes])
224- PHP_CHECK_LIBRARY(rt, shm_unlink, [PHP_ADD_LIBRARY(rt,1,OPCACHE_SHARED_LIBADD)])
225- ],[
226- AC_MSG_RESULT([no])
227- ],[
228- AC_MSG_RESULT([no])
229- ])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400230+ AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
Andrew Geissler7f40b712020-05-15 14:09:53 -0500231+ PHP_CHECK_LIBRARY(rt, shm_unlink, [PHP_ADD_LIBRARY(rt,1,OPCACHE_SHARED_LIBADD)])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400232
Brad Bishopc342db32019-05-15 21:57:59 -0400233 PHP_NEW_EXTENSION(opcache,
234 ZendAccelerator.c \
Brad Bishop316dfdd2018-06-25 12:45:53 -0400235--
Andrew Geissler7f40b712020-05-15 14:09:53 -05002362.17.1
Brad Bishop316dfdd2018-06-25 12:45:53 -0400237