maths: rename align as round_to

reduces confusion between pointer align, and number rounding
This commit is contained in:
Danny Robson 2015-11-13 13:37:35 +11:00
parent 11256c2645
commit cd58dc8cc3
4 changed files with 6 additions and 6 deletions

View File

@ -90,7 +90,7 @@ rootsquare [[gnu::pure]] (T a, T b);
// Rounding
template <typename T, typename U>
typename std::common_type<T, U>::type
align [[gnu::pure]] (T value, U size);
round_to [[gnu::pure]] (T value, U size);
template <typename T>

View File

@ -25,7 +25,7 @@
//-----------------------------------------------------------------------------
template <typename T, typename U>
typename std::common_type<T,U>::type
align (T value, U size) {
round_to (T value, U size) {
static_assert (std::is_integral<T>::value, "align requires integral types");
static_assert (std::is_integral<U>::value, "align requires integral types");

View File

@ -58,7 +58,7 @@ tmpname (std::string &str, size_t length)
circular::circular (size_t bytes)
{
bytes = max (bytes, sizeof (value_type));
bytes = align (bytes, pagesize ());
bytes = round_to (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 (align (_window, pagesize ()))
m_window (round_to (_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 + align (min (m_window, bytes), pagesize ());
m_cursor = m_begin + round_to (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 + align (bytes, pagesize ());
m_end = m_begin + round_to (bytes, pagesize ());
}