diff options
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 75 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/chrono_io.h | 55 | ||||
-rw-r--r-- | libstdc++-v3/include/std/format | 64 | ||||
-rw-r--r-- | libstdc++-v3/src/c++23/print.cc | 4 |
4 files changed, 151 insertions, 47 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8aa7ec8..94d4d02 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,78 @@ +2025-05-10 Alexandre Oliva <oliva@adacore.com> + + * src/c++23/print.cc [__VXWORKS__]: Include ioLib.h. + +2025-05-09 Tomasz Kamiński <tkaminsk@redhat.com> + + * include/bits/chrono_io.h (__formatter_chrono::_M_format_to): + Extracted from _M_format. + (__formatter_chrono::_M_format): Use _Padding_sink and delegate + to _M_format_to. + +2025-05-09 Tomasz Kamiński <tkaminsk@redhat.com> + + * include/std/format (__Sink_iter<_CharT>::_M_discarding) + (__Sink<_CharT>::_M_discarding, _Iter_sink<_CharT, _OutIter>::_M_discarding) + (_Padding_sinl<_CharT, _Out>::_M_padwidth) + (_Padding_sink<_CharT, _Out>::_M_maxwidth): Remove const. + (_Padding_sink<_CharT, _Out>::_M_sync_discarding) + (_Padding_sink<_CharT, _Out>::_M_discarding): Define. + (_Padding_sink<_CharT, _Out>::_Padding_sink(_Out, size_t, size_t)) + (_Padding_sink<_CharT, _Out>::_M_force_update): + (_Padding_sink<_CharT, _Out>::_M_flush): Call _M_sync_discarding. + (_Padding_sink<_CharT, _Out>::_Padding_sink(_Out, size_t)): Delegate. + +2025-05-07 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/120159 + * src/c++23/std.cc.in (is_layout_compatible_v): Export. + +2025-05-07 Jonathan Wakely <jwakely@redhat.com> + + * src/c++23/std.cc.in: Fix export for std::extents. + +2025-05-07 Luc Grosheintz <luc.grosheintz@gmail.com> + + * testsuite/23_containers/mdspan/extents/class_mandates_neg.cc: New test. + * testsuite/23_containers/mdspan/extents/ctor_copy.cc: New test. + * testsuite/23_containers/mdspan/extents/ctor_ints.cc: New test. + * testsuite/23_containers/mdspan/extents/ctor_shape.cc: New test. + * testsuite/23_containers/mdspan/extents/custom_integer.cc: New test. + * testsuite/23_containers/mdspan/extents/misc.cc: New test. + +2025-05-07 Luc Grosheintz <luc.grosheintz@gmail.com> + + PR libstdc++/107761 + * include/std/mdspan (extents): New class. + * src/c++23/std.cc.in: Add 'using std::extents'. + +2025-05-07 Luc Grosheintz <luc.grosheintz@gmail.com> + + * doc/doxygen/user.cfg.in: Add <mdspan>. + * include/Makefile.am: Ditto. + * include/Makefile.in: Ditto. + * include/precompiled/stdc++.h: Ditto. + * include/std/mdspan: New file. + +2025-05-07 Luc Grosheintz <luc.grosheintz@gmail.com> + + * include/bits/version.def: Add internal feature testing macro + __glibcxx_mdspan. + * include/bits/version.h: Regenerate. + +2025-05-07 Tomasz Kamiński <tkaminsk@redhat.com> + + PR libstdc++/120114 + * include/bits/chrono_io.h (__formatter_chrono::_M_format): Use __field_width. + * testsuite/std/time/format/pr120114.cc: New test. + +2025-05-07 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/120147 + * acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Restore use of + AC_LANG_CPLUSPLUS. + * configure: Regenerate. + 2025-05-06 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/70560 diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h index 620227a..ace8b9f 100644 --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -503,9 +503,7 @@ namespace __format _M_format(const _Tp& __t, _FormatContext& __fc, bool __is_neg = false) const { - auto __first = _M_spec._M_chrono_specs.begin(); - const auto __last = _M_spec._M_chrono_specs.end(); - if (__first == __last) + if (_M_spec._M_chrono_specs.empty()) return _M_format_to_ostream(__t, __fc, __is_neg); #if defined _GLIBCXX_USE_NL_LANGINFO_L && __CHAR_BIT__ == 8 @@ -525,29 +523,29 @@ namespace __format __fc._M_loc = __with_encoding_conversion(__loc); } #endif - - _Sink_iter<_CharT> __out; - __format::_Str_sink<_CharT> __sink; - bool __write_direct = false; - if constexpr (is_same_v<typename _FormatContext::iterator, - _Sink_iter<_CharT>>) - { - if (_M_spec._M_width_kind == __format::_WP_none) - { - __out = __fc.out(); - __write_direct = true; - } - else - __out = __sink.out(); - } - else - __out = __sink.out(); - // formatter<duration> passes the correct value of __is_neg // for durations but for hh_mm_ss we decide it here. if constexpr (__is_specialization_of<_Tp, chrono::hh_mm_ss>) __is_neg = __t.is_negative(); + const size_t __padwidth = _M_spec._M_get_width(__fc); + if (__padwidth == 0) + return _M_format_to(__t, __fc.out(), __fc, __is_neg); + + using _Out = typename _FormatContext::iterator; + _Padding_sink<_Out, _CharT> __sink(__fc.out(), __padwidth); + _M_format_to(__t, __sink.out(), __fc, __is_neg); + return __sink._M_finish(_M_spec._M_align, _M_spec._M_fill); + } + + template<typename _Tp, typename _Out, typename _FormatContext> + _Out + _M_format_to(const _Tp& __t, _Out __out, _FormatContext& __fc, + bool __is_neg) const + { + auto __first = _M_spec._M_chrono_specs.begin(); + const auto __last = _M_spec._M_chrono_specs.end(); + auto __print_sign = [&__is_neg, &__out] { if constexpr (chrono::__is_duration_v<_Tp> || __is_specialization_of<_Tp, chrono::hh_mm_ss>) @@ -699,20 +697,7 @@ namespace __format } } while (__first != __last); - - if constexpr (is_same_v<typename _FormatContext::iterator, - _Sink_iter<_CharT>>) - if (__write_direct) - return __out; - - auto __str = __sink.view(); - size_t __width; - if constexpr (__unicode::__literal_encoding_is_unicode<_CharT>()) - __width = __unicode::__field_width(__str); - else - __width = __str.size(); - return __format::__write_padded_as_spec(__str, __width, - __fc, _M_spec); + return std::move(__out); } _ChronoSpec<_CharT> _M_spec; diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 054ce35..b3192cf 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -3144,6 +3144,10 @@ namespace __format auto _M_reserve(size_t __n) const { return _M_sink->_M_reserve(__n); } + + bool + _M_discarding() const + { return _M_sink->_M_discarding(); } }; // Abstract base class for type-erased character sinks. @@ -3263,6 +3267,11 @@ namespace __format _M_bump(size_t __n) { _M_next += __n; } + // Returns true if the _Sink is discarding incoming characters. + virtual bool + _M_discarding() const + { return false; } + public: _Sink(const _Sink&) = delete; _Sink& operator=(const _Sink&) = delete; @@ -3488,6 +3497,14 @@ namespace __format _M_count += __s.size(); } + bool + _M_discarding() const override + { + // format_to_n return total number of characters, that would be written, + // see C++20 [format.functions] p20 + return false; + } + public: [[__gnu__::__always_inline__]] explicit @@ -3550,6 +3567,14 @@ namespace __format } } + bool + _M_discarding() const override + { + // format_to_n return total number of characters, that would be written, + // see C++20 [format.functions] p20 + return false; + } + typename _Sink<_CharT>::_Reservation _M_reserve(size_t __n) final { @@ -3636,17 +3661,15 @@ namespace __format template<typename _Out, typename _CharT> class _Padding_sink : public _Str_sink<_CharT> { - const size_t _M_padwidth; - const size_t _M_maxwidth; + size_t _M_padwidth; + size_t _M_maxwidth; _Out _M_out; size_t _M_printwidth; [[__gnu__::__always_inline__]] bool _M_ignoring() const - { - return _M_printwidth >= _M_maxwidth; - } + { return _M_printwidth >= _M_maxwidth; } [[__gnu__::__always_inline__]] bool @@ -3660,11 +3683,20 @@ namespace __format } void + _M_sync_discarding() + { + if constexpr (is_same_v<_Out, _Sink_iter<_CharT>>) + if (_M_out._M_discarding()) + _M_maxwidth = _M_printwidth; + } + + void _M_flush() { span<_CharT> __new = this->_M_used(); basic_string_view<_CharT> __str(__new.data(), __new.size()); _M_out = __format::__write(std::move(_M_out), __str); + _M_sync_discarding(); this->_M_rewind(); } @@ -3682,7 +3714,10 @@ namespace __format // We have more characters than padidng, no padding is needed, // write direclty to _M_out. if (_M_printwidth >= _M_padwidth) - _M_out = __format::__write(std::move(_M_out), __str); + { + _M_out = __format::__write(std::move(_M_out), __str); + _M_sync_discarding(); + } // We reached _M_maxwidth that is smaller than _M_padwidth. // Store the prefix sequence in _M_seq, and free _M_buf. else @@ -3718,6 +3753,10 @@ namespace __format _Str_sink<_CharT>::_M_overflow(); } + bool + _M_discarding() const override + { return _M_ignoring(); } + typename _Sink<_CharT>::_Reservation _M_reserve(size_t __n) override { @@ -3752,15 +3791,16 @@ namespace __format public: [[__gnu__::__always_inline__]] - explicit _Padding_sink(_Out __out, size_t __padwidth) - : _M_padwidth(__padwidth), _M_maxwidth(-1), + explicit + _Padding_sink(_Out __out, size_t __padwidth, size_t __maxwidth) + : _M_padwidth(__padwidth), _M_maxwidth(__maxwidth), _M_out(std::move(__out)), _M_printwidth(0) - { } + { _M_sync_discarding(); } [[__gnu__::__always_inline__]] - explicit _Padding_sink(_Out __out, size_t __padwidth, size_t __maxwidth) - : _M_padwidth(__padwidth), _M_maxwidth(__maxwidth), - _M_out(std::move(__out)), _M_printwidth(0) + explicit + _Padding_sink(_Out __out, size_t __padwidth) + : _Padding_sink(std::move(__out), __padwidth, (size_t)-1) { } _Out diff --git a/libstdc++-v3/src/c++23/print.cc b/libstdc++-v3/src/c++23/print.cc index 8ba7140..f343699 100644 --- a/libstdc++-v3/src/c++23/print.cc +++ b/libstdc++-v3/src/c++23/print.cc @@ -43,6 +43,10 @@ # include <unistd.h> // isatty #endif +#ifdef __VXWORKS__ +#include <ioLib.h> +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION |