[llvm] r340751 - Use a lambda for calls to ::open in RetryAfterSignal
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 30 02:32:54 PDT 2018
Merged to 7.0 in r341044.
On Mon, Aug 27, 2018 at 5:55 PM, Hans Wennborg via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: hans
> Date: Mon Aug 27 08:55:39 2018
> New Revision: 340751
>
> URL: http://llvm.org/viewvc/llvm-project?rev=340751&view=rev
> Log:
> Use a lambda for calls to ::open in RetryAfterSignal
>
> In Bionic, open can be overloaded for _FORTIFY_SOURCE support, causing
> compile errors of RetryAfterSignal due to overload resolution. Wrapping
> the call in a lambda avoids this.
>
> Based on a patch by Chih-Wei Huang <cwhuang at linux.org.tw>!
>
> Modified:
> llvm/trunk/lib/Support/Unix/Path.inc
> llvm/trunk/lib/Support/Unix/Process.inc
>
> Modified: llvm/trunk/lib/Support/Unix/Path.inc
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=340751&r1=340750&r2=340751&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/Unix/Path.inc (original)
> +++ llvm/trunk/lib/Support/Unix/Path.inc Mon Aug 27 08:55:39 2018
> @@ -774,8 +774,10 @@ std::error_code openFile(const Twine &Na
>
> SmallString<128> Storage;
> StringRef P = Name.toNullTerminatedStringRef(Storage);
> - if ((ResultFD = sys::RetryAfterSignal(-1, ::open, P.begin(), OpenFlags, Mode)) <
> - 0)
> + // Call ::open in a lambda to avoid overload resolution in RetryAfterSignal
> + // when open is overloaded, such as in Bionic.
> + auto Open = [&]() { return ::open(P.begin(), OpenFlags, Mode); };
> + if ((ResultFD = sys::RetryAfterSignal(-1, Open)) < 0)
> return std::error_code(errno, std::generic_category());
> #ifndef O_CLOEXEC
> if (!(Flags & OF_ChildInherit)) {
>
> Modified: llvm/trunk/lib/Support/Unix/Process.inc
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Process.inc?rev=340751&r1=340750&r2=340751&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/Unix/Process.inc (original)
> +++ llvm/trunk/lib/Support/Unix/Process.inc Mon Aug 27 08:55:39 2018
> @@ -211,7 +211,10 @@ std::error_code Process::FixupStandardFi
> assert(errno == EBADF && "expected errno to have EBADF at this point!");
>
> if (NullFD < 0) {
> - if ((NullFD = RetryAfterSignal(-1, ::open, "/dev/null", O_RDWR)) < 0)
> + // Call ::open in a lambda to avoid overload resolution in
> + // RetryAfterSignal when open is overloaded, such as in Bionic.
> + auto Open = [&]() { return ::open("/dev/null", O_RDWR); };
> + if ((NullFD = RetryAfterSignal(-1, Open)) < 0)
> return std::error_code(errno, std::generic_category());
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list