Commit Graph

11147 Commits

Author SHA1 Message Date
Alexandre Oliva 85129ff10a Define HAVE_ for math long double functions declared in vxworks headers
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-25 06:43:22 +00:00
Jonathan Wakely 7770bd7e9a libstdc++: Add inline to maybe-constexpr functions (PR 92927)
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-20 17:10:18 +00:00
Jerome Lambourg 84de780d46 libstdc++: Test setrlimit with c++ in configure
* acinclude.m4 (GLIBCXX_CHECK_SETRLIMIT): Test with AC_LANG_CPLUSPLUS.
	* configure: Regenerate.

From-SVN: r279644
2019-12-20 15:30:41 +00:00
François Dumont 33bd8e5e22 libstdc++: Fix versioned namespace tests
* 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-20 13:24:52 +00:00
François Dumont e278e62f91 libstdc++: Fix pretty printers script and tests
* 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-20 12:42:50 +00:00
Jerome Lambourg 7607ff49af libstdc++: Strengthen the check for availability of pthread_rwlock_t
* acinclude.m4 (_GLIBCXX_USE_PTHREAD_RWLOCK_T): Checks that
        _PTHREADS is defined after including gthr.h.
        * configure: Regenerate.

From-SVN: r279635
2019-12-20 09:30:48 +00:00
Jonathan Wakely d1505d0146 libstdc++: Simplify std::common_comparison_category
* 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-12 14:35:55 +00:00
François Dumont 5345a1906a libstdc++: Fix tr1 definition ambiguity in versioned namespace
* 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-12 07:23:34 +00:00
François Dumont 8bc1995989 libstdc++: Qualify isdigit call to fix versioned namespace build.
* src/c++11/random.cc: Include <cctype>.
	(random_devise::_M_init_pretr1): Qualify isdigit call.

From-SVN: r279271
2019-12-12 07:14:55 +00:00
Jonathan Wakely 554c02a590 libstdc++: Fix whitepace in changelog
From-SVN: r279220
2019-12-11 13:19:18 +00:00
Thomas Rodgers 2aae713bb4 Restore enable_if lost during original import of pstl
* 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-11 03:38:24 +00:00
Jonathan Wakely cff87282f4 libstdc++: Correct noexcept-specifiers on span constructors
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-10 23:50:26 +00:00
François Dumont 6004c17b4d libstdc++: Rework std::copy/copy_backward/move/move_backward/fill/fill_n algos
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-10 21:49:55 +00:00
Jonathan Wakely 91fd16a7bd libstdc++: Fix description of std::ios::trunc (PR 92886)
PR libstdc++/92886
	* include/bits/ios_base.h (std::ios_base::trunc): Fix comment.

From-SVN: r279175
2019-12-10 17:35:42 +00:00
Jonathan Wakely 393283b8ef libstdc++: Define __cpp_lib_constexpr_complex macro
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-10 16:15:59 +00:00
Jonathan Wakely b65bdd27fd libstdc++: Reduce header dependencies in <span>
* include/std/span: Do not include <tuple> and <utility>.
	(tuple_size, tuple_element): Declare.

From-SVN: r279171
2019-12-10 16:15:55 +00:00
Jonathan Wakely 990a09e486 libstdc++: Fix bug in std::indirect_result_t
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-10 16:15:49 +00:00
Jonathan Wakely b5b2e3879d libstdc++: Implement ranges::safe_range for C++20 (P1870R1)
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-09 17:35:24 +00:00
Jonathan Wakely 1d214c3f83 libstdc++: Improve testing for path::operator+=(const string&)
* testsuite/27_io/filesystem/path/concat/strings.cc: Test more cases.

From-SVN: r279111
2019-12-09 09:59:00 +00:00
Jonathan Wakely 023a3fb491 libstdc++: fix buffer overflow in path::operator+= (PR92853)
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-09 09:58:56 +00:00
François Dumont 4383959047 libstdc++: Add C++20 P1032 constexpr to _GLIBCXX_DEBUG array
* 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-09 08:44:15 +00:00
Andrew Pinski c44e87ac7c Fix libstdc++ compiling for an aarch64 multilib with big-endian.
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-07 16:08:55 -08:00
Jonathan Wakely 5a784d350c libstdc++: Fix bug in std::span test
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-05 13:50:08 +00:00
JeanHeyd "ThePhD" Meneide a7922ddf48 libstdc++: Implement P1872R0 and P1394R0 for std::span
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-05 13:50:01 +00:00
Jonathan Wakely f1355c8dda libstdc++: Define std::lexicographical_compare_three_way for C++20
* 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-05 12:46:50 +00:00
Jonathan Wakely a59c50bd14 libstdc++: Define pretty printer for comparison categories
* python/libstdcxx/v6/printers.py (StdCmpCatPrinter): New printer.
	* testsuite/libstdc++-prettyprinters/cxx20.cc: New test.

From-SVN: r278982
2019-12-05 00:42:11 +00:00
Jonathan Wakely 3a4cc6281b libstdc++: Implement spaceship for std::array (P1614R2)
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-05 00:42:06 +00:00
Jonathan Wakely 7f397e4519 libstdc++: Implement spaceship for std::pair (P1614R2)
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-03 23:57:46 +00:00
Jonathan Wakely 6fb3d28f13 libstdc++: Fix Doxygen markup error
* include/bits/stl_pair.h (pair): Remove stray Doxygen closing marker.

From-SVN: r278950
2019-12-03 23:57:28 +00:00
Jonathan Wakely 819fb01933 libstdc++: Fix copyright date on new test header
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-03 09:51:49 +00:00
Mike Crowe b789efeae8 libstdc++: Fix try_lock_until and try_lock_shared_until on arbitrary clock
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-02 16:23:14 +00:00
Mike Crowe ab40695a46 libstdc++: Add full steady_clock support to shared_timed_mutex
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-02 16:23:10 +00:00
Mike Crowe a7334019b1 libstdc++: Fix timed_mutex::try_lock_until on arbitrary clock (PR 91906)
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-02 16:23:06 +00:00
Mike Crowe 3b2fb54353 libstdc++: PR 78237 Add full steady_clock support to timed_mutex
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-02 16:23:01 +00:00
Mike Crowe 49638674a4 libstdc++: Improve tests for try_lock_until members of mutex types
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-12-02 16:22:53 +00:00
Jonathan Wakely f0cfae9f4e libstdc++: Default to --enable-libstdcxx-filesystem-ts for *-*-mingw*
* acinclude.m4 (GLIBCXX_ENABLE_FILESYSTEM_TS): Enable by default for
	mingw targets.
	* configure: Regenerate.

From-SVN: r278870
2019-11-30 01:03:40 +00:00
Jonathan Wakely 3eda32cb9b libstdc++: Fix experimental::filesystem::u8path(const Source&) for Windows
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-30 01:03:36 +00:00
Jonathan Wakely 24cc0de967 libstdc++: Adjust some function templates for coding conventions
* 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-29 17:43:55 +00:00
Tom Honermann cd502796cf libstdc++: P1423R3 char8_t remediation (4/4)
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-29 17:43:51 +00:00
Tom Honermann 2b68cdc7e5 libstdc++: P1423R3 char8_t remediation (3/4)
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-29 17:43:46 +00:00
Tom Honermann 2b4e2c93d9 libstdc++: P1423R3 char8_t remediation (2/4)
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-29 17:43:42 +00:00
Tom Honermann a1e7d33bb9 libstdc++: P1423R3 char8_t remediation (1/4)
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-29 17:43:37 +00:00
Jonathan Wakely 9d50a6a785 libstdc++:: improve how pretty printers find node types (PR 91997)
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-29 14:47:03 +00:00
François Dumont e32b9ce4d5 libstdc++: Use C++98 syntax to instantiate input_iterator_tag
* include/debug/helper_functions.h (__valid_range_aux): Use C++98
	std::input_iterator_tag default constructor invocation.

From-SVN: r278731
2019-11-26 19:23:11 +00:00
François Dumont 59d37e9709 libstdc++: Add C++20 P1032 constexpr to _GLIBCXX_DEBUG array
* include/debug/array (array<>::fill): Add C++20 constexpr.
	(array<>::swap): Likewise.

From-SVN: r278718
2019-11-26 06:12:34 +00:00
François Dumont db58c8e919 libstdc++: Add _GLIBCXX_DEBUG safe iterator C++20 iterator concept
* include/debug/safe_iterator.h
	[__cpp_lib_concepts](_Safe_iterator<>::iterator_concept): Define for
	C++20.

From-SVN: r278717
2019-11-26 06:07:23 +00:00
Jonathan Wakely 7def9bd7cd libstdc++: Add move_sentinel, common_iterator and counted_iterator
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
2019-11-25 19:02:03 +00:00
Jonathan Wakely d6039f5ce1 PR libstdc++/91786 fix compilation error with Clang
PR libstdc++/91786
	* include/bits/fs_path.h (filesystem_error): Move definition before
	the use in u8path.

From-SVN: r278697
2019-11-25 19:01:58 +00:00
François Dumont af4e8d4d5a libstdc++: Improve _GLIBCXX_DEBUG __valid_range check
Adds iterator singular check within the valid range check.

	* include/debug/functions.h: Remove <bits/move.h> include.
	(__check_singular_aux, __check_singular): Move...
	* include/debug/helper_functions.h:
	(__check_singular_aux, __check_singular): ...here.
	(__valid_range_aux): Adapt to use latter.
	Add <bits/move.h> include.
	* testsuite/25_algorithms/copy/debug/2_neg.cc: New.

From-SVN: r278658
2019-11-24 17:09:44 +00:00
Janne Blomqvist aeebd94c77 Switch gcc ftp URL's to https
The FTP protocol is getting long in the tooth, and we should emphasize
HTTPS where that is available. This patch changes various gcc.gnu.org
URL's to instead use HTTPS.

For instance, kernel.org shut down FTP access in 2017, with the
explanation:

- The protocol is inefficient and requires adding awkward kludges to
  firewalls and load-balancing daemons
- FTP servers have no support for caching or accelerators, which has
  significant performance impacts
- Most software implementations have stagnated and see infrequent
  updates

ChangeLog:

2019-11-20  Janne Blomqvist  <jb@gcc.gnu.org>

        * configure.ac: Use https for gcc.gnu.org.
        * configure: Regenerated.

gcc/ChangeLog:

2019-11-20  Janne Blomqvist  <jb@gcc.gnu.org>

        * configure.ac: Use https for gcc.gnu.org.
        * configure: Regenerated.
        * doc/install.texi: Use https for gcc.gnu.org.
        * doc/sourcebuild.texi: Likewise.

gcc/testsuite/ChangeLog:

2019-11-20  Janne Blomqvist  <jb@gcc.gnu.org>

        * README: Use https for gcc.gnu.org.

libstdc++-v3/ChangeLog:

2019-11-20  Janne Blomqvist  <jb@gcc.gnu.org>

        * doc/html/api.html: Use https for gcc.gnu.org.
        * doc/xml/api.xml: Likewise.

maintainer-scripts/ChangeLog:

2019-11-20  Janne Blomqvist  <jb@gcc.gnu.org>

        * gcc_release: Use https for gcc.gnu.org.

From-SVN: r278526
2019-11-20 22:24:48 +02:00