Skip to content

Commit 5bebd89

Browse files
TysonAndrenikic
authored andcommitted
[skip ci] Add editorconfig file for APCu
https://editorconfig.org/ has integrations with many editors/IDEs to apply project-specific settings (e.g. to consistently use tabs) https://www.php-fig.org/psr/psr-12/ recommends using spaces for php code. Replace the mix of tabs and spaces in config.m4 with spaces.
1 parent 5acb4cc commit 5bebd89

File tree

3 files changed

+139
-120
lines changed

3 files changed

+139
-120
lines changed

.editorconfig

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; 4 space indentation (no size specified)
2+
[*]
3+
charset = utf-8
4+
indent_style = tab
5+
indent_size = 4
6+
[*.{php,c,h,m4,w32,md}]
7+
trim_trailing_whitespace = true
8+
[*.{phpt,php}]
9+
indent_style = space
10+
[*.xml]
11+
indent_size = 1
12+
indent_style = space
13+
[*.m4]
14+
indent_size = 2
15+
indent_style = space
16+
[*.w32]
17+
charset = utf-8
18+
indent_style = tab
19+
indent_size = 2

apc_mutex.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ typedef apc_lock_t apc_mutex_t;
5050

5151
// Fallback to normal locks
5252

53-
#define APC_MUTEX_INIT()
54-
#define APC_MUTEX_CLEANUP()
53+
#define APC_MUTEX_INIT()
54+
#define APC_MUTEX_CLEANUP()
5555

5656
#define APC_CREATE_MUTEX(lock) CREATE_LOCK(lock)
5757
#define APC_DESTROY_MUTEX(lock) DESTROY_LOCK(lock)

config.m4

+118-118
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ AC_ARG_ENABLE(apcu-debug,
1818
[ --enable-apcu-debug Enable APCu debugging],
1919
[
2020
PHP_APCU_DEBUG=$enableval
21-
],
21+
],
2222
[
2323
PHP_APCU_DEBUG=no
2424
])
@@ -61,133 +61,133 @@ AC_ARG_ENABLE(apcu-spinlocks,
6161
AC_MSG_RESULT($PHP_APCU_SPINLOCK)
6262

6363
if test "$PHP_APCU_RWLOCKS" != "no"; then
64-
AC_CACHE_CHECK([whether the target compiler supports builtin atomics], PHP_cv_APCU_GCC_ATOMICS, [
65-
66-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
67-
int foo = 0;
68-
__sync_add_and_fetch(&foo, 1);
69-
__sync_sub_and_fetch(&foo, 1);
70-
return 0;
71-
]])],[PHP_cv_APCU_GCC_ATOMICS=yes],[PHP_cv_APCU_GCC_ATOMICS=no])
72-
])
73-
74-
if test "x${PHP_cv_APCU_GCC_ATOMICS}" != "xyes"; then
75-
AC_MSG_ERROR([Compiler does not support atomics])
76-
fi
64+
AC_CACHE_CHECK([whether the target compiler supports builtin atomics], PHP_cv_APCU_GCC_ATOMICS, [
65+
66+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
67+
int foo = 0;
68+
__sync_add_and_fetch(&foo, 1);
69+
__sync_sub_and_fetch(&foo, 1);
70+
return 0;
71+
]])],[PHP_cv_APCU_GCC_ATOMICS=yes],[PHP_cv_APCU_GCC_ATOMICS=no])
72+
])
73+
74+
if test "x${PHP_cv_APCU_GCC_ATOMICS}" != "xyes"; then
75+
AC_MSG_ERROR([Compiler does not support atomics])
76+
fi
7777
fi
7878

7979
if test "$PHP_APCU" != "no"; then
80-
if test "$PHP_APCU_DEBUG" != "no"; then
81-
AC_DEFINE(APC_DEBUG, 1, [ ])
82-
fi
83-
84-
if test "$PHP_APCU_MMAP" != "no"; then
85-
AC_DEFINE(APC_MMAP, 1, [ ])
86-
fi
80+
if test "$PHP_APCU_DEBUG" != "no"; then
81+
AC_DEFINE(APC_DEBUG, 1, [ ])
82+
fi
83+
84+
if test "$PHP_APCU_MMAP" != "no"; then
85+
AC_DEFINE(APC_MMAP, 1, [ ])
86+
fi
8787

8888
if test "$PHP_APCU_RWLOCKS" != "no"; then
89-
orig_LIBS="$LIBS"
90-
LIBS="$LIBS -lpthread"
89+
orig_LIBS="$LIBS"
90+
LIBS="$LIBS -lpthread"
9191
AC_MSG_CHECKING([for pthread rwlocks])
92-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
93-
#include <sys/types.h>
94-
#include <pthread.h>
92+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
93+
#include <sys/types.h>
94+
#include <pthread.h>
9595
#include <stdio.h>
9696
int main() {
97-
pthread_rwlock_t rwlock;
98-
pthread_rwlockattr_t attr;
99-
100-
if(pthread_rwlockattr_init(&attr)) {
101-
puts("Unable to initialize pthread attributes (pthread_rwlockattr_init).");
102-
return -1;
103-
}
104-
if(pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) {
105-
puts("Unable to set PTHREAD_PROCESS_SHARED (pthread_rwlockattr_setpshared), your system may not support shared rwlock's.");
106-
return -1;
107-
}
108-
if(pthread_rwlock_init(&rwlock, &attr)) {
109-
puts("Unable to initialize the rwlock (pthread_rwlock_init).");
110-
return -1;
111-
}
112-
if(pthread_rwlockattr_destroy(&attr)) {
113-
puts("Unable to destroy rwlock attributes (pthread_rwlockattr_destroy).");
114-
return -1;
115-
}
116-
if(pthread_rwlock_destroy(&rwlock)) {
117-
puts("Unable to destroy rwlock (pthread_rwlock_destroy).");
118-
return -1;
119-
}
120-
121-
return 0;
97+
pthread_rwlock_t rwlock;
98+
pthread_rwlockattr_t attr;
99+
100+
if(pthread_rwlockattr_init(&attr)) {
101+
puts("Unable to initialize pthread attributes (pthread_rwlockattr_init).");
102+
return -1;
103+
}
104+
if(pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) {
105+
puts("Unable to set PTHREAD_PROCESS_SHARED (pthread_rwlockattr_setpshared), your system may not support shared rwlock's.");
106+
return -1;
107+
}
108+
if(pthread_rwlock_init(&rwlock, &attr)) {
109+
puts("Unable to initialize the rwlock (pthread_rwlock_init).");
110+
return -1;
111+
}
112+
if(pthread_rwlockattr_destroy(&attr)) {
113+
puts("Unable to destroy rwlock attributes (pthread_rwlockattr_destroy).");
114+
return -1;
115+
}
116+
if(pthread_rwlock_destroy(&rwlock)) {
117+
puts("Unable to destroy rwlock (pthread_rwlock_destroy).");
118+
return -1;
119+
}
120+
121+
return 0;
122122
}
123-
]])],[ dnl -Success-
124-
APCU_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
125-
PHP_ADD_LIBRARY(pthread)
126-
PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
127-
AC_DEFINE(APC_NATIVE_RWLOCK, 1, [ ])
128-
AC_MSG_RESULT([yes])
129-
],[ dnl -Failure-
130-
AC_MSG_RESULT([no])
131-
PHP_APCU_RWLOCKS=no
132-
],[
133-
APCU_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
134-
PHP_ADD_LIBRARY(pthread)
135-
PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
123+
]])],[ dnl -Success-
124+
APCU_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
125+
PHP_ADD_LIBRARY(pthread)
126+
PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
127+
AC_DEFINE(APC_NATIVE_RWLOCK, 1, [ ])
128+
AC_MSG_RESULT([yes])
129+
],[ dnl -Failure-
130+
AC_MSG_RESULT([no])
131+
PHP_APCU_RWLOCKS=no
132+
],[
133+
APCU_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
134+
PHP_ADD_LIBRARY(pthread)
135+
PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
136136
])
137137
LIBS="$orig_LIBS"
138138
fi
139-
139+
140140
if test "$PHP_APCU" != "no"; then
141141
orig_LIBS="$LIBS"
142-
LIBS="$LIBS -lpthread"
142+
LIBS="$LIBS -lpthread"
143143
AC_MSG_CHECKING([for pthread mutexes])
144-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
145-
#include <sys/types.h>
146-
#include <pthread.h>
144+
AC_RUN_IFELSE([AC_LANG_SOURCE([[
145+
#include <sys/types.h>
146+
#include <pthread.h>
147147
#include <stdio.h>
148148
int main() {
149-
pthread_mutex_t mutex;
150-
pthread_mutexattr_t attr;
151-
152-
if(pthread_mutexattr_init(&attr)) {
153-
puts("Unable to initialize pthread attributes (pthread_mutexattr_init).");
154-
return -1;
155-
}
156-
if(pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) {
157-
puts("Unable to set PTHREAD_PROCESS_SHARED (pthread_mutexattr_setpshared), your system may not support shared mutex's.");
158-
return -1;
159-
}
160-
if(pthread_mutex_init(&mutex, &attr)) {
161-
puts("Unable to initialize the mutex (pthread_mutex_init).");
162-
return -1;
163-
}
164-
if(pthread_mutexattr_destroy(&attr)) {
165-
puts("Unable to destroy mutex attributes (pthread_mutexattr_destroy).");
166-
return -1;
167-
}
168-
if(pthread_mutex_destroy(&mutex)) {
169-
puts("Unable to destroy mutex (pthread_mutex_destroy).");
170-
return -1;
171-
}
172-
return 0;
149+
pthread_mutex_t mutex;
150+
pthread_mutexattr_t attr;
151+
152+
if(pthread_mutexattr_init(&attr)) {
153+
puts("Unable to initialize pthread attributes (pthread_mutexattr_init).");
154+
return -1;
155+
}
156+
if(pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) {
157+
puts("Unable to set PTHREAD_PROCESS_SHARED (pthread_mutexattr_setpshared), your system may not support shared mutex's.");
158+
return -1;
159+
}
160+
if(pthread_mutex_init(&mutex, &attr)) {
161+
puts("Unable to initialize the mutex (pthread_mutex_init).");
162+
return -1;
163+
}
164+
if(pthread_mutexattr_destroy(&attr)) {
165+
puts("Unable to destroy mutex attributes (pthread_mutexattr_destroy).");
166+
return -1;
167+
}
168+
if(pthread_mutex_destroy(&mutex)) {
169+
puts("Unable to destroy mutex (pthread_mutex_destroy).");
170+
return -1;
171+
}
172+
return 0;
173173
}
174-
]])],[ dnl -Success-
175-
APCU_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
176-
PHP_ADD_LIBRARY(pthread)
177-
PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
178-
AC_MSG_RESULT([yes])
179-
AC_DEFINE(APC_HAS_PTHREAD_MUTEX, 1, [ ])
180-
],[ dnl -Failure-
181-
AC_MSG_RESULT([no])
182-
PHP_APCU_MUTEX=no
183-
],[
184-
APCU_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
185-
PHP_ADD_LIBRARY(pthread)
186-
PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
187-
])
188-
LIBS="$orig_LIBS"
174+
]])],[ dnl -Success-
175+
APCU_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
176+
PHP_ADD_LIBRARY(pthread)
177+
PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
178+
AC_MSG_RESULT([yes])
179+
AC_DEFINE(APC_HAS_PTHREAD_MUTEX, 1, [ ])
180+
],[ dnl -Failure-
181+
AC_MSG_RESULT([no])
182+
PHP_APCU_MUTEX=no
183+
],[
184+
APCU_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
185+
PHP_ADD_LIBRARY(pthread)
186+
PHP_LDFLAGS="$PHP_LDFLAGS -lpthread"
187+
])
188+
LIBS="$orig_LIBS"
189189
fi
190-
190+
191191
if test "$PHP_APCU_RWLOCKS" = "no"; then
192192
if test "$PHP_APCU_MUTEX" = "no"; then
193193
if test "$PHP_APCU_SPINLOCK" != "no"; then
@@ -199,7 +199,7 @@ if test "$PHP_APCU" != "no"; then
199199
fi
200200
fi
201201
fi
202-
202+
203203
AC_CHECK_FUNCS(sigaction)
204204
AC_CACHE_CHECK(for union semun, php_cv_semun,
205205
[
@@ -226,8 +226,8 @@ if test "$PHP_APCU" != "no"; then
226226
PHP_APCU_VALGRIND=no
227227
], [
228228
PHP_APCU_VALGRIND=yes
229-
AC_CHECK_HEADER(valgrind/memcheck.h,
230-
[AC_DEFINE([HAVE_VALGRIND_MEMCHECK_H],1, [enable valgrind memchecks])])
229+
AC_CHECK_HEADER(valgrind/memcheck.h,
230+
[AC_DEFINE([HAVE_VALGRIND_MEMCHECK_H],1, [enable valgrind memchecks])])
231231
])
232232

233233
for i in -Wall -Wextra -Wno-unused-parameter; do
@@ -244,7 +244,7 @@ if test "$PHP_APCU" != "no"; then
244244
apc_time.c \
245245
apc_iterator.c \
246246
apc_persist.c"
247-
247+
248248
PHP_CHECK_LIBRARY(rt, shm_open, [PHP_ADD_LIBRARY(rt,,APCU_SHARED_LIBADD)])
249249
PHP_NEW_EXTENSION(apcu, $apc_sources, $ext_shared,, \\$(APCU_CFLAGS))
250250
PHP_SUBST(APCU_SHARED_LIBADD)
@@ -262,18 +262,18 @@ if test "$PHP_COVERAGE" = "yes"; then
262262
if test "$GCC" != "yes"; then
263263
AC_MSG_ERROR([GCC is required for --enable-coverage])
264264
fi
265-
265+
266266
dnl Check if ccache is being used
267267
case `$php_shtool path $CC` in
268268
*ccache*[)] gcc_ccache=yes;;
269269
*[)] gcc_ccache=no;;
270270
esac
271271

272272
if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
273-
AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable
273+
AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable
274274
CCACHE_DISABLE=1.])
275275
fi
276-
276+
277277
lcov_version_list="1.5 1.6 1.7 1.9"
278278

279279
AC_CHECK_PROG(LCOV, lcov, lcov)
@@ -292,7 +292,7 @@ CCACHE_DISABLE=1.])
292292
done
293293
])
294294
else
295-
lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list"
295+
lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list"
296296
AC_MSG_ERROR([$lcov_msg])
297297
fi
298298

@@ -320,4 +320,4 @@ CCACHE_DISABLE=1.])
320320
CFLAGS="$CFLAGS -O0 -ggdb -fprofile-arcs -ftest-coverage"
321321
CXXFLAGS="$CXXFLAGS -ggdb -O0 -fprofile-arcs -ftest-coverage"
322322
fi
323-
dnl vim: set ts=2
323+
dnl vim: set ts=2

0 commit comments

Comments
 (0)