Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:42:50

0001 /*
0002 Copyright 2014 Glen Joseph Fernandes
0003 (glenjofe@gmail.com)
0004 
0005 Distributed under the Boost Software License, Version 1.0.
0006 (http://www.boost.org/LICENSE_1_0.txt)
0007 */
0008 #ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
0009 #define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
0010 
0011 #include <boost/align/detail/is_alignment.hpp>
0012 #include <boost/assert.hpp>
0013 #include <stdlib.h>
0014 
0015 namespace boost {
0016 namespace alignment {
0017 
0018 inline void*
0019 aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
0020 {
0021     BOOST_ASSERT(detail::is_alignment(alignment));
0022     if (size == 0) {
0023         return 0;
0024     }
0025     if (alignment < sizeof(void*)) {
0026         alignment = sizeof(void*);
0027     }
0028     void* p;
0029     if (::posix_memalign(&p, alignment, size) != 0) {
0030         p = 0;
0031     }
0032     return p;
0033 }
0034 
0035 inline void
0036 aligned_free(void* ptr) BOOST_NOEXCEPT
0037 {
0038     ::free(ptr);
0039 }
0040 
0041 } /* alignment */
0042 } /* boost */
0043 
0044 #endif