mirror of
https://github.com/boostorg/move.git
synced 2025-07-29 20:07:13 +02:00
Sync from upstream.
This commit is contained in:
53
include/boost/move/detail/launder.hpp
Normal file
53
include/boost/move/detail/launder.hpp
Normal 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
|
@ -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);
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user