Skip to content

Commit ea4e8d5

Browse files
authored
Autotools: Check copy_file_range with AC_COMPILE_IFELSE (#15858)
Running the test program is not required as compilation step already errors out if needed.
1 parent adfd7de commit ea4e8d5

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

configure.ac

+11-14
Original file line numberDiff line numberDiff line change
@@ -664,28 +664,25 @@ AS_VAR_IF([php_cv_func_getaddrinfo], [yes],
664664
dnl on FreeBSD, copy_file_range() works only with the undocumented flag 0x01000000;
665665
dnl until the problem is fixed properly, copy_file_range() is used only on Linux
666666
AC_CACHE_CHECK([for copy_file_range], [php_cv_func_copy_file_range],
667-
[AC_RUN_IFELSE([AC_LANG_SOURCE([
668-
#ifdef __linux__
667+
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
668+
#ifndef __linux__
669+
# error "unsupported platform"
670+
#endif
669671
#ifndef _GNU_SOURCE
670-
#define _GNU_SOURCE
672+
# define _GNU_SOURCE
671673
#endif
672674
#include <linux/version.h>
673-
#include <unistd.h>
674-
675-
int main(void) {
676-
(void)copy_file_range(-1, 0, -1, 0, 0, 0);
677675
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
678-
#error "kernel too old"
679-
#else
680-
return 0;
676+
# error "kernel too old"
681677
#endif
678+
#include <unistd.h>
679+
int main(void)
680+
{
681+
(void)copy_file_range(-1, 0, -1, 0, 0, 0);
682+
return 0;
682683
}
683-
#else
684-
#error "unsupported platform"
685-
#endif
686684
])],
687685
[php_cv_func_copy_file_range=yes],
688-
[php_cv_func_copy_file_range=no],
689686
[php_cv_func_copy_file_range=no])
690687
])
691688
AS_VAR_IF([php_cv_func_copy_file_range], [yes],

0 commit comments

Comments
 (0)