[PATCH] D48755: Clear errno before calling the function in RetryAfterSignal.
Chandler Carruth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 6 19:51:08 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336479: [Support] Clear errno before calling the function in RetryAfterSignal. (authored by chandlerc, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D48755?vs=153440&id=154482#toc
Repository:
rL LLVM
https://reviews.llvm.org/D48755
Files:
llvm/trunk/include/llvm/Support/Errno.h
llvm/trunk/unittests/Support/ErrnoTest.cpp
Index: llvm/trunk/unittests/Support/ErrnoTest.cpp
===================================================================
--- llvm/trunk/unittests/Support/ErrnoTest.cpp
+++ llvm/trunk/unittests/Support/ErrnoTest.cpp
@@ -33,4 +33,7 @@
std::unique_ptr<int> P(RetryAfterSignal(nullptr, [] { return new int(47); }));
EXPECT_EQ(47, *P);
+
+ errno = EINTR;
+ EXPECT_EQ(-1, RetryAfterSignal(-1, [] { return -1; }));
}
Index: llvm/trunk/include/llvm/Support/Errno.h
===================================================================
--- llvm/trunk/include/llvm/Support/Errno.h
+++ llvm/trunk/include/llvm/Support/Errno.h
@@ -34,9 +34,10 @@
inline auto RetryAfterSignal(const FailT &Fail, const Fun &F,
const Args &... As) -> decltype(F(As...)) {
decltype(F(As...)) Res;
- do
+ do {
+ errno = 0;
Res = F(As...);
- while (Res == Fail && errno == EINTR);
+ } while (Res == Fail && errno == EINTR);
return Res;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48755.154482.patch
Type: text/x-patch
Size: 961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180707/6cafbf6e/attachment.bin>
More information about the llvm-commits
mailing list