commit: 18976a7de983fa266a2b4b3ddd0b8962a9406269
parent 46143b945adadd876cb050b34d3c5e201492b004
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 31 Mar 2024 17:35:55 +0200
configure: Add test for copy_file_range(2)
Diffstat:
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
@@ -237,9 +237,9 @@ if ! check_header sys/sysmacros.h; then
echo 'cmd/mknod' >> target_filter
fi
-if check_conftest configure.d/splice.c; then
- CFLAGS="${CFLAGS} -DHAS_SPLICE"
-fi
+check_conftest configure.d/splice.c && CFLAGS="${CFLAGS} -DHAS_SPLICE"
+
+check_conftest configure.d/copy_file_range.c && CFLAGS="${CFLAGS} -DCOPY_FILE_RANGE"
if ! check_conftest configure.d/reallocarray.c; then
echo 'Disabling cmd/tr'
diff --git a/configure.d/copy_file_range.c b/configure.d/copy_file_range.c
@@ -0,0 +1,18 @@
+// utils-std: Collection of commonly available Unix tools
+// SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+// SPDX-License-Identifier: MPL-2.0
+
+// Because that's what our utilities will use :)
+#define _POSIX_C_SOURCE 200809L
+#define _GNU_SOURCE // for copy_file_range
+
+#include <stdint.h> // SIZE_MAX
+#include <sys/types.h>
+#include <unistd.h>
+
+ssize_t
+test(int in, int out)
+{
+ off_t in_pos = 0, out_pos = 0;
+ return copy_file_range(in, &in_pos, out, &out_pos, SIZE_MAX, 0);
+}