Skip to content

Commit ff2b508

Browse files
petkbukka
authored andcommitted
Refactor checks for fpathconf and pathconf
These two might not be available everywhere so we check them in config.m4 when doing the configure step. Check is skipped for musl libc due to limited implementation. Constants that are defined into main/php_config.h: HAVE_FPATHCONF HAVE_PATHCONF Implemented via GH-10238 Related to GH-10350 Fixes GH-12725
1 parent 05a8153 commit ff2b508

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ PHP NEWS
3131
- PHPDBG:
3232
. Fixed bug GH-12675 (MEMORY_LEAK in phpdbg_prompt.c). (nielsdos)
3333

34+
- POSIX:
35+
. Fixed bug GH-12725 (Call to undefined function posix_fpathconf() in default
36+
configure setting). (petk)
37+
3438
- SPL:
3539
. Fixed bug GH-12721 (SplFileInfo::getFilename() segfault in combination
3640
with GlobIterator and no directory separator). (nielsdos)

ext/posix/config.m4

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ if test "$PHP_POSIX" = "yes"; then
1010

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

13-
AC_CHECK_FUNCS(seteuid setegid setsid getsid getpgid ctermid mkfifo mknod setrlimit getrlimit getgroups makedev initgroups getgrgid_r posix_pathconf eaccess)
13+
AC_CHECK_FUNCS(seteuid setegid setsid getsid getpgid ctermid mkfifo mknod setrlimit getrlimit getgroups makedev initgroups getgrgid_r eaccess)
14+
15+
dnl Skip pathconf and fpathconf check on musl libc due to limited implementation
16+
dnl (first argument is not validated and has different error).
17+
AS_IF([command -v ldd >/dev/null && ldd --version 2>&1 | grep -q "^musl"],[],
18+
[AC_CHECK_FUNCS(pathconf fpathconf)])
1419

1520
AC_MSG_CHECKING([for working ttyname_r() implementation])
1621
AC_RUN_IFELSE([AC_LANG_SOURCE([[

ext/posix/posix.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ PHP_FUNCTION(posix_isatty)
533533
/* }}} */
534534

535535
/*
536-
POSIX.1, 4.8.1 sysconf() - TODO
537-
POSIX.1, 5.7.1 pathconf(), fpathconf() - TODO
536+
POSIX.1, 4.8.1 sysconf()
537+
POSIX.1, 5.7.1 pathconf(), fpathconf()
538538
539539
POSIX.1, 5.1.2 opendir(), readdir(), rewinddir(), closedir()
540540
POSIX.1, 5.2.1 chdir()
@@ -1240,7 +1240,7 @@ PHP_FUNCTION(posix_sysconf)
12401240
RETURN_LONG(sysconf(conf_id));
12411241
}
12421242

1243-
#ifdef HAVE_POSIX_PATHCONF
1243+
#ifdef HAVE_PATHCONF
12441244
PHP_FUNCTION(posix_pathconf)
12451245
{
12461246
zend_long name, ret;
@@ -1269,7 +1269,9 @@ PHP_FUNCTION(posix_pathconf)
12691269

12701270
RETURN_LONG(ret);
12711271
}
1272+
#endif
12721273

1274+
#ifdef HAVE_FPATHCONF
12731275
PHP_FUNCTION(posix_fpathconf)
12741276
{
12751277
zend_long name, ret, fd = 0;

ext/posix/posix.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,11 @@ function posix_initgroups(string $username, int $group_id): bool {}
432432

433433
function posix_sysconf(int $conf_id): int {}
434434

435-
#ifdef HAVE_POSIX_PATHCONF
435+
#ifdef HAVE_PATHCONF
436436
function posix_pathconf(string $path, int $name): int|false {}
437+
#endif
438+
439+
#ifdef HAVE_FPATHCONF
437440
/** @param resource|int $file_descriptor */
438441
function posix_fpathconf($file_descriptor, int $name): int|false {}
439442
#endif

ext/posix/posix_arginfo.h

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)