Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autotools: Refactor --enable-apcu-rwlocks option to PHP_ARG_ENABLE #514

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ PHP_ARG_ENABLE([apcu],
[AS_HELP_STRING([--enable-apcu],
[Enable APCu support])])

AC_MSG_CHECKING(if APCu should be allowed to use rwlocks)
AC_ARG_ENABLE([apcu-rwlocks],
PHP_ARG_ENABLE([apcu-rwlocks],
[if APCu should be allowed to use rwlocks],
[AS_HELP_STRING([--disable-apcu-rwlocks],
[Disable rwlocks in APCu])],
[
PHP_APCU_RWLOCKS=$enableval
AC_MSG_RESULT($enableval)
],
[
PHP_APCU_RWLOCKS=yes
AC_MSG_RESULT(yes)
])
[yes],
[no])

AC_MSG_CHECKING(if APCu should be built in debug mode)
AC_ARG_ENABLE([apcu-debug],
Expand Down Expand Up @@ -63,23 +57,20 @@ AC_ARG_ENABLE([apcu-spinlocks],
])
AC_MSG_RESULT($PHP_APCU_SPINLOCK)

if test "$PHP_APCU_RWLOCKS" != "no"; then
AC_CACHE_CHECK([whether the target compiler supports builtin atomics], PHP_cv_APCU_GCC_ATOMICS, [

AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
if test "$PHP_APCU" != "no"; then
AS_VAR_IF([PHP_APCU_RWLOCKS], [no], [], [
AC_CACHE_CHECK([whether the target compiler supports builtin atomics],
[PHP_cv_APCU_GCC_ATOMICS],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [
int foo = 0;
__sync_add_and_fetch(&foo, 1);
__sync_sub_and_fetch(&foo, 1);
return 0;
]])],[PHP_cv_APCU_GCC_ATOMICS=yes],[PHP_cv_APCU_GCC_ATOMICS=no])
])], [PHP_cv_APCU_GCC_ATOMICS=yes], [PHP_cv_APCU_GCC_ATOMICS=no])])
AS_VAR_IF([PHP_cv_APCU_GCC_ATOMICS], [no],
[AC_MSG_FAILURE([Compiler does not support atomics])])
])

if test "x${PHP_cv_APCU_GCC_ATOMICS}" != "xyes"; then
AC_MSG_ERROR([Compiler does not support atomics])
fi
fi

if test "$PHP_APCU" != "no"; then
if test "$PHP_APCU_DEBUG" != "no"; then
AC_DEFINE(APC_DEBUG, 1, [ ])
fi
Expand Down
Loading