diff options
| author | Mark de Wever <koraq@xs4all.nl> | 2025-03-16 18:24:40 +0100 |
|---|---|---|
| committer | Mark de Wever <koraq@xs4all.nl> | 2025-03-17 18:03:53 +0100 |
| commit | b190535b0c056366cc764241a67d053193b054aa (patch) | |
| tree | 0f3e863e20ff5bbb9a53016908f7234bfa95a763 | |
| parent | 4fcce8dc4c58ccc092087d89c4ee73c326165373 (diff) | |
Final polish and fixes.users/mordante/P3107R5-implementation
9 files changed, 36 insertions, 44 deletions
diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index dcf9838edd74..952043f652c2 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -358,7 +358,7 @@ Status ---------------------------------------------------------- ----------------- ``__cpp_lib_out_ptr`` ``202106L`` ---------------------------------------------------------- ----------------- - ``__cpp_lib_print`` ``202207L`` + ``__cpp_lib_print`` ``202403L`` ---------------------------------------------------------- ----------------- ``__cpp_lib_ranges`` ``202406L`` ---------------------------------------------------------- ----------------- diff --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv index 1436db6cf2b4..5ccb60e9cf66 100644 --- a/libcxx/docs/Status/Cxx2cPapers.csv +++ b/libcxx/docs/Status/Cxx2cPapers.csv @@ -50,7 +50,7 @@ "`P2867R2 <https://wg21.link/P2867R2>`__","Remove Deprecated ``strstreams`` From C++26","2024-03 (Tokyo)","|Complete|","19","" "`P2869R4 <https://wg21.link/P2869R4>`__","Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26","2024-03 (Tokyo)","","","" "`P2872R3 <https://wg21.link/P2872R3>`__","Remove ``wstring_convert`` From C++26","2024-03 (Tokyo)","|Complete|","19","" -"`P3107R5 <https://wg21.link/P3107R5>`__","Permit an efficient implementation of ``std::print``","2024-03 (Tokyo)","","","" +"`P3107R5 <https://wg21.link/P3107R5>`__","Permit an efficient implementation of ``std::print``","2024-03 (Tokyo)","|Complete|","21","" "`P3142R0 <https://wg21.link/P3142R0>`__","Printing Blank Lines with ``println``","2024-03 (Tokyo)","|Complete|","19","Implemented as a DR against C++23. (MSVC STL and libstdc++ will do the same.)" "`P2845R8 <https://wg21.link/P2845R8>`__","Formatting of ``std::filesystem::path``","2024-03 (Tokyo)","","","" "`P0493R5 <https://wg21.link/P0493R5>`__","Atomic minimum/maximum","2024-03 (Tokyo)","","","" diff --git a/libcxx/include/print b/libcxx/include/print index 3372b08bbcad..8cc7c07aa0d2 100644 --- a/libcxx/include/print +++ b/libcxx/include/print @@ -241,7 +241,7 @@ _LIBCPP_HIDE_FROM_ABI inline void __funlockfile(FILE* __stream) { _LIBCPP_HIDE_FROM_ABI inline int __fflush_unlocked(FILE* __stream) { # if defined(_LIBCPP_WIN32API) return ::_fflush_nolock(__stream); -# elif defined(__PICOLIBC__) || defined(_AIX) || defined(__ANDROID__) +# elif defined(__PICOLIBC__) || defined(_AIX) || defined(__ANDROID__) || defined(__APPLE__) // There is no fflush_unlocked on these systems. // This funcion is not part of POSIX. return ::fflush(__stream); @@ -257,7 +257,7 @@ _LIBCPP_HIDE_FROM_ABI inline size_t __fwrite_unlocked(const void* __buffer, [[maybe_unused]] size_t __size, size_t __n, FILE* __stream) { # if defined(_LIBCPP_WIN32API) return ::_fwrite_nolock(__buffer, __size, __n, __stream); -# elif defined(__PICOLIBC__) || defined(_AIX) || defined(__ANDROID__) +# elif defined(__PICOLIBC__) || defined(_AIX) || defined(__ANDROID__) || defined(__APPLE__) // The function fwrite_unlocked is not part of POSIX and not available on // these systems. auto __b = static_cast<const char*>(__buffer); @@ -291,7 +291,7 @@ _LIBCPP_HIDE_FROM_ABI int __fflush(FILE* __stream) { return std::fflush(__stream); else # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600 - sizeof(__lock_policy) == 0 + static_assert(sizeof(__lock_policy) == 0, "Unsupported policy"); # else static_assert(false, "Unsupported policy"); # endif @@ -316,7 +316,7 @@ public: __print::__flockfile(__stream_); else if constexpr (__policy != __lock_policy::__stdio) # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600 - sizeof(__lock_policy) == 0 + static_assert(sizeof(__lock_policy) == 0, "Unsupported policy"); # else static_assert(false, "Unsupported policy"); # endif @@ -327,7 +327,7 @@ public: __print::__funlockfile(__stream_); else if constexpr (__policy != __lock_policy::__stdio) # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600 - sizeof(__lock_policy) == 0 + static_assert(sizeof(__lock_policy) == 0, "Unsupported policy"); # else static_assert(false, "Unsupported policy"); # endif @@ -359,7 +359,7 @@ private: return std::fwrite(__small_buffer_, 1, __n, __stream_); else # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600 - sizeof(__lock_policy) == 0 + static_assert(sizeof(__lock_policy) == 0, "Unsupported policy"); # else static_assert(false, "Unsupported policy"); # endif @@ -505,20 +505,19 @@ __vprint_unicode([[maybe_unused]] FILE* __stream, template <class... _Args> _LIBCPP_HIDE_FROM_ABI void print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) { -# if _LIBCPP_HAS_UNICODE - constexpr bool __use_unicode = __print::__use_unicode_execution_charset; -# else // _LIBCPP_HAS_UNICODE - constexpr bool __use_unicode = false; -# endif // _LIBCPP_HAS_UNICODE constexpr bool __locksafe = (enable_nonlocking_formatter_optimization<remove_cvref_t<_Args>> && ...); using enum __print::__lock_policy; - if constexpr (__use_unicode) +# if _LIBCPP_HAS_UNICODE + if constexpr (__print::__use_unicode_execution_charset) __print::__vprint_unicode<__locksafe ? __manual : __stdio>( __stream, __fmt.get(), std::make_format_args(__args...), false); else +# endif // _LIBCPP_HAS_UNICODE + { __print::__vprint_nonunicode<__locksafe ? __manual : __stdio>( __stream, __fmt.get(), std::make_format_args(__args...), false); + } } template <class... _Args> @@ -528,23 +527,22 @@ _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __arg template <class... _Args> _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) { -# if _LIBCPP_HAS_UNICODE - constexpr bool __use_unicode = __print::__use_unicode_execution_charset; -# else // _LIBCPP_HAS_UNICODE - constexpr bool __use_unicode = false; -# endif // _LIBCPP_HAS_UNICODE constexpr bool __locksafe = (enable_nonlocking_formatter_optimization<remove_cvref_t<_Args>> && ...); // Note the wording in the Standard is inefficient. The output of // std::format is a std::string which is then copied. This solution // just appends a newline at the end of the output. using enum __print::__lock_policy; - if constexpr (__use_unicode) +# if _LIBCPP_HAS_UNICODE + if constexpr (__print::__use_unicode_execution_charset) __print::__vprint_unicode<__locksafe ? __manual : __stdio>( __stream, __fmt.get(), std::make_format_args(__args...), true); else +# endif // _LIBCPP_HAS_UNICODE + { __print::__vprint_nonunicode<__locksafe ? __manual : __stdio>( __stream, __fmt.get(), std::make_format_args(__args...), true); + } } template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). diff --git a/libcxx/include/version b/libcxx/include/version index 63ead9fd5d29..f2f3352815db 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -185,7 +185,7 @@ __cpp_lib_out_ptr 202311L <memory> __cpp_lib_parallel_algorithm 201603L <algorithm> <numeric> __cpp_lib_philox_engine 202406L <random> __cpp_lib_polymorphic_allocator 201902L <memory_resource> -__cpp_lib_print 202207L <ostream> <print> +__cpp_lib_print 202403L <ostream> <print> __cpp_lib_quoted_string_io 201304L <iomanip> __cpp_lib_ranges 202406L <algorithm> <functional> <iterator> <memory> <ranges> @@ -502,7 +502,7 @@ __cpp_lib_void_t 201411L <type_traits> # define __cpp_lib_optional 202110L # define __cpp_lib_out_ptr 202106L # if _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT -# define __cpp_lib_print 202207L +# define __cpp_lib_print 202403L # endif # undef __cpp_lib_ranges # define __cpp_lib_ranges 202406L diff --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py index 304c803b76c3..f01126249c88 100644 --- a/libcxx/test/libcxx/system_reserved_names.gen.py +++ b/libcxx/test/libcxx/system_reserved_names.gen.py @@ -119,11 +119,6 @@ for header in public_headers: #define __acquire SYSTEM_RESERVED_NAME #define __release SYSTEM_RESERVED_NAME -// Android and FreeBSD use this for __attribute__((__unused__)) -#if !defined(__FreeBSD__) && !defined(__ANDROID__) -#define __unused SYSTEM_RESERVED_NAME -#endif - // These names are not reserved, so the user can macro-define them. // These are intended to find improperly _Uglified template parameters. #define A SYSTEM_RESERVED_NAME diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.compile.pass.cpp index 61d7747e4b6d..16bcb02c2516 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.compile.pass.cpp @@ -19,7 +19,7 @@ /* Constant Value __cpp_lib_char8_t 201907L [C++20] - __cpp_lib_print 202207L [C++23] + __cpp_lib_print 202403L [C++23] */ #include <ostream> @@ -93,8 +93,8 @@ # ifndef __cpp_lib_print # error "__cpp_lib_print should be defined in c++23" # endif -# if __cpp_lib_print != 202207L -# error "__cpp_lib_print should have the value 202207L in c++23" +# if __cpp_lib_print != 202403L +# error "__cpp_lib_print should have the value 202403L in c++23" # endif # else # ifdef __cpp_lib_print @@ -121,8 +121,8 @@ # ifndef __cpp_lib_print # error "__cpp_lib_print should be defined in c++26" # endif -# if __cpp_lib_print != 202207L -# error "__cpp_lib_print should have the value 202207L in c++26" +# if __cpp_lib_print != 202403L +# error "__cpp_lib_print should have the value 202403L in c++26" # endif # else # ifdef __cpp_lib_print diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/print.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/print.version.compile.pass.cpp index c9743cf41ef1..de04d0bf02ba 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/print.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/print.version.compile.pass.cpp @@ -18,7 +18,7 @@ // Test the feature test macros defined by <print> /* Constant Value - __cpp_lib_print 202207L [C++23] + __cpp_lib_print 202403L [C++23] */ #include <print> @@ -54,8 +54,8 @@ # ifndef __cpp_lib_print # error "__cpp_lib_print should be defined in c++23" # endif -# if __cpp_lib_print != 202207L -# error "__cpp_lib_print should have the value 202207L in c++23" +# if __cpp_lib_print != 202403L +# error "__cpp_lib_print should have the value 202403L in c++23" # endif # else # ifdef __cpp_lib_print @@ -69,8 +69,8 @@ # ifndef __cpp_lib_print # error "__cpp_lib_print should be defined in c++26" # endif -# if __cpp_lib_print != 202207L -# error "__cpp_lib_print should have the value 202207L in c++26" +# if __cpp_lib_print != 202403L +# error "__cpp_lib_print should have the value 202403L in c++26" # endif # else # ifdef __cpp_lib_print 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 index 1e4465d515e6..6e2d3eec7f36 100644 --- 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 @@ -169,7 +169,7 @@ __cpp_lib_parallel_algorithm 201603L [C++17] __cpp_lib_philox_engine 202406L [C++26] __cpp_lib_polymorphic_allocator 201902L [C++20] - __cpp_lib_print 202207L [C++23] + __cpp_lib_print 202403L [C++23] __cpp_lib_quoted_string_io 201304L [C++14] __cpp_lib_ranges 202110L [C++20] 202406L [C++23] @@ -5683,8 +5683,8 @@ # ifndef __cpp_lib_print # error "__cpp_lib_print should be defined in c++23" # endif -# if __cpp_lib_print != 202207L -# error "__cpp_lib_print should have the value 202207L in c++23" +# if __cpp_lib_print != 202403L +# error "__cpp_lib_print should have the value 202403L in c++23" # endif # else # ifdef __cpp_lib_print @@ -7567,8 +7567,8 @@ # ifndef __cpp_lib_print # error "__cpp_lib_print should be defined in c++26" # endif -# if __cpp_lib_print != 202207L -# error "__cpp_lib_print should have the value 202207L in c++26" +# if __cpp_lib_print != 202403L +# error "__cpp_lib_print should have the value 202403L in c++26" # endif # else # ifdef __cpp_lib_print diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 8bf7633e985d..7a0f31e6b746 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -1010,8 +1010,7 @@ feature_test_macros = [ { "name": "__cpp_lib_print", "values": { - "c++23": 202207, - # "c++26": 202403, # P3107R5: Permit an efficient implementation of std::print + "c++23": 202403, # "c++26": 202406, # P3235R3 std::print more types faster with less memory }, "headers": ["ostream", "print"], |
