Skip to content

Wrap ttyname_r check in AC_CACHE_CHECK #14417

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
Jun 1, 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
32 changes: 14 additions & 18 deletions ext/posix/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,20 @@ dnl (first argument is not validated and has different error).
AS_IF([command -v ldd >/dev/null && ldd --version 2>&1 | grep -q "^musl"],[],
[AC_CHECK_FUNCS(pathconf fpathconf)])

AC_MSG_CHECKING([for working ttyname_r() implementation])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <unistd.h>

int main(int argc, char *argv[])
{
char buf[64];

return !ttyname_r(0, buf, 64);
}
]])],[
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_TTYNAME_R, 1, [Whether you have a working ttyname_r])
],[
AC_MSG_RESULT([no, 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 working ttyname_r() implementation],
[php_cv_func_ttyname_r],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [[
char buf[64];
return !ttyname_r(0, buf, 64);
]])],
[php_cv_func_ttyname_r=yes],
[php_cv_func_ttyname_r=no],
[AC_CHECK_FUNC([ttyname_r],
[php_cv_func_ttyname_r=yes], [php_cv_func_ttyname_r=no])])])
AS_VAR_IF([php_cv_func_ttyname_r], [yes],
[AC_DEFINE([HAVE_TTYNAME_R], [1],
[Define to 1 if you have a working ttyname_r.])],
[AC_MSG_NOTICE([posix_ttyname() will be thread-unsafe])])

AC_CHECK_MEMBERS([struct utsname.domainname],,,[
#ifndef _GNU_SOURCE
Expand Down
Loading