config.m4 7.5 KB

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