Skip to content

Commit f7fe4cc

Browse files
petknikic
authored andcommitted
Autotools: Sync configure options
- AC_ARG_ENABLE replaced with PHP_ARG_ENABLE - checks sorted - AS_VAR_IF macros used - For checking the Valgrind header, the AC_CHECK_HEADERS is used which defines the HAVE_VALGRIND_MEMCHECK_H preprocessor macro by default - The APC_MMAP preprocessor macro is either undefined or defined to 1 so the `#if` checks are also replaced with `#ifdef` to not cause possible -Wundef warnings emitted if such compiler configuration is set
1 parent cf43c19 commit f7fe4cc

File tree

7 files changed

+54
-62
lines changed

7 files changed

+54
-62
lines changed

apc_cache.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ PHP_APCU_API zend_bool apc_cache_info(zval *info, apc_cache_t *cache, zend_bool
11001100
add_assoc_long(info, "start_time", cache->header->stime);
11011101
array_add_double(info, apc_str_mem_size, (double) cache->header->mem_size);
11021102

1103-
#if APC_MMAP
1103+
#ifdef APC_MMAP
11041104
add_assoc_stringl(info, "memory_type", "mmap", sizeof("mmap")-1);
11051105
#else
11061106
add_assoc_stringl(info, "memory_type", "IPC shared", sizeof("IPC shared")-1);

apc_globals.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ZEND_BEGIN_MODULE_GLOBALS(apcu)
4444
zend_long ttl; /* parameter to apc_cache_create */
4545
zend_long smart; /* smart value */
4646

47-
#if APC_MMAP
47+
#ifdef APC_MMAP
4848
char *mmap_file_mask; /* mktemp-style file-mask to pass to mmap */
4949
#endif
5050

apc_mmap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "apc_mmap.h"
3030
#include "apc_lock.h"
3131

32-
#if APC_MMAP
32+
#ifdef APC_MMAP
3333

3434
#include <fcntl.h>
3535
#include <sys/types.h>

apc_mmap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
/* Wrapper functions for shared memory mapped files */
3737

38-
#if APC_MMAP
38+
#ifdef APC_MMAP
3939
apc_segment_t apc_mmap(char *file_mask, size_t size);
4040
void apc_unmap(apc_segment_t* segment);
4141
#endif

apc_sma.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ PHP_APCU_API void apc_sma_init(apc_sma_t* sma, void** data, apc_sma_expunge_f ex
299299
sma->expunge = expunge;
300300
sma->data = data;
301301

302-
#if APC_MMAP
302+
#ifdef APC_MMAP
303303
/*
304304
* I don't think multiple anonymous mmaps makes any sense
305305
* 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
324324
block_t *first, *empty, *last;
325325
void* shmaddr;
326326

327-
#if APC_MMAP
327+
#ifdef APC_MMAP
328328
sma->segs[i] = apc_mmap(mask, sma->size);
329329
if(sma->num != 1)
330330
memcpy(&mask[strlen(mask)-6], "XXXXXX", 6);
@@ -388,7 +388,7 @@ PHP_APCU_API void apc_sma_detach(apc_sma_t* sma) {
388388
sma->initialized = 0;
389389

390390
for (i = 0; i < sma->num; i++) {
391-
#if APC_MMAP
391+
#ifdef APC_MMAP
392392
apc_unmap(&sma->segs[i]);
393393
#else
394394
apc_shm_detach(&sma->segs[i]);

config.m4

+43-51
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,26 @@ PHP_ARG_ENABLE([apcu-rwlocks],
1010
[yes],
1111
[no])
1212

13-
AC_MSG_CHECKING(if APCu should be built in debug mode)
14-
AC_ARG_ENABLE([apcu-debug],
13+
PHP_ARG_ENABLE([apcu-debug],
14+
[if APCu should be built in debug mode],
1515
[AS_HELP_STRING([--enable-apcu-debug],
1616
[Enable APCu debugging])],
17-
[PHP_APCU_DEBUG=$enableval],
18-
[PHP_APCU_DEBUG=no])
19-
AC_MSG_RESULT($PHP_APCU_DEBUG)
17+
[no],
18+
[no])
2019

21-
AC_MSG_CHECKING(if APCu should clear on SIGUSR1)
22-
AC_ARG_ENABLE([apcu-clear-signal],
20+
PHP_ARG_ENABLE([apcu-clear-signal],
21+
[if APCu should clear on SIGUSR1],
2322
[AS_HELP_STRING([--enable-apcu-clear-signal],
2423
[Enable SIGUSR1 clearing handler])],
25-
[
26-
AC_DEFINE(APC_CLEAR_SIGNAL, 1, [ ])
27-
AC_MSG_RESULT(yes)
28-
],
29-
[
30-
AC_MSG_RESULT(no)
31-
])
32-
33-
PHP_APCU_MMAP=yes
34-
AC_MSG_CHECKING([if APCu will use mmap (or shm)])
35-
AC_ARG_ENABLE([apcu-mmap],
24+
[no],
25+
[no])
26+
27+
PHP_ARG_ENABLE([apcu-mmap],
28+
[if APCu should use mmap instead of shm],
3629
[AS_HELP_STRING([--disable-apcu-mmap],
3730
[Disable mmap, falls back on shm])],
38-
[
39-
if test "x$enableval" = "xno"; then
40-
PHP_APCU_MMAP=no
41-
else
42-
PHP_APCU_MMAP=yes
43-
fi
44-
])
45-
AC_MSG_RESULT($PHP_APCU_MMAP)
31+
[yes],
32+
[no])
4633

4734
PHP_ARG_ENABLE([apcu-spinlocks],
4835
[if APCu should utilize spinlocks before flocks],
@@ -51,7 +38,37 @@ PHP_ARG_ENABLE([apcu-spinlocks],
5138
[no],
5239
[no])
5340

41+
PHP_ARG_ENABLE([valgrind-checks],
42+
[whether to enable Valgrind-based memory checks],
43+
[AS_HELP_STRING([--disable-valgrind-checks],
44+
[Disable Valgrind-based memory checks])],
45+
[yes],
46+
[no])
47+
48+
PHP_ARG_ENABLE([coverage],
49+
[whether to include code coverage symbols],
50+
[AS_HELP_STRING([--enable-coverage],
51+
[Include code coverage symbols (DEVELOPERS ONLY!!)])],
52+
[no],
53+
[no])
54+
5455
if test "$PHP_APCU" != "no"; then
56+
AS_VAR_IF([PHP_APCU_DEBUG], [no], [],
57+
[AC_DEFINE([APC_DEBUG], [1],
58+
[Define to 1 if APCu debugging mode is enabled.])])
59+
60+
AS_VAR_IF([PHP_APCU_CLEAR_SIGNAL], [no], [],
61+
[AC_DEFINE([APC_CLEAR_SIGNAL], [1],
62+
[Define to 1 if SIGUSR1 clearing handler is enabled.])])
63+
64+
AS_VAR_IF([PHP_APCU_MMAP], [no], [],
65+
[AC_DEFINE([APC_MMAP], [1],
66+
[Define to 1 if APCu uses mmap instead of shm.])])
67+
68+
AS_VAR_IF([PHP_VALGRIND_CHECKS], [no], [],
69+
[AC_CHECK_HEADERS([valgrind/memcheck.h], [],
70+
[AC_MSG_NOTICE([Valgrind-based memory checks are disabled.])])])
71+
5572
AS_VAR_IF([PHP_APCU_RWLOCKS], [no], [], [
5673
AC_CACHE_CHECK([whether the target compiler supports builtin atomics],
5774
[PHP_cv_APCU_GCC_ATOMICS],
@@ -65,14 +82,6 @@ if test "$PHP_APCU" != "no"; then
6582
[AC_MSG_FAILURE([Compiler does not support atomics])])
6683
])
6784

68-
if test "$PHP_APCU_DEBUG" != "no"; then
69-
AC_DEFINE(APC_DEBUG, 1, [ ])
70-
fi
71-
72-
if test "$PHP_APCU_MMAP" != "no"; then
73-
AC_DEFINE(APC_MMAP, 1, [ ])
74-
fi
75-
7685
if test "$PHP_APCU_RWLOCKS" != "no"; then
7786
orig_LIBS="$LIBS"
7887
LIBS="$LIBS -lpthread"
@@ -192,16 +201,6 @@ if test "$PHP_APCU" != "no"; then
192201

193202
AC_CHECK_FUNCS(sigaction)
194203

195-
AC_ARG_ENABLE([valgrind-checks],
196-
[AS_HELP_STRING([--disable-valgrind-checks],
197-
[Disable Valgrind based memory checks])],
198-
[PHP_APCU_VALGRIND=no],
199-
[
200-
PHP_APCU_VALGRIND=yes
201-
AC_CHECK_HEADER(valgrind/memcheck.h,
202-
[AC_DEFINE([HAVE_VALGRIND_MEMCHECK_H],1, [enable valgrind memchecks])])
203-
])
204-
205204
for i in -Wall -Wextra -Wno-unused-parameter; do
206205
AX_CHECK_COMPILE_FLAG([$i], [APCU_CFLAGS="$APCU_CFLAGS $i"])
207206
done
@@ -225,13 +224,6 @@ if test "$PHP_APCU" != "no"; then
225224
AC_DEFINE(HAVE_APCU, 1, [ ])
226225
fi
227226

228-
PHP_ARG_ENABLE([coverage],
229-
[whether to include code coverage symbols],
230-
[AS_HELP_STRING([--enable-coverage],
231-
[Include code coverage symbols (DEVELOPERS ONLY!!)])],
232-
[no],
233-
[no])
234-
235227
if test "$PHP_COVERAGE" = "yes"; then
236228

237229
if test "$GCC" != "yes"; then

php_apc.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static void php_apc_init_globals(zend_apcu_globals* apcu_globals)
9494
static PHP_INI_MH(OnUpdateShmSegments) /* {{{ */
9595
{
9696
zend_long shm_segments = ZEND_STRTOL(new_value->val, NULL, 10);
97-
#if APC_MMAP
97+
#ifdef APC_MMAP
9898
if (shm_segments != 1) {
9999
php_error_docref(NULL, E_WARNING, "apc.shm_segments setting ignored in MMAP mode");
100100
}
@@ -139,7 +139,7 @@ STD_PHP_INI_ENTRY("apc.entries_hint", "4096", PHP_INI_SYSTEM, OnUpdateLong,
139139
STD_PHP_INI_ENTRY("apc.gc_ttl", "3600", PHP_INI_SYSTEM, OnUpdateLong, gc_ttl, zend_apcu_globals, apcu_globals)
140140
STD_PHP_INI_ENTRY("apc.ttl", "0", PHP_INI_SYSTEM, OnUpdateLong, ttl, zend_apcu_globals, apcu_globals)
141141
STD_PHP_INI_ENTRY("apc.smart", "0", PHP_INI_SYSTEM, OnUpdateLong, smart, zend_apcu_globals, apcu_globals)
142-
#if APC_MMAP
142+
#ifdef APC_MMAP
143143
STD_PHP_INI_ENTRY("apc.mmap_file_mask", NULL, PHP_INI_SYSTEM, OnUpdateString, mmap_file_mask, zend_apcu_globals, apcu_globals)
144144
#endif
145145
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)
168168
#else
169169
php_info_print_table_row(2, "APCu Debugging", "Disabled");
170170
#endif
171-
#if APC_MMAP
171+
#ifdef APC_MMAP
172172
php_info_print_table_row(2, "MMAP Support", "Enabled");
173173
php_info_print_table_row(2, "MMAP File Mask", APCG(mmap_file_mask));
174174
#else
@@ -235,7 +235,7 @@ static PHP_MINIT_FUNCTION(apcu)
235235
if (APCG(enabled)) {
236236

237237
if (!APCG(initialized)) {
238-
#if APC_MMAP
238+
#ifdef APC_MMAP
239239
char *mmap_file_mask = APCG(mmap_file_mask);
240240
#else
241241
char *mmap_file_mask = NULL;

0 commit comments

Comments
 (0)