diff options
author | Masaki Matsushita <glass.saga@gmail.com> | 2020-09-12 13:36:53 +0900 |
---|---|---|
committer | Masaki Matsushita <glass.saga@gmail.com> | 2020-09-12 16:07:35 +0900 |
commit | 012785ef352d6eee983e087adad71692b3aeb354 (patch) | |
tree | 5ff998f3d576f1b7e76fd6d3a2e95a45f6b3da36 /configure.ac | |
parent | ae508633b7798dd600fd5c6d5095af5361b28c70 (diff) |
Check copy_file_range(2) is actually supported.
see also: https://gitlab.com/gitlab-org/gitlab/-/issues/218999#note_363225872
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index cbfce070e9..6a58a80b2c 100644 --- a/configure.ac +++ b/configure.ac @@ -2396,6 +2396,42 @@ AS_IF([test "$rb_cv_rshift_sign" = yes], [ AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>(int)(y)) : (x)>>(int)(y))) ]) +AS_IF([test "$ac_cv_func_copy_file_range" = no], [ + AC_CACHE_CHECK([for copy_file_range], + rb_cv_use_copy_file_range, + [AC_TRY_RUN([ +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/syscall.h> +#include <fcntl.h> +#include <unistd.h> + +#ifndef O_TMPFILE + #define O_TMPFILE __O_TMPFILE +#endif + +int +main() +{ +#ifdef __NR_copy_file_range + int ret, fd_in, fd_out; + 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); + if (ret == -1) { return 1; } + return 0; +#else + return 1; +#endif +} + ], + [rb_cv_use_copy_file_range=yes], + [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_gettimeofday:$ac_cv_func_clock_gettime"], [*yes*], [], [ |