[libcxx-commits] [libcxx] [libc++][FreeBSD] use copy_file_range() in FreeBSD >= 13.0 (PR #169179)

Raman Shishniou via libcxx-commits libcxx-commits at lists.llvm.org
Sat Nov 22 10:05:37 PST 2025


https://github.com/004helix created https://github.com/llvm/llvm-project/pull/169179

The copy_file_range() function appeared in FreeBSD 13.0.

https://man.freebsd.org/cgi/man.cgi?copy_file_range

>From 19113a4d95d0dbcf8794659050926801dacd9c0c Mon Sep 17 00:00:00 2001
From: Raman Shyshniou <raman.shyshniou at anti-virus.by>
Date: Sat, 22 Nov 2025 21:03:14 +0300
Subject: [PATCH] [libc++][FreeBSD] use copy_file_range() in FreeBSD >= 13.0

---
 libcxx/src/filesystem/operations.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index b71f94a89d6df..e58486bf5cbbd 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -50,7 +50,10 @@
 #    define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
 #  endif
 #elif defined(__FreeBSD__)
-#  define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
+#  include <sys/param.h>
+#  if __FreeBSD_version >= 1300000
+#    define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
+#  endif
 #endif
 #if __has_include(<sys/sendfile.h>)
 #  include <sys/sendfile.h>



More information about the libcxx-commits mailing list