]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Do not use off64_t in calls to copy_file_range [PR110462]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 28 Jun 2023 18:10:29 +0000 (19:10 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 29 Jun 2023 15:17:23 +0000 (16:17 +0100)
Although the copy_file_range(2) man page shows the arguments as off64_t*
that is not portable. For musl there is no off64_t type, as off_t is
always 64-bit. Use the loff_t type which is always 64-bit even if off_t
isn't. We could just use off_t because the filesystem library is
compiled with _FILE_OFFSET_BITS=64, but loff_t is the more correct type
for this interface.

libstdc++-v3/ChangeLog:

PR libstdc++/110462
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check that
copy_file_range can be called with loff_t* arguments.
* configure: Regenerate.
* src/filesystem/ops-common.h (copy_file_copy_file_range):
Use loff_t for offsets.

libstdc++-v3/acinclude.m4
libstdc++-v3/configure
libstdc++-v3/src/filesystem/ops-common.h

index efc27aa493ed43b8c906bc104e9201ead79fa55c..277ae10e031a27c16354e3902a3bd7ea19780f53 100644 (file)
@@ -5160,7 +5160,7 @@ dnl
       linux*)
        GCC_TRY_COMPILE_OR_LINK(
          [#include <unistd.h>],
-         [copy_file_range(1, nullptr, 2, nullptr, 1, 0);],
+         [copy_file_range(1, (loff_t*)nullptr, 2, (loff_t*)nullptr, 1, 0);],
          [glibcxx_cv_copy_file_range=yes],
          [glibcxx_cv_copy_file_range=no])
        ;;
index bda8053ecc279c26cc6dbe3705ac73f1b74eaaa6..98568ae0c30bc4d27c7a402614c3c07c55ff2139 100755 (executable)
@@ -72473,7 +72473,7 @@ else
 int
 main ()
 {
-copy_file_range(1, nullptr, 2, nullptr, 1, 0);
+copy_file_range(1, (loff_t*)nullptr, 2, (loff_t*)nullptr, 1, 0);
   ;
   return 0;
 }
@@ -72494,7 +72494,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 int
 main ()
 {
-copy_file_range(1, nullptr, 2, nullptr, 1, 0);
+copy_file_range(1, (loff_t*)nullptr, 2, (loff_t*)nullptr, 1, 0);
   ;
   return 0;
 }
index f04bbc66d7d2c966736b602570b0417b439f4567..2e4331bb682915519bac3cfb59d0bf75405b3224 100644 (file)
@@ -374,7 +374,7 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM
        return false;
       }
     size_t bytes_left = length;
-    off64_t off_in = 0, off_out = 0;
+    loff_t off_in = 0, off_out = 0;
     ssize_t bytes_copied;
     do
       {