Skip to content

Commit f9cfd40

Browse files
authored
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...).
1 parent 0b1ab42 commit f9cfd40

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

UPGRADING.INTERNALS

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
5050
- The configure option --with-zlib-dir has been removed.
5151
- COOKIE_IO_FUNCTIONS_T symbol has been removed (use cookie_io_functions_t).
5252
- HAVE_SOCKADDR_UN_SUN_LEN symbol renamed to HAVE_STRUCT_SOCKADDR_UN_SUN_LEN.
53+
- HAVE_UTSNAME_DOMAINNAME symbol renamed to HAVE_STRUCT_UTSNAME_DOMAINNAME.
5354
- PHP_CHECK_IN_ADDR_T M4 macro and 'in_addr_t' fallback definition to 'u_int'
5455
removed (use AC_CHECK_TYPES Autoconf macro instead).
5556
- HAVE_ODBC2 symbol has been removed in ext/odbc.

ext/posix/config.m4

+5-16
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,10 @@ int main(int argc, char *argv[])
3636
AC_MSG_RESULT([no, cannot detect working ttyname_r() when cross compiling. posix_ttyname() will be thread-unsafe])
3737
])
3838

39-
AC_CACHE_CHECK([for utsname.domainname], ac_cv_have_utsname_domainname, [
40-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
41-
#ifndef _GNU_SOURCE
42-
#define _GNU_SOURCE
43-
#endif
44-
#include <sys/utsname.h>
45-
]],[[
46-
return sizeof(((struct utsname *)0)->domainname);
47-
]])],[
48-
ac_cv_have_utsname_domainname=yes
49-
],[
50-
ac_cv_have_utsname_domainname=no
51-
])
39+
AC_CHECK_MEMBERS([struct utsname.domainname],,,[
40+
#ifndef _GNU_SOURCE
41+
#define _GNU_SOURCE
42+
#endif
43+
#include <sys/utsname.h>
5244
])
53-
if test "$ac_cv_have_utsname_domainname" = yes; then
54-
AC_DEFINE(HAVE_UTSNAME_DOMAINNAME, 1, [Whether struct utsname has domainname])
55-
fi
5645
fi

ext/posix/posix.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ PHP_FUNCTION(posix_uname)
358358
add_assoc_string(return_value, "version", u.version);
359359
add_assoc_string(return_value, "machine", u.machine);
360360

361-
#if defined(_GNU_SOURCE) && !defined(DARWIN) && defined(HAVE_UTSNAME_DOMAINNAME)
361+
#if defined(_GNU_SOURCE) && defined(HAVE_STRUCT_UTSNAME_DOMAINNAME)
362362
add_assoc_string(return_value, "domainname", u.domainname);
363363
#endif
364364
}

0 commit comments

Comments
 (0)