LLVM  16.0.0git
Errno.h
Go to the documentation of this file.
1 //===- llvm/Support/Errno.h - Portable+convenient errno handling -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares some portable and convenient functions to deal with errno.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_SUPPORT_ERRNO_H
14 #define LLVM_SUPPORT_ERRNO_H
15 
16 #include <cerrno>
17 #include <string>
18 
19 namespace llvm {
20 namespace sys {
21 
22 /// Returns a string representation of the errno value, using whatever
23 /// thread-safe variant of strerror() is available. Be sure to call this
24 /// immediately after the function that set errno, or errno may have been
25 /// overwritten by an intervening call.
26 std::string StrError();
27 
28 /// Like the no-argument version above, but uses \p errnum instead of errno.
29 std::string StrError(int errnum);
30 
31 template <typename FailT, typename Fun, typename... Args>
32 inline decltype(auto) RetryAfterSignal(const FailT &Fail, const Fun &F,
33  const Args &... As) {
34  decltype(F(As...)) Res;
35  do {
36  errno = 0;
37  Res = F(As...);
38  } while (Res == Fail && errno == EINTR);
39  return Res;
40 }
41 
42 } // namespace sys
43 } // namespace llvm
44 
45 #endif // LLVM_SUPPORT_ERRNO_H
llvm::sys::StrError
std::string StrError()
Returns a string representation of the errno value, using whatever thread-safe variant of strerror() ...
Definition: Errno.cpp:30
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::sys::RetryAfterSignal
decltype(auto) RetryAfterSignal(const FailT &Fail, const Fun &F, const Args &... As)
Definition: Errno.h:32
Fail
#define Fail
Definition: AArch64Disassembler.cpp:296
F
#define F(x, y, z)
Definition: MD5.cpp:55
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394