annotate DEPENDENCIES/generic/include/boost/container/detail/pool_common_alloc.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 //////////////////////////////////////////////////////////////////////////////
Chris@102 2 //
Chris@102 3 // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
Chris@102 4 // Software License, Version 1.0. (See accompanying file
Chris@102 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@102 6 //
Chris@102 7 // See http://www.boost.org/libs/container for documentation.
Chris@102 8 //
Chris@102 9 //////////////////////////////////////////////////////////////////////////////
Chris@102 10
Chris@102 11 #ifndef BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP
Chris@102 12 #define BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP
Chris@102 13
Chris@102 14 #ifndef BOOST_CONFIG_HPP
Chris@102 15 # include <boost/config.hpp>
Chris@102 16 #endif
Chris@102 17
Chris@102 18 #if defined(BOOST_HAS_PRAGMA_ONCE)
Chris@102 19 # pragma once
Chris@102 20 #endif
Chris@102 21
Chris@102 22 #include <boost/container/detail/config_begin.hpp>
Chris@102 23 #include <boost/container/detail/workaround.hpp>
Chris@102 24 #include <boost/container/throw_exception.hpp>
Chris@102 25
Chris@102 26 #include <boost/intrusive/slist.hpp>
Chris@102 27 #include <boost/container/detail/pool_common.hpp>
Chris@102 28 #include <boost/container/detail/alloc_lib.h>
Chris@102 29 #include <cstddef>
Chris@102 30
Chris@102 31 namespace boost{
Chris@102 32 namespace container{
Chris@102 33 namespace container_detail{
Chris@102 34
Chris@102 35 struct node_slist_helper
Chris@102 36 : public boost::container::container_detail::node_slist<void*>
Chris@102 37 {};
Chris@102 38
Chris@102 39 struct fake_segment_manager
Chris@102 40 {
Chris@102 41 typedef void * void_pointer;
Chris@102 42 static const std::size_t PayloadPerAllocation = BOOST_CONTAINER_ALLOCATION_PAYLOAD;
Chris@102 43
Chris@102 44 typedef boost::container::container_detail::
Chris@102 45 basic_multiallocation_chain<void*> multiallocation_chain;
Chris@102 46 static void deallocate(void_pointer p)
Chris@102 47 { boost_cont_free(p); }
Chris@102 48
Chris@102 49 static void deallocate_many(multiallocation_chain &chain)
Chris@102 50 {
Chris@102 51 std::size_t size = chain.size();
Chris@102 52 std::pair<void*, void*> ptrs = chain.extract_data();
Chris@102 53 boost_cont_memchain dlchain;
Chris@102 54 BOOST_CONTAINER_MEMCHAIN_INIT_FROM(&dlchain, ptrs.first, ptrs.second, size);
Chris@102 55 boost_cont_multidealloc(&dlchain);
Chris@102 56 }
Chris@102 57
Chris@102 58 typedef std::ptrdiff_t difference_type;
Chris@102 59 typedef std::size_t size_type;
Chris@102 60
Chris@102 61 static void *allocate_aligned(std::size_t nbytes, std::size_t alignment)
Chris@102 62 {
Chris@102 63 void *ret = boost_cont_memalign(nbytes, alignment);
Chris@102 64 if(!ret)
Chris@102 65 boost::container::throw_bad_alloc();
Chris@102 66 return ret;
Chris@102 67 }
Chris@102 68
Chris@102 69 static void *allocate(std::size_t nbytes)
Chris@102 70 {
Chris@102 71 void *ret = boost_cont_malloc(nbytes);
Chris@102 72 if(!ret)
Chris@102 73 boost::container::throw_bad_alloc();
Chris@102 74 return ret;
Chris@102 75 }
Chris@102 76 };
Chris@102 77
Chris@102 78 } //namespace boost{
Chris@102 79 } //namespace container{
Chris@102 80 } //namespace container_detail{
Chris@102 81
Chris@102 82 namespace boost {
Chris@102 83 namespace container {
Chris@102 84 namespace container_detail {
Chris@102 85
Chris@102 86 template<class T>
Chris@102 87 struct is_stateless_segment_manager;
Chris@102 88
Chris@102 89 template<>
Chris@102 90 struct is_stateless_segment_manager
Chris@102 91 <boost::container::container_detail::fake_segment_manager>
Chris@102 92 {
Chris@102 93 static const bool value = true;
Chris@102 94 };
Chris@102 95
Chris@102 96 } //namespace container_detail {
Chris@102 97 } //namespace container {
Chris@102 98 } //namespace boost {
Chris@102 99
Chris@102 100 #include <boost/container/detail/config_end.hpp>
Chris@102 101
Chris@102 102 #endif //BOOST_CONTAINER_DETAIL_POOL_COMMON_ALLOC_HPP