mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Replace deprecated builtin __is_trivially_relocatable if possible (#1402)
Fixes: #1400
This commit is contained in:
parent
a97817010e
commit
fbd738db69
@ -159,6 +159,12 @@ SOFTWARE.
|
||||
#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE)
|
||||
#define ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE __has_builtin(__is_trivially_relocatable)
|
||||
#endif
|
||||
|
||||
// __builtin_is_cpp_trivially_relocatable replaces __is_trivially_relocatable by an
|
||||
// effort of standardization for newer C++ standards
|
||||
#if !defined(ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE)
|
||||
#define ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE __has_builtin(__builtin_is_cpp_trivially_relocatable)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// The default. Set to 0, if not already set.
|
||||
@ -226,28 +232,33 @@ SOFTWARE.
|
||||
#define ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE 0
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE)
|
||||
#define ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE 0
|
||||
#endif
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace traits
|
||||
{
|
||||
// Documentation: https://www.etlcpp.com/etl_traits.html
|
||||
|
||||
static ETL_CONSTANT bool using_builtin_is_assignable = (ETL_USING_BUILTIN_IS_ASSIGNABLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_constructible = (ETL_USING_BUILTIN_IS_CONSTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_nothrow_constructible = (ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_nothrow_assignable = (ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_trivially_constructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_trivially_destructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_trivially_copyable = (ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_underlying_type = (ETL_USING_BUILTIN_UNDERLYING_TYPE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_constant_evaluated = (ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memcpy = (ETL_USING_BUILTIN_MEMCPY == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memmove = (ETL_USING_BUILTIN_MEMMOVE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memset = (ETL_USING_BUILTIN_MEMSET == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memcmp = (ETL_USING_BUILTIN_MEMCMP == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memchr = (ETL_USING_BUILTIN_MEMCHR == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_virtual_base_of = (ETL_USING_BUILTIN_IS_VIRTUAL_BASE_OF == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_trivially_relocatable = (ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_assignable = (ETL_USING_BUILTIN_IS_ASSIGNABLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_constructible = (ETL_USING_BUILTIN_IS_CONSTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_nothrow_constructible = (ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_nothrow_assignable = (ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_trivially_constructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_trivially_destructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_trivially_copyable = (ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_underlying_type = (ETL_USING_BUILTIN_UNDERLYING_TYPE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_constant_evaluated = (ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memcpy = (ETL_USING_BUILTIN_MEMCPY == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memmove = (ETL_USING_BUILTIN_MEMMOVE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memset = (ETL_USING_BUILTIN_MEMSET == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memcmp = (ETL_USING_BUILTIN_MEMCMP == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memchr = (ETL_USING_BUILTIN_MEMCHR == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_virtual_base_of = (ETL_USING_BUILTIN_IS_VIRTUAL_BASE_OF == 1);
|
||||
static ETL_CONSTANT bool using_builtin_is_trivially_relocatable = (ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE == 1);
|
||||
static ETL_CONSTANT bool using_builtin_builtin_is_cpp_trivially_relocatable = (ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE == 1);
|
||||
} // namespace traits
|
||||
} // namespace etl
|
||||
|
||||
|
||||
@ -2728,6 +2728,9 @@ namespace etl
|
||||
#if ETL_HAS_STD_TRIVIALLY_RELOCATABLE && ETL_USING_STL
|
||||
template <typename T>
|
||||
using is_trivially_relocatable = std::is_trivially_relocatable<T>;
|
||||
#elif ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE
|
||||
template <typename T>
|
||||
using is_trivially_relocatable = etl::bool_constant<__builtin_is_cpp_trivially_relocatable(T)>;
|
||||
#elif ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE
|
||||
template <typename T>
|
||||
using is_trivially_relocatable = etl::bool_constant<__is_trivially_relocatable(T)>;
|
||||
@ -2977,7 +2980,9 @@ namespace etl
|
||||
template <typename T>
|
||||
struct is_trivially_relocatable
|
||||
{
|
||||
#if ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE
|
||||
#if ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE
|
||||
static ETL_CONSTANT bool value = __builtin_is_cpp_trivially_relocatable(T);
|
||||
#elif ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE
|
||||
static ETL_CONSTANT bool value = __is_trivially_relocatable(T);
|
||||
#else
|
||||
static ETL_CONSTANT bool value = etl::is_trivially_copyable<T>::value && etl::is_trivially_destructible<T>::value;
|
||||
@ -3500,7 +3505,9 @@ namespace etl
|
||||
//*********************************************
|
||||
// is_trivially_relocatable
|
||||
template <typename T>
|
||||
#if ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE
|
||||
#if ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE
|
||||
struct is_trivially_relocatable : public etl::bool_constant<__builtin_is_cpp_trivially_relocatable(T)>
|
||||
#elif ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE
|
||||
struct is_trivially_relocatable : public etl::bool_constant<__is_trivially_relocatable(T)>
|
||||
#else
|
||||
struct is_trivially_relocatable : public etl::bool_constant<etl::is_trivially_copyable<T>::value && etl::is_trivially_destructible<T>::value>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user