Sync from upstream.

This commit is contained in:
Rene Rivera
2024-04-20 15:33:29 -05:00
3 changed files with 68 additions and 2 deletions

View File

@ -0,0 +1,53 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_MOVE_DETAIL_LAUNDER_HPP
#define BOOST_MOVE_DETAIL_LAUNDER_HPP
#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/move/detail/workaround.hpp>
namespace boost {
namespace move_detail {
#if defined(BOOST_MOVE_HAS_BUILTIN_LAUNDER)
template<class T>
BOOST_MOVE_FORCEINLINE T* launder(T* p)
{
return __builtin_launder( p );
}
#else
template<class T>
BOOST_MOVE_FORCEINLINE T* launder(T* p)
{
return p;
}
#endif
template<class T>
BOOST_MOVE_FORCEINLINE T launder_cast(const volatile void* p)
{
return (launder)((T)p);
}
} //namespace move_detail {
} //namespace boost {
#endif //#ifndef BOOST_MOVE_DETAIL_LAUNDER_HPP

View File

@ -1197,12 +1197,20 @@ struct aligned_struct;
template <> struct aligned_struct<1> { char data; };
template <> struct aligned_struct<2> { short data; };
template <> struct aligned_struct<4> { int data; };
template <> struct aligned_struct<8> { double data; };
//8 byte alignment does not propely work in x86 if attribute is not used.
//If a user declares a variable with 8 byte alignment, such as a double
//the compiler will not realign the stack.
//
//If _declspec(align) is used MSVC will realign the stack.
//
//Disabled specialization
//template <> struct aligned_struct<8> { double data; };
#define BOOST_MOVE_ALIGNED_STRUCT(x) \
template <> struct aligned_struct<x> { \
__declspec(align(x)) char data; \
}
BOOST_MOVE_ALIGNED_STRUCT(8);
BOOST_MOVE_ALIGNED_STRUCT(16);
BOOST_MOVE_ALIGNED_STRUCT(32);
BOOST_MOVE_ALIGNED_STRUCT(64);

View File

@ -147,5 +147,10 @@ template<unsigned> struct static_assert_test {};
#define BOOST_MOVE_INTRINSIC_CAST BOOST_MOVE_FORCEINLINE
#endif
#endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP
#if defined(__has_builtin)
#if __has_builtin(__builtin_launder)
#define BOOST_MOVE_HAS_BUILTIN_LAUNDER
#endif
#endif
#endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP