WPILibC++  2020.3.2
Errno.h
1 //===- llvm/Support/Errno.h - Portable+convenient errno handling -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares some portable and convenient functions to deal with errno.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef WPIUTIL_WPI_ERRNO_H
15 #define WPIUTIL_WPI_ERRNO_H
16 
17 #include <cerrno>
18 #include <string>
19 #include <type_traits>
20 
21 namespace wpi {
22 namespace sys {
23 
24 template <typename FailT, typename Fun, typename... Args>
25 inline auto RetryAfterSignal(const FailT &Fail, const Fun &F,
26  const Args &... As) -> decltype(F(As...)) {
27  decltype(F(As...)) Res;
28  do {
29  errno = 0;
30  Res = F(As...);
31  } while (Res == Fail && errno == EINTR);
32  return Res;
33 }
34 
35 } // namespace sys
36 } // namespace wpi
37 
38 #endif // WPIUTIL_WPI_ERRNO_H
wpi
WPILib C++ utilities (wpiutil) namespace.
Definition: EventLoopRunner.h:17