Skip to content

Refactor utsname.domainname struct member Autoconf check #13336

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 2 commits into from
Feb 6, 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
1 change: 1 addition & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
- The configure option --with-zlib-dir has been removed.
- 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_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'
removed (use AC_CHECK_TYPES Autoconf macro instead).
- HAVE_ODBC2 symbol has been removed in ext/odbc.
Expand Down
21 changes: 5 additions & 16 deletions ext/posix/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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_CACHE_CHECK([for utsname.domainname], ac_cv_have_utsname_domainname, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/utsname.h>
]],[[
return sizeof(((struct utsname *)0)->domainname);
]])],[
ac_cv_have_utsname_domainname=yes
],[
ac_cv_have_utsname_domainname=no
])
AC_CHECK_MEMBERS([struct utsname.domainname],,,[
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/utsname.h>
])
if test "$ac_cv_have_utsname_domainname" = yes; then
AC_DEFINE(HAVE_UTSNAME_DOMAINNAME, 1, [Whether struct utsname has domainname])
fi
fi
2 changes: 1 addition & 1 deletion ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ PHP_FUNCTION(posix_uname)
add_assoc_string(return_value, "version", u.version);
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);
#endif
}
Expand Down