Refactor utsname.domainname struct member Autoconf check (#13336)

* Refactor utsname.domainname struct member Autoconf check

Autoconf's AC_CHECK_MEMBERS macro (available since Autoconf 2.50) can be
used instead of the compile check. This was originally implemented for
IRIX compatibility, when Autoconf 2.13 didn't have the struct members
checking macro yet.

Macro by default here defines the HAVE_STRUCT_UTSNAME_DOMAINNAME symbol.

* Remove also redundant DARWIN symbol check

Checking in the configuration step also correctly detects missing struct
member on Darwin systems (macos...).
This commit is contained in:
Peter Kokot 2024-02-06 23:21:42 +01:00 committed by GitHub
parent 0b1ab42ab8
commit f9cfd40fa2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 17 deletions

View file

@ -50,6 +50,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
- The configure option --with-zlib-dir has been removed. - The configure option --with-zlib-dir has been removed.
- COOKIE_IO_FUNCTIONS_T symbol has been removed (use cookie_io_functions_t). - COOKIE_IO_FUNCTIONS_T symbol has been removed (use cookie_io_functions_t).
- HAVE_SOCKADDR_UN_SUN_LEN symbol renamed to HAVE_STRUCT_SOCKADDR_UN_SUN_LEN. - HAVE_SOCKADDR_UN_SUN_LEN symbol renamed to HAVE_STRUCT_SOCKADDR_UN_SUN_LEN.
- HAVE_UTSNAME_DOMAINNAME symbol renamed to HAVE_STRUCT_UTSNAME_DOMAINNAME.
- PHP_CHECK_IN_ADDR_T M4 macro and 'in_addr_t' fallback definition to 'u_int' - PHP_CHECK_IN_ADDR_T M4 macro and 'in_addr_t' fallback definition to 'u_int'
removed (use AC_CHECK_TYPES Autoconf macro instead). removed (use AC_CHECK_TYPES Autoconf macro instead).
- HAVE_ODBC2 symbol has been removed in ext/odbc. - HAVE_ODBC2 symbol has been removed in ext/odbc.

View file

@ -36,21 +36,10 @@ int main(int argc, char *argv[])
AC_MSG_RESULT([no, cannot detect working ttyname_r() when cross compiling. posix_ttyname() will be thread-unsafe]) AC_MSG_RESULT([no, cannot detect working ttyname_r() when cross compiling. posix_ttyname() will be thread-unsafe])
]) ])
AC_CACHE_CHECK([for utsname.domainname], ac_cv_have_utsname_domainname, [ AC_CHECK_MEMBERS([struct utsname.domainname],,,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
#include <sys/utsname.h> #include <sys/utsname.h>
]],[[
return sizeof(((struct utsname *)0)->domainname);
]])],[
ac_cv_have_utsname_domainname=yes
],[
ac_cv_have_utsname_domainname=no
]) ])
])
if test "$ac_cv_have_utsname_domainname" = yes; then
AC_DEFINE(HAVE_UTSNAME_DOMAINNAME, 1, [Whether struct utsname has domainname])
fi
fi fi

View file

@ -358,7 +358,7 @@ PHP_FUNCTION(posix_uname)
add_assoc_string(return_value, "version", u.version); add_assoc_string(return_value, "version", u.version);
add_assoc_string(return_value, "machine", u.machine); add_assoc_string(return_value, "machine", u.machine);
#if defined(_GNU_SOURCE) && !defined(DARWIN) && defined(HAVE_UTSNAME_DOMAINNAME) #if defined(_GNU_SOURCE) && defined(HAVE_STRUCT_UTSNAME_DOMAINNAME)
add_assoc_string(return_value, "domainname", u.domainname); add_assoc_string(return_value, "domainname", u.domainname);
#endif #endif
} }