aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport/eintr.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdbsupport/eintr.h')
-rw-r--r--gdbsupport/eintr.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/gdbsupport/eintr.h b/gdbsupport/eintr.h
index 64ff594..e097047 100644
--- a/gdbsupport/eintr.h
+++ b/gdbsupport/eintr.h
@@ -43,25 +43,29 @@ namespace gdb
You could wrap it by writing the wrapped form:
- ssize_t ret = gdb::handle_eintr<ssize_t> (-1, ::write, pipe[1], "+", 1);
+ ssize_t ret = gdb::handle_eintr (-1, ::write, pipe[1], "+", 1);
- The RET typename specifies the return type of the wrapped system call, which
- is typically int or ssize_t. The R argument specifies the failure value
- indicating the interrupted syscall when calling the F function with
- the A... arguments. */
+ ERRVAL specifies the failure value indicating that the call to the
+ F function with ARGS... arguments was possibly interrupted with a
+ signal. */
-template <typename Ret, typename Fun, typename... Args>
-inline Ret handle_eintr (const Ret &R, const Fun &F, const Args &... A)
+template<typename ErrorValType, typename Fun, typename... Args>
+inline auto
+handle_eintr (ErrorValType errval, const Fun &f, const Args &... args)
+ -> decltype (f (args...))
{
- Ret ret;
+ decltype (f (args...)) ret;
+
do
{
errno = 0;
- ret = F (A...);
+ ret = f (args...);
}
- while (ret == R && errno == EINTR);
+ while (ret == errval && errno == EINTR);
+
return ret;
}
-}
+
+} /* namespace gdb */
#endif /* GDBSUPPORT_EINTR_H */