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/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -45,6 +45,7 @@ - P2216R3 (std::format improvements) - P0174R2 (Deprecating Vestigial Library Parts in C++17) - N4190 (Removing auto_ptr, random_shuffle(), And Old Stuff) +- P0154R1 (Hardware inference size) - Marked the following papers as "Complete" (note that some of those might have been implemented in a previous release but not marked as such): diff --git a/libcxx/docs/Status/Cxx17.rst b/libcxx/docs/Status/Cxx17.rst --- a/libcxx/docs/Status/Cxx17.rst +++ b/libcxx/docs/Status/Cxx17.rst @@ -42,7 +42,7 @@ .. [#note-P0067] P0067: ``std::(to|from)_chars`` for integrals has been available since version 7.0. ``std::to_chars`` for ``float`` and ``double`` since version 14.0 ``std::to_chars`` for ``long double`` uses the implementation for ``double``. .. [#note-P0607] P0607: The parts of P0607 that are not done are the ```` bits. - + .. [#note-P0154] P0154: This is currently not implemented for clang because clang does not implement the required macros. .. _issues-status-cxx17: 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","|Partial| [#note-P0154]_","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 @@ -360,6 +360,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 @@ -247,7 +247,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,17 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// XFAIL: clang && stdlib=libc++ + +#include + +#include "test_macros.h" + +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); diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/new.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/new.version.compile.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/new.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/new.version.compile.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.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -1806,16 +1806,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 @@ -2851,16 +2851,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 @@ -4088,16 +4088,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 @@ -329,8 +329,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 },