Attached patch improves sendfile syscall compatibility with (older)
Solaris 12, where non-null third argument is required. It also paves
the way for compatibility with Solaris 10/11, where otherwise
additional -lsendfile is needed to link with libsendfile library. The
change has no effect on linux.


2016-10-27  Uros Bizjak  <ubiz...@gmail.com>

    PR libstdc++/70975
    * src/filesystem/ops.cc (do_copy_file) [_GLIBCXX_USE_SENDFILE]:
    Use pointer to zero as non-null third argument of sendfile call.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32} CentOS
5 and Fedora 24. Also tested by Rainer on older Solaris 12, where the
patch fixes testsuite failure.

OK for mainline?

Uros.
diff --git a/libstdc++-v3/src/filesystem/ops.cc 
b/libstdc++-v3/src/filesystem/ops.cc
index 9abcee0..b709858 100644
--- a/libstdc++-v3/src/filesystem/ops.cc
+++ b/libstdc++-v3/src/filesystem/ops.cc
@@ -444,7 +444,9 @@ namespace
       }
 
 #ifdef _GLIBCXX_USE_SENDFILE
-    const auto n = ::sendfile(out.fd, in.fd, nullptr, from_st->st_size);
+    off_t always_zero_offset = 0;
+    const auto n = ::sendfile(out.fd, in.fd,
+                             &always_zero_offset, from_st->st_size);
     if (n < 0 && (errno == ENOSYS || errno == EINVAL))
       {
 #endif

Reply via email to