maths: rename round_to as round_up

this shows more explicitly the rounding policy we're using
This commit is contained in:
Danny Robson 2017-08-30 15:39:02 +10:00
parent 885b0b4669
commit a9f8594b26
3 changed files with 5 additions and 5 deletions

View File

@ -260,7 +260,7 @@ namespace util {
std::enable_if_t<std::is_integral<T>::value,T>,
std::enable_if_t<std::is_integral<U>::value,U>
>::type
round_to (T value, U size)
round_up (T value, U size)
{
// we perform this as two steps to avoid unnecessarily incrementing when
// remainder is zero.

View File

@ -57,7 +57,7 @@ tmpname (std::string &str, size_t length)
circular::circular (size_t bytes)
{
bytes = max (bytes, sizeof (value_type));
bytes = round_to (bytes, pagesize ());
bytes = round_up (bytes, pagesize ());
int fd = -1;

View File

@ -29,7 +29,7 @@ using util::memory::buffer::paged;
///////////////////////////////////////////////////////////////////////////////
paged::paged (size_t bytes, size_t _window):
m_window (round_to (_window, pagesize ()))
m_window (round_up (_window, pagesize ()))
{
// reserve the address region with no access permissions
m_begin = reinterpret_cast<char*> (
@ -40,7 +40,7 @@ paged::paged (size_t bytes, size_t _window):
errno_error::throw_code ();
// remap the initial window with read/write permissions
m_cursor = m_begin + round_to (min (m_window, bytes), pagesize ());
m_cursor = m_begin + round_up (min (m_window, bytes), pagesize ());
if (MAP_FAILED == mmap (m_begin,
m_cursor - m_begin,
PROT_READ | PROT_WRITE,
@ -48,7 +48,7 @@ paged::paged (size_t bytes, size_t _window):
errno_error::throw_code ();
// record the nominal end address
m_end = m_begin + round_to (bytes, pagesize ());
m_end = m_begin + round_up (bytes, pagesize ());
}