123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- dnl
- dnl $Id$
- dnl
- PHP_ARG_ENABLE(opcache, whether to enable Zend OPcache support,
- [ --enable-opcache Enable Zend OPcache support], yes)
- if test "$PHP_OPCACHE" != "no"; then
- AC_CHECK_FUNC(mprotect,[
- AC_DEFINE(HAVE_MPROTECT, 1, [Define if you have mprotect() function])
- ])
- AC_MSG_CHECKING(for sysvipc shared memory support)
- AC_TRY_RUN([
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <unistd.h>
- #include <string.h>
- int main() {
- pid_t pid;
- int status;
- int ipc_id;
- char *shm;
- struct shmid_ds shmbuf;
- ipc_id = shmget(IPC_PRIVATE, 4096, (IPC_CREAT | SHM_R | SHM_W));
- if (ipc_id == -1) {
- return 1;
- }
- shm = shmat(ipc_id, NULL, 0);
- if (shm == (void *)-1) {
- shmctl(ipc_id, IPC_RMID, NULL);
- return 2;
- }
- if (shmctl(ipc_id, IPC_STAT, &shmbuf) != 0) {
- shmdt(shm);
- shmctl(ipc_id, IPC_RMID, NULL);
- return 3;
- }
- shmbuf.shm_perm.uid = getuid();
- shmbuf.shm_perm.gid = getgid();
- shmbuf.shm_perm.mode = 0600;
- if (shmctl(ipc_id, IPC_SET, &shmbuf) != 0) {
- shmdt(shm);
- shmctl(ipc_id, IPC_RMID, NULL);
- return 4;
- }
- shmctl(ipc_id, IPC_RMID, NULL);
- strcpy(shm, "hello");
- pid = fork();
- if (pid < 0) {
- return 5;
- } else if (pid == 0) {
- strcpy(shm, "bye");
- return 6;
- }
- if (wait(&status) != pid) {
- return 7;
- }
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
- return 8;
- }
- if (strcmp(shm, "bye") != 0) {
- return 9;
- }
- return 0;
- }
- ],dnl
- AC_DEFINE(HAVE_SHM_IPC, 1, [Define if you have SysV IPC SHM support])
- msg=yes,msg=no,msg=no)
- AC_MSG_RESULT([$msg])
- AC_MSG_CHECKING(for mmap() using MAP_ANON shared memory support)
- AC_TRY_RUN([
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <sys/mman.h>
- #include <unistd.h>
- #include <string.h>
- #ifndef MAP_ANON
- # ifdef MAP_ANONYMOUS
- # define MAP_ANON MAP_ANONYMOUS
- # endif
- #endif
- #ifndef MAP_FAILED
- # define MAP_FAILED ((void*)-1)
- #endif
- int main() {
- pid_t pid;
- int status;
- char *shm;
- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
- if (shm == MAP_FAILED) {
- return 1;
- }
- strcpy(shm, "hello");
- pid = fork();
- if (pid < 0) {
- return 5;
- } else if (pid == 0) {
- strcpy(shm, "bye");
- return 6;
- }
- if (wait(&status) != pid) {
- return 7;
- }
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
- return 8;
- }
- if (strcmp(shm, "bye") != 0) {
- return 9;
- }
- return 0;
- }
- ],dnl
- AC_DEFINE(HAVE_SHM_MMAP_ANON, 1, [Define if you have mmap(MAP_ANON) SHM support])
- msg=yes,msg=no,msg=no)
- AC_MSG_RESULT([$msg])
- AC_MSG_CHECKING(for mmap() using /dev/zero shared memory support)
- AC_TRY_RUN([
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <sys/mman.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- #ifndef MAP_FAILED
- # define MAP_FAILED ((void*)-1)
- #endif
- int main() {
- pid_t pid;
- int status;
- int fd;
- char *shm;
- fd = open("/dev/zero", O_RDWR, S_IRUSR | S_IWUSR);
- if (fd == -1) {
- return 1;
- }
- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (shm == MAP_FAILED) {
- return 2;
- }
- strcpy(shm, "hello");
- pid = fork();
- if (pid < 0) {
- return 5;
- } else if (pid == 0) {
- strcpy(shm, "bye");
- return 6;
- }
- if (wait(&status) != pid) {
- return 7;
- }
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
- return 8;
- }
- if (strcmp(shm, "bye") != 0) {
- return 9;
- }
- return 0;
- }
- ],dnl
- AC_DEFINE(HAVE_SHM_MMAP_ZERO, 1, [Define if you have mmap("/dev/zero") SHM support])
- msg=yes,msg=no,msg=no)
- AC_MSG_RESULT([$msg])
- AC_MSG_CHECKING(for mmap() using shm_open() shared memory support)
- AC_TRY_RUN([
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <sys/mman.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #ifndef MAP_FAILED
- # define MAP_FAILED ((void*)-1)
- #endif
- int main() {
- pid_t pid;
- int status;
- int fd;
- char *shm;
- char tmpname[4096];
- sprintf(tmpname,"test.shm.%dXXXXXX", getpid());
- if (mktemp(tmpname) == NULL) {
- return 1;
- }
- fd = shm_open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
- if (fd == -1) {
- return 2;
- }
- if (ftruncate(fd, 4096) < 0) {
- close(fd);
- shm_unlink(tmpname);
- return 3;
- }
- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (shm == MAP_FAILED) {
- return 4;
- }
- shm_unlink(tmpname);
- close(fd);
- strcpy(shm, "hello");
- pid = fork();
- if (pid < 0) {
- return 5;
- } else if (pid == 0) {
- strcpy(shm, "bye");
- return 6;
- }
- if (wait(&status) != pid) {
- return 7;
- }
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
- return 8;
- }
- if (strcmp(shm, "bye") != 0) {
- return 9;
- }
- return 0;
- }
- ],dnl
- AC_DEFINE(HAVE_SHM_MMAP_POSIX, 1, [Define if you have POSIX mmap() SHM support])
- msg=yes,msg=no,msg=no)
- AC_MSG_RESULT([$msg])
- AC_MSG_CHECKING(for mmap() using regular file shared memory support)
- AC_TRY_RUN([
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <sys/mman.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #ifndef MAP_FAILED
- # define MAP_FAILED ((void*)-1)
- #endif
- int main() {
- pid_t pid;
- int status;
- int fd;
- char *shm;
- char tmpname[4096];
- sprintf(tmpname,"test.shm.%dXXXXXX", getpid());
- if (mktemp(tmpname) == NULL) {
- return 1;
- }
- fd = open(tmpname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
- if (fd == -1) {
- return 2;
- }
- if (ftruncate(fd, 4096) < 0) {
- close(fd);
- unlink(tmpname);
- return 3;
- }
- shm = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (shm == MAP_FAILED) {
- return 4;
- }
- unlink(tmpname);
- close(fd);
- strcpy(shm, "hello");
- pid = fork();
- if (pid < 0) {
- return 5;
- } else if (pid == 0) {
- strcpy(shm, "bye");
- return 6;
- }
- if (wait(&status) != pid) {
- return 7;
- }
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 6) {
- return 8;
- }
- if (strcmp(shm, "bye") != 0) {
- return 9;
- }
- return 0;
- }
- ],dnl
- AC_DEFINE(HAVE_SHM_MMAP_FILE, 1, [Define if you have mmap() SHM support])
- msg=yes,msg=no,msg=no)
- AC_MSG_RESULT([$msg])
- flock_type=unknown
- AC_MSG_CHECKING("whether flock struct is linux ordered")
- AC_TRY_RUN([
- #include <fcntl.h>
- struct flock lock = { 1, 2, 3, 4, 5 };
- int main() {
- if(lock.l_type == 1 && lock.l_whence == 2 && lock.l_start == 3 && lock.l_len == 4) {
- return 0;
- }
- return 1;
- }
- ], [
- flock_type=linux
- AC_DEFINE([HAVE_FLOCK_LINUX], [], [Struct flock is Linux-type])
- AC_MSG_RESULT("yes")
- ], AC_MSG_RESULT("no") )
- AC_MSG_CHECKING("whether flock struct is BSD ordered")
- AC_TRY_RUN([
- #include <fcntl.h>
- struct flock lock = { 1, 2, 3, 4, 5 };
- int main() {
- if(lock.l_start == 1 && lock.l_len == 2 && lock.l_type == 4 && lock.l_whence == 5) {
- return 0;
- }
- return 1;
- }
- ], [
- flock_type=bsd
- AC_DEFINE([HAVE_FLOCK_BSD], [], [Struct flock is BSD-type])
- AC_MSG_RESULT("yes")
- ], AC_MSG_RESULT("no") )
- if test "$flock_type" = "unknown"; then
- AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])
- fi
- PHP_NEW_EXTENSION(opcache,
- ZendAccelerator.c \
- zend_accelerator_blacklist.c \
- zend_accelerator_debug.c \
- zend_accelerator_hash.c \
- zend_accelerator_module.c \
- zend_persist.c \
- zend_persist_calc.c \
- zend_shared_alloc.c \
- zend_accelerator_util_funcs.c \
- shared_alloc_shm.c \
- shared_alloc_mmap.c \
- shared_alloc_posix.c \
- Optimizer/zend_optimizer.c,
- shared,,,,yes)
- PHP_ADD_BUILD_DIR([$ext_builddir/Optimizer], 1)
- fi
|