update boost on linux
This commit is contained in:
@@ -28,8 +28,7 @@ namespace alignment {
|
||||
|
||||
template<class T, std::size_t Alignment>
|
||||
class aligned_allocator {
|
||||
BOOST_STATIC_ASSERT(detail::
|
||||
is_alignment_constant<Alignment>::value);
|
||||
BOOST_STATIC_ASSERT(detail::is_alignment_constant<Alignment>::value);
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
@@ -42,13 +41,6 @@ public:
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
|
||||
private:
|
||||
enum {
|
||||
min_align = detail::max_size<Alignment,
|
||||
alignment_of<value_type>::value>::value
|
||||
};
|
||||
|
||||
public:
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef aligned_allocator<U, Alignment> other;
|
||||
@@ -73,10 +65,14 @@ public:
|
||||
}
|
||||
|
||||
pointer allocate(size_type size, const_void_pointer = 0) {
|
||||
enum {
|
||||
m = detail::max_size<Alignment,
|
||||
alignment_of<value_type>::value>::value
|
||||
};
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
}
|
||||
void* p = aligned_alloc(min_align, sizeof(T) * size);
|
||||
void* p = boost::alignment::aligned_alloc(m, sizeof(T) * size);
|
||||
if (!p) {
|
||||
boost::throw_exception(std::bad_alloc());
|
||||
}
|
||||
@@ -124,8 +120,7 @@ public:
|
||||
|
||||
template<std::size_t Alignment>
|
||||
class aligned_allocator<void, Alignment> {
|
||||
BOOST_STATIC_ASSERT(detail::
|
||||
is_alignment_constant<Alignment>::value);
|
||||
BOOST_STATIC_ASSERT(detail::is_alignment_constant<Alignment>::value);
|
||||
|
||||
public:
|
||||
typedef void value_type;
|
||||
|
||||
@@ -8,13 +8,13 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_HPP
|
||||
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_HPP
|
||||
|
||||
#include <boost/align/detail/addressof.hpp>
|
||||
#include <boost/align/detail/is_alignment_constant.hpp>
|
||||
#include <boost/align/detail/max_align.hpp>
|
||||
#include <boost/align/detail/max_size.hpp>
|
||||
#include <boost/align/align.hpp>
|
||||
#include <boost/align/aligned_allocator_adaptor_forward.hpp>
|
||||
#include <boost/align/alignment_of.hpp>
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <new>
|
||||
|
||||
@@ -32,56 +32,45 @@ namespace alignment {
|
||||
template<class Allocator, std::size_t Alignment>
|
||||
class aligned_allocator_adaptor
|
||||
: public Allocator {
|
||||
BOOST_STATIC_ASSERT(detail::
|
||||
is_alignment_constant<Alignment>::value);
|
||||
BOOST_STATIC_ASSERT(detail::is_alignment_constant<Alignment>::value);
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef std::allocator_traits<Allocator> traits;
|
||||
|
||||
typedef typename traits::
|
||||
template rebind_alloc<char> char_alloc;
|
||||
|
||||
typedef typename traits::
|
||||
template rebind_traits<char> char_traits;
|
||||
|
||||
typedef typename traits::template rebind_alloc<char> char_alloc;
|
||||
typedef typename traits::template rebind_traits<char> char_traits;
|
||||
typedef typename char_traits::pointer char_ptr;
|
||||
#else
|
||||
typedef typename Allocator::
|
||||
template rebind<char>::other char_alloc;
|
||||
|
||||
typedef typename Allocator::template rebind<char>::other char_alloc;
|
||||
typedef typename char_alloc::pointer char_ptr;
|
||||
#endif
|
||||
|
||||
public:
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef typename traits::value_type value_type;
|
||||
typedef typename traits::size_type size_type;
|
||||
#else
|
||||
typedef typename Allocator::value_type value_type;
|
||||
typedef typename Allocator::size_type size_type;
|
||||
#endif
|
||||
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef void* void_pointer;
|
||||
typedef const void* const_void_pointer;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
private:
|
||||
enum {
|
||||
min_align = detail::max_size<Alignment,
|
||||
detail::max_align<value_type, char_ptr>::value>::value
|
||||
template<class U>
|
||||
struct min_align {
|
||||
enum {
|
||||
value = detail::max_size<Alignment,
|
||||
detail::max_align<U, char_ptr>::value>::value
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
template<class U>
|
||||
struct rebind {
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef aligned_allocator_adaptor<typename traits::
|
||||
template rebind_alloc<U>, Alignment> other;
|
||||
typedef aligned_allocator_adaptor<typename traits::template
|
||||
rebind_alloc<U>, Alignment> other;
|
||||
#else
|
||||
typedef aligned_allocator_adaptor<typename Allocator::
|
||||
template rebind<U>::other, Alignment> other;
|
||||
typedef aligned_allocator_adaptor<typename Allocator::template
|
||||
rebind<U>::other, Alignment> other;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -116,20 +105,25 @@ public:
|
||||
}
|
||||
|
||||
pointer allocate(size_type size) {
|
||||
enum {
|
||||
m = min_align<value_type>::value
|
||||
};
|
||||
std::size_t s = size * sizeof(value_type);
|
||||
std::size_t n = s + min_align - 1;
|
||||
std::size_t n = s + m - 1;
|
||||
char_alloc a(base());
|
||||
char_ptr p = a.allocate(sizeof p + n);
|
||||
void* r = detail::addressof(*p) + sizeof p;
|
||||
(void)align(min_align, s, r, n);
|
||||
::new(static_cast<void*>(static_cast<char_ptr*>(r)
|
||||
- 1)) char_ptr(p);
|
||||
void* r = boost::to_address(p) + sizeof p;
|
||||
(void)boost::alignment::align(m, s, r, n);
|
||||
::new(static_cast<void*>(static_cast<char_ptr*>(r) - 1)) char_ptr(p);
|
||||
return static_cast<pointer>(r);
|
||||
}
|
||||
|
||||
pointer allocate(size_type size, const_void_pointer hint) {
|
||||
enum {
|
||||
m = min_align<value_type>::value
|
||||
};
|
||||
std::size_t s = size * sizeof(value_type);
|
||||
std::size_t n = s + min_align - 1;
|
||||
std::size_t n = s + m - 1;
|
||||
char_ptr h = char_ptr();
|
||||
if (hint) {
|
||||
h = *(static_cast<const char_ptr*>(hint) - 1);
|
||||
@@ -140,20 +134,21 @@ public:
|
||||
#else
|
||||
char_ptr p = a.allocate(sizeof p + n, h);
|
||||
#endif
|
||||
void* r = detail::addressof(*p) + sizeof p;
|
||||
(void)align(min_align, s, r, n);
|
||||
::new(static_cast<void*>(static_cast<char_ptr*>(r)
|
||||
- 1)) char_ptr(p);
|
||||
void* r = boost::to_address(p) + sizeof p;
|
||||
(void)boost::alignment::align(m, s, r, n);
|
||||
::new(static_cast<void*>(static_cast<char_ptr*>(r) - 1)) char_ptr(p);
|
||||
return static_cast<pointer>(r);
|
||||
}
|
||||
|
||||
void deallocate(pointer ptr, size_type size) {
|
||||
enum {
|
||||
m = min_align<value_type>::value
|
||||
};
|
||||
char_ptr* p = reinterpret_cast<char_ptr*>(ptr) - 1;
|
||||
char_ptr r = *p;
|
||||
p->~char_ptr();
|
||||
char_alloc a(base());
|
||||
a.deallocate(r, sizeof r + size * sizeof(value_type) +
|
||||
min_align - 1);
|
||||
a.deallocate(r, sizeof r + size * sizeof(value_type) + m - 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ align(std::size_t alignment, std::size_t size, void*& ptr,
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
if (size <= space) {
|
||||
char* p = reinterpret_cast<char*>((reinterpret_cast<std::
|
||||
size_t>(ptr) + alignment - 1) & ~(alignment - 1));
|
||||
char* p = reinterpret_cast<char*>(~(alignment - 1) &
|
||||
(reinterpret_cast<std::size_t>(ptr) + alignment - 1));
|
||||
std::size_t n = space - (p - static_cast<char*>(ptr));
|
||||
if (size <= n) {
|
||||
ptr = p;
|
||||
|
||||
@@ -18,8 +18,8 @@ inline void*
|
||||
align_down(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
return reinterpret_cast<void*>(reinterpret_cast<std::
|
||||
size_t>(ptr) & ~(alignment - 1));
|
||||
return reinterpret_cast<void*>(~(alignment - 1) &
|
||||
reinterpret_cast<std::size_t>(ptr));
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
|
||||
@@ -18,8 +18,8 @@ inline void*
|
||||
align_up(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
return reinterpret_cast<void*>((reinterpret_cast<std::
|
||||
size_t>(ptr) + alignment - 1) & ~(alignment - 1));
|
||||
return reinterpret_cast<void*>(~(alignment - 1) &
|
||||
(reinterpret_cast<std::size_t>(ptr) + alignment - 1));
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
|
||||
@@ -31,7 +31,7 @@ aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
|
||||
void* p = std::malloc(sizeof(void*) + n);
|
||||
if (p) {
|
||||
void* r = static_cast<char*>(p) + sizeof(void*);
|
||||
(void)align(alignment, size, r, n);
|
||||
(void)boost::alignment::align(alignment, size, r, n);
|
||||
*(static_cast<void**>(r) - 1) = p;
|
||||
p = r;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ struct offset_value {
|
||||
|
||||
template<class T>
|
||||
struct alignment_of
|
||||
: min_size<sizeof(T),
|
||||
sizeof(offset_value<T>) - (sizeof(T) << 1)> { };
|
||||
: min_size<sizeof(T), sizeof(offset_value<T>) - (sizeof(T) << 1)> { };
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
|
||||
@@ -4,7 +4,6 @@ Copyright 2014 Glen Joseph Fernandes
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNMENT_HPP
|
||||
#define BOOST_ALIGN_DETAIL_IS_ALIGNMENT_HPP
|
||||
|
||||
Reference in New Issue
Block a user