aboutsummaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4')
-rw-r--r--m4/copy-file-range.m436
-rw-r--r--m4/gnulib-comp.m48
2 files changed, 44 insertions, 0 deletions
diff --git a/m4/copy-file-range.m4 b/m4/copy-file-range.m4
new file mode 100644
index 00000000000..20fd05697fe
--- /dev/null
+++ b/m4/copy-file-range.m4
@@ -0,0 +1,36 @@
1# copy-file-range.m4
2dnl Copyright 2019 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_COPY_FILE_RANGE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10
11 dnl Persuade glibc <unistd.h> to declare copy_file_range.
12 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
13
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
18 dnl for a glibc stub.
19 AC_CACHE_CHECK([for copy_file_range], [gl_cv_func_copy_file_range],
20 [AC_LINK_IFELSE(
21 [AC_LANG_PROGRAM(
22 [[#include <unistd.h>
23 ]],
24 [[ssize_t (*func) (int, off_t *, int, off_t, size_t, unsigned)
25 = copy_file_range;
26 return func (0, 0, 0, 0, 0, 0) & 127;
27 ]])
28 ],
29 [gl_cv_func_copy_file_range=yes],
30 [gl_cv_func_copy_file_range=no])
31 ])
32
33 if test "$gl_cv_func_copy_file_range" != yes; then
34 HAVE_COPY_FILE_RANGE=0
35 fi
36])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 0a7a30e5ae2..4627575bf63 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -56,6 +56,7 @@ AC_DEFUN([gl_EARLY],
56 # Code from module clock-time: 56 # Code from module clock-time:
57 # Code from module cloexec: 57 # Code from module cloexec:
58 # Code from module close-stream: 58 # Code from module close-stream:
59 # Code from module copy-file-range:
59 # Code from module count-leading-zeros: 60 # Code from module count-leading-zeros:
60 # Code from module count-one-bits: 61 # Code from module count-one-bits:
61 # Code from module count-trailing-zeros: 62 # Code from module count-trailing-zeros:
@@ -201,6 +202,11 @@ AC_DEFUN([gl_INIT],
201 AC_CHECK_FUNCS_ONCE([readlinkat]) 202 AC_CHECK_FUNCS_ONCE([readlinkat])
202 gl_CLOCK_TIME 203 gl_CLOCK_TIME
203 gl_MODULE_INDICATOR([close-stream]) 204 gl_MODULE_INDICATOR([close-stream])
205 gl_FUNC_COPY_FILE_RANGE
206 if test $HAVE_COPY_FILE_RANGE = 0; then
207 AC_LIBOBJ([copy-file-range])
208 fi
209 gl_UNISTD_MODULE_INDICATOR([copy-file-range])
204 gl_COUNT_LEADING_ZEROS 210 gl_COUNT_LEADING_ZEROS
205 gl_COUNT_ONE_BITS 211 gl_COUNT_ONE_BITS
206 gl_COUNT_TRAILING_ZEROS 212 gl_COUNT_TRAILING_ZEROS
@@ -846,6 +852,7 @@ AC_DEFUN([gl_FILE_LIST], [
846 lib/cloexec.h 852 lib/cloexec.h
847 lib/close-stream.c 853 lib/close-stream.c
848 lib/close-stream.h 854 lib/close-stream.h
855 lib/copy-file-range.c
849 lib/count-leading-zeros.c 856 lib/count-leading-zeros.c
850 lib/count-leading-zeros.h 857 lib/count-leading-zeros.h
851 lib/count-one-bits.c 858 lib/count-one-bits.c
@@ -995,6 +1002,7 @@ AC_DEFUN([gl_FILE_LIST], [
995 m4/builtin-expect.m4 1002 m4/builtin-expect.m4
996 m4/byteswap.m4 1003 m4/byteswap.m4
997 m4/clock_time.m4 1004 m4/clock_time.m4
1005 m4/copy-file-range.m4
998 m4/count-leading-zeros.m4 1006 m4/count-leading-zeros.m4
999 m4/count-one-bits.m4 1007 m4/count-one-bits.m4
1000 m4/count-trailing-zeros.m4 1008 m4/count-trailing-zeros.m4