1From 889583912ddd7abc628f2703892ec4884db6419a Mon Sep 17 00:00:00 2001
2From: Soumya Sambu <soumya.sambu@windriver.com>
3Date: Tue, 7 May 2024 08:39:16 +0000
4Subject: [PATCH 01/11] ext/opcache/config.m4: enable opcache
5
6We can't use AC_TRY_RUN to run programs in a cross compile
7environment. Set the variables directly instead since we know
8that we'd be running on latest enough linux kernel.
9
10Upstream-Status: Inappropriate [Configuration]
11
12Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
13
14update patch to version 7.4.4
15Signed-off-by: Changqing Li <changqing.li@windriver.com>
16
17update patch to version 8.0.12
18fix issue linking with librt
19Signed-off-by: Claude Bing <cbing@cybernetics.com>
20
21update patch to version 8.1.0
22Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
23
24update patch to version 8.2.18
25Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
26---
27 ext/opcache/config.m4 | 204 ++----------------------------------------
28 1 file changed, 8 insertions(+), 196 deletions(-)
29
30diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
31index 6bf07ad3..5d645b86 100644
32--- a/ext/opcache/config.m4
33+++ b/ext/opcache/config.m4
34@@ -113,209 +113,21 @@ if test "$PHP_OPCACHE" != "no"; then
35   AC_CHECK_FUNCS([mprotect])
36
37   AC_MSG_CHECKING(for sysvipc shared memory support)
38-  AC_RUN_IFELSE([AC_LANG_SOURCE([[
39-#include <sys/types.h>
40-#include <sys/wait.h>
41-#include <sys/ipc.h>
42-#include <sys/shm.h>
43-#include <unistd.h>
44-#include <string.h>
45-
46-int main(void) {
47-  pid_t pid;
48-  int status;
49-  int ipc_id;
50-  char *shm;
51-  struct shmid_ds shmbuf;
52-
53-  ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
54-  if (ipc_id == -1) {
55-    return 1;
56-  }
57-
58-  shm = shmat(ipc_id, NULL, 0);
59-  if (shm == (void *)-1) {
60-    shmctl(ipc_id, IPC_RMID, NULL);
61-    return 2;
62-  }
63-
64-  if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
65-    shmdt(shm);
66-    shmctl(ipc_id, IPC_RMID, NULL);
67-    return 3;
68-  }
69-
70-  shmbuf.shm_perm.uid = getuid();
71-  shmbuf.shm_perm.gid = getgid();
72-  shmbuf.shm_perm.mode = 0600;
73-
74-  if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
75-    shmdt(shm);
76-    shmctl(ipc_id, IPC_RMID, NULL);
77-    return 4;
78-  }
79-
80-  shmctl(ipc_id, IPC_RMID, NULL);
81-
82-  strcpy(shm, "hello");
83-
84-  pid = fork();
85-  if (pid < 0) {
86-    return 5;
87-  } else if (pid == 0) {
88-    strcpy(shm, "bye");
89-    return 6;
90-  }
91-  if (wait(&status) != pid) {
92-    return 7;
93-  }
94-  if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
95-    return 8;
96-  }
97-  if (strcmp(shm, "bye") != 0) {
98-    return 9;
99-  }
100-  return 0;
101-}
102-]])],[have_shm_ipc=yes],[have_shm_ipc=no],[have_shm_ipc=no])
103-  if test "$have_shm_ipc" = "yes"; then
104-    AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
105-  fi
106+  AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
107+  have_shm_ipc=yes
108   AC_MSG_RESULT([$have_shm_ipc])
109
110   AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
111-  AC_RUN_IFELSE([AC_LANG_SOURCE([[
112-#include <sys/types.h>
113-#include <sys/wait.h>
114-#include <sys/mman.h>
115-#include <unistd.h>
116-#include <string.h>
117-
118-#ifndef MAP_ANON
119-# ifdef MAP_ANONYMOUS
120-#  define MAP_ANON MAP_ANONYMOUS
121-# endif
122-#endif
123-#ifndef MAP_FAILED
124-# define MAP_FAILED ((void*)-1)
125-#endif
126-
127-int main(void) {
128-  pid_t pid;
129-  int status;
130-  char *shm;
131-
132-  shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
133-  if (shm == MAP_FAILED) {
134-    return 1;
135-  }
136-
137-  strcpy(shm, "hello");
138-
139-  pid = fork();
140-  if (pid < 0) {
141-    return 5;
142-  } else if (pid == 0) {
143-    strcpy(shm, "bye");
144-    return 6;
145-  }
146-  if (wait(&status) != pid) {
147-    return 7;
148-  }
149-  if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
150-    return 8;
151-  }
152-  if (strcmp(shm, "bye") != 0) {
153-    return 9;
154-  }
155-  return 0;
156-}
157-]])],[have_shm_mmap_anon=yes],[have_shm_mmap_anon=no],[
158-  case $host_alias in
159-    *linux*)
160-      have_shm_mmap_anon=yes
161-      ;;
162-    *)
163-      have_shm_mmap_anon=no
164-      ;;
165-  esac
166-])
167-  if test "$have_shm_mmap_anon" = "yes"; then
168-    AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
169-  fi
170+  AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
171+  have_shm_mmap_anon=yes
172   AC_MSG_RESULT([$have_shm_mmap_anon])
173
174   PHP_CHECK_FUNC_LIB(shm_open, rt, root)
175   AC_MSG_CHECKING(for mmap() using shm_open() shared memory support)
176-  AC_RUN_IFELSE([AC_LANG_SOURCE([[
177-#include <sys/types.h>
178-#include <sys/wait.h>
179-#include <sys/mman.h>
180-#include <sys/stat.h>
181-#include <fcntl.h>
182-#include <unistd.h>
183-#include <string.h>
184-#include <stdlib.h>
185-#include <stdio.h>
186-
187-#ifndef MAP_FAILED
188-# define MAP_FAILED ((void*)-1)
189-#endif
190-
191-int main(void) {
192-  pid_t pid;
193-  int status;
194-  int fd;
195-  char *shm;
196-  char tmpname[4096];
197-
198-  sprintf(tmpname,"/opcache.test.shm.%dXXXXXX", getpid());
199-  if (mktemp(tmpname) == NULL) {
200-    return 1;
201-  }
202-  fd = shm_open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
203-  if (fd == -1) {
204-    return 2;
205-  }
206-  if (ftruncate(fd, 4096) < 0) {
207-    close(fd);
208-    shm_unlink(tmpname);
209-    return 3;
210-  }
211-
212-  shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
213-  if (shm == MAP_FAILED) {
214-    return 4;
215-  }
216-  shm_unlink(tmpname);
217-  close(fd);
218-
219-  strcpy(shm, "hello");
220-
221-  pid = fork();
222-  if (pid < 0) {
223-    return 5;
224-  } else if (pid == 0) {
225-    strcpy(shm, "bye");
226-    return 6;
227-  }
228-  if (wait(&status) != pid) {
229-    return 7;
230-  }
231-  if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
232-    return 8;
233-  }
234-  if (strcmp(shm, "bye") != 0) {
235-    return 9;
236-  }
237-  return 0;
238-}
239-]])],[have_shm_mmap_posix=yes],[have_shm_mmap_posix=no],[have_shm_mmap_posix=no])
240-  if test "$have_shm_mmap_posix" = "yes"; then
241-    AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
242-    PHP_CHECK_LIBRARY(rt, shm_unlink, [PHP_ADD_LIBRARY(rt,1,OPCACHE_SHARED_LIBADD)])
243-  fi
244-  AC_MSG_RESULT([$have_shm_mmap_posix])
245+  AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
246+  AC_MSG_RESULT([yes])
247+  have_shm_mmap_posix=yes
248+  PHP_CHECK_LIBRARY(rt, shm_unlink, [PHP_ADD_LIBRARY(rt,1,OPCACHE_SHARED_LIBADD)])
249
250   PHP_NEW_EXTENSION(opcache,
251 	ZendAccelerator.c \
252--
2532.40.0
254
255