diff options
Diffstat (limited to 'include/llvm/Support/Errno.h')
-rw-r--r-- | include/llvm/Support/Errno.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/Support/Errno.h b/include/llvm/Support/Errno.h index 4ce65e7dc83c..35dc1ea7cf84 100644 --- a/include/llvm/Support/Errno.h +++ b/include/llvm/Support/Errno.h @@ -16,6 +16,7 @@ #include <cerrno> #include <string> +#include <type_traits> namespace llvm { namespace sys { @@ -29,6 +30,16 @@ std::string StrError(); /// Like the no-argument version above, but uses \p errnum instead of errno. std::string StrError(int errnum); +template <typename FailT, typename Fun, typename... Args> +inline auto RetryAfterSignal(const FailT &Fail, const Fun &F, + const Args &... As) -> decltype(F(As...)) { + decltype(F(As...)) Res; + do + Res = F(As...); + while (Res == Fail && errno == EINTR); + return Res; +} + } // namespace sys } // namespace llvm |