Sources Pipelines Documentation

Allocators  
alignment.hpp
1 // Copyright (c) 2016 Lukasz Laszko
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 #pragma once
6 
7 #include <cstddef>
8 #include <cstdint>
9 
10 
11 namespace boost { namespace memory {
12 
16 static constexpr std::size_t NO_ALIGNMENT = 1ul;
17 
18 #if defined(__amd64__) || defined(__aarch64__)
19 
25 static constexpr std::size_t WORD_ALIGNMENT = 8ul;
26 static constexpr std::size_t HALF_WORD_ALIGNMENT = 4ul;
27 #elif defined(__i686__) || defined(__arm__)
28 static constexpr std::size_t WORD_ALIGNMENT = 4ul;
29 static constexpr std::size_t HALF_WORD_ALIGNMENT = 2ul;
30 #else
31 # error Unsupported CPU architecture
32 #endif
33 
39 static constexpr bool is_power_of_2(std::size_t x) noexcept;
40 
49 template <std::size_t alignment>
50 inline constexpr std::uint8_t* align_forward(std::uint8_t* address) noexcept;
51 
60 template <std::size_t alignment>
61 inline constexpr std::uint8_t* align_backward(std::uint8_t* address) noexcept;
62 
72 template <std::size_t alignment>
73 inline constexpr std::size_t align_size(std::size_t size) noexcept;
74 
75 } }
76 
77 #include "alignment.ipp"
78