diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -100,7 +100,7 @@ ------------------------------------------------- ----------------- ``__cpp_lib_gcd_lcm`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_hardware_interference_size`` *unimplemented* + ``__cpp_lib_hardware_interference_size`` ``201703L`` ------------------------------------------------- ----------------- ``__cpp_lib_has_unique_object_representations`` ``201606L`` ------------------------------------------------- ----------------- diff --git a/libcxx/docs/Status/Cxx17Papers.csv b/libcxx/docs/Status/Cxx17Papers.csv --- a/libcxx/docs/Status/Cxx17Papers.csv +++ b/libcxx/docs/Status/Cxx17Papers.csv @@ -35,7 +35,7 @@ "`P0185R1 `__","LWG","Adding [nothrow-]swappable traits","Jacksonville","|Complete|","3.9" "`P0253R1 `__","LWG","Fixing a design mistake in the searchers interface","Jacksonville","|Complete|","3.9" "`P0025R0 `__","LWG","An algorithm to ""clamp"" a value between a pair of boundary values","Jacksonville","|Complete|","3.9" -"`P0154R1 `__","LWG","constexpr std::hardware_{constructive,destructive}_interference_size","Jacksonville","","" +"`P0154R1 `__","LWG","constexpr std::hardware_{constructive,destructive}_interference_size","Jacksonville","|Complete|","15.0" "`P0030R1 `__","LWG","Proposal to Introduce a 3-Argument Overload to std::hypot","Jacksonville","|Complete|","3.9" "`P0031R0 `__","LWG","A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access","Jacksonville","|Complete|","4.0" "`P0272R1 `__","LWG","Give ``std::string``\ a non-const ``.data()``\ member function","Jacksonville","|Complete|","3.9" diff --git a/libcxx/include/new b/libcxx/include/new --- a/libcxx/include/new +++ b/libcxx/include/new @@ -359,6 +359,17 @@ } #endif +#if _LIBCPP_STD_VER > 14 + +#if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) + +inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; +inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; + +#endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) + +#endif // _LIBCPP_STD_VER > 14 + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_NEW diff --git a/libcxx/include/version b/libcxx/include/version --- a/libcxx/include/version +++ b/libcxx/include/version @@ -245,7 +245,9 @@ # define __cpp_lib_filesystem 201703L # endif # define __cpp_lib_gcd_lcm 201606L -// # define __cpp_lib_hardware_interference_size 201703L +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) +# define __cpp_lib_hardware_interference_size 201703L +# endif # define __cpp_lib_has_unique_object_representations 201606L # define __cpp_lib_hypot 201603L # define __cpp_lib_incomplete_container_elements 201505L diff --git a/libcxx/test/std/language.support/support.dynamic/hardware_inference_size.compile.pass.cpp b/libcxx/test/std/language.support/support.dynamic/hardware_inference_size.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/language.support/support.dynamic/hardware_inference_size.compile.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 + +#include + +#include "test_macros.h" + +#if defined(__cpp_lib_hardware_interference_size) && __cpp_lib_hardware_interference_size >= 201703 + +ASSERT_SAME_TYPE(decltype(std::hardware_destructive_interference_size), const std::size_t); +ASSERT_SAME_TYPE(decltype(std::hardware_constructive_interference_size), const std::size_t); + +#endif diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp @@ -58,16 +58,16 @@ # error "__cpp_lib_destroying_delete should not be defined before c++20" # endif -# if !defined(_LIBCPP_VERSION) +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) # ifndef __cpp_lib_hardware_interference_size # error "__cpp_lib_hardware_interference_size should be defined in c++17" # endif # if __cpp_lib_hardware_interference_size != 201703L # error "__cpp_lib_hardware_interference_size should have the value 201703L in c++17" # endif -# else // _LIBCPP_VERSION +# else # ifdef __cpp_lib_hardware_interference_size -# error "__cpp_lib_hardware_interference_size should not be defined because it is unimplemented in libc++!" +# error "__cpp_lib_hardware_interference_size should not be defined when defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) is not defined!" # endif # endif @@ -93,16 +93,16 @@ # endif # endif -# if !defined(_LIBCPP_VERSION) +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) # ifndef __cpp_lib_hardware_interference_size # error "__cpp_lib_hardware_interference_size should be defined in c++20" # endif # if __cpp_lib_hardware_interference_size != 201703L # error "__cpp_lib_hardware_interference_size should have the value 201703L in c++20" # endif -# else // _LIBCPP_VERSION +# else # ifdef __cpp_lib_hardware_interference_size -# error "__cpp_lib_hardware_interference_size should not be defined because it is unimplemented in libc++!" +# error "__cpp_lib_hardware_interference_size should not be defined when defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) is not defined!" # endif # endif @@ -128,16 +128,16 @@ # endif # endif -# if !defined(_LIBCPP_VERSION) +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) # ifndef __cpp_lib_hardware_interference_size # error "__cpp_lib_hardware_interference_size should be defined in c++2b" # endif # if __cpp_lib_hardware_interference_size != 201703L # error "__cpp_lib_hardware_interference_size should have the value 201703L in c++2b" # endif -# else // _LIBCPP_VERSION +# else # ifdef __cpp_lib_hardware_interference_size -# error "__cpp_lib_hardware_interference_size should not be defined because it is unimplemented in libc++!" +# error "__cpp_lib_hardware_interference_size should not be defined when defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) is not defined!" # endif # endif diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp @@ -1819,16 +1819,16 @@ # error "__cpp_lib_generic_unordered_lookup should not be defined before c++20" # endif -# if !defined(_LIBCPP_VERSION) +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) # ifndef __cpp_lib_hardware_interference_size # error "__cpp_lib_hardware_interference_size should be defined in c++17" # endif # if __cpp_lib_hardware_interference_size != 201703L # error "__cpp_lib_hardware_interference_size should have the value 201703L in c++17" # endif -# else // _LIBCPP_VERSION +# else # ifdef __cpp_lib_hardware_interference_size -# error "__cpp_lib_hardware_interference_size should not be defined because it is unimplemented in libc++!" +# error "__cpp_lib_hardware_interference_size should not be defined when defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) is not defined!" # endif # endif @@ -2880,16 +2880,16 @@ # error "__cpp_lib_generic_unordered_lookup should have the value 201811L in c++20" # endif -# if !defined(_LIBCPP_VERSION) +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) # ifndef __cpp_lib_hardware_interference_size # error "__cpp_lib_hardware_interference_size should be defined in c++20" # endif # if __cpp_lib_hardware_interference_size != 201703L # error "__cpp_lib_hardware_interference_size should have the value 201703L in c++20" # endif -# else // _LIBCPP_VERSION +# else # ifdef __cpp_lib_hardware_interference_size -# error "__cpp_lib_hardware_interference_size should not be defined because it is unimplemented in libc++!" +# error "__cpp_lib_hardware_interference_size should not be defined when defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) is not defined!" # endif # endif @@ -4139,16 +4139,16 @@ # error "__cpp_lib_generic_unordered_lookup should have the value 201811L in c++2b" # endif -# if !defined(_LIBCPP_VERSION) +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) # ifndef __cpp_lib_hardware_interference_size # error "__cpp_lib_hardware_interference_size should be defined in c++2b" # endif # if __cpp_lib_hardware_interference_size != 201703L # error "__cpp_lib_hardware_interference_size should have the value 201703L in c++2b" # endif -# else // _LIBCPP_VERSION +# else # ifdef __cpp_lib_hardware_interference_size -# error "__cpp_lib_hardware_interference_size should not be defined because it is unimplemented in libc++!" +# error "__cpp_lib_hardware_interference_size should not be defined when defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) is not defined!" # endif # endif diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -332,8 +332,9 @@ }, { "name": "__cpp_lib_hardware_interference_size", "values": { "c++17": 201703 }, + "test_suite_guard": "defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)", + "libcxx_guard": "defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)", "headers": ["new"], - "unimplemented": True, }, { "name": "__cpp_lib_has_unique_object_representations", "values": { "c++17": 201606 },