1 From dc8bb6a53bfdfe42d9ae81d4e78c6155ad4bfd6e Mon Sep 17 00:00:00 2001
2 From: Michael Heimpold <mhei@heimpold.de>
3 Date: Sun, 17 May 2015 16:50:50 +0200
4 Subject: [PATCH] ext/opcache: fix detection of shm/mmap
6 The detection of sysvipc and mmap doesn't work well when cross-compiling,
7 so I decided to only check for the availability of the functions involved.
8 This is not a clean solution, but works for now(tm) :-)
10 It should be discussed with upstream to find a better solution.
12 This solves the issue reported at
13 https://github.com/openwrt/packages/issues/1010
14 and makes opcache usable on OpenWrt.
16 Signed-off-by: Michael Heimpold <mhei@heimpold.de>
18 ext/opcache/config.m4 | 122 ++-----------------------------------------------
19 1 file changed, 4 insertions(+), 118 deletions(-)
21 diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
22 index b7e4835..7b6c0aa 100644
23 --- a/ext/opcache/config.m4
24 +++ b/ext/opcache/config.m4
25 @@ -11,127 +11,13 @@ if test "$PHP_OPCACHE" != "no"; then
26 AC_DEFINE(HAVE_MPROTECT, 1, [Define if you have mprotect() function])
29 - AC_MSG_CHECKING(for sysvipc shared memory support)
31 -#include <sys/types.h>
32 -#include <sys/wait.h>
43 - struct shmid_ds shmbuf;
45 - ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
50 - shm = shmat(ipc_id, NULL, 0);
51 - if (shm == (void *)-1) {
52 - shmctl(ipc_id, IPC_RMID, NULL);
56 - if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
58 - shmctl(ipc_id, IPC_RMID, NULL);
62 - shmbuf.shm_perm.uid = getuid();
63 - shmbuf.shm_perm.gid = getgid();
64 - shmbuf.shm_perm.mode = 0600;
66 - if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
68 - shmctl(ipc_id, IPC_RMID, NULL);
72 - shmctl(ipc_id, IPC_RMID, NULL);
74 - strcpy(shm, "hello");
79 - } else if (pid == 0) {
83 - if (wait(&status) != pid) {
86 - if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
89 - if (strcmp(shm, "bye") != 0) {
95 + AC_CHECK_FUNC(shmget,[
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])
100 - AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
102 -#include <sys/types.h>
103 -#include <sys/wait.h>
104 -#include <sys/mman.h>
109 -# ifdef MAP_ANONYMOUS
110 -# define MAP_ANON MAP_ANONYMOUS
114 -# define MAP_FAILED ((void*)-1)
122 - shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
123 - if (shm == MAP_FAILED) {
127 - strcpy(shm, "hello");
133 - } else if (pid == 0) {
134 - strcpy(shm, "bye");
137 - if (wait(&status) != pid) {
140 - if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
143 - if (strcmp(shm, "bye") != 0) {
149 + AC_CHECK_FUNC(mmap,[
150 AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
151 - msg=yes,msg=no,msg=no)
152 - AC_MSG_RESULT([$msg])
155 AC_MSG_CHECKING(for mmap() using /dev/zero shared memory support)