summaryrefslogtreecommitdiff
path: root/m4/copy-file-range.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/copy-file-range.m4')
-rw-r--r--m4/copy-file-range.m441
1 files changed, 26 insertions, 15 deletions
diff --git a/m4/copy-file-range.m4 b/m4/copy-file-range.m4
index e9198549510..443e598ba55 100644
--- a/m4/copy-file-range.m4
+++ b/m4/copy-file-range.m4
@@ -1,4 +1,4 @@
-# copy-file-range.m4
+# copy-file-range.m4 serial 5
dnl Copyright 2019-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -17,22 +17,33 @@ AC_DEFUN([gl_FUNC_COPY_FILE_RANGE],
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])
- ])
-
+ case "$host_os" in
+ *-gnu* | gnu*)
+ 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])
+ ])
+ gl_cv_onwards_func_copy_file_range="$gl_cv_func_copy_file_range"
+ ;;
+ *)
+ gl_CHECK_FUNCS_ANDROID([copy_file_range], [[#include <unistd.h>]])
+ gl_cv_func_copy_file_range="$ac_cv_func_copy_file_range"
+ ;;
+ esac
if test "$gl_cv_func_copy_file_range" != yes; then
HAVE_COPY_FILE_RANGE=0
+ case "$gl_cv_onwards_func_copy_file_range" in
+ future*) REPLACE_COPY_FILE_RANGE=1 ;;
+ esac
else
AC_DEFINE([HAVE_COPY_FILE_RANGE], 1,
[Define to 1 if the function copy_file_range exists.])