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. @@ -28,127 +28,13 @@ if test "$PHP_OPCACHE" != "no"; then
  21. AC_CHECK_HEADERS([unistd.h sys/uio.h])
  22. - AC_MSG_CHECKING(for sysvipc shared memory support)
  23. - AC_TRY_RUN([
  24. -#include <sys/types.h>
  25. -#include <sys/wait.h>
  26. -#include <sys/ipc.h>
  27. -#include <sys/shm.h>
  28. -#include <unistd.h>
  29. -#include <string.h>
  30. -
  31. -int main() {
  32. - pid_t pid;
  33. - int status;
  34. - int ipc_id;
  35. - char *shm;
  36. - struct shmid_ds shmbuf;
  37. -
  38. - ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
  39. - if (ipc_id == -1) {
  40. - return 1;
  41. - }
  42. -
  43. - shm = shmat(ipc_id, NULL, 0);
  44. - if (shm == (void *)-1) {
  45. - shmctl(ipc_id, IPC_RMID, NULL);
  46. - return 2;
  47. - }
  48. -
  49. - if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
  50. - shmdt(shm);
  51. - shmctl(ipc_id, IPC_RMID, NULL);
  52. - return 3;
  53. - }
  54. -
  55. - shmbuf.shm_perm.uid = getuid();
  56. - shmbuf.shm_perm.gid = getgid();
  57. - shmbuf.shm_perm.mode = 0600;
  58. -
  59. - if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
  60. - shmdt(shm);
  61. - shmctl(ipc_id, IPC_RMID, NULL);
  62. - return 4;
  63. - }
  64. -
  65. - shmctl(ipc_id, IPC_RMID, NULL);
  66. -
  67. - strcpy(shm, "hello");
  68. -
  69. - pid = fork();
  70. - if (pid < 0) {
  71. - return 5;
  72. - } else if (pid == 0) {
  73. - strcpy(shm, "bye");
  74. - return 6;
  75. - }
  76. - if (wait(&status) != pid) {
  77. - return 7;
  78. - }
  79. - if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
  80. - return 8;
  81. - }
  82. - if (strcmp(shm, "bye") != 0) {
  83. - return 9;
  84. - }
  85. - return 0;
  86. -}
  87. -],dnl
  88. + AC_CHECK_FUNC(shmget,[
  89. AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
  90. - msg=yes,msg=no,msg=no)
  91. - AC_MSG_RESULT([$msg])
  92. -
  93. - AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
  94. - AC_TRY_RUN([
  95. -#include <sys/types.h>
  96. -#include <sys/wait.h>
  97. -#include <sys/mman.h>
  98. -#include <unistd.h>
  99. -#include <string.h>
  100. -
  101. -#ifndef MAP_ANON
  102. -# ifdef MAP_ANONYMOUS
  103. -# define MAP_ANON MAP_ANONYMOUS
  104. -# endif
  105. -#endif
  106. -#ifndef MAP_FAILED
  107. -# define MAP_FAILED ((void*)-1)
  108. -#endif
  109. -
  110. -int main() {
  111. - pid_t pid;
  112. - int status;
  113. - char *shm;
  114. -
  115. - shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
  116. - if (shm == MAP_FAILED) {
  117. - return 1;
  118. - }
  119. -
  120. - strcpy(shm, "hello");
  121. + ])
  122. - pid = fork();
  123. - if (pid < 0) {
  124. - return 5;
  125. - } else if (pid == 0) {
  126. - strcpy(shm, "bye");
  127. - return 6;
  128. - }
  129. - if (wait(&status) != pid) {
  130. - return 7;
  131. - }
  132. - if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
  133. - return 8;
  134. - }
  135. - if (strcmp(shm, "bye") != 0) {
  136. - return 9;
  137. - }
  138. - return 0;
  139. -}
  140. -],dnl
  141. + AC_CHECK_FUNC(mmap,[
  142. AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
  143. - msg=yes,msg=no,msg=no)
  144. - AC_MSG_RESULT([$msg])
  145. + ])
  146. AC_MSG_CHECKING(for mmap() using /dev/zero shared memory support)
  147. AC_TRY_RUN([
  148. --
  149. 1.7.10.4