]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/align/include/boost/align/detail/aligned_alloc_macos.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / align / include / boost / align / detail / aligned_alloc_macos.hpp
1 /*
2 (c) 2014 Glen Joseph Fernandes
3 <glenjofe -at- gmail.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_ALIGNED_ALLOC_MACOS_HPP
10 #define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
11
12 #include <boost/align/detail/is_alignment.hpp>
13 #include <boost/assert.hpp>
14 #include <stdlib.h>
15
16 namespace boost {
17 namespace alignment {
18
19 inline void* aligned_alloc(std::size_t alignment, std::size_t size)
20 BOOST_NOEXCEPT
21 {
22 BOOST_ASSERT(detail::is_alignment(alignment));
23 if (size == 0) {
24 return 0;
25 }
26 if (alignment < sizeof(void*)) {
27 alignment = sizeof(void*);
28 }
29 void* p;
30 if (::posix_memalign(&p, alignment, size) != 0) {
31 p = 0;
32 }
33 return p;
34 }
35
36 inline void aligned_free(void* ptr) BOOST_NOEXCEPT
37 {
38 ::free(ptr);
39 }
40
41 } /* .alignment */
42 } /* .boost */
43
44 #endif