2 dnl Copyright 2019-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_COPY_FILE_RANGE],
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
11 dnl Persuade glibc <unistd.h> to declare copy_file_range.
12 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
14 dnl Use AC_LINK_IFELSE, rather than AC_CHECK_FUNCS or a variant,
15 dnl since we don't want AC_CHECK_FUNCS's checks for glibc stubs.
16 dnl Programs that use copy_file_range must fall back on read+write
17 dnl anyway, and there's little point to substituting the Gnulib stub
19 AC_CACHE_CHECK([for copy_file_range], [gl_cv_func_copy_file_range],
24 [[ssize_t (*func) (int, off_t *, int, off_t, size_t, unsigned)
26 return func (0, 0, 0, 0, 0, 0) & 127;
29 [gl_cv_func_copy_file_range=yes],
30 [gl_cv_func_copy_file_range=no])
33 if test "$gl_cv_func_copy_file_range" != yes; then
34 HAVE_COPY_FILE_RANGE=0