maths: rename align as round_to
reduces confusion between pointer align, and number rounding
This commit is contained in:
parent
11256c2645
commit
cd58dc8cc3
@ -90,7 +90,7 @@ rootsquare [[gnu::pure]] (T a, T b);
|
|||||||
// Rounding
|
// Rounding
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
typename std::common_type<T, U>::type
|
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>
|
template <typename T>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
typename std::common_type<T,U>::type
|
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<T>::value, "align requires integral types");
|
||||||
static_assert (std::is_integral<U>::value, "align requires integral types");
|
static_assert (std::is_integral<U>::value, "align requires integral types");
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ tmpname (std::string &str, size_t length)
|
|||||||
circular::circular (size_t bytes)
|
circular::circular (size_t bytes)
|
||||||
{
|
{
|
||||||
bytes = max (bytes, sizeof (value_type));
|
bytes = max (bytes, sizeof (value_type));
|
||||||
bytes = align (bytes, pagesize ());
|
bytes = round_to (bytes, pagesize ());
|
||||||
|
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ using util::memory::buffer::paged;
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
paged::paged (size_t bytes, size_t _window):
|
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
|
// reserve the address region with no access permissions
|
||||||
m_begin = reinterpret_cast<char*> (
|
m_begin = reinterpret_cast<char*> (
|
||||||
@ -40,7 +40,7 @@ paged::paged (size_t bytes, size_t _window):
|
|||||||
errno_error::throw_code ();
|
errno_error::throw_code ();
|
||||||
|
|
||||||
// remap the initial window with read/write permissions
|
// 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,
|
if (MAP_FAILED == mmap (m_begin,
|
||||||
m_cursor - m_begin,
|
m_cursor - m_begin,
|
||||||
PROT_READ | PROT_WRITE,
|
PROT_READ | PROT_WRITE,
|
||||||
@ -48,7 +48,7 @@ paged::paged (size_t bytes, size_t _window):
|
|||||||
errno_error::throw_code ();
|
errno_error::throw_code ();
|
||||||
|
|
||||||
// record the nominal end address
|
// record the nominal end address
|
||||||
m_end = m_begin + align (bytes, pagesize ());
|
m_end = m_begin + round_to (bytes, pagesize ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user