You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
3.6 KiB

  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
  5. The detection of sysvipc and mmap doesn't work well when cross-compiling,
  6. so I decided to only check for the availability of the functions involved.
  7. This is not a clean solution, but works for now(tm) :-)
  8. It should be discussed with upstream to find a better solution.
  9. This solves the issue reported at
  10. https://github.com/openwrt/packages/issues/1010
  11. and makes opcache usable on OpenWrt.
  12. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
  13. ---
  14. ext/opcache/config.m4 | 122 ++-----------------------------------------------
  15. 1 file changed, 4 insertions(+), 118 deletions(-)
  16. diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4
  17. index b7e4835..7b6c0aa 100644
  18. --- a/ext/opcache/config.m4
  19. +++ b/ext/opcache/config.m4
  20. @@ -11,127 +11,13 @@ if test "$PHP_OPCACHE" != "no"; then
  21. AC_DEFINE(HAVE_MPROTECT, 1, [Define if you have mprotect() function])
  22. ])
  23. - AC_MSG_CHECKING(for sysvipc shared memory support)
  24. - AC_TRY_RUN([
  25. -#include <sys/types.h>
  26. -#include <sys/wait.h>
  27. -#include <sys/ipc.h>
  28. -#include <sys/shm.h>
  29. -#include <unistd.h>
  30. -#include <string.h>
  31. -
  32. -int main() {
  33. - pid_t pid;
  34. - int status;
  35. - int ipc_id;
  36. - char *shm;
  37. - struct shmid_ds shmbuf;
  38. -
  39. - ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
  40. - if (ipc_id == -1) {
  41. - return 1;
  42. - }
  43. -
  44. - shm = shmat(ipc_id, NULL, 0);
  45. - if (shm == (void *)-1) {
  46. - shmctl(ipc_id, IPC_RMID, NULL);
  47. - return 2;
  48. - }
  49. -
  50. - if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
  51. - shmdt(shm);
  52. - shmctl(ipc_id, IPC_RMID, NULL);
  53. - return 3;
  54. - }
  55. -
  56. - shmbuf.shm_perm.uid = getuid();
  57. - shmbuf.shm_perm.gid = getgid();
  58. - shmbuf.shm_perm.mode = 0600;
  59. -
  60. - if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
  61. - shmdt(shm);
  62. - shmctl(ipc_id, IPC_RMID, NULL);
  63. - return 4;
  64. - }
  65. -
  66. - shmctl(ipc_id, IPC_RMID, NULL);
  67. -
  68. - strcpy(shm, "hello");
  69. -
  70. - pid = fork();
  71. - if (pid < 0) {
  72. - return 5;
  73. - } else if (pid == 0) {
  74. - strcpy(shm, "bye");
  75. - return 6;
  76. - }
  77. - if (wait(&status) != pid) {
  78. - return 7;
  79. - }
  80. - if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
  81. - return 8;
  82. - }
  83. - if (strcmp(shm, "bye") != 0) {
  84. - return 9;
  85. - }
  86. - return 0;
  87. -}
  88. -],dnl
  89. + AC_CHECK_FUNC(shmget,[
  90. AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
  91. - msg=yes,msg=no,msg=no)
  92. - AC_MSG_RESULT([$msg])
  93. -
  94. - AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
  95. - AC_TRY_RUN([
  96. -#include <sys/types.h>
  97. -#include <sys/wait.h>
  98. -#include <sys/mman.h>
  99. -#include <unistd.h>
  100. -#include <string.h>
  101. -
  102. -#ifndef MAP_ANON
  103. -# ifdef MAP_ANONYMOUS
  104. -# define MAP_ANON MAP_ANONYMOUS
  105. -# endif
  106. -#endif
  107. -#ifndef MAP_FAILED
  108. -# define MAP_FAILED ((void*)-1)
  109. -#endif
  110. -
  111. -int main() {
  112. - pid_t pid;
  113. - int status;
  114. - char *shm;
  115. -
  116. - shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
  117. - if (shm == MAP_FAILED) {
  118. - return 1;
  119. - }
  120. -
  121. - strcpy(shm, "hello");
  122. + ])
  123. - pid = fork();
  124. - if (pid < 0) {
  125. - return 5;
  126. - } else if (pid == 0) {
  127. - strcpy(shm, "bye");
  128. - return 6;
  129. - }
  130. - if (wait(&status) != pid) {
  131. - return 7;
  132. - }
  133. - if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
  134. - return 8;
  135. - }
  136. - if (strcmp(shm, "bye") != 0) {
  137. - return 9;
  138. - }
  139. - return 0;
  140. -}
  141. -],dnl
  142. + AC_CHECK_FUNC(mmap,[
  143. AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
  144. - msg=yes,msg=no,msg=no)
  145. - AC_MSG_RESULT([$msg])
  146. + ])
  147. AC_MSG_CHECKING(for mmap() using /dev/zero shared memory support)
  148. AC_TRY_RUN([
  149. --
  150. 1.7.10.4