diff mbox

[libstdc++] : Fix PR 70975, experimental/filesystem/operations/copy.cc FAILs on Solaris 12

Message ID CAFULd4ZXugSW4_buBE8YvpTQU25FCRY1Zf9L3mYTB3Cbcb5VFA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Oct. 27, 2016, 6:33 p.m. UTC
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  <ubizjak@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.

Comments

Jonathan Wakely Oct. 27, 2016, 6:41 p.m. UTC | #1
On 27/10/16 20:33 +0200, Uros Bizjak wrote:
>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  <ubizjak@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

Is there a good reason to call it "always_zero_offset" rather than
something that fits on one line, like "offset"?

OK for trunk anyway, thanks.
Jonathan Wakely Oct. 27, 2016, 6:43 p.m. UTC | #2
On 27/10/16 19:41 +0100, Jonathan Wakely wrote:
>On 27/10/16 20:33 +0200, Uros Bizjak wrote:
>>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  <ubizjak@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
>
>Is there a good reason to call it "always_zero_offset" rather than
>something that fits on one line, like "offset"?
>
>OK for trunk anyway, thanks.


(I actually already sent a similar patch, see
https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02276.html but I didn't
commit it yet due to some network issues I've been having today).
Uros Bizjak Oct. 27, 2016, 6:46 p.m. UTC | #3
On Thu, Oct 27, 2016 at 8:43 PM, Jonathan Wakely <jwakely@redhat.com> wrote:

>> Is there a good reason to call it "always_zero_offset" rather than
>> something that fits on one line, like "offset"?
>>
>> OK for trunk anyway, thanks.
>
>
>
> (I actually already sent a similar patch, see
> https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02276.html but I didn't
> commit it yet due to some network issues I've been having today).

Oh, I just planned to re-test and submit exactly the version you sent.
I'll take care for commit to SVN.

Thanks,
Uros.
diff mbox

Patch

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