]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/align/test/aligned_alloc_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / align / test / aligned_alloc_test.cpp
CommitLineData
7c673cae 1/*
b32b8144
FG
2Copyright 2014 Glen Joseph Fernandes
3(glenjofe@gmail.com)
7c673cae 4
b32b8144
FG
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7c673cae
FG
7*/
8#include <boost/align/aligned_alloc.hpp>
9#include <boost/align/is_aligned.hpp>
10#include <boost/core/lightweight_test.hpp>
11#include <cstring>
12
13void test(std::size_t alignment)
14{
15 {
b32b8144 16 void* p = boost::alignment::aligned_alloc(alignment, alignment + 1);
7c673cae
FG
17 BOOST_TEST(p != 0);
18 BOOST_TEST(boost::alignment::is_aligned(p, alignment));
b32b8144 19 std::memset(p, 0, alignment);
7c673cae
FG
20 boost::alignment::aligned_free(p);
21 }
22 {
b32b8144 23 void* p = boost::alignment::aligned_alloc(alignment, 1);
7c673cae
FG
24 BOOST_TEST(p != 0);
25 BOOST_TEST(boost::alignment::is_aligned(p, alignment));
26 std::memset(p, 0, 1);
27 boost::alignment::aligned_free(p);
28 }
b32b8144 29 {
7c673cae
FG
30 void* p = boost::alignment::aligned_alloc(alignment, 0);
31 boost::alignment::aligned_free(p);
32 }
33}
34
35int main()
36{
37 test(1);
38 test(2);
39 test(4);
40 test(8);
41 test(16);
42 test(32);
43 test(64);
44 test(128);
45
46 return boost::report_errors();
47}