1
0
mirror of https://github.com/php/php-src.git synced 2026-04-04 22:52:40 +02:00

Avoid compilation of unsupported SHM backends

This commit is contained in:
Dmitry Stogov
2013-02-14 10:01:29 +04:00
parent 7334835143
commit bfcbe7849b
5 changed files with 55 additions and 22 deletions

View File

@@ -19,14 +19,16 @@
+----------------------------------------------------------------------+
*/
#include "zend_shared_alloc.h"
#ifdef USE_MMAP
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include "zend_shared_alloc.h"
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
# define MAP_ANONYMOUS MAP_ANON
#endif
@@ -68,3 +70,5 @@ zend_shared_memory_handlers zend_alloc_mmap_handlers = {
detach_segment,
segment_type_size
};
#endif /* USE_MMAP */

View File

@@ -19,6 +19,10 @@
+----------------------------------------------------------------------+
*/
#include "zend_shared_alloc.h"
#ifdef USE_SHM_OPEN
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
@@ -27,8 +31,6 @@
#include <unistd.h>
#include <stdlib.h>
#include "zend_shared_alloc.h"
typedef struct {
zend_shared_segment common;
int shm_fd;
@@ -88,3 +90,5 @@ zend_shared_memory_handlers zend_alloc_posix_handlers = {
(detach_segment_t)detach_segment,
segment_type_size
};
#endif /* USE_SHM_OPEN */

View File

@@ -19,6 +19,10 @@
+----------------------------------------------------------------------+
*/
#include "zend_shared_alloc.h"
#ifdef USE_SHM
#if defined(__FreeBSD__)
# include <machine/param.h>
#endif
@@ -35,8 +39,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include "zend_shared_alloc.h"
#ifndef MIN
# define MIN(x, y) ((x) > (y)? (y) : (x))
#endif
@@ -135,3 +137,5 @@ zend_shared_memory_handlers zend_alloc_shm_handlers = {
(detach_segment_t)detach_segment,
segment_type_size
};
#endif /* USE_SHM */

View File

@@ -58,13 +58,13 @@ static char lockfile_name[sizeof(TMP_DIR)+sizeof(SEM_FILENAME_PREFIX)+8];
#endif
static const zend_shared_memory_handler_entry handler_table[] = {
#if USE_MMAP
#ifdef USE_MMAP
{ "mmap", &zend_alloc_mmap_handlers },
#endif
#if USE_SHM
#ifdef USE_SHM
{ "shm", &zend_alloc_shm_handlers },
#endif
#if USE_SHM_OPEN
#ifdef USE_SHM_OPEN
{ "posix", &zend_alloc_posix_handlers },
#endif
#ifdef ZEND_WIN32

View File

@@ -23,23 +23,44 @@
#define ZEND_SHARED_ALLOC_H
#include "zend.h"
#include "ZendAccelerator.h"
#if defined(__APPLE__) && defined(__MACH__) /* darwin */
# define USE_SHM_OPEN 1
# define USE_MMAP 1
#elif defined(__linux__) || defined(_AIX)
# define USE_SHM 1
# define USE_MMAP 1
#elif defined(__FreeBSD__)
# define USE_SHM_OPEN 1
# define USE_MMAP 1
# define USE_SHM 1
#elif defined(__sparc) || defined(__sun)
# define USE_SHM_OPEN 1
# define USE_SHM 1
# if defined(__i386)
# ifdef HAVE_SHM_MMAP_POSIX
# define USE_SHM_OPEN 1
# endif
# ifdef HAVE_SHM_MMAP_ANON
# define USE_MMAP 1
# endif
#elif defined(__linux__) || defined(_AIX)
# ifdef HAVE_SHM_IPC
# define USE_SHM 1
# endif
# ifdef HAVE_SHM_MMAP_ANON
# define USE_MMAP 1
# endif
#elif defined(__sparc) || defined(__sun)
# ifdef HAVE_SHM_MMAP_POSIX
# define USE_SHM_OPEN 1
# endif
# ifdef HAVE_SHM_IPC
# define USE_SHM 1
# endif
# if defined(__i386)
# ifdef HAVE_SHM_MMAP_ANON
# define USE_MMAP 1
# endif
# endif
#else
# ifdef HAVE_SHM_MMAP_POSIX
# define USE_SHM_OPEN 1
# endif
# ifdef HAVE_SHM_MMAP_ANON
# define USE_MMAP 1
# endif
# ifdef HAVE_SHM_IPC
# define USE_SHM 1
# endif
#endif
#define ALLOC_FAILURE 0