Skip to content

Refactor HAVE_GETIFADDRS checks #14787

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

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,7 @@ function getmxrr(string $hostname, &$hosts, &$weights = null): bool {}

/* net.c */

#if (defined(PHP_WIN32) || HAVE_GETIFADDRS || defined(__PASE__))
#if (defined(PHP_WIN32) || defined(HAVE_GETIFADDRS) || defined(__PASE__))
function net_get_interfaces(): array|false {}
#endif

Expand Down
8 changes: 4 additions & 4 deletions ext/standard/basic_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 10 additions & 11 deletions ext/standard/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -390,22 +390,21 @@ AC_CHECK_HEADERS([net/if.h],,, [dnl
#endif
])

AC_MSG_CHECKING([for usable getifaddrs])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
AC_CACHE_CHECK([for usable getifaddrs], [php_cv_func_getifaddrs],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <sys/types.h>
#include <ifaddrs.h>
]],[[
], [
struct ifaddrs *interfaces;
if (!getifaddrs(&interfaces)) {
freeifaddrs(interfaces);
freeifaddrs(interfaces);
}
]])], [ac_have_getifaddrs=yes], [ac_have_getifaddrs=no])
if test "$ac_have_getifaddrs" = "yes" ; then
AC_DEFINE(HAVE_GETIFADDRS, 1, [whether getifaddrs is present and usable])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])],
[php_cv_func_getifaddrs=yes],
[php_cv_func_getifaddrs=no])])
AS_VAR_IF([php_cv_func_getifaddrs], [yes],
[AC_DEFINE([HAVE_GETIFADDRS], [1],
[Define to 1 if you have the 'getifaddrs' function.])])

dnl
dnl Setup extension sources
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ PHP_FUNCTION(net_get_interfaces) {
FREE(pAddresses);
#undef MALLOC
#undef FREE
#elif HAVE_GETIFADDRS || defined(__PASE__) /* !PHP_WIN32 */
#elif defined(HAVE_GETIFADDRS) || defined(__PASE__) /* !PHP_WIN32 */
struct ifaddrs *addrs = NULL, *p;

ZEND_PARSE_PARAMETERS_NONE();
Expand Down
Loading