From 0ac185be403e361da31901be4d58710000367330 Mon Sep 17 00:00:00 2001 From: Masaki Matsushita Date: Sat, 12 Sep 2020 16:27:14 +0900 Subject: Fix compile-time check for copy_file_range(2) * close fds properly * define USE_COPY_FILE_RANGE if HAVE_COPY_FILE_RANGE is defined * avoid errors on cross-compiling environments --- configure.ac | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 6a58a80b2c..ab5d532c10 100644 --- a/configure.ac +++ b/configure.ac @@ -2418,6 +2418,8 @@ main() fd_in = open("/tmp", O_TMPFILE|O_RDWR, S_IRUSR); fd_out = open("/tmp", O_TMPFILE|O_WRONLY, S_IWUSR); ret = syscall(__NR_copy_file_range, fd_in, NULL, fd_out, NULL, 0, 0); + close(fd_in); + close(fd_out); if (ret == -1) { return 1; } return 0; #else @@ -2426,10 +2428,11 @@ main() } ], [rb_cv_use_copy_file_range=yes], + [rb_cv_use_copy_file_range=no], [rb_cv_use_copy_file_range=no])]) - AS_IF([test "$rb_cv_use_copy_file_range" = yes], [ - AC_DEFINE(USE_COPY_FILE_RANGE) - ]) +]) +AS_CASE(["$ac_cv_func_copy_file_range:$rb_cv_use_copy_file_range"], [*yes*], [ + AC_DEFINE(USE_COPY_FILE_RANGE) ]) AS_CASE(["$ac_cv_func_gettimeofday:$ac_cv_func_clock_gettime"], -- cgit v1.2.3