Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/align/detail/align.hpp @ 102:f46d142149f5
Whoops, finish that update
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:13:41 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
101:c530137014c0 | 102:f46d142149f5 |
---|---|
1 /* | |
2 (c) 2014 Glen Joseph Fernandes | |
3 glenjofe at gmail dot com | |
4 | |
5 Distributed under the Boost Software | |
6 License, Version 1.0. | |
7 http://boost.org/LICENSE_1_0.txt | |
8 */ | |
9 #ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP | |
10 #define BOOST_ALIGN_DETAIL_ALIGN_HPP | |
11 | |
12 #include <boost/assert.hpp> | |
13 #include <boost/align/detail/address.hpp> | |
14 #include <boost/align/detail/is_alignment.hpp> | |
15 #include <cstddef> | |
16 | |
17 namespace boost { | |
18 namespace alignment { | |
19 inline void* align(std::size_t alignment, std::size_t size, | |
20 void*& ptr, std::size_t& space) | |
21 { | |
22 BOOST_ASSERT(detail::is_alignment(alignment)); | |
23 std::size_t n = detail::address_t(ptr) & (alignment - 1); | |
24 if (n != 0) { | |
25 n = alignment - n; | |
26 } | |
27 void* p = 0; | |
28 if (n <= space && size <= space - n) { | |
29 p = static_cast<char*>(ptr) + n; | |
30 ptr = p; | |
31 space -= n; | |
32 } | |
33 return p; | |
34 } | |
35 } | |
36 } | |
37 | |
38 #endif |