diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-06-06 15:44:33 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-06-06 15:46:20 -0700 |
commit | b0d998d2e04050dd3c65816b277cf0f91c9ca74c (patch) | |
tree | d38b87aaa26d3e7ff94c484b4ca34d689be564c9 /m4/copy-file-range.m4 | |
parent | a1beabcb14cde661c36f7a3c7c17b5871704003e (diff) | |
download | gnulib-b0d998d2e04050dd3c65816b277cf0f91c9ca74c.tar.gz |
copy-file-range: simplify into a stub
Based on a comment by Florian Weimer in:
https://lists.gnu.org/r/bug-gnulib/2019-06/msg00007.html
It turns out that Emacs (which will use this module) won’t need an
emulation and I suspect other programs won’t either, because these
programs will need to fall back on read+write anyway. Perhaps I
am wrong and other programs will be able to use an emulation; if
so, this patch can be reverted.
* lib/copy-file-range.c (COPY_FILE_RANGE): Replace with a stub.
Just call it copy_file_range.
* m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE):
Check via AC_LINK_IFELSE.
* modules/copy-file-range (Depends-on): Remove modules no longer used.
Diffstat (limited to 'm4/copy-file-range.m4')
-rw-r--r-- | m4/copy-file-range.m4 | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/m4/copy-file-range.m4 b/m4/copy-file-range.m4 index edd2c4aedb..20fd05697f 100644 --- a/m4/copy-file-range.m4 +++ b/m4/copy-file-range.m4 @@ -11,8 +11,26 @@ AC_DEFUN([gl_FUNC_COPY_FILE_RANGE], dnl Persuade glibc <unistd.h> to declare copy_file_range. AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS_ONCE([copy_file_range]) - if test $ac_cv_func_copy_file_range != yes; then + dnl Use AC_LINK_IFELSE, rather than AC_CHECK_FUNCS or a variant, + dnl since we don't want AC_CHECK_FUNCS's checks for glibc stubs. + dnl Programs that use copy_file_range must fall back on read+write + dnl anyway, and there's little point to substituting the Gnulib stub + dnl for a glibc stub. + AC_CACHE_CHECK([for copy_file_range], [gl_cv_func_copy_file_range], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <unistd.h> + ]], + [[ssize_t (*func) (int, off_t *, int, off_t, size_t, unsigned) + = copy_file_range; + return func (0, 0, 0, 0, 0, 0) & 127; + ]]) + ], + [gl_cv_func_copy_file_range=yes], + [gl_cv_func_copy_file_range=no]) + ]) + + if test "$gl_cv_func_copy_file_range" != yes; then HAVE_COPY_FILE_RANGE=0 fi ]) |