Skip to content

Fix GH-9653: does not inconditionally support copy_file_range on olde… #9656

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
Closed
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
28 changes: 27 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ PHP_CHECK_FUNC(socketpair, socket, network)
PHP_CHECK_FUNC(htonl, socket, network)
PHP_CHECK_FUNC(gethostname, nsl, network)
PHP_CHECK_FUNC(gethostbyaddr, nsl, network)
PHP_CHECK_FUNC(copy_file_range)
PHP_CHECK_FUNC(dlopen, dl, root)
PHP_CHECK_FUNC(dlsym, dl, root)
if test "$ac_cv_func_dlopen" = "yes"; then
Expand Down Expand Up @@ -691,6 +690,33 @@ if test "$ac_cv_func_getaddrinfo" = yes; then
AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
fi

AC_CACHE_CHECK([for copy_file_range], ac_cv_copy_file_range,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#ifdef __linux__
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <linux/version.h>
#include <unistd.h>

int main(void) {
(void)copy_file_range(-1, 0, -1, 0, 0, 0);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
#error "kernel too old"
#else
return 0;
#endif
}
#else
#error "unsupported platform"
#endif
]])], [ac_cv_copy_file_range=yes], [ac_cv_copy_file_range=no])
])

if test "$ac_cv_copy_file_range" = yes; then
AC_DEFINE(HAVE_COPY_FILE_RANGE,1,[Define if copy_file_range support])
fi

AC_REPLACE_FUNCS(strlcat strlcpy explicit_bzero getopt)
AC_FUNC_ALLOCA
PHP_TIME_R_TYPE
Expand Down