aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
AgeCommit message (Collapse)AuthorFilesLines
2020-01-01Update copyright years.Jakub Jelinek9390-16600/+16609
From-SVN: r279813
2019-12-30VxWorks has_nanosleep for libstdc++ enable-libstdcxx-time autoCorentin Gay3-0/+15
2019-12-30 Corentin Gay <gay@adacore.com> * acinclude.m4 (vxworks*): New entry. Set ac_has_nanosleep=yes. * configure: Regenerate. From-SVN: r279796
2019-12-30Adapt libstdc++ os_defines for VxWorks to more recent versionsJerome Lambourg2-4/+82
This change reworks the VxWorks specific os_defines.h internal lisbstdc++ header to help fix build and runtime failures of various kinds in environments from 6.4/6.9 to 7 SR640, based on experiments and observations conducted against real installs of these OSes for different CPU architectures. 2019-12-30 Jerome Lambourg <lambourg@adacore.com> Olivier Hainque <hainque@adacore.com> libstdc++ * config/os/vxworks/os_defines.h (NOMINMAX): Always redefine to 1. (_NO_CPP_INLINES): Likewise. (_GLIBCXX_USE_WEAK_REF): Define to 1 for RTP on VxWorks >= 7, to 0 otherwise. (_GLIBCXX_HAVE_TLS): Define to 1. For VxWorks >= 7: (_GLIBCXX_USE_C99_MATH): Define to 1. (_GLIBCXX_USE_C99_MATH_FP_MACROS_DYNAMIC): Define to 0. (_HAS_TR1_DECLARATIONS): Redefine to 0. For VxWorks < 7, RTP: (_GLIBCXX_INCLUDE_NEXT_C_HEADERS): Define to 1. (_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC): Redefine to 1. (__CORRECT_ISO_CPP11_MATH_H_PROTO_FP): Define. For VxWorks < 7, kernel: #include <vxWorks.h> Co-Authored-By: Olivier Hainque <hainque@adacore.com> From-SVN: r279792
2019-12-25Define HAVE_ for math long double functions declared in vxworks headersAlexandre Oliva3-0/+1173
When cross-building for vxworks, test for declarations of long double functions in math.h. We don't normally test for these functions when cross compiling, because link tests don't work, or ever really, but not defining them as available causes replacements to be defined in ways that may cause duplicate definition linker errors if the units defining both the replacement and the actual implementation are brought in because of other symbols. for libstdc++-v3/ChangeLog * crossconfig.m4 (GLIBCXX_CROSSCONFIG) [*-vxworks*]: Define long double functions as available if declared by math.h. (GLIBCXX_CHECK_MATH_DECL, GLIBCXX_CHECK_MATH_DECLS): New. * configure: Rebuild. From-SVN: r279731
2019-12-20libstdc++: Add inline to maybe-constexpr functions (PR 92927)Jonathan Wakely2-3/+9
Originally these functions were always inline. I changed them in r277342 to be always constexpr, then in r277588 changed them to be constexpr for C++14, but I didn't restore the 'inline' for C++11. That leads to linker errors when libstdc++.so is built unoptimized, because those functions don't get instantiated in src/c++11/string-inst.o PR libstdc++/92927 * include/bits/alloc_traits.h (__alloc_on_copy, __alloc_on_move) (__alloc_on_swap): Add inline specifier. From-SVN: r279656
2019-12-20libstdc++: Test setrlimit with c++ in configureJerome Lambourg3-7/+28
* acinclude.m4 (GLIBCXX_CHECK_SETRLIMIT): Test with AC_LANG_CPLUSPLUS. * configure: Regenerate. From-SVN: r279644
2019-12-20libstdc++: Fix versioned namespace testsFrançois Dumont4-4/+11
* testsuite/23_containers/map/48101_neg.cc: Add versioned namespace pattern to tested error message. * testsuite/23_containers/multimap/48101_neg.cc: Likewise. * testsuite/30_threads/headers/stop_token/synopsis.cc: Add dg-require-normal-namepace. From-SVN: r279641
2019-12-20libstdc++: Fix pretty printers script and testsFrançois Dumont4-2/+13
* python/libstdcxx/v6/printers.py (lookup_node_type): Remove redundant call to lookup_node_type. * testsuite/libstdc++-prettyprinters/80276.cc: Define _GLIBCXX_USE_CXX11_ABI to 0. * testsuite/libstdc++-prettyprinters/91997.cc: Use regexp-test to check 'a' content. From-SVN: r279640
2019-12-20libstdc++: Strengthen the check for availability of pthread_rwlock_tJerome Lambourg3-11/+56
* acinclude.m4 (_GLIBCXX_USE_PTHREAD_RWLOCK_T): Checks that _PTHREADS is defined after including gthr.h. * configure: Regenerate. From-SVN: r279635
2019-12-12libstdc++: Simplify std::common_comparison_categoryJonathan Wakely2-31/+30
* libsupc++/compare (common_comparison_category): Define without using concepts and optimise for compilation time. (__detail::__cmp_cat_ids): Remove. (__detail::__common_cmp_cat): Replace class template and specializations with constexpr function. From-SVN: r279307
2019-12-12libstdc++: Fix tr1 definition ambiguity in versioned namespaceFrançois Dumont9-0/+40
* include/tr1/cctype: Add _GLIBCXX_BEGIN_VERSION_NAMESPACE and _GLIBCXX_END_VERSION_NAMESPACE. * include/tr1/cfenv: Likewise. * include/tr1/cinttypes: Likewise. * include/tr1/cstdint: Likewise. * include/tr1/cstdio: Likewise. * include/tr1/cstdlib: Likewise. * include/tr1/cwchar: Likewise. * include/tr1/cwctype: Likewise. From-SVN: r279272
2019-12-12libstdc++: Qualify isdigit call to fix versioned namespace build.François Dumont2-1/+7
* src/c++11/random.cc: Include <cctype>. (random_devise::_M_init_pretr1): Qualify isdigit call. From-SVN: r279271
2019-12-11libstdc++: Fix whitepace in changelogJonathan Wakely1-2/+2
From-SVN: r279220
2019-12-11Restore enable_if lost during original import of pstlThomas Rodgers3-2/+8
* include/pstl/glue_numeric_defs.h: Restore enable_if lost during original import of pstl. * include/pstl/glue_numeric_impl.h: Likewise. From-SVN: r279212
2019-12-10libstdc++: Correct noexcept-specifiers on span constructorsJonathan Wakely3-1/+68
As discussed at https://github.com/cplusplus/draft/issues/3534 two std::span constructors specify incorrect conditions for throwing exceptions. This patch makes those constructors have correct noexcept-specifiers that accurately reflect what can actually throw. (span(ContiguousIterator, Sentinel)): Add conditional noexcept. * include/std/span (span(ContiguousIterator, size_type)): Change noexcept to be unconditionally true. * testsuite/23_containers/span/nothrow_cons.cc: New test. From-SVN: r279206
2019-12-10libstdc++: Rework std::copy/copy_backward/move/move_backward/fill/fill_n algosFrançois Dumont28-259/+1988
Enhance those algos overloads to generalize existing optimization for __gnu_debug::_Safe_iterator w/o _GLIBCXX_DEBUG mode and for std::deque iterators. Also extend __copy_move_a2 ostreambuf_iterator overloads to std::vector and std::deque iterators. * include/bits/stl_algobase.h (__copy_move_a1<>(_II, _II, _OI)): New. (__copy_move_a1<>(_Deque_iterator<>, _Deque_iterator<>, _OI)): New. (__copy_move_a1<>(_Deque_iterator<>, _Deque_iterator<>, _Deque_iterator<>)): New. (__copy_move_a1<>(_II, _II, _Deque_iterator<>)): New. (__copy_move_a<>(_II, _II, _OI)): Adapt, call __copy_move_a1<>. (__copy_move_a<>(const _Safe_iterator<>&, const _Safe_iterator<>&, _OI)): New. (__copy_move_a<>(const _Safe_iterator<>&, const _Safe_iterator<>&, const _Safe_iterator<>&)): New. (__copy_move_a<>(_II, _II, const _Safe_iterator<>&)): New. (copy, move): Adapt, call __copy_move_a. (__copy_move_backward_a1<>(_II, _II, _OI)): New, call __copy_move_backward_a2. (__copy_move_backward_a1<>(_Deque_iterator<>, _Deque_iterator<>, _OI)): New. (__copy_move_backward_a1<>(_Deque_iterator<>, _Deque_iterator<>, _Deque_iterator<>)): New. (__copy_move_backward_a1<>(_II, _II, _Deque_iterator<>)): New. (__copy_move_backward_a<>(_II, _II, _OI)): Adapt, call __copy_move_backward_a1<>. (__copy_move_backward_a<>(const _Safe_iterator<>&, const _Safe_iterator<>&, _OI)): New. (__copy_move_backward_a<>(const _Safe_iterator<>&, const _Safe_iterator<>&, const _Safe_iterator<>&)): New. (__copy_move_backward_a<>(_II, _II, const _Safe_iterator<>&)): New. (copy_backward, move_backward): Adapt, call __copy_move_backward_a<>. (__fill_a): Rename into... (__fill_a1): ... this. (__fill_a1(__normal_iterator<>, __normal_iterator<>, const _Tp&)): New. (__fill_a1(const _Deque_iterator<>&, const _Deque_iterator<>&, _VTp)): New. (__fill_a(_FIte, _FIte, const _Tp&)): New, call __fill_a1. (__fill_a(const _Safe_iterator<>&, const _Safe_iterator<>&, const _Tp&)): New. (fill): Adapt, remove __niter_base usage. (__fill_n_a): Rename into... (__fill_n_a1): ...this. (__fill_n_a(const _Safe_iterator<>&, _Size, const _Tp&, input_iterator_tag)): New. (__fill_n_a(_OI, _Size, const _Tp&, output_iterator_tag)): New, call __fill_n_a1. (__fill_n_a(_OI, _Size, const _Tp&, random_access_iterator_tag)): New, call __fill_a. (__equal_aux): Rename into... (__equal_aux1): ...this. (__equal_aux1(_Deque_iterator<>, _Deque_iterator<>, _OI)): New. (__equal_aux1(_Deque_iterator<>, _Deque_iterator<>, _Deque_iterator<>)): New. (__equal_aux1(_II, _II, _Deque_iterator<>)): New. (__equal_aux(_II1, _II1, _II2)): New, call __equal_aux1. (__equal_aux(const _Safe_iterator<>&, const _Safe_iterator<>&, _OI)): New. (__equal_aux(const _Safe_iterator<>&, const _Safe_iterator<>&, const _Safe_iterator<>&)): New. (__equal_aux(_II, _II, const _Safe_iterator<>&)): New. (equal(_II1, _II1, _II2)): Adapt. * include/bits/stl_deque.h (fill, copy, copy_backward, move, move_backward): Remove. * include/bits/deque.tcc: Include <bits/stl_algobase.h>. (__fill_a1): New. (__copy_move_dit): New. (__copy_move_a1): New, use latter. (__copy_move_a1(_II, _II, _Deque_iterator<>)): New. (__copy_move_backward_dit): New. (__copy_move_backward_a1): New, use latter. (__copy_move_backward_a1(_II, _II, _Deque_iterator<>)): New. (__equal_dit): New. (__equal_aux1): New, use latter. (__equal_aux1(_II, _II, _Deque_iterator<>)): New. * include/std/numeric (__is_random_access_iter): Move... * include/bits/stl_iterator_base_types.h (__is_random_access_iter): ... here. Provide pre-C++11 definition. * include/debug/debug.h (_Safe_iterator<>): New declaration. * include/debug/safe_iterator.h (_Safe_iterator<>::_M_can_advance): Add __strict parameter. * include/debug/safe_iterator.tcc: Include <bits/stl_algobase.h>. (_Safe_iterator<>::_M_can_advance): Adapt. (std::__copy_move_a, std::__copy_move_backward_a, __fill_a): New. (__fill_n_a, __equal_aux): New. * include/debug/stl_iterator.h (__niter_base): Remove. * include/debug/vector (__niter_base): Remove. * testsuite/performance/25_algorithms/copy_backward_deque_iterators.cc: Include <vector> and <list>. Add benches. * testsuite/performance/25_algorithms/copy_deque_iterators.cc: Likewise. * testsuite/performance/25_algorithms/equal_deque_iterators.cc: Likewise. * testsuite/25_algorithms/copy/debug/1_neg.cc: New. * testsuite/25_algorithms/copy/deque_iterators/2.cc: New. * testsuite/25_algorithms/copy/deque_iterators/31.cc: New. * testsuite/25_algorithms/copy/deque_iterators/32.cc: New. * testsuite/25_algorithms/copy/deque_iterators/33.cc: New. * testsuite/25_algorithms/copy/deque_iterators/41.cc: New. * testsuite/25_algorithms/copy/deque_iterators/42.cc: New. * testsuite/25_algorithms/copy/deque_iterators/43.cc: New. * testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc (test02): New. * testsuite/25_algorithms/copy_backward/deque_iterators/2.cc: New. * testsuite/25_algorithms/equal/deque_iterators/1.cc: New. * testsuite/25_algorithms/fill/deque_iterators/1.cc: New. * testsuite/25_algorithms/move/deque_iterators/2.cc: New. * testsuite/25_algorithms/move_backward/deque_iterators/2.cc: New. From-SVN: r279201
2019-12-10libstdc++: Fix description of std::ios::trunc (PR 92886)Jonathan Wakely2-1/+4
PR libstdc++/92886 * include/bits/ios_base.h (std::ios_base::trunc): Fix comment. From-SVN: r279175
2019-12-10libstdc++: Define __cpp_lib_constexpr_complex macroJonathan Wakely5-0/+64
This is LWG issue 3349. * include/std/complex (__cpp_lib_constexpr_complex): Define. * include/std/version (__cpp_lib_constexpr_complex): Likewise. * testsuite/26_numerics/complex/1.cc: New test. * testsuite/26_numerics/complex/2.cc: New test. From-SVN: r279172
2019-12-10libstdc++: Reduce header dependencies in <span>Jonathan Wakely2-2/+6
* include/std/span: Do not include <tuple> and <utility>. (tuple_size, tuple_element): Declare. From-SVN: r279171
2019-12-10libstdc++: Fix bug in std::indirect_result_tJonathan Wakely3-13/+64
The alias template wasn't working because it applied iter_reference_t to the pack of iterators before and after passing the pack to the __indeirect_result helper. * include/bits/iterator_concepts.h (indirect_result_t): Do not apply iter_reference_t to parameter pack. * testsuite/24_iterators/indirect_callable/projected.cc: New test. From-SVN: r279170
2019-12-09libstdc++: Implement ranges::safe_range for C++20 (P1870R1)Jonathan Wakely20-183/+482
This change replaces the __forwarding_range implementation detail with the ranges::safe_range concept and adds the ranges::enable_safe_range variable template for opt-in in to the concept. It also adjusts the begin/end/rbegin/rend customization point objects to match the new rules for accessing rvalue ranges only when safe to do so. * include/bits/range_access.h (ranges::enable_safe_range): Define. (ranges::begin, ranges::end, ranges::rbegin, ranges::rend): Constrain to only accept types satisfying safe_range and treat argument as an lvalue when calling a member of performing ADL. (ranges::__detail::__range_impl, ranges::__detail::__forwarding_range): Remove. (ranges::range): Adjust definition. (ranges::safe_range): Define. (ranges::iterator_t, ranges::range_difference_t): Reorder definitions to match the synopsis in the working draft. (ranges::disable_sized_range): Remove duplicate definition. * include/experimental/string_view (ranges::enable_safe_range): Add partial specialization for std::experimental::basic_string_view. * include/std/ranges (ranges::viewable_range, ranges::subrange) (ranges::empty_view, ranges::iota_view): Use safe_range. Specialize enable_safe_range. (ranges::safe_iterator_t, ranges::safe_subrange_t): Define. * include/std/span (ranges::enable_safe_range): Add partial specialization for std::span. * include/std/string_view (ranges::enable_safe_range): Likewise for std::basic_string_view. * testsuite/std/ranges/access/begin.cc: Adjust expected results. * testsuite/std/ranges/access/cbegin.cc: Likewise. * testsuite/std/ranges/access/cdata.cc: Likewise. * testsuite/std/ranges/access/cend.cc: Likewise. * testsuite/std/ranges/access/crbegin.cc: Likewise. * testsuite/std/ranges/access/crend.cc: Likewise. * testsuite/std/ranges/access/data.cc: Likewise. * testsuite/std/ranges/access/end.cc: Likewise. * testsuite/std/ranges/access/rbegin.cc: Likewise. * testsuite/std/ranges/access/rend.cc: Likewise. * testsuite/std/ranges/empty_view.cc: Test ranges::begin and ranges::end instead of unqualified calls to begin and end. * testsuite/std/ranges/safe_range.cc: New test. * testsuite/std/ranges/safe_range_types.cc: New test. * testsuite/util/testsuite_iterators.h: Add comment about safe_range. From-SVN: r279135
2019-12-09libstdc++: Improve testing for path::operator+=(const string&)Jonathan Wakely2-0/+21
* testsuite/27_io/filesystem/path/concat/strings.cc: Test more cases. From-SVN: r279111
2019-12-09libstdc++: fix buffer overflow in path::operator+= (PR92853)Jonathan Wakely4-10/+90
When concatenating a path ending in a root-directory onto another path, we added an empty filename to the end of the path twice, but only reserved space for one. That meant the second write went past the end of the allocated buffer. PR libstdc++/92853 * src/c++17/fs_path.cc (filesystem::path::operator+=(const path&)): Do not process a trailing directory separator twice. * testsuite/27_io/filesystem/path/concat/92853.cc: New test. * testsuite/27_io/filesystem/path/concat/path.cc: Test more cases. From-SVN: r279110
2019-12-09libstdc++: Add C++20 P1032 constexpr to _GLIBCXX_DEBUG arrayFrançois Dumont3-4/+11
* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: Fix static_assert line number. * testsuite/23_containers/array/tuple_interface/ tuple_element_debug_neg.cc: Likewise. From-SVN: r279108
2019-12-07Fix libstdc++ compiling for an aarch64 multilib with big-endian.Andrew Pinski2-0/+7
2019-12-07 Andrew Pinski <apinski@marvell.com> * config/cpu/aarch64/opt/ext/opt_random.h: Wrap around with check for little-endian like ext/random is done. From-SVN: r279081
2019-12-05libstdc++: Fix bug in std::span testJonathan Wakely2-2/+13
The previous commit fixed the std::span constructors from const arrays, revealing a bug in this test. * testsuite/23_containers/span/lwg3255.cc: Fix test. Constructing a span of non-const elements should not be possible from a const array or an array of const elements. From-SVN: r279001
2019-12-05libstdc++: Implement P1872R0 and P1394R0 for std::spanJeanHeyd "ThePhD" Meneide5-227/+141
This also fixes a bug in the implementation of LWG 3255, which causes: FAIL: 23_containers/span/lwg3255.cc (test for excess errors) That's because the test was wrong and verified the buggy behaviour. That will be fixed in the following commit. 2019-12-05 JeanHeyd "ThePhD" Meneide <phdofthehouse@gmail.com> Implement P1872R0 and P1394R0 for std::span * include/bits/range_access.h (__adl_begin, __adl_end): Remove. (sentinel_t, range_value_t, range_reference_t) (range_rvalue_reference_t, __forwarding_range, disable_sized_range) (output_range, input_range, forward_range, bidirectional_range) (random_access_range, contiguous_range, common_range): Move here from <ranges>, to make this the "ranges lite" internal header. * include/std/ranges: Move basic aliases and concepts to <bits/range_access.h>. * include/std/span: Use concepts and ranges:: calls instead of enable_if and friends. * include/std/type_traits: Add __is_array_convertible trait. From-SVN: r279000
2019-12-05libstdc++: Define std::lexicographical_compare_three_way for C++20Jonathan Wakely4-0/+302
* include/bits/stl_algobase.h (lexicographical_compare_three_way): Define for C++20. * testsuite/25_algorithms/lexicographical_compare_three_way/1.cc: New test. * testsuite/25_algorithms/lexicographical_compare_three_way/ constexpr.cc: New test. From-SVN: r278996
2019-12-05libstdc++: Define pretty printer for comparison categoriesJonathan Wakely3-0/+83
* python/libstdcxx/v6/printers.py (StdCmpCatPrinter): New printer. * testsuite/libstdc++-prettyprinters/cxx20.cc: New test. From-SVN: r278982
2019-12-05libstdc++: Implement spaceship for std::array (P1614R2)Jonathan Wakely5-3/+62
As done for std::pair, this defines operator<=> as a non-member function template and does not alter operator==, as expected to be proposed as the resolution to an unpublished LWG issue. Instead of calling std::lexicographical_compare_three_way the <=> overload is implemented by hand to take advantage of the fact the element types and array sizes are known to be the same. * include/bits/cpp_type_traits.h (__is_byte<char8_t>): Add specialization. * include/std/array (operator<=>): Likewise. * testsuite/23_containers/array/comparison_operators/constexpr.cc: Test three-way comparisons and arrays of unsigned char. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust dg-error line numbers. From-SVN: r278981
2019-12-03libstdc++: Implement spaceship for std::pair (P1614R2)Jonathan Wakely4-20/+126
This defines operator<=> as a non-member function template and does not alter operator==. This contradicts the changes made by P1614R2, which specify both as hidden friends, but that specification of operator<=> is broken and the subject of a soon-to-be-published LWG issue. * include/bits/stl_pair.h [__cpp_lib_three_way_comparison] (operator<=>): Define for C++20. * libsupc++/compare (__cmp2way_res_t): Rename to __cmp3way_res_t, move into __detail namespace. Do not turn argument types into lvalues. (__cmp3way_helper): Rename to __cmp3way_res_impl, move into __detail namespace. Constrain with concepts instead of using void_t. (compare_three_way_result): Adjust name of base class. (compare_three_way_result_t): Use __cmp3way_res_impl directly. (__detail::__3way_cmp_with): Add workaround for PR 91073. (compare_three_way): Use workaround. (__detail::__synth3way, __detail::__synth3way_t): Define new helpers implementing synth-three-way and synth-three-way-result semantics. * testsuite/20_util/pair/comparison_operators/constexpr_c++20.cc: New test. From-SVN: r278951
2019-12-03libstdc++: Fix Doxygen markup errorJonathan Wakely2-1/+2
* include/bits/stl_pair.h (pair): Remove stray Doxygen closing marker. From-SVN: r278950
2019-12-03libstdc++: Fix copyright date on new test headerJonathan Wakely2-2/+6
The slow_clock type was introduced to the testsuite in 2018 in the testsuite/30_threads/condition_variable/members/2.cc test, so the new header should have that date. * testsuite/util/slow_clock.h: Fix copyright date. From-SVN: r278926
2019-12-02libstdc++: Fix try_lock_until and try_lock_shared_until on arbitrary clockMike Crowe2-4/+31
This is the equivalent to PR libstdc++/91906, but for shared_mutex. A non-standard clock may tick more slowly than std::chrono::steady_clock. This means that we risk returning false early when the specified timeout may not have expired. This can be avoided by looping until the timeout time as reported by the non-standard clock has been reached. Unfortunately, we have no way to tell whether the non-standard clock ticks more quickly that std::chrono::steady_clock. If it does then we risk returning later than would be expected, but that is unavoidable without waking up periodically to check, which would be rather too expensive. François Dumont pointed out[1] a flaw in an earlier version of this patch that revealed a hole in the test coverage, so I've added a new test that try_lock_until acts as try_lock if the timeout has already expired. [1] https://gcc.gnu.org/ml/libstdc++/2019-10/msg00021.html 2019-12-02 Mike Crowe <mac@mcrowe.com> Fix try_lock_until and try_lock_shared_until on arbitrary clock * include/std/shared_mutex (shared_timed_mutex::try_lock_until) (shared_timed_mutex::try_lock_shared_until): Loop until the absolute timeout time is reached as measured against the appropriate clock. * testsuite/30_threads/shared_timed_mutex/try_lock_until/1.cc: New file. Test try_lock_until and try_lock_shared_until timeouts against various clocks. * testsuite/30_threads/shared_timed_mutex/try_lock_until/1.cc: New file. Test try_lock_until and try_lock_shared_until timeouts against various clocks. From-SVN: r278904
2019-12-02libstdc++: Add full steady_clock support to shared_timed_mutexMike Crowe6-21/+226
The pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock functions were added to glibc in v2.30. They have also been added to Android Bionic. If these functions are available in the C library then they can be used to implement shared_timed_mutex::try_lock_until, shared_timed_mutex::try_lock_for, shared_timed_mutex::try_lock_shared_until and shared_timed_mutex::try_lock_shared_for so that they are no longer unaffected by the system clock being warped. (This is the shared_mutex equivalent of PR libstdc++/78237 for mutex.) If the new functions are available then steady_clock is deemed to be the "best" clock available which means that it is used for the relative try_lock_for calls and absolute try_lock_until calls using steady_clock and user-defined clocks. It's not possible to have _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK defined without _GLIBCXX_USE_PTHREAD_RWLOCK_T, so the requirement that the clock be the same as condition_variable is maintained. Calls explicitly using system_clock (aka high_resolution_clock) continue to use CLOCK_REALTIME via the old pthread_rwlock_timedrdlock and pthread_rwlock_timedwrlock functions. If the new functions are not available then system_clock is deemed to be the "best" clock available which means that the previous suboptimal behaviour remains. Additionally, the user-defined clock used with shared_timed_mutex::try_lock_for and shared_mutex::try_lock_shared_for may have higher precision than __clock_t. We may need to round the duration up to ensure that the timeout is long enough. (See __timed_mutex_impl::_M_try_lock_for) 2019-12-02 Mike Crowe <mac@mcrowe.com> Add full steady_clock support to shared_timed_mutex * acinclude.m4 (GLIBCXX_CHECK_PTHREAD_RWLOCK_CLOCKLOCK): Define to check for the presence of both pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock. * config.h.in: Regenerate. * configure.ac: Call GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK. * configure: Regenerate. * include/std/shared_mutex (shared_timed_mutex): Define __clock_t as the best clock to use for relative waits. (shared_timed_mutex::try_lock_for) Round up wait duration if necessary. (shared_timed_mutex::try_lock_shared_for): Likewise. (shared_timed_mutex::try_lock_until): Use existing try_lock_until implementation for system_clock (which matches __clock_t when _GLIBCCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK is not defined). Add new overload for steady_clock that uses pthread_rwlock_clockwrlock if it is available. Simplify overload for non-standard clock to just call try_lock_for with a relative timeout. (shared_timed_mutex::try_lock_shared_until): Likewise. From-SVN: r278903
2019-12-02libstdc++: Fix timed_mutex::try_lock_until on arbitrary clock (PR 91906)Mike Crowe8-23/+153
A non-standard clock may tick more slowly than std::chrono::steady_clock. This means that we risk returning false early when the specified timeout may not have expired. This can be avoided by looping until the timeout time as reported by the non-standard clock has been reached. Unfortunately, we have no way to tell whether the non-standard clock ticks more quickly that std::chrono::steady_clock. If it does then we risk returning later than would be expected, but that is unavoidable and permitted by the standard. 2019-12-02 Mike Crowe <mac@mcrowe.com> PR libstdc++/91906 Fix timed_mutex::try_lock_until on arbitrary clock * include/std/mutex (__timed_mutex_impl::_M_try_lock_until): Loop until the absolute timeout time is reached as measured against the appropriate clock. * testsuite/util/slow_clock.h: New file. Move implementation of slow_clock test class. * testsuite/30_threads/condition_variable/members/2.cc: Include slow_clock from header. * testsuite/30_threads/shared_timed_mutex/try_lock/3.cc: Convert existing test to templated function so that it can be called with both system_clock and steady_clock. * testsuite/30_threads/timed_mutex/try_lock_until/3.cc: Also run test using slow_clock to test above fix. * testsuite/30_threads/recursive_timed_mutex/try_lock_until/3.cc: Likewise. * testsuite/30_threads/recursive_timed_mutex/try_lock_until/4.cc: Add new test that try_lock_until behaves as try_lock if the timeout has already expired or exactly matches the current time. From-SVN: r278902
2019-12-02libstdc++: PR 78237 Add full steady_clock support to timed_mutexMike Crowe6-8/+179
The pthread_mutex_clocklock function is available in glibc since the 2.30 release. If this function is available in the C library it can be used to fix PR libstdc++/78237 by supporting steady_clock properly with timed_mutex. This means that code using timed_mutex::try_lock_for or timed_mutex::wait_until with steady_clock is no longer subject to timing out early or potentially waiting for much longer if the system clock is warped at an inopportune moment. If pthread_mutex_clocklock is available then steady_clock is deemed to be the "best" clock available which means that it is used for the relative try_lock_for calls and absolute try_lock_until calls using steady_clock and user-defined clocks. Calls explicitly using system_clock (aka high_resolution_clock) continue to use CLOCK_REALTIME via __gthread_cond_timedwait. If pthread_mutex_clocklock is not available then system_clock is deemed to be the "best" clock available which means that the previous suboptimal behaviour remains. 2019-12-02 Mike Crowe <mac@mcrowe.com> PR libstdc++/78237 Add full steady_clock support to timed_mutex * acinclude.m4 (GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK): Define to detect presence of pthread_mutex_clocklock function. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Call GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK. * include/std/mutex (__timed_mutex_impl): Remove unnecessary __clock_t. (__timed_mutex_impl::_M_try_lock_for): Use best clock to turn relative timeout into absolute timeout. (__timed_mutex_impl::_M_try_lock_until): Keep existing implementation for system_clock. Add new implementation for steady_clock that calls _M_clocklock. Modify overload for user-defined clock to use a relative wait so that it automatically uses the best clock. [_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK] (timed_mutex::_M_clocklock): New member function. (recursive_timed_mutex::_M_clocklock): Likewise. From-SVN: r278901
2019-12-02libstdc++: Improve tests for try_lock_until members of mutex typesMike Crowe5-9/+185
2019-12-02 Mike Crowe <mac@mcrowe.com> * testsuite/30_threads/recursive_timed_mutex/try_lock_until/3.cc: New test. Ensure that timed_mutex::try_lock_until actually times out after the specified time when using both system_clock and steady_clock. * testsuite/30_threads/timed_mutex/try_lock_until/3.cc: New test. Likewise but for recursive_timed_mutex. * testsuite/30_threads/timed_mutex/try_lock_until/57641.cc: Template test functions and use them to test both steady_clock and system_clock. * testsuite/30_threads/unique_lock/locking/4.cc: Likewise. Wrap call to timed_mutex::try_lock_until in VERIFY macro to check its return value. From-SVN: r278900
2019-11-30libstdc++: Default to --enable-libstdcxx-filesystem-ts for *-*-mingw*Jonathan Wakely3-0/+10
* acinclude.m4 (GLIBCXX_ENABLE_FILESYSTEM_TS): Enable by default for mingw targets. * configure: Regenerate. From-SVN: r278870
2019-11-30libstdc++: Fix experimental::filesystem::u8path(const Source&) for WindowsJonathan Wakely3-50/+67
This function failed to compile when called with a std::string. Also, constructing a path with a char8_t string did not correctly treat the string as already UTF-8 encoded. * include/bits/fs_path.h (u8path(InputIterator, InputIterator)) (u8path(const Source&)) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Simplify conditions. * include/experimental/bits/fs_path.h [_GLIBCXX_FILESYSTEM_IS_WINDOWS] (__u8path(const Source&, char)): Add overloads for std::string and types convertible to std::string. (_Cvt::_S_wconvert): Add a new overload for char8_t strings and use codecvt_utf8_utf16 to do the correct conversion. From-SVN: r278869
2019-11-29libstdc++: Adjust some function templates for coding conventionsJonathan Wakely4-22/+29
* include/bits/fs_path.h (path::operator/=): Change template-head to use typename instead of class. * include/experimental/bits/fs_path.h (path::operator/=): Likewise. * include/std/ostream (operator<<): Likewise. From-SVN: r278859
2019-11-29libstdc++: P1423R3 char8_t remediation (4/4)Tom Honermann5-0/+210
New tests This patch adds new tests to validate new deleted overloads of wchar_t, char8_t, char16_t, and char32_t for ordinary and wide formatted character and string ostream inserters. Additionally, new tests are added to validate invocations of u8path with sequences of char8_t for both the C++17 and filesystem TS implementations. 2019-11-29 Tom Honermann <tom@honermann.net> New tests * testsuite/27_io/basic_ostream/inserters_character/char/deleted.cc: New test to validate deleted overloads of character and string inserters for narrow ostreams. * testsuite/27_io/basic_ostream/inserters_character/wchar_t/deleted.cc: New test to validate deleted overloads of character and string inserters for wide ostreams. * testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc: New test to validate u8path invocations with sequences of char8_t. * testsuite/experimental/filesystem/path/factory/u8path-char8_t.cc: New test to validate u8path invocations with sequences of char8_t. From-SVN: r278858
2019-11-29libstdc++: P1423R3 char8_t remediation (3/4)Tom Honermann4-2/+37
Updates to existing tests This patch updates existing tests to validate the new value for the __cpp_lib_char8_t feature test macros and to exercise u8path factory function invocations with std::string, std::string_view, and interator pair arguments. 2019-11-29 Tom Honermann <tom@honermann.net> Updates to existing tests * testsuite/experimental/feat-char8_t.cc: Updated the expected __cpp_lib_char8_t feature test macro value. * testsuite/27_io/filesystem/path/factory/u8path.cc: Added testing of u8path invocation with std::string, std::string_view, and iterators thereof. * testsuite/experimental/filesystem/path/factory/u8path.cc: Added testing of u8path invocation with std::string, std::string_view, and iterators thereof. From-SVN: r278857
2019-11-29libstdc++: P1423R3 char8_t remediation (2/4)Tom Honermann5-34/+216
Update feature test macro, add deleted operators, update u8path This patch increments the __cpp_lib_char8_t feature test macro, adds deleted operator<< overloads for basic_ostream, and modifies u8path to accept sequences of char8_t for both the C++17 implementation of std::filesystem, and the filesystem TS implementation. The implementation mechanism used for u8path differs between the C++17 and filesystem TS implementations. The changes to the former take advantage of C++17 'if constexpr'. The changes to the latter retain C++11 compatibility and rely on tag dispatching. 2019-11-29 Tom Honermann <tom@honermann.net> Update feature test macro, add deleted operators, update u8path * include/bits/c++config: Bumped the value of the __cpp_lib_char8_t feature test macro. * include/bits/fs_path.h (u8path): Modified u8path to accept sequences of char8_t. * include/experimental/bits/fs_path.h (u8path): Modified u8path to accept sequences of char8_t. * include/std/ostream: Added deleted overloads of wchar_t, char8_t, char16_t, and char32_t for ordinary and wide formatted character and string inserters. From-SVN: r278856
2019-11-29libstdc++: P1423R3 char8_t remediation (1/4)Tom Honermann3-223/+256
Decouple constraints for u8path from path constructors This patch moves helper classes and functions for std::filesystem::path out of the class definition to a detail namespace so that they are available to the implementations of std::filesystem::u8path. Prior to this patch, the SFINAE constraints for those implementations were specified via delegation to the overloads of path constructors with a std::locale parameter; it just so happened that those overloads had the same constraints. As of P1423R3, u8path and those overloads no longer have the same constraints, so this dependency must be broken. This patch also updates the experimental implementation of the filesystem TS to add SFINAE constraints to its implementations of u8path. These functions were previously unconstrained and marked with a TODO comment. This patch does not provide any intentional behavioral changes other than the added constraints to the experimental filesystem TS implementation of u8path. Alternatives to this refactoring would have been to make the u8path overloads friends of class path, or to make the helpers public members. Both of those approaches struck me as less desirable than this approach, though this approach does require more code changes and will affect implementation detail portions of mangled names for path constructors and inline member functions (mostly function template specializations). 2019-11-29 Tom Honermann <tom@honermann.net> Decouple constraints for u8path from path constructors * include/bits/fs_path.h: Moved helper utilities out of std::filesystem::path into a detail namespace to make them available for use by u8path. * include/experimental/bits/fs_path.h: Moved helper utilities out of std::experimental::filesystem::v1::path into a detail namespace to make them available for use by u8path. From-SVN: r278855
2019-11-29libstdc++:: improve how pretty printers find node types (PR 91997)Jonathan Wakely4-42/+173
This fixes two related problems. The iterators for node-based containers use nested typedefs such as std::list<T>::iterator::_Node to denote their node types. As reported in https://bugzilla.redhat.com/show_bug.cgi?id=1053438 those typedefs are not always present in the debug info. That means the pretty printers cannot find them using gdb.lookup_type (via the find_type helper). Instead of looking up the nested typedefs this patch makes the printers look up the actual class templates directly. A related problem (and the original topic of PR 91997) is that GDB fails to find types via gdb.lookup_type when printing a backtrace from a non-C++ functiion: https://sourceware.org/bugzilla/show_bug.cgi?id=25234 That is also solved by not looking up the nested typedef. PR libstdc++/91997 * python/libstdcxx/v6/printers.py (find_type): Fail more gracefully if we run out of base classes to look at. (llokup_templ_spec, lookup_node_type): New utilities to find node types for node-based containers. (StdListPrinter.children, NodeIteratorPrinter.__init__) (NodeIteratorPrinter.to_string, StdSlistPrinter.children) (StdSlistIteratorPrinter.to_string, StdRbtreeIteratorPrinter.__init__) (StdMapPrinter.children, StdSetPrinter.children) (StdForwardListPrinter.children): Use lookup_node_type instead of find_type. (StdListIteratorPrinter.__init__, StdFwdListIteratorPrinter.__init__): Pass name of node type to NodeIteratorPrinter constructor. (Tr1HashtableIterator.__init__): Rename argument. (StdHashtableIterator.__init__): Likewise. Use lookup_templ_spec instead of find_type. * testsuite/libstdc++-prettyprinters/59161.cc: Remove workaround for _Node typedef not being present in debuginfo. * testsuite/libstdc++-prettyprinters/91997.cc: New test. From-SVN: r278846
2019-11-26libstdc++: Use C++98 syntax to instantiate input_iterator_tagFrançois Dumont2-2/+5
* include/debug/helper_functions.h (__valid_range_aux): Use C++98 std::input_iterator_tag default constructor invocation. From-SVN: r278731
2019-11-26libstdc++: Add C++20 P1032 constexpr to _GLIBCXX_DEBUG arrayFrançois Dumont2-2/+6
* include/debug/array (array<>::fill): Add C++20 constexpr. (array<>::swap): Likewise. From-SVN: r278718
2019-11-26libstdc++: Add _GLIBCXX_DEBUG safe iterator C++20 iterator conceptFrançois Dumont2-0/+10
* include/debug/safe_iterator.h [__cpp_lib_concepts](_Safe_iterator<>::iterator_concept): Define for C++20. From-SVN: r278717
2019-11-25libstdc++: Add move_sentinel, common_iterator and counted_iteratorJonathan Wakely7-9/+1105
This implements most of the remaining C++20 additions to the <iterator> header. * include/bits/iterator_concepts.h (ranges::iter_swap): Fix parameter types of poison pill overload. Use remove_reference_t when checking constraints. * include/bits/stl_iterator.h (move_sentinel): Define for C++20. (move_iterator): Adjust definitions of nested types for C++20. Add hidden friends for move_sentinel operations, iter_move and iter_swap. (common_iterator, counted_iterator): Define for C++20. * testsuite/24_iterators/move_iterator/cust.cc: New test. * testsuite/24_iterators/move_iterator/sentinel.cc: New test. * testsuite/24_iterators/common_iterator/1.cc: New test. * testsuite/24_iterators/counted_iterator/1.cc: New test. From-SVN: r278698