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