Skip to content

Refactor checks for fpathconf and pathconf #11774

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

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 6 additions & 1 deletion ext/posix/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ if test "$PHP_POSIX" = "yes"; then

AC_CHECK_HEADERS([sys/mkdev.h sys/sysmacros.h])

AC_CHECK_FUNCS(seteuid setegid setsid getsid getpgid ctermid mkfifo mknod setrlimit getrlimit getgroups makedev initgroups getgrgid_r posix_pathconf eaccess)
AC_CHECK_FUNCS(seteuid setegid setsid getsid getpgid ctermid mkfifo mknod setrlimit getrlimit getgroups makedev initgroups getgrgid_r eaccess)

dnl Skip pathconf and fpathconf check on musl libc due to limited implementation
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([[
Expand Down
8 changes: 5 additions & 3 deletions ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ PHP_FUNCTION(posix_isatty)
/* }}} */

/*
POSIX.1, 4.8.1 sysconf() - TODO
POSIX.1, 5.7.1 pathconf(), fpathconf() - TODO
POSIX.1, 4.8.1 sysconf()
POSIX.1, 5.7.1 pathconf(), fpathconf()

POSIX.1, 5.1.2 opendir(), readdir(), rewinddir(), closedir()
POSIX.1, 5.2.1 chdir()
Expand Down Expand Up @@ -1240,7 +1240,7 @@ PHP_FUNCTION(posix_sysconf)
RETURN_LONG(sysconf(conf_id));
}

#ifdef HAVE_POSIX_PATHCONF
#ifdef HAVE_PATHCONF
PHP_FUNCTION(posix_pathconf)
{
zend_long name, ret;
Expand Down Expand Up @@ -1269,7 +1269,9 @@ PHP_FUNCTION(posix_pathconf)

RETURN_LONG(ret);
}
#endif

#ifdef HAVE_FPATHCONF
PHP_FUNCTION(posix_fpathconf)
{
zend_long name, ret, fd = 0;
Expand Down
5 changes: 4 additions & 1 deletion ext/posix/posix.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,11 @@ function posix_initgroups(string $username, int $group_id): bool {}

function posix_sysconf(int $conf_id): int {}

#ifdef HAVE_POSIX_PATHCONF
#ifdef HAVE_PATHCONF
function posix_pathconf(string $path, int $name): int|false {}
#endif

#ifdef HAVE_FPATHCONF
/** @param resource|int $file_descriptor */
function posix_fpathconf($file_descriptor, int $name): int|false {}
#endif
14 changes: 7 additions & 7 deletions ext/posix/posix_arginfo.h

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