From 08c1e93fa36a49f49325a07fe91ff92c964c2b6c Mon Sep 17 00:00:00 2001 From: Chanho Park Date: Thu, 11 Dec 2014 18:55:56 +0900 Subject: Imported Upstream version 1.57.0 --- boost/align/detail/align.hpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 boost/align/detail/align.hpp (limited to 'boost/align/detail/align.hpp') diff --git a/boost/align/detail/align.hpp b/boost/align/detail/align.hpp new file mode 100644 index 0000000000..e3a90dffda --- /dev/null +++ b/boost/align/detail/align.hpp @@ -0,0 +1,38 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP +#define BOOST_ALIGN_DETAIL_ALIGN_HPP + +#include +#include +#include +#include + +namespace boost { + namespace alignment { + inline void* align(std::size_t alignment, std::size_t size, + void*& ptr, std::size_t& space) + { + BOOST_ASSERT(detail::is_alignment(alignment)); + std::size_t n = detail::address_t(ptr) & (alignment - 1); + if (n != 0) { + n = alignment - n; + } + void* p = 0; + if (n <= space && size <= space - n) { + p = static_cast(ptr) + n; + ptr = p; + space -= n; + } + return p; + } + } +} + +#endif -- cgit v1.2.3