ircd::exception: Move throwing errno+system_category out-of-line.

This commit is contained in:
Jason Volk 2022-07-08 11:37:12 -07:00
parent 6c7a978a60
commit 09021ac28b
6 changed files with 19 additions and 28 deletions

View File

@ -40,6 +40,7 @@ namespace ircd
std::system_error make_system_error(const std::error_code &);
std::system_error make_system_error(const boost::system::error_code &);
std::system_error make_system_error(const boost::system::system_error &);
[[noreturn]] void throw_system_error();
template<class... args> std::exception_ptr make_system_eptr(args&&...);
template<class... args> [[noreturn]] void throw_system_error(args&&...);
template<class E, class... args> std::exception_ptr make_exception_ptr(args&&...);

View File

@ -107,10 +107,7 @@ ircd::sys::call(function&& f,
};
if(unlikely(!nothrow && ret == -1L))
throw std::system_error
{
errno, std::system_category()
};
throw_system_error();
return ret;
}

View File

@ -63,10 +63,8 @@ ircd::allocator::allocate(const size_t alignment,
throw std::bad_alloc{};
default:
throw std::system_error
{
errc, std::system_category()
};
throw_system_error();
__builtin_unreachable();
}
assert(ret != nullptr);

View File

@ -152,6 +152,16 @@ noexcept
ec == boost::system::generic_category();
}
[[noreturn]]
void
ircd::throw_system_error()
{
throw std::system_error
{
errno, std::system_category()
};
}
std::system_error
ircd::make_system_error(const boost::system::system_error &e)
{

View File

@ -1022,10 +1022,7 @@ ircd::fs::_read_preadv(const fd &fd,
return 0UL;
if(unlikely(ret == -1))
throw std::system_error
{
errno, std::system_category()
};
throw_system_error();
return ret;
}
@ -1052,10 +1049,7 @@ ircd::fs::_read_preadv2(const fd &fd,
return 0UL;
if(unlikely(ret == -1))
throw std::system_error
{
errno, std::system_category()
};
throw_system_error();
return ret;
}
@ -1407,10 +1401,7 @@ ircd::fs::_write_pwritev(const fd &fd,
return 0UL;
if(unlikely(ret == -1))
throw std::system_error
{
errno, std::system_category()
};
throw_system_error();
return ret;
}
@ -1440,10 +1431,7 @@ ircd::fs::_write_pwritev2(const fd &fd,
return 0UL;
if(unlikely(ret == -1))
throw std::system_error
{
errno, std::system_category()
};
throw_system_error();
return ret;
}

View File

@ -432,10 +432,7 @@ ircd::prof::event::event(const int &group,
};
if(ret == (void *)-1)
throw std::system_error
{
errno, std::system_category()
};
throw_system_error();
if(map_size && ret == nullptr)
throw error