1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-09-08 23:36:34 -05:00

Initial commit

This commit is contained in:
Crimson-Hawk
2024-03-05 16:42:40 +08:00
commit f1e4595ebf
39576 changed files with 7006612 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_HPP
#define BOOST_ALIGN_HPP
#include <boost/align/align.hpp>
#include <boost/align/align_down.hpp>
#include <boost/align/align_up.hpp>
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/aligned_allocator.hpp>
#include <boost/align/aligned_allocator_adaptor.hpp>
#include <boost/align/aligned_delete.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/align/assume_aligned.hpp>
#include <boost/align/is_aligned.hpp>
#endif

View File

@@ -0,0 +1,19 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGN_HPP
#define BOOST_ALIGN_ALIGN_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_STD_ALIGN) && !defined(BOOST_LIBSTDCXX_VERSION)
#include <boost/align/detail/align_cxx11.hpp>
#else
#include <boost/align/detail/align.hpp>
#endif
#endif

View File

@@ -0,0 +1,27 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGN_DOWN_HPP
#define BOOST_ALIGN_ALIGN_DOWN_HPP
#include <boost/align/detail/align_down.hpp>
#include <boost/align/detail/not_pointer.hpp>
namespace boost {
namespace alignment {
template<class T>
BOOST_CONSTEXPR inline typename detail::not_pointer<T, T>::type
align_down(T value, std::size_t alignment) BOOST_NOEXCEPT
{
return T(value & ~T(alignment - 1));
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,27 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGN_UP_HPP
#define BOOST_ALIGN_ALIGN_UP_HPP
#include <boost/align/detail/align_up.hpp>
#include <boost/align/detail/not_pointer.hpp>
namespace boost {
namespace alignment {
template<class T>
BOOST_CONSTEXPR inline typename detail::not_pointer<T, T>::type
align_up(T value, std::size_t alignment) BOOST_NOEXCEPT
{
return T((value + (T(alignment) - 1)) & ~T(alignment - 1));
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,47 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOC_HPP
#define BOOST_ALIGN_ALIGNED_ALLOC_HPP
#include <boost/config.hpp>
#if defined(BOOST_HAS_UNISTD_H)
#include <unistd.h>
#endif
#if defined(__APPLE__) || defined(__APPLE_CC__) || defined(macintosh)
#include <AvailabilityMacros.h>
#endif
#if defined(BOOST_ALIGN_USE_ALIGN)
#include <boost/align/detail/aligned_alloc.hpp>
#elif defined(BOOST_ALIGN_USE_NEW)
#include <boost/align/detail/aligned_alloc_new.hpp>
#elif defined(_MSC_VER) && !defined(UNDER_CE)
#include <boost/align/detail/aligned_alloc_msvc.hpp>
#elif defined(__MINGW32__) && (__MSVCRT_VERSION__ >= 0x0700)
#include <boost/align/detail/aligned_alloc_msvc.hpp>
#elif defined(__MINGW32__)
#include <boost/align/detail/aligned_alloc_mingw.hpp>
#elif MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
#include <boost/align/detail/aligned_alloc_posix.hpp>
#elif MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
#include <boost/align/detail/aligned_alloc_macos.hpp>
#elif defined(__ANDROID__)
#include <boost/align/detail/aligned_alloc_android.hpp>
#elif defined(__SunOS_5_11) || defined(__SunOS_5_12)
#include <boost/align/detail/aligned_alloc_posix.hpp>
#elif defined(sun) || defined(__sun)
#include <boost/align/detail/aligned_alloc_sunos.hpp>
#elif (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600)
#include <boost/align/detail/aligned_alloc_posix.hpp>
#else
#include <boost/align/detail/aligned_alloc.hpp>
#endif
#endif

View File

@@ -0,0 +1,140 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_HPP
#include <boost/align/detail/add_reference.hpp>
#include <boost/align/detail/is_alignment_constant.hpp>
#include <boost/align/detail/max_objects.hpp>
#include <boost/align/detail/max_size.hpp>
#include <boost/align/detail/throw_exception.hpp>
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/aligned_allocator_forward.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/static_assert.hpp>
#include <new>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
namespace boost {
namespace alignment {
template<class T, std::size_t Alignment>
class aligned_allocator {
BOOST_STATIC_ASSERT(detail::is_alignment_constant<Alignment>::value);
public:
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef void* void_pointer;
typedef const void* const_void_pointer;
typedef typename detail::add_lvalue_reference<T>::type reference;
typedef typename detail::add_lvalue_reference<const
T>::type const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef detail::true_type propagate_on_container_move_assignment;
typedef detail::true_type is_always_equal;
template<class U>
struct rebind {
typedef aligned_allocator<U, Alignment> other;
};
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
aligned_allocator() = default;
#else
aligned_allocator() BOOST_NOEXCEPT { }
#endif
template<class U>
aligned_allocator(const aligned_allocator<U, Alignment>&)
BOOST_NOEXCEPT { }
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 = boost::alignment::aligned_alloc(m, sizeof(T) * size);
if (!p) {
detail::throw_exception(std::bad_alloc());
}
return static_cast<T*>(p);
}
void deallocate(pointer ptr, size_type) {
boost::alignment::aligned_free(ptr);
}
BOOST_CONSTEXPR size_type max_size() const BOOST_NOEXCEPT {
return detail::max_objects<T>::value;
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class U, class... Args>
void construct(U* ptr, Args&&... args) {
::new((void*)ptr) U(std::forward<Args>(args)...);
}
#else
template<class U, class V>
void construct(U* ptr, V&& value) {
::new((void*)ptr) U(std::forward<V>(value));
}
#endif
#else
template<class U, class V>
void construct(U* ptr, const V& value) {
::new((void*)ptr) U(value);
}
template<class U, class V>
void construct(U* ptr, V& value) {
::new((void*)ptr) U(value);
}
#endif
template<class U>
void construct(U* ptr) {
::new((void*)ptr) U();
}
template<class U>
void destroy(U* ptr) {
(void)ptr;
ptr->~U();
}
};
template<class T, class U, std::size_t Alignment>
inline bool
operator==(const aligned_allocator<T, Alignment>&,
const aligned_allocator<U, Alignment>&) BOOST_NOEXCEPT
{
return true;
}
template<class T, class U, std::size_t Alignment>
inline bool
operator!=(const aligned_allocator<T, Alignment>&,
const aligned_allocator<U, Alignment>&) BOOST_NOEXCEPT
{
return false;
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,170 @@
/*
Copyright 2014-2016 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_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>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <memory>
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
namespace boost {
namespace alignment {
template<class Allocator, std::size_t Alignment>
class aligned_allocator_adaptor
: public Allocator {
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 char_traits::pointer char_ptr;
#else
typedef typename Allocator::template rebind<char>::other char_alloc;
typedef typename char_alloc::pointer char_ptr;
#endif
public:
typedef typename Allocator::value_type value_type;
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:
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;
#else
typedef aligned_allocator_adaptor<typename Allocator::template
rebind<U>::other, Alignment> other;
#endif
};
aligned_allocator_adaptor()
: Allocator() { }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class A>
explicit aligned_allocator_adaptor(A&& alloc) BOOST_NOEXCEPT
: Allocator(std::forward<A>(alloc)) { }
#else
template<class A>
explicit aligned_allocator_adaptor(const A& alloc) BOOST_NOEXCEPT
: Allocator(alloc) { }
#endif
template<class U>
aligned_allocator_adaptor(const aligned_allocator_adaptor<U,
Alignment>& other) BOOST_NOEXCEPT
: Allocator(other.base()) { }
Allocator& base() BOOST_NOEXCEPT {
return static_cast<Allocator&>(*this);
}
const Allocator& base() const BOOST_NOEXCEPT {
return static_cast<const Allocator&>(*this);
}
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 + m - 1;
char_alloc a(base());
char_ptr p = a.allocate(sizeof p + n);
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 + m - 1;
char_ptr h = char_ptr();
if (hint) {
h = *(static_cast<const char_ptr*>(hint) - 1);
}
char_alloc a(base());
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
char_ptr p = char_traits::allocate(a, sizeof p + n, h);
#else
char_ptr p = a.allocate(sizeof p + n, h);
#endif
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) + m - 1);
}
};
template<class A, class B, std::size_t Alignment>
inline bool
operator==(const aligned_allocator_adaptor<A, Alignment>& a,
const aligned_allocator_adaptor<B, Alignment>& b) BOOST_NOEXCEPT
{
return a.base() == b.base();
}
template<class A, class B, std::size_t Alignment>
inline bool
operator!=(const aligned_allocator_adaptor<A, Alignment>& a,
const aligned_allocator_adaptor<B, Alignment>& b) BOOST_NOEXCEPT
{
return !(a == b);
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,22 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_FORWARD_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_ADAPTOR_FORWARD_HPP
#include <cstddef>
namespace boost {
namespace alignment {
template<class Allocator, std::size_t Alignment = 1>
class aligned_allocator_adaptor;
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,22 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_ALLOCATOR_FORWARD_HPP
#define BOOST_ALIGN_ALIGNED_ALLOCATOR_FORWARD_HPP
#include <cstddef>
namespace boost {
namespace alignment {
template<class T, std::size_t Alignment = 1>
class aligned_allocator;
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,31 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_DELETE_HPP
#define BOOST_ALIGN_ALIGNED_DELETE_HPP
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/aligned_delete_forward.hpp>
namespace boost {
namespace alignment {
struct aligned_delete {
template<class T>
void operator()(T* ptr) const
BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(ptr->~T())) {
if (ptr) {
ptr->~T();
boost::alignment::aligned_free(ptr);
}
}
};
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,19 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNED_DELETE_FORWARD_HPP
#define BOOST_ALIGN_ALIGNED_DELETE_FORWARD_HPP
namespace boost {
namespace alignment {
struct aligned_delete;
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,54 @@
/*
Copyright 2014-2016 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNMENT_OF_HPP
#define BOOST_ALIGN_ALIGNMENT_OF_HPP
#include <boost/align/detail/element_type.hpp>
#include <boost/align/alignment_of_forward.hpp>
#if defined(_MSC_VER) && defined(__clang__)
#include <boost/align/detail/alignment_of_cxx11.hpp>
#elif defined(BOOST_MSVC)
#include <boost/align/detail/alignment_of_msvc.hpp>
#elif defined(__GNUC__) && defined(__unix__) && !defined(__LP64__)
#include <boost/align/detail/alignment_of.hpp>
#elif defined(BOOST_CLANG) && !defined(__x86_64__)
#include <boost/align/detail/alignment_of.hpp>
#elif !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
#include <boost/align/detail/alignment_of_cxx11.hpp>
#elif defined(__ghs__) && (__GHS_VERSION_NUMBER >= 600)
#include <boost/align/detail/alignment_of_gcc.hpp>
#elif defined(BOOST_CODEGEARC)
#include <boost/align/detail/alignment_of_codegear.hpp>
#elif defined(BOOST_CLANG)
#include <boost/align/detail/alignment_of_clang.hpp>
#elif __GNUC__ > 4
#include <boost/align/detail/alignment_of_gcc.hpp>
#elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)
#include <boost/align/detail/alignment_of_gcc.hpp>
#else
#include <boost/align/detail/alignment_of.hpp>
#endif
namespace boost {
namespace alignment {
template<class T>
struct alignment_of
: detail::alignment_of<typename
detail::element_type<T>::type>::type { };
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
template<class T>
constexpr std::size_t alignment_of_v = alignment_of<T>::value;
#endif
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,20 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ALIGNMENT_OF_FORWARD_HPP
#define BOOST_ALIGN_ALIGNMENT_OF_FORWARD_HPP
namespace boost {
namespace alignment {
template<class T>
struct alignment_of;
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,28 @@
/*
Copyright 2015 NumScale SAS
Copyright 2015 LRI UMR 8623 CNRS/University Paris Sud XI
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_ASSUME_ALIGNED_HPP
#define BOOST_ALIGN_ASSUME_ALIGNED_HPP
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#include <boost/align/detail/assume_aligned_msvc.hpp>
#elif defined(BOOST_CLANG) && defined(__has_builtin)
#include <boost/align/detail/assume_aligned_clang.hpp>
#elif BOOST_GCC_VERSION >= 40700
#include <boost/align/detail/assume_aligned_gcc.hpp>
#elif defined(__INTEL_COMPILER)
#include <boost/align/detail/assume_aligned_intel.hpp>
#else
#include <boost/align/detail/assume_aligned.hpp>
#endif
#endif

View File

@@ -0,0 +1,44 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ADD_REFERENCE_HPP
#define BOOST_ALIGN_DETAIL_ADD_REFERENCE_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
#include <type_traits>
#endif
namespace boost {
namespace alignment {
namespace detail {
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
using std::add_lvalue_reference;
#else
template<class T>
struct add_lvalue_reference {
typedef T& type;
};
template<>
struct add_lvalue_reference<void> {
typedef void type;
};
template<>
struct add_lvalue_reference<const void> {
typedef const void type;
};
#endif
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,38 @@
/*
Copyright 2014-2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace alignment {
inline void*
align(std::size_t alignment, std::size_t size, void*& ptr,
std::size_t& space)
{
BOOST_ASSERT(boost::alignment::detail::is_alignment(alignment));
if (size <= space) {
char* p = reinterpret_cast<char*>(~(alignment - 1) &
(reinterpret_cast<std::size_t>(ptr) + alignment - 1));
std::size_t n = p - static_cast<char*>(ptr);
if (n <= space - size) {
ptr = p;
space -= n;
return p;
}
}
return 0;
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,21 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
#include <memory>
namespace boost {
namespace alignment {
using std::align;
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,28 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_DOWN_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_DOWN_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace alignment {
inline void*
align_down(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return reinterpret_cast<void*>(~(alignment - 1) &
reinterpret_cast<std::size_t>(ptr));
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,28 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGN_UP_HPP
#define BOOST_ALIGN_DETAIL_ALIGN_UP_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace alignment {
inline void*
align_up(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return reinterpret_cast<void*>(~(alignment - 1) &
(reinterpret_cast<std::size_t>(ptr) + alignment - 1));
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,52 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/align/align.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/assert.hpp>
#include <cstdlib>
namespace boost {
namespace alignment {
inline void*
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
enum {
N = alignment_of<void*>::value
};
if (alignment < N) {
alignment = N;
}
std::size_t n = size + alignment - N;
void* p = std::malloc(sizeof(void*) + n);
if (p) {
void* r = static_cast<char*>(p) + sizeof(void*);
(void)boost::alignment::align(alignment, size, r, n);
*(static_cast<void**>(r) - 1) = p;
p = r;
}
return p;
}
inline void
aligned_free(void* ptr) BOOST_NOEXCEPT
{
if (ptr) {
std::free(*(static_cast<void**>(ptr) - 1));
}
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,34 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_ANDROID_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_ANDROID_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
#include <malloc.h>
namespace boost {
namespace alignment {
inline void*
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return ::memalign(alignment, size);
}
inline void
aligned_free(void* ptr) BOOST_NOEXCEPT
{
::free(ptr);
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,44 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
#include <stdlib.h>
namespace boost {
namespace alignment {
inline void*
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
if (size == 0) {
return 0;
}
if (alignment < sizeof(void*)) {
alignment = sizeof(void*);
}
void* p;
if (::posix_memalign(&p, alignment, size) != 0) {
p = 0;
}
return p;
}
inline void
aligned_free(void* ptr) BOOST_NOEXCEPT
{
::free(ptr);
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MINGW_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MINGW_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
#include <malloc.h>
namespace boost {
namespace alignment {
inline void*
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return ::__mingw_aligned_malloc(size, alignment);
}
inline void
aligned_free(void* ptr) BOOST_NOEXCEPT
{
::__mingw_aligned_free(ptr);
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,34 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MSVC_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MSVC_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
#include <malloc.h>
namespace boost {
namespace alignment {
inline void*
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return ::_aligned_malloc(size, alignment);
}
inline void
aligned_free(void* ptr) BOOST_NOEXCEPT
{
::_aligned_free(ptr);
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,52 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_NEW_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_NEW_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/align/align.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/assert.hpp>
#include <new>
namespace boost {
namespace alignment {
inline void*
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
enum {
N = alignment_of<void*>::value
};
if (alignment < N) {
alignment = N;
}
std::size_t n = size + alignment - N;
void* p = ::operator new(sizeof(void*) + n, std::nothrow);
if (p) {
void* r = static_cast<char*>(p) + sizeof(void*);
(void)boost::alignment::align(alignment, size, r, n);
*(static_cast<void**>(r) - 1) = p;
p = r;
}
return p;
}
inline void
aligned_free(void* ptr) BOOST_NOEXCEPT
{
if (ptr) {
::operator delete(*(static_cast<void**>(ptr) - 1));
}
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,41 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_POSIX_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_POSIX_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
#include <stdlib.h>
namespace boost {
namespace alignment {
inline void*
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
if (alignment < sizeof(void*)) {
alignment = sizeof(void*);
}
void* p;
if (::posix_memalign(&p, alignment, size) != 0) {
p = 0;
}
return p;
}
inline void
aligned_free(void* ptr) BOOST_NOEXCEPT
{
::free(ptr);
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,34 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_SUNOS_HPP
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_SUNOS_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
#include <stdlib.h>
namespace boost {
namespace alignment {
inline void*
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return ::memalign(alignment, size);
}
inline void
aligned_free(void* ptr) BOOST_NOEXCEPT
{
::free(ptr);
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,31 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP
#include <boost/align/detail/min_size.hpp>
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct offset_value {
char value;
T object;
};
template<class T>
struct alignment_of
: min_size<sizeof(T), sizeof(offset_value<T>) - sizeof(T)> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CLANG_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CLANG_HPP
#include <boost/align/detail/integral_constant.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct alignment_of
: integral_constant<std::size_t, __alignof(T)> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CODEGEAR_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CODEGEAR_HPP
#include <boost/align/detail/integral_constant.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct alignment_of
: integral_constant<std::size_t, alignof(T)> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,23 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CXX11_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CXX11_HPP
#include <type_traits>
namespace boost {
namespace alignment {
namespace detail {
using std::alignment_of;
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_GCC_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_GCC_HPP
#include <boost/align/detail/integral_constant.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct alignment_of
: integral_constant<std::size_t, __alignof__(T)> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,32 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_MSVC_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_MSVC_HPP
#include <boost/align/detail/min_size.hpp>
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct offset_value {
T first;
char value;
T second;
};
template<class T>
struct alignment_of
: min_size<sizeof(T), sizeof(offset_value<T>) - (sizeof(T) << 1)> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,16 @@
/*
Copyright 2015 NumScale SAS
Copyright 2015 LRI UMR 8623 CNRS/University Paris Sud XI
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_HPP
#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment)
#endif

View File

@@ -0,0 +1,18 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_CLANG_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_CLANG_HPP
#if __has_builtin(__builtin_assume_aligned)
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
(p) = static_cast<__typeof__(p)>(__builtin_assume_aligned((p), (n)))
#else
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n)
#endif
#endif

View File

@@ -0,0 +1,17 @@
/*
Copyright 2015 NumScale SAS
Copyright 2015 LRI UMR 8623 CNRS/University Paris Sud XI
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_GCC_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_GCC_HPP
#define BOOST_ALIGN_ASSUME_ALIGNED(p, n) \
(p) = static_cast<__typeof__(p)>(__builtin_assume_aligned((p), (n)))
#endif

View File

@@ -0,0 +1,17 @@
/*
Copyright 2015 NumScale SAS
Copyright 2015 LRI UMR 8623 CNRS/University Paris Sud XI
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_INTEL_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_INTEL_HPP
#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment) \
__assume_aligned((ptr), (alignment))
#endif

View File

@@ -0,0 +1,19 @@
/*
Copyright 2015 NumScale SAS
Copyright 2015 LRI UMR 8623 CNRS/University Paris Sud XI
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_MSVC_HPP
#define BOOST_ALIGN_DETAIL_ASSUME_ALIGNED_MSVC_HPP
#include <cstddef>
#define BOOST_ALIGN_ASSUME_ALIGNED(ptr, alignment) \
__assume((reinterpret_cast<std::size_t>(ptr) & ((alignment) - 1)) == 0)
#endif

View File

@@ -0,0 +1,91 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_ELEMENT_TYPE_HPP
#define BOOST_ALIGN_DETAIL_ELEMENT_TYPE_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
#include <type_traits>
#else
#include <cstddef>
#endif
namespace boost {
namespace alignment {
namespace detail {
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
using std::remove_reference;
using std::remove_all_extents;
using std::remove_cv;
#else
template<class T>
struct remove_reference {
typedef T type;
};
template<class T>
struct remove_reference<T&> {
typedef T type;
};
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T>
struct remove_reference<T&&> {
typedef T type;
};
#endif
template<class T>
struct remove_all_extents {
typedef T type;
};
template<class T>
struct remove_all_extents<T[]> {
typedef typename remove_all_extents<T>::type type;
};
template<class T, std::size_t N>
struct remove_all_extents<T[N]> {
typedef typename remove_all_extents<T>::type type;
};
template<class T>
struct remove_cv {
typedef T type;
};
template<class T>
struct remove_cv<const T> {
typedef T type;
};
template<class T>
struct remove_cv<volatile T> {
typedef T type;
};
template<class T>
struct remove_cv<const volatile T> {
typedef T type;
};
#endif
template<class T>
struct element_type {
typedef typename remove_cv<typename remove_all_extents<typename
remove_reference<T>::type>::type>::type type;
};
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,53 @@
/*
Copyright 2014-2016 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_INTEGRAL_CONSTANT_HPP
#define BOOST_ALIGN_DETAIL_INTEGRAL_CONSTANT_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
#include <type_traits>
#endif
namespace boost {
namespace alignment {
namespace detail {
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
using std::integral_constant;
using std::true_type;
using std::false_type;
#else
template<class T, T Value>
struct integral_constant {
typedef T value_type;
typedef integral_constant type;
BOOST_CONSTEXPR operator value_type() const BOOST_NOEXCEPT {
return Value;
}
BOOST_CONSTEXPR value_type operator()() const BOOST_NOEXCEPT {
return Value;
}
BOOST_STATIC_CONSTEXPR T value = Value;
};
template<class T, T Value>
BOOST_CONSTEXPR_OR_CONST T integral_constant<T, Value>::value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
#endif
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,34 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP
#define BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP
#include <boost/align/detail/is_alignment.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace alignment {
inline bool
is_aligned(const volatile void* ptr, std::size_t alignment) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return (reinterpret_cast<std::size_t>(ptr) & (alignment - 1)) == 0;
}
inline bool
is_aligned(std::size_t alignment, const volatile void* ptr) BOOST_NOEXCEPT
{
BOOST_ASSERT(detail::is_alignment(alignment));
return (reinterpret_cast<std::size_t>(ptr) & (alignment - 1)) == 0;
}
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,28 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
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
#include <boost/config.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
BOOST_CONSTEXPR inline bool
is_alignment(std::size_t value) BOOST_NOEXCEPT
{
return (value > 0) && ((value & (value - 1)) == 0);
}
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNMENT_CONSTANT_HPP
#define BOOST_ALIGN_DETAIL_IS_ALIGNMENT_CONSTANT_HPP
#include <boost/align/detail/integral_constant.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
template<std::size_t N>
struct is_alignment_constant
: integral_constant<bool, (N > 0) && ((N & (N - 1)) == 0)> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_MAX_ALIGN_HPP
#define BOOST_ALIGN_DETAIL_MAX_ALIGN_HPP
#include <boost/align/detail/max_size.hpp>
#include <boost/align/alignment_of.hpp>
namespace boost {
namespace alignment {
namespace detail {
template<class A, class B>
struct max_align
: max_size<alignment_of<A>::value, alignment_of<B>::value> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,27 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_MAX_OBJECTS_HPP
#define BOOST_ALIGN_DETAIL_MAX_OBJECTS_HPP
#include <boost/align/detail/integral_constant.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct max_objects
: integral_constant<std::size_t,
~static_cast<std::size_t>(0) / sizeof(T)> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_MAX_SIZE_HPP
#define BOOST_ALIGN_DETAIL_MAX_SIZE_HPP
#include <boost/align/detail/integral_constant.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
template<std::size_t A, std::size_t B>
struct max_size
: integral_constant<std::size_t, (A > B) ? A : B> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_MIN_SIZE_HPP
#define BOOST_ALIGN_DETAIL_MIN_SIZE_HPP
#include <boost/align/detail/integral_constant.hpp>
#include <cstddef>
namespace boost {
namespace alignment {
namespace detail {
template<std::size_t A, std::size_t B>
struct min_size
: integral_constant<std::size_t, (A < B) ? A : B> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,27 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_NOT_POINTER_HPP
#define BOOST_ALIGN_DETAIL_NOT_POINTER_HPP
namespace boost {
namespace alignment {
namespace detail {
template<class T, class U>
struct not_pointer {
typedef U type;
};
template<class T, class U>
struct not_pointer<T*, U> { };
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,44 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_DETAIL_THROW_EXCEPTION_HPP
#define BOOST_ALIGN_DETAIL_THROW_EXCEPTION_HPP
#include <boost/config.hpp>
#if defined(BOOST_NO_EXCEPTIONS)
#include <exception>
#endif
namespace boost {
#if defined(BOOST_NO_EXCEPTIONS)
BOOST_NORETURN void throw_exception(const std::exception&);
#endif
namespace alignment {
namespace detail {
#if !defined(BOOST_NO_EXCEPTIONS)
template<class E>
BOOST_NORETURN inline void
throw_exception(const E& error)
{
throw error;
}
#else
BOOST_NORETURN inline void
throw_exception(const std::exception& error)
{
boost::throw_exception(error);
}
#endif
} /* detail */
} /* alignment */
} /* boost */
#endif

View File

@@ -0,0 +1,28 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_ALIGN_IS_ALIGNED_HPP
#define BOOST_ALIGN_IS_ALIGNED_HPP
#include <boost/align/detail/is_aligned.hpp>
#include <boost/align/detail/not_pointer.hpp>
namespace boost {
namespace alignment {
template<class T>
BOOST_CONSTEXPR inline typename detail::not_pointer<T, bool>::type
is_aligned(T value, std::size_t alignment) BOOST_NOEXCEPT
{
return (value & (T(alignment) - 1)) == 0;
}
} /* alignment */
} /* boost */
#endif