Clean up align_up align_down header organization

This commit is contained in:
Glen Fernandes 2017-02-28 22:15:49 -05:00
parent d86fbd4be3
commit 39a372ea59
9 changed files with 5 additions and 79 deletions

View File

@ -9,7 +9,6 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_ALIGN_ALIGN_DOWN_HPP
#include <boost/align/detail/align_down.hpp>
#include <boost/align/align_down_forward.hpp>
namespace boost {
namespace alignment {

View File

@ -1,23 +0,0 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGN_DOWN_FORWARD_HPP
#define BOOST_ALIGN_ALIGN_DOWN_FORWARD_HPP
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR std::size_t align_down(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT;
} /* .alignment */
} /* .boost */
#endif

View File

@ -9,7 +9,6 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_ALIGN_ALIGN_UP_HPP
#include <boost/align/detail/align_up.hpp>
#include <boost/align/align_up_forward.hpp>
namespace boost {
namespace alignment {

View File

@ -1,23 +0,0 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGN_UP_FORWARD_HPP
#define BOOST_ALIGN_ALIGN_UP_FORWARD_HPP
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR std::size_t align_up(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT;
} /* .alignment */
} /* .boost */
#endif

View File

@ -9,7 +9,6 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_ALIGN_DETAIL_ALIGN_DOWN_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/align/align_down_forward.hpp>
#include <boost/assert.hpp>
namespace boost {
@ -18,7 +17,7 @@ namespace alignment {
inline void* align_down(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return (void*)(align_down((std::size_t)ptr, alignment));
return (void*)((std::size_t)ptr & ~(alignment - 1));
}
} /* .alignment */

View File

@ -9,7 +9,6 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_ALIGN_DETAIL_ALIGN_UP_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/align/align_up_forward.hpp>
#include <boost/assert.hpp>
namespace boost {
@ -18,7 +17,8 @@ namespace alignment {
inline void* align_up(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return (void*)(align_up((std::size_t)ptr, alignment));
return (void*)(((std::size_t)ptr + alignment - 1) &
~(alignment - 1));
}
} /* .alignment */

View File

@ -9,7 +9,6 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/align/is_aligned_forward.hpp>
#include <boost/assert.hpp>
namespace boost {
@ -19,14 +18,14 @@ inline bool is_aligned(const void* ptr, std::size_t alignment)
BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return is_aligned((std::size_t)ptr, alignment);
return ((std::size_t)ptr & (alignment - 1)) == 0;
}
inline bool is_aligned(std::size_t alignment, const void* ptr)
BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return is_aligned((std::size_t)ptr, alignment);
return ((std::size_t)ptr & (alignment - 1)) == 0;
}
} /* .alignment */

View File

@ -10,7 +10,6 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_ALIGN_IS_ALIGNED_HPP
#include <boost/align/detail/is_aligned.hpp>
#include <boost/align/is_aligned_forward.hpp>
namespace boost {
namespace alignment {

View File

@ -1,23 +0,0 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_IS_ALIGNED_FORWARD_HPP
#define BOOST_ALIGN_IS_ALIGNED_FORWARD_HPP
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
BOOST_CONSTEXPR bool is_aligned(std::size_t value,
std::size_t alignment) BOOST_NOEXCEPT;
} /* .alignment */
} /* .boost */
#endif