Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:33:48

0001 /*
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * Copyright (c) 2020 Andrey Semashev
0007  */
0008 /*!
0009  * \file   atomic/detail/aligned_variable.hpp
0010  *
0011  * This header defines a convenience macro for declaring aligned variables
0012  */
0013 
0014 #ifndef BOOST_ATOMIC_DETAIL_ALIGNED_VARIABLE_HPP_INCLUDED_
0015 #define BOOST_ATOMIC_DETAIL_ALIGNED_VARIABLE_HPP_INCLUDED_
0016 
0017 #include <boost/atomic/detail/config.hpp>
0018 #if defined(BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS)
0019 #include <boost/config/helper_macros.hpp>
0020 #include <boost/type_traits/type_with_alignment.hpp>
0021 #endif
0022 #include <boost/atomic/detail/header.hpp>
0023 
0024 #ifdef BOOST_HAS_PRAGMA_ONCE
0025 #pragma once
0026 #endif
0027 
0028 #if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS)
0029 
0030 #define BOOST_ATOMIC_DETAIL_ALIGNED_VAR(var_alignment, var_type, var_name) \
0031     alignas(var_alignment) var_type var_name
0032 
0033 #define BOOST_ATOMIC_DETAIL_ALIGNED_VAR_TPL(var_alignment, var_type, var_name) \
0034     alignas(var_alignment) var_type var_name
0035 
0036 #else // !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS)
0037 
0038 // Note: Some compilers cannot use constant expressions in alignment attributes or alignas, so we have to use the union trick
0039 #define BOOST_ATOMIC_DETAIL_ALIGNED_VAR(var_alignment, var_type, var_name) \
0040     union \
0041     { \
0042         var_type var_name; \
0043         boost::type_with_alignment< var_alignment >::type BOOST_JOIN(var_name, _aligner); \
0044     }
0045 
0046 #define BOOST_ATOMIC_DETAIL_ALIGNED_VAR_TPL(var_alignment, var_type, var_name) \
0047     union \
0048     { \
0049         var_type var_name; \
0050         typename boost::type_with_alignment< var_alignment >::type BOOST_JOIN(var_name, _aligner); \
0051     }
0052 
0053 #endif // !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_ALIGNAS)
0054 
0055 #include <boost/atomic/detail/footer.hpp>
0056 
0057 #endif // BOOST_ATOMIC_DETAIL_ALIGNED_VARIABLE_HPP_INCLUDED_