source: src/router/php7/ext/opcache/config.m4 @ 31879

Last change on this file since 31879 was 31879, checked in by brainslayer, 6 weeks ago

update php

File size: 6.9 KB
Line 
1dnl
2dnl $Id$
3dnl
4
5PHP_ARG_ENABLE(opcache, whether to enable Zend OPcache support,
6[  --disable-opcache       Disable Zend OPcache support], yes)
7
8PHP_ARG_ENABLE(opcache-file, whether to enable file based caching,
9[  --disable-opcache-file  Disable file based caching], yes, no)
10
11PHP_ARG_ENABLE(huge-code-pages, whether to enable copying PHP CODE pages into HUGE PAGES,
12[  --disable-huge-code-pages
13                          Disable copying PHP CODE pages into HUGE PAGES], yes, no)
14
15if test "$PHP_OPCACHE" != "no"; then
16
17  if test "$PHP_OPCACHE_FILE" = "yes"; then
18    AC_DEFINE(HAVE_OPCACHE_FILE_CACHE, 1, [Define to enable file based caching (experimental)])
19  fi
20
21  if test "$PHP_HUGE_CODE_PAGES" = "yes"; then
22    AC_DEFINE(HAVE_HUGE_CODE_PAGES, 1, [Define to enable copying PHP CODE pages into HUGE PAGES (experimental)])
23  fi
24
25  AC_CHECK_FUNC(mprotect,[
26    AC_DEFINE(HAVE_MPROTECT, 1, [Define if you have mprotect() function])
27  ])
28
29  AC_CHECK_HEADERS([unistd.h sys/uio.h])
30
31  AC_CHECK_FUNC(shmget,[
32    AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
33  ])
34
35  AC_CHECK_FUNC(mmap,[
36    AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
37  ])
38
39  AC_MSG_CHECKING(for mmap() using /dev/zero shared memory support)
40  AC_TRY_RUN([
41#include <sys/types.h>
42#include <sys/wait.h>
43#include <sys/mman.h>
44#include <sys/stat.h>
45#include <fcntl.h>
46#include <unistd.h>
47#include <string.h>
48
49#ifndef MAP_FAILED
50# define MAP_FAILED ((void*)-1)
51#endif
52
53int main() {
54  pid_t pid;
55  int status;
56  int fd;
57  char *shm;
58
59  fd = open("/dev/zero", O_RDWR, S_IRUSR | S_IWUSR);
60  if (fd == -1) {
61    return 1;
62  }
63
64  shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
65  if (shm == MAP_FAILED) {
66    return 2;
67  }
68
69  strcpy(shm, "hello");
70
71  pid = fork();
72  if (pid < 0) {
73    return 5;
74  } else if (pid == 0) {
75    strcpy(shm, "bye");
76    return 6;
77  }
78  if (wait(&status) != pid) {
79    return 7;
80  }
81  if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
82    return 8;
83  }
84  if (strcmp(shm, "bye") != 0) {
85    return 9;
86  }
87  return 0;
88}
89],dnl
90    AC_DEFINE(HAVE_SHM_MMAP_ZERO, 1, [Define if you have mmap("/dev/zero") SHM support])
91    msg=yes,msg=no,msg=no)
92  AC_MSG_RESULT([$msg])
93
94  AC_MSG_CHECKING(for mmap() using shm_open() shared memory support)
95  AC_TRY_RUN([
96#include <sys/types.h>
97#include <sys/wait.h>
98#include <sys/mman.h>
99#include <sys/stat.h>
100#include <fcntl.h>
101#include <unistd.h>
102#include <string.h>
103#include <stdlib.h>
104#include <stdio.h>
105
106#ifndef MAP_FAILED
107# define MAP_FAILED ((void*)-1)
108#endif
109
110int main() {
111  pid_t pid;
112  int status;
113  int fd;
114  char *shm;
115  char tmpname[4096];
116
117  sprintf(tmpname,"test.shm.%dXXXXXX", getpid());
118  if (mktemp(tmpname) == NULL) {
119    return 1;
120  }
121  fd = shm_open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
122  if (fd == -1) {
123    return 2;
124  }
125  if (ftruncate(fd, 4096) < 0) {
126    close(fd);
127    shm_unlink(tmpname);
128    return 3;
129  }
130
131  shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
132  if (shm == MAP_FAILED) {
133    return 4;
134  }
135  shm_unlink(tmpname);
136  close(fd);
137
138  strcpy(shm, "hello");
139
140  pid = fork();
141  if (pid < 0) {
142    return 5;
143  } else if (pid == 0) {
144    strcpy(shm, "bye");
145    return 6;
146  }
147  if (wait(&status) != pid) {
148    return 7;
149  }
150  if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
151    return 8;
152  }
153  if (strcmp(shm, "bye") != 0) {
154    return 9;
155  }
156  return 0;
157}
158],dnl
159    AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
160    msg=yes,msg=no,msg=no)
161  AC_MSG_RESULT([$msg])
162
163  AC_MSG_CHECKING(for mmap() using regular file shared memory support)
164  AC_TRY_RUN([
165#include <sys/types.h>
166#include <sys/wait.h>
167#include <sys/mman.h>
168#include <sys/stat.h>
169#include <fcntl.h>
170#include <unistd.h>
171#include <string.h>
172#include <stdlib.h>
173#include <stdio.h>
174
175#ifndef MAP_FAILED
176# define MAP_FAILED ((void*)-1)
177#endif
178
179int main() {
180  pid_t pid;
181  int status;
182  int fd;
183  char *shm;
184  char tmpname[4096];
185
186  sprintf(tmpname,"test.shm.%dXXXXXX", getpid());
187  if (mktemp(tmpname) == NULL) {
188    return 1;
189  }
190  fd = open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
191  if (fd == -1) {
192    return 2;
193  }
194  if (ftruncate(fd, 4096) < 0) {
195    close(fd);
196    unlink(tmpname);
197    return 3;
198  }
199
200  shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
201  if (shm == MAP_FAILED) {
202    return 4;
203  }
204  unlink(tmpname);
205  close(fd);
206
207  strcpy(shm, "hello");
208
209  pid = fork();
210  if (pid < 0) {
211    return 5;
212  } else if (pid == 0) {
213    strcpy(shm, "bye");
214    return 6;
215  }
216  if (wait(&status) != pid) {
217    return 7;
218  }
219  if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
220    return 8;
221  }
222  if (strcmp(shm, "bye") != 0) {
223    return 9;
224  }
225  return 0;
226}
227],dnl
228    AC_DEFINE(HAVE_SHM_MMAP_FILE, 1, [Define if you have mmap() SHM support])
229    msg=yes,msg=no,msg=no)
230  AC_MSG_RESULT([$msg])
231
232flock_type=unknown
233AC_MSG_CHECKING("whether flock struct is linux ordered")
234AC_TRY_RUN([
235  #include <fcntl.h>
236  struct flock lock = { 1, 2, 3, 4, 5 };
237  int main() {
238    if(lock.l_type == 1 && lock.l_whence == 2 && lock.l_start == 3 && lock.l_len == 4) {
239                return 0;
240    }
241    return 1;
242  }
243], [
244        flock_type=linux
245    AC_DEFINE([HAVE_FLOCK_LINUX], [], [Struct flock is Linux-type])
246    AC_MSG_RESULT("yes")
247], [
248    AC_MSG_RESULT("no")
249], [
250    dnl cross-compiling; assume Linux
251        flock_type=linux
252    AC_DEFINE([HAVE_FLOCK_LINUX], [], [Struct flock is Linux-type])
253    AC_MSG_RESULT("yes")
254])
255
256AC_MSG_CHECKING("whether flock struct is BSD ordered")
257AC_TRY_RUN([
258  #include <fcntl.h>
259  struct flock lock = { 1, 2, 3, 4, 5 };
260  int main() {
261    if(lock.l_start == 1 && lock.l_len == 2 && lock.l_type == 4 && lock.l_whence == 5) {
262                return 0;
263    }
264    return 1;
265  }
266], [
267        flock_type=bsd
268    AC_DEFINE([HAVE_FLOCK_BSD], [], [Struct flock is BSD-type])
269    AC_MSG_RESULT("yes")
270], [
271    AC_MSG_RESULT("no")
272], [
273    dnl cross-compiling; assume Linux
274    AC_MSG_RESULT("no")
275])
276
277if test "$flock_type" = "unknown"; then
278        AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])
279fi
280
281  PHP_NEW_EXTENSION(opcache,
282        ZendAccelerator.c \
283        zend_accelerator_blacklist.c \
284        zend_accelerator_debug.c \
285        zend_accelerator_hash.c \
286        zend_accelerator_module.c \
287        zend_persist.c \
288        zend_persist_calc.c \
289        zend_file_cache.c \
290        zend_shared_alloc.c \
291        zend_accelerator_util_funcs.c \
292        shared_alloc_shm.c \
293        shared_alloc_mmap.c \
294        shared_alloc_posix.c \
295        Optimizer/zend_optimizer.c \
296        Optimizer/pass1_5.c \
297        Optimizer/pass2.c \
298        Optimizer/pass3.c \
299        Optimizer/optimize_func_calls.c \
300        Optimizer/block_pass.c \
301        Optimizer/optimize_temp_vars_5.c \
302        Optimizer/nop_removal.c \
303        Optimizer/compact_literals.c \
304        Optimizer/zend_cfg.c \
305        Optimizer/zend_dfg.c \
306        Optimizer/dfa_pass.c \
307        Optimizer/zend_ssa.c \
308        Optimizer/zend_inference.c \
309        Optimizer/zend_func_info.c \
310        Optimizer/zend_call_graph.c \
311        Optimizer/zend_dump.c,
312        shared,,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1,,yes)
313
314  PHP_ADD_BUILD_DIR([$ext_builddir/Optimizer], 1)
315  PHP_ADD_EXTENSION_DEP(opcache, pcre)
316fi
Note: See TracBrowser for help on using the repository browser.