diff --git a/apc_cache.c b/apc_cache.c index baa19ce..142f0d4 100644 --- a/apc_cache.c +++ b/apc_cache.c @@ -1100,7 +1100,7 @@ PHP_APCU_API zend_bool apc_cache_info(zval *info, apc_cache_t *cache, zend_bool add_assoc_long(info, "start_time", cache->header->stime); array_add_double(info, apc_str_mem_size, (double) cache->header->mem_size); -#if APC_MMAP +#ifdef APC_MMAP add_assoc_stringl(info, "memory_type", "mmap", sizeof("mmap")-1); #else add_assoc_stringl(info, "memory_type", "IPC shared", sizeof("IPC shared")-1); diff --git a/apc_globals.h b/apc_globals.h index c0a4436..8ad84a3 100644 --- a/apc_globals.h +++ b/apc_globals.h @@ -44,7 +44,7 @@ ZEND_BEGIN_MODULE_GLOBALS(apcu) zend_long ttl; /* parameter to apc_cache_create */ zend_long smart; /* smart value */ -#if APC_MMAP +#ifdef APC_MMAP char *mmap_file_mask; /* mktemp-style file-mask to pass to mmap */ #endif diff --git a/apc_mmap.c b/apc_mmap.c index 9337d45..faabf93 100644 --- a/apc_mmap.c +++ b/apc_mmap.c @@ -29,7 +29,7 @@ #include "apc_mmap.h" #include "apc_lock.h" -#if APC_MMAP +#ifdef APC_MMAP #include #include diff --git a/apc_mmap.h b/apc_mmap.h index 16ababc..30eec9f 100644 --- a/apc_mmap.h +++ b/apc_mmap.h @@ -35,7 +35,7 @@ /* Wrapper functions for shared memory mapped files */ -#if APC_MMAP +#ifdef APC_MMAP apc_segment_t apc_mmap(char *file_mask, size_t size); void apc_unmap(apc_segment_t* segment); #endif diff --git a/apc_sma.c b/apc_sma.c index 751c325..b0bbbc8 100644 --- a/apc_sma.c +++ b/apc_sma.c @@ -299,7 +299,7 @@ PHP_APCU_API void apc_sma_init(apc_sma_t* sma, void** data, apc_sma_expunge_f ex sma->expunge = expunge; sma->data = data; -#if APC_MMAP +#ifdef APC_MMAP /* * I don't think multiple anonymous mmaps makes any sense * so force sma_numseg to 1 in this case @@ -324,7 +324,7 @@ PHP_APCU_API void apc_sma_init(apc_sma_t* sma, void** data, apc_sma_expunge_f ex block_t *first, *empty, *last; void* shmaddr; -#if APC_MMAP +#ifdef APC_MMAP sma->segs[i] = apc_mmap(mask, sma->size); if(sma->num != 1) memcpy(&mask[strlen(mask)-6], "XXXXXX", 6); @@ -388,7 +388,7 @@ PHP_APCU_API void apc_sma_detach(apc_sma_t* sma) { sma->initialized = 0; for (i = 0; i < sma->num; i++) { -#if APC_MMAP +#ifdef APC_MMAP apc_unmap(&sma->segs[i]); #else apc_shm_detach(&sma->segs[i]); diff --git a/config.m4 b/config.m4 index c14402c..47edf36 100644 --- a/config.m4 +++ b/config.m4 @@ -10,39 +10,26 @@ PHP_ARG_ENABLE([apcu-rwlocks], [yes], [no]) -AC_MSG_CHECKING(if APCu should be built in debug mode) -AC_ARG_ENABLE([apcu-debug], +PHP_ARG_ENABLE([apcu-debug], + [if APCu should be built in debug mode], [AS_HELP_STRING([--enable-apcu-debug], [Enable APCu debugging])], - [PHP_APCU_DEBUG=$enableval], - [PHP_APCU_DEBUG=no]) -AC_MSG_RESULT($PHP_APCU_DEBUG) + [no], + [no]) -AC_MSG_CHECKING(if APCu should clear on SIGUSR1) -AC_ARG_ENABLE([apcu-clear-signal], +PHP_ARG_ENABLE([apcu-clear-signal], + [if APCu should clear on SIGUSR1], [AS_HELP_STRING([--enable-apcu-clear-signal], [Enable SIGUSR1 clearing handler])], -[ - AC_DEFINE(APC_CLEAR_SIGNAL, 1, [ ]) - AC_MSG_RESULT(yes) -], -[ - AC_MSG_RESULT(no) -]) - -PHP_APCU_MMAP=yes -AC_MSG_CHECKING([if APCu will use mmap (or shm)]) -AC_ARG_ENABLE([apcu-mmap], + [no], + [no]) + +PHP_ARG_ENABLE([apcu-mmap], + [if APCu should use mmap instead of shm], [AS_HELP_STRING([--disable-apcu-mmap], [Disable mmap, falls back on shm])], -[ - if test "x$enableval" = "xno"; then - PHP_APCU_MMAP=no - else - PHP_APCU_MMAP=yes - fi -]) -AC_MSG_RESULT($PHP_APCU_MMAP) + [yes], + [no]) PHP_ARG_ENABLE([apcu-spinlocks], [if APCu should utilize spinlocks before flocks], @@ -51,7 +38,37 @@ PHP_ARG_ENABLE([apcu-spinlocks], [no], [no]) +PHP_ARG_ENABLE([valgrind-checks], + [whether to enable Valgrind-based memory checks], + [AS_HELP_STRING([--disable-valgrind-checks], + [Disable Valgrind-based memory checks])], + [yes], + [no]) + +PHP_ARG_ENABLE([coverage], + [whether to include code coverage symbols], + [AS_HELP_STRING([--enable-coverage], + [Include code coverage symbols (DEVELOPERS ONLY!!)])], + [no], + [no]) + if test "$PHP_APCU" != "no"; then + AS_VAR_IF([PHP_APCU_DEBUG], [no], [], + [AC_DEFINE([APC_DEBUG], [1], + [Define to 1 if APCu debugging mode is enabled.])]) + + AS_VAR_IF([PHP_APCU_CLEAR_SIGNAL], [no], [], + [AC_DEFINE([APC_CLEAR_SIGNAL], [1], + [Define to 1 if SIGUSR1 clearing handler is enabled.])]) + + AS_VAR_IF([PHP_APCU_MMAP], [no], [], + [AC_DEFINE([APC_MMAP], [1], + [Define to 1 if APCu uses mmap instead of shm.])]) + + AS_VAR_IF([PHP_VALGRIND_CHECKS], [no], [], + [AC_CHECK_HEADERS([valgrind/memcheck.h], [], + [AC_MSG_NOTICE([Valgrind-based memory checks are disabled.])])]) + AS_VAR_IF([PHP_APCU_RWLOCKS], [no], [], [ AC_CACHE_CHECK([whether the target compiler supports builtin atomics], [PHP_cv_APCU_GCC_ATOMICS], @@ -65,14 +82,6 @@ if test "$PHP_APCU" != "no"; then [AC_MSG_FAILURE([Compiler does not support atomics])]) ]) - if test "$PHP_APCU_DEBUG" != "no"; then - AC_DEFINE(APC_DEBUG, 1, [ ]) - fi - - if test "$PHP_APCU_MMAP" != "no"; then - AC_DEFINE(APC_MMAP, 1, [ ]) - fi - if test "$PHP_APCU_RWLOCKS" != "no"; then orig_LIBS="$LIBS" LIBS="$LIBS -lpthread" @@ -192,16 +201,6 @@ if test "$PHP_APCU" != "no"; then AC_CHECK_FUNCS(sigaction) - AC_ARG_ENABLE([valgrind-checks], - [AS_HELP_STRING([--disable-valgrind-checks], - [Disable Valgrind based memory checks])], - [PHP_APCU_VALGRIND=no], - [ - PHP_APCU_VALGRIND=yes - AC_CHECK_HEADER(valgrind/memcheck.h, - [AC_DEFINE([HAVE_VALGRIND_MEMCHECK_H],1, [enable valgrind memchecks])]) - ]) - for i in -Wall -Wextra -Wno-unused-parameter; do AX_CHECK_COMPILE_FLAG([$i], [APCU_CFLAGS="$APCU_CFLAGS $i"]) done @@ -225,13 +224,6 @@ if test "$PHP_APCU" != "no"; then AC_DEFINE(HAVE_APCU, 1, [ ]) fi -PHP_ARG_ENABLE([coverage], - [whether to include code coverage symbols], - [AS_HELP_STRING([--enable-coverage], - [Include code coverage symbols (DEVELOPERS ONLY!!)])], - [no], - [no]) - if test "$PHP_COVERAGE" = "yes"; then if test "$GCC" != "yes"; then diff --git a/php_apc.c b/php_apc.c index 6193d89..d00b5f3 100644 --- a/php_apc.c +++ b/php_apc.c @@ -94,7 +94,7 @@ static void php_apc_init_globals(zend_apcu_globals* apcu_globals) static PHP_INI_MH(OnUpdateShmSegments) /* {{{ */ { zend_long shm_segments = ZEND_STRTOL(new_value->val, NULL, 10); -#if APC_MMAP +#ifdef APC_MMAP if (shm_segments != 1) { php_error_docref(NULL, E_WARNING, "apc.shm_segments setting ignored in MMAP mode"); } @@ -139,7 +139,7 @@ STD_PHP_INI_ENTRY("apc.entries_hint", "4096", PHP_INI_SYSTEM, OnUpdateLong, STD_PHP_INI_ENTRY("apc.gc_ttl", "3600", PHP_INI_SYSTEM, OnUpdateLong, gc_ttl, zend_apcu_globals, apcu_globals) STD_PHP_INI_ENTRY("apc.ttl", "0", PHP_INI_SYSTEM, OnUpdateLong, ttl, zend_apcu_globals, apcu_globals) STD_PHP_INI_ENTRY("apc.smart", "0", PHP_INI_SYSTEM, OnUpdateLong, smart, zend_apcu_globals, apcu_globals) -#if APC_MMAP +#ifdef APC_MMAP STD_PHP_INI_ENTRY("apc.mmap_file_mask", NULL, PHP_INI_SYSTEM, OnUpdateString, mmap_file_mask, zend_apcu_globals, apcu_globals) #endif STD_PHP_INI_BOOLEAN("apc.enable_cli", "0", PHP_INI_SYSTEM, OnUpdateBool, enable_cli, zend_apcu_globals, apcu_globals) @@ -168,7 +168,7 @@ static PHP_MINFO_FUNCTION(apcu) #else php_info_print_table_row(2, "APCu Debugging", "Disabled"); #endif -#if APC_MMAP +#ifdef APC_MMAP php_info_print_table_row(2, "MMAP Support", "Enabled"); php_info_print_table_row(2, "MMAP File Mask", APCG(mmap_file_mask)); #else @@ -235,7 +235,7 @@ static PHP_MINIT_FUNCTION(apcu) if (APCG(enabled)) { if (!APCG(initialized)) { -#if APC_MMAP +#ifdef APC_MMAP char *mmap_file_mask = APCG(mmap_file_mask); #else char *mmap_file_mask = NULL;