diff --git a/posix.hh b/posix.hh index b41ea43d9b..e40f5405ee 100644 --- a/posix.hh +++ b/posix.hh @@ -5,7 +5,6 @@ #ifndef FILE_DESC_HH_ #define FILE_DESC_HH_ -#include "reactor.hh" #include "sstring.hh" #include #include @@ -13,6 +12,12 @@ #include #include +inline void throw_system_error_on(bool condition); + +template +inline void throw_kernel_error(T r); + + class file_desc { int _fd; public: @@ -82,6 +87,20 @@ private: file_desc(int fd) : _fd(fd) {} }; +inline +void throw_system_error_on(bool condition) { + if (condition) { + throw std::system_error(errno, std::system_category()); + } +} +template +inline +void throw_kernel_error(T r) { + static_assert(std::is_signed::value, "kernel error variables must be signed"); + if (r < 0) { + throw std::system_error(-r, std::system_category()); + } +} #endif /* FILE_DESC_HH_ */ diff --git a/reactor.hh b/reactor.hh index ac8a12f703..8d27f10885 100644 --- a/reactor.hh +++ b/reactor.hh @@ -27,6 +27,7 @@ #include #include #include +#include "posix.hh" #include "apply.hh" #include "sstring.hh" @@ -335,22 +336,6 @@ future make_exception_future(std::exception_ptr ex) { return future::do_make_exception_future(std::move(ex)); } -inline -void throw_system_error_on(bool condition) { - if (condition) { - throw std::system_error(errno, std::system_category()); - } -} - -template -inline -void throw_kernel_error(T r) { - static_assert(std::is_signed::value, "kernel error variables must be signed"); - if (r < 0) { - throw std::system_error(-r, std::system_category()); - } -} - struct free_deleter { void operator()(void* p) { ::free(p); } };