summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/Makefile.in
AgeCommit message (Collapse)Author
2022-07-07libstdc++: Add missing prerequisite to generated header [PR106162]Jonathan Wakely
The ${host_builddir}/largefile-config.h header can't be written until its parent directory has been created, so it needs to have the creation of that directory as a prerequisite. libstdc++-v3/ChangeLog: PR libstdc++/106162 * include/Makefile.am (largefile-config.h): Add stamp-${host_alias} prerequisite. * include/Makefile.in: Regenerate. (cherry picked from commit 8a6ee426c2be3bd4359520e02c00ec60cac2fece)
2022-03-27libstdc++: Define std::expected for C++23 (P0323R12)Jonathan Wakely
Because this adds a new class template called std::unexpected, we have to stop declaring the std::unexpected() function (which was deprecated in C++11 and removed in C++17). libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in: Add new header. * include/Makefile.am: Likewise. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Add new header. * include/std/version (__cpp_lib_expected): Define. * libsupc++/exception [__cplusplus > 202002] (unexpected) (unexpected_handler, set_unexpected): Do not declare for C++23. * include/std/expected: New file. * testsuite/20_util/expected/assign.cc: New test. * testsuite/20_util/expected/cons.cc: New test. * testsuite/20_util/expected/illformed_neg.cc: New test. * testsuite/20_util/expected/observers.cc: New test. * testsuite/20_util/expected/requirements.cc: New test. * testsuite/20_util/expected/swap.cc: New test. * testsuite/20_util/expected/synopsis.cc: New test. * testsuite/20_util/expected/unexpected.cc: New test. * testsuite/20_util/expected/version.cc: New test.
2022-01-18libstdc++: Define <stdatomic.h> for C++23Jonathan Wakely
This adds the C++23 <stdatomic.h> header, as proposed by P0943R6, for compatibility with C code. There are still some ABI differences between atomic_xxx in C and C++ std::atomic_xxx in C++, so this only provides source compatibility, not binary compatibility. libstdc++-v3/ChangeLog: * include/Makefile.am: Install new header. * include/Makefile.in: Regenerate. * include/c_compatibility/stdatomic.h: New file. * testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: New test.
2022-01-17libstdc++: Define <stacktrace> header for C++23Jonathan Wakely
Add the <stacktrace> header and a new libstdc++_libbacktrace.a library that provides the implementation. For now, the new library is only built if --enable-libstdcxx-backtrace=yes is used. As with the Filesystem TS, the new library is only provided as a static archive. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): New macro. * configure.ac: Use GLIBCXX_ENABLE_BACKTRACE. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/std/stacktrace: New header. * include/std/version (__cpp_lib_stacktrace): Define. * Makefile.in: Regenerate. * config.h.in: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.am: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. * src/libbacktrace/Makefile.am: New file. * src/libbacktrace/Makefile.in: New file. * src/libbacktrace/backtrace-rename.h: New file. * src/libbacktrace/backtrace-supported.h.in: New file. * src/libbacktrace/config.h.in: New file. * testsuite/lib/libstdc++.exp (check_effective_target_stacktrace): New proc. * testsuite/20_util/stacktrace/entry.cc: New test. * testsuite/20_util/stacktrace/synopsis.cc: New test. * testsuite/20_util/stacktrace/version.cc: New test.
2022-01-17libstdc++: Rename non-reserved macros in config header [PR103650]Jonathan Wakely
libstdc++-v3/ChangeLog: PR libstdc++/103650 * include/Makefile.am: Rename LT_OBJDIR and STDC_HEADERS. * include/Makefile.in: Regenerate. * testsuite/17_intro/headers/c++1998/103650.cc: New test.
2022-01-11libstdc++: Install <source_location> header for freestanding [PR103726]Jonathan Wakely
This C++20 header is also supposed to be present for freestanding. libstdc++-v3/ChangeLog: PR libstdc++/103726 * include/Makefile.am: Install <source_location> for freestanding. * include/Makefile.in: Regenerate. * include/std/version (__cpp_lib_source_location): Define for freestanding.
2022-01-11libstdc++: Install <coroutine> header for freestanding [PR103726]Jonathan Wakely
The standard says that <coroutine> should be present for freestanding. That was intentionally left out of the initial implementation, but can be done without much trouble. The header should be moved to libsupc++ at some point in stage 1. The standard also says that <coroutine> defines a std::hash specialization, which was missing from our implementation. That's a problem for freestanding (see LWG 3653) so only do that for hosted. We can use concepts to constrain the __coroutine_traits_impl base class when compiled with concepts enabled. In a pure C++20 implementation we would not need that base class at all and could just use a constrained partial specialization of coroutine_traits. But the absence of the __coroutine_traits_impl<R, void> base would create an ABI difference between the non-standard C++14/C++17 support for coroutines and the same code compiled as C++20. If we drop support for <coroutine> pre-C++20 we should revisit this. libstdc++-v3/ChangeLog: PR libstdc++/103726 * include/Makefile.am: Install <coroutine> for freestanding. * include/Makefile.in: Regenerate. * include/std/coroutine: Adjust headers and preprocessor conditions. (__coroutine_traits_impl): Use concepts when available. [_GLIBCXX_HOSTED] (hash<coroutine_handle>): Define.
2022-01-10libstdc++: Fix and simplify freestanding configuration [PR103866]Jonathan Wakely
This fixes the --disable-hosted-libstdcxx build so that it works with --without-headers. Currently you need to also use --with-newlib, which is confusing for users who aren't actually using newlib. The AM_PROG_LIBTOOL checks are currently skipped for --with-newlib and --with-avrlibc builds, with this change they are also skipped when using --without-headers. It would be nice if using --disable-hosted-libstdcxx automatically skipped those checks, but GLIBCXX_ENABLE_HOSTED comes too late to make the AM_PROG_LIBTOOL checks depend on $is_hosted. The checks for EOF, SEEK_CUR etc. cause the build to fail if there is no <stdio.h> available. Unlike most headers, which get a HAVE_FOO_H macro, <stdio.h> is in autoconf's default includes, so every check tries to include it unconditionally. This change skips those checks for freestanding builds. Similarly, the checks for <stdint.h> types done by GCC_HEADER_STDINT try to include <stdio.h> and fail for --without-headers builds. This change skips the use of GCC_HEADER_STDINT for freestanding. We can probably stop using GCC_HEADER_STDINT entirely, since only one file uses the gstdint.h header that is generated, and that could easily be changed to use <stdint.h> instead. That can wait for stage 1. We also need to skip the GLIBCXX_CROSSCONFIG stage if --without-headers was used, since we don't have any of the functions it deals with. The end result of the changes above is that it should not be necessary for a --disable-hosted-libstdcxx --without-headers build to also use --with-newlib. Finally, compile libsupc++ with -ffreestanding when --without-headers is used, so that <stdint.h> will use <gcc-stdint.h> instead of expecting it to come from libc. libstdc++-v3/ChangeLog: PR libstdc++/103866 * acinclude.m4 (GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS): Do nothing for freestanding builds. (GLIBCXX_ENABLE_HOSTED): Define FREESTANDING_FLAGS. * configure.ac: Do not use AC_LIBTOOL_DLOPEN when configured with --without-headers. Do not use GCC_HEADER_STDINT for freestanding builds. * libsupc++/Makefile.am (HOSTED_CXXFLAGS): Use -ffreestanding for freestanding builds. * configure: Regenerate. * Makefile.in: Regenerate. * doc/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
2021-12-09libstdc++: Fix non-reserved name in std::allocator base class [PR64135]Jonathan Wakely
The possible base classes of std::allocator are new_allocator and malloc_allocator, which both cause a non-reserved name to be declared in every program that includes the definition of std::allocator. This is non-conforming. This change replaces __gnu_cxx::new_allocator with std::__new_allocator which is identical except for using a reserved name. The non-standard extension __gnu_cxx::new_allocator is preserved as a thin wrapper over std::__new_allocator. There is no problem with the extension using a non-reserved name now that it's not included by default in other headers. The same change could be done to __gnu_cxx::malloc_allocator but as it's not the default configuration it can wait. libstdc++-v3/ChangeLog: PR libstdc++/64135 * config/allocator/new_allocator_base.h: Include <bits/new_allocator.h> instead of <ext/new_allocator.h>. (__allocator_base): Use std::__new_allocator instead of __gnu_cxx::new_allocator. * doc/xml/manual/allocator.xml: Document new default base class for std::allocator. * doc/xml/manual/evolution.xml: Likewise. * doc/html/*: Regenerate. * include/Makefile.am: Add bits/new_allocator.h. * include/Makefile.in: Regenerate. * include/experimental/memory_resource (new_delete_resource): Use std::__new_allocator instead of __gnu_cxx::new_allocator. * include/ext/new_allocator.h (new_allocator): Derive from std::__new_allocator. Move implementation to ... * include/bits/new_allocator.h: New file. * testsuite/20_util/allocator/64135.cc: New test.
2021-11-13libstdc++: Implement std::spanstream for C++23Jonathan Wakely
This implements the <spanstream> header, as proposed for C++23 by P0448R4. libstdc++-v3/ChangeLog: * include/Makefile.am: Add spanstream header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Add spanstream header. * include/std/version (__cpp_lib_spanstream): Define. * include/std/spanstream: New file. * testsuite/27_io/spanstream/1.cc: New test. * testsuite/27_io/spanstream/version.cc: New test.
2021-10-07libstdc++: Move C++14 <chrono> components to new <bits/chrono.h> headerJonathan Wakely
This moves the "classic" contents of <chrono> to a new header, so that <future>, <thread> etc. can get use durations and clocks without calendar types, time zones, and chrono I/O. libstdc++-v3/ChangeLog: * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/std/chrono (duration, time_point, system_clock) (steady_clock, high_resolution_clock, chrono_literals, sys_time) (file_clock, file_time): Move to ... * include/bits/chrono.h: New file. * include/bits/atomic_futex.h: Include new header instead of <chrono>. * include/bits/atomic_timed_wait.h: Likewise. * include/bits/fs_fwd.h: Likewise. * include/bits/semaphore_base.h: Likewise. * include/bits/this_thread_sleep.h: Likewise. * include/bits/unique_lock.h: Likewise. * include/experimental/bits/fs_fwd.h: Likewise. * include/experimental/chrono: Likewise. * include/experimental/io_context: Likewise. * include/experimental/netfwd: Likewise. * include/experimental/timer: Likewise. * include/std/condition_variable: Likewise. * include/std/mutex: Likewise. * include/std/shared_mutex: Likewise.
2021-10-06libstdc++: Implement std::move_only_function for C++23 (P0288R9)Jonathan Wakely
libstdc++-v3/ChangeLog: * include/Makefile.am: Add new headers. * include/Makefile.in: Regenerate. * include/std/functional: Include <bits/move_only_function.h>. * include/std/version (__cpp_lib_move_only_function): Define. * include/bits/mofunc_impl.h: New file. * include/bits/move_only_function.h: New file. * testsuite/20_util/move_only_function/call.cc: New test. * testsuite/20_util/move_only_function/cons.cc: New test. * testsuite/20_util/move_only_function/move.cc: New test. * testsuite/20_util/move_only_function/version.cc: New test.
2021-10-01libstdc++: Restore printing of assertion messages [PR102100]Jonathan Wakely
My changes for PR 101429 broke the _-replacement_assert function, because we now always just abort without printing anything. That's because I added checks for _GLIBCXX_HOSTED and _GLIBCXX_VERBOSE, but the checks are done before those get defined. This adds a new macro which is set by the sed command in include/Makefile, once the HOSTED and VERBOSE macros have been set by the configure script. libstdc++-v3/ChangeLog: PR libstdc++/102100 * include/Makefile.am (c++config.h): Define _GLIBCXX_VERBOSE_ASSERT based on configure output. * include/Makefile.in: Regenerate. * include/bits/c++config: Fix condition for verbose assertions.
2021-07-27libstdc++: Move COW string definitions to separate headerJonathan Wakely
This moves the definitions of the COW string to a separate file, so that they don't need to be preprocessed for the common case. We could also move the SSO string definitions to a new file, so that they don't need to be preprocessed for the old ABI case, but that would require more shovel work because there are some parts of <bits/basic_string.h> and <bits/basic_string.tcc> that are common to both definitions. libstdc++-v3/ChangeLog: * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI] (basic_string): Move definition of Copy-on-Write string to new file. * include/bits/basic_string.tcc: Likewise. * include/bits/cow_string.h: New file.
2021-07-27libstdc++: Reduce header dependencies on <array> and <utility>Jonathan Wakely
This refactoring reduces the memory usage and compilation time to parse a number of headers that depend on std::pair, std::tuple or std::array. Previously the headers for these class templates were all intertwined, due to the common dependency on std::tuple_size, std::tuple_element and their std::get overloads. This decouples the headers by moving some parts of <utility> into a new <bits/utility.h> header. This means that <array> and <tuple> no longer need to include the whole of <utility>, and <tuple> no longer needs to include <array>. This decoupling benefits headers such as <thread> and <scoped_allocator> which only need std::tuple, and so no longer have to parse std::array. Some other headers such as <any>, <optional> and <variant> no longer need to include <utility> just for the std::in_place tag types, so do not have to parse the std::pair definitions. Removing direct uses of <utility> also means that the std::rel_ops namespace is not transitively declared by other headers. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/Makefile.am: Add bits/utility.h header. * include/Makefile.in: Regenerate. * include/bits/utility.h: New file. * include/std/utility (tuple_size, tuple_element): Move to new header. * include/std/type_traits (__is_tuple_like_impl<tuple<T...>>): Move to <tuple>. (_Index_tuple, _Build_index_tuple, integer_sequence): Likewise. (in_place_t, in_place_index_t, in_place_type_t): Likewise. * include/bits/ranges_util.h: Include new header instead of <utility>. * include/bits/stl_pair.h (tuple_size, tuple_element): Move partial specializations for std::pair here. (get): Move overloads for std::pair here. * include/std/any: Include new header instead of <utility>. * include/std/array: Likewise. * include/std/memory_resource: Likewise. * include/std/optional: Likewise. * include/std/variant: Likewise. * include/std/tuple: Likewise. (__is_tuple_like_impl<tuple<T...>>): Move here. (get) Declare overloads for std::array. * include/std/version (__cpp_lib_tuples_by_type): Change type to long. * testsuite/20_util/optional/84601.cc: Include <utility>. * testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc: Likewise. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust dg-error line numbers. * testsuite/std/ranges/access/cbegin.cc: Include <utility>. * testsuite/std/ranges/access/cend.cc: Likewise. * testsuite/std/ranges/access/end.cc: Likewise. * testsuite/std/ranges/single_view.cc: Likewise.
2021-04-20libstdc++: Refactor/cleanup of C++20 atomic wait implementationThomas Rodgers
This is a substantial rewrite of the atomic wait/notify (and timed wait counterparts) implementation. The previous __platform_wait looped on EINTR however this behavior is not required by the standard. A new _GLIBCXX_HAVE_PLATFORM_WAIT macro now controls whether wait/notify are implemented using a platform specific primitive or with a platform agnostic mutex/condvar. This patch only supplies a definition for linux futexes. A future update could add support __ulock_wait/wake on Darwin, for instance. The members of __waiters were lifted to a new base class. The members are now arranged such that overall sizeof(__waiter_pool_base) fits in two cache lines (on platforms with at least 64 byte cache lines). The definition will also use destructive_interference_size for this if it is available. The __waiters type is now specific to untimed waits, and is renamed to __waiter_pool. Timed waits have a corresponding __timed_waiter_pool type. Much of the code has been moved from the previous __atomic_wait() free function to the __waiter_base template and a __waiter derived type is provided to implement the un-timed wait operations. A similar change has been made to the timed wait implementation. The __atomic_spin code has been extended to take a spin policy which is invoked after the initial busy wait loop. The default policy is to return from the spin. The timed wait code adds a timed backoff spinning policy. The code from <thread> which implements this_thread::sleep_for, sleep_until has been moved to a new <bits/std_thread_sleep.h> header which allows the thread sleep code to be consumed without pulling in the whole of <thread>. The entry points into the wait/notify code have been restructured to support either - * Testing the current value of the atomic stored at the given address and waiting on a notification. * Applying a predicate to determine if the wait was satisfied. The entry points were renamed to make it clear that the wait and wake operations operate on addresses. The first variant takes the expected value and a function which returns the current value that should be used in comparison operations, these operations are named with a _v suffix (e.g. 'value'). All atomic<_Tp> wait/notify operations use the first variant. Barriers, latches and semaphores use the predicate variant. This change also centralizes what it means to compare values for the purposes of atomic<T>::wait rather than scattering through individual predicates. This change also centralizes the repetitive code which adjusts for different user supplied clocks (this should be moved elsewhere and all such adjustments should use a common implementation). This change also removes the hashing of the pointer and uses the pointer value directly for indexing into the waiters table. libstdc++-v3/ChangeLog: * include/Makefile.am: Add new <bits/this_thread_sleep.h> header. * include/Makefile.in: Regenerate. * include/bits/this_thread_sleep.h: New file. * include/bits/atomic_base.h: Adjust all calls to __atomic_wait/__atomic_notify for new call signatures. * include/bits/atomic_timed_wait.h: Extensive rewrite. * include/bits/atomic_wait.h: Likewise. * include/bits/semaphore_base.h: Adjust all calls to __atomic_wait/__atomic_notify for new call signatures. * include/std/atomic: Likewise. * include/std/barrier: Likewise. * include/std/latch: Likewise. * include/std/semaphore: Likewise. * include/std/thread (this_thread::sleep_for) (this_thread::sleep_until): Move to new header. * testsuite/29_atomics/atomic/wait_notify/bool.cc: Simplify test. * testsuite/29_atomics/atomic/wait_notify/generic.cc: Likewise. * testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise. * testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise. * testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise. * testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise. * testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
2021-01-27libstdc++: Add std::experimental::simd from the Parallelism TS 2Matthias Kretz
Adds <experimental/simd>. This implements the simd and simd_mask class templates via [[gnu::vector_size(N)]] data members. It implements overloads for all of <cmath> for simd. Explicit vectorization of the <cmath> functions is not finished. The majority of functions are marked as [[gnu::always_inline]] to enable quasi-ODR-conforming linking of TUs with different -m flags. Performance optimization was done for x86_64. ARM, Aarch64, and POWER rely on the compiler to recognize reduction, conversion, and shuffle patterns. Besides verification using many different machine flages, the code was also verified with different fast-math flags. libstdc++-v3/ChangeLog: * doc/xml/manual/status_cxx2017.xml: Add implementation status of the Parallelism TS 2. Document implementation-defined types and behavior. * include/Makefile.am: Add new headers. * include/Makefile.in: Regenerate. * include/experimental/simd: New file. New header for Parallelism TS 2. * include/experimental/bits/numeric_traits.h: New file. Implementation of P1841R1 using internal naming. Addition of missing IEC559 functionality query. * include/experimental/bits/simd.h: New file. Definition of the public simd interfaces and general implementation helpers. * include/experimental/bits/simd_builtin.h: New file. Implementation of the _VecBuiltin simd_abi. * include/experimental/bits/simd_converter.h: New file. Generic simd conversions. * include/experimental/bits/simd_detail.h: New file. Internal macros for the simd implementation. * include/experimental/bits/simd_fixed_size.h: New file. Simd fixed_size ABI specific implementations. * include/experimental/bits/simd_math.h: New file. Math overloads for simd. * include/experimental/bits/simd_neon.h: New file. Simd NEON specific implementations. * include/experimental/bits/simd_ppc.h: New file. Implement bit shifts to avoid invalid results for integral types smaller than int. * include/experimental/bits/simd_scalar.h: New file. Simd scalar ABI specific implementations. * include/experimental/bits/simd_x86.h: New file. Simd x86 specific implementations. * include/experimental/bits/simd_x86_conversions.h: New file. x86 specific conversion optimizations. The conversion patterns work around missing conversion patterns in the compiler and should be removed as soon as PR85048 is resolved. * testsuite/experimental/simd/standard_abi_usable.cc: New file. Test that all (not all fixed_size<N>, though) standard simd and simd_mask types are usable. * testsuite/experimental/simd/standard_abi_usable_2.cc: New file. As above but with -ffast-math. * testsuite/libstdc++-dg/conformance.exp: Don't build simd tests from the standard test loop. Instead use check_vect_support_and_set_flags to build simd tests with the relevant machine flags.
2021-01-07libstdc++: Add support for C++20 barriersThomas Rodgers
Adds <barrier> libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in: Add new header. * include/Makefile.am (std_headers): likewise. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Add new header. * include/std/barrier: New file. * include/std/version: Add __cpp_lib_barrier feature test macro. * testsuite/30_threads/barrier/1.cc: New test. * testsuite/30_threads/barrier/2.cc: Likewise. * testsuite/30_threads/barrier/arrive_and_drop.cc: Likewise. * testsuite/30_threads/barrier/arrive_and_wait.cc: Likewise. * testsuite/30_threads/barrier/arrive.cc: Likewise. * testsuite/30_threads/barrier/completion.cc: Likewise.
2020-12-16libstdc++: Add C++ runtime support for new 128-bit long double formatJonathan Wakely
This adds support for the new __ieee128 long double format on powerpc64le targets. Most of the complexity comes from wanting a single libstdc++.so library that contains the symbols needed by code compiled with both -mabi=ibmlongdouble and -mabi=ieeelongdouble (and not forgetting -mlong-double-64 as well!) In a few places this just requires an extra overload, for example std::from_chars has to be overloaded for both forms of long double. That can be done in a single translation unit that defines overloads for 'long double' and also '__ieee128', so that user code including <charconv> will be able to link to a definition for either type of long double. Those are the easy cases. The difficult parts are (as for the std::string ABI transition) the I/O and locale facets. In order to be able to write either form of long double to an ostream such as std::cout we need the locale to contain a std::num_put facet that can handle both forms. The same approach is taken as was already done for supporting 64-bit long double and 128-bit long double: adding extra overloads of do_put to the facet class. On targets where the new long double code is enabled, the facets that are registered in the locale at program startup have additional overloads so that they can work with any long double type. Where this fails to work is if user code installs its own facet, which will probably not have the additional overloads and so will only be able to output one or the other type. In practice the number of users expecting to be able to use their own locale facets in code using a mix of -mabi=ibmlongdouble and -mabi=ieeelongdouble is probably close to zero. libstdc++-v3/ChangeLog: * Makefile.in: Regenerate. * config.h.in: Regenerate. * config/abi/pre/gnu.ver: Make patterns less greedy. * config/os/gnu-linux/ldbl-ieee128-extra.ver: New file with patterns for IEEE128 long double symbols. * configure: Regenerate. * configure.ac: Enable alternative 128-bit long double format on powerpc64*-*-linux*. * doc/Makefile.in: Regenerate. * fragment.am: Regenerate. * include/Makefile.am: Set _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT. * include/Makefile.in: Regenerate. * include/bits/c++config: Define inline namespace for new long double symbols. Don't define _GLIBCXX_USE_FLOAT128 when it's the same type as long double. * include/bits/locale_classes.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT] (locale::_Impl::_M_init_extra_ldbl128): Declare new member function. * include/bits/locale_facets.h (_GLIBCXX_NUM_FACETS): Simplify by only counting narrow character facets. (_GLIBCXX_NUM_CXX11_FACETS): Likewise. (_GLIBCXX_NUM_LBDL_ALT128_FACETS): New. [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT] (num_get::__do_get): Define vtable placeholder for __ibm128 long double type. [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (num_get::__do_get): Declare vtable placeholder for __ibm128 long double type. [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (num_put::__do_put): Likewise. * include/bits/locale_facets.tcc [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (num_get::__do_get, num_put::__do_put): Define. * include/bits/locale_facets_nonio.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (money_get::__do_get): Declare vtable placeholder for __ibm128 long double type. [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (money_put::__do_put): Likewise. * include/bits/locale_facets_nonio.tcc [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__] (money_get::__do_get, money_put::__do_put): Define. * include/ext/numeric_traits.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT] (__numeric_traits<__ibm128>, __numeric_traits<__ieee128>): Define. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.am: Add compatibility-ldbl-alt128.cc and compatibility-ldbl-alt128-cxx11.cc sources and recipes for objects. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++11/compatibility-ldbl-alt128-cxx11.cc: New file defining symbols using the old 128-bit long double format, for the cxx11 ABI. * src/c++11/compatibility-ldbl-alt128.cc: Likewise, for the gcc4-compatible ABI. * src/c++11/compatibility-ldbl-facets-aliases.h: New header for long double compat aliases. * src/c++11/cow-locale_init.cc: Add comment. * src/c++11/cxx11-locale-inst.cc: Define C and C_is_char unconditionally. * src/c++11/cxx11-wlocale-inst.cc: Add sanity check. Include locale-inst.cc directly, not via cxx11-locale-inst.cc. * src/c++11/locale-inst-monetary.h: New header for monetary category instantiations. * src/c++11/locale-inst-numeric.h: New header for numeric category instantiations. * src/c++11/locale-inst.cc: Include new headers for monetary, numeric, and long double definitions. * src/c++11/wlocale-inst.cc: Remove long double compat aliases that are defined in new header now. * src/c++17/Makefile.am: Use -mabi=ibmlongdouble for floating_from_chars.cc. * src/c++17/Makefile.in: Regenerate. * src/c++17/floating_from_chars.cc (from_chars_impl): Add if-constexpr branch for __ieee128. (from_chars): Overload for __ieee128. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/c++98/locale_init.cc (num_facets): Adjust calculation. (locale::_Impl::_Impl(size_t)): Call _M_init_extra_ldbl128. * src/c++98/localename.cc (num_facets): Adjust calculation. (locale::_Impl::_Impl(const char*, size_t)): Call _M_init_extra_ldbl128. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. * testsuite/util/testsuite_abi.cc: Add new symbol versions. Allow new symbols to be added to GLIBCXX_IEEE128_3.4.29 and CXXABI_IEEE128_1.3.13 too. * testsuite/26_numerics/complex/abi_tag.cc: Add u9__ieee128 to regex matching expected symbols.
2020-12-03libtdc++: Define std::source_location for C++20JeanHeyd Meneide
This doesn't define a new _GLIBCXX_HAVE_BUILTIN_SOURCE_LOCATION macro. because using __has_builtin(__builtin_source_location) is sufficient. Currently only GCC supports it, but if/when Clang and Intel add it the __has_builtin check should for them too. Co-authored-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (INPUT): Add <source_location>. * include/Makefile.am: Add <source_location>. * include/Makefile.in: Regenerate. * include/std/version (__cpp_lib_source_location): Define. * include/std/source_location: New file. * testsuite/18_support/source_location/1.cc: New test. * testsuite/18_support/source_location/consteval.cc: New test. * testsuite/18_support/source_location/srcloc.h: New test. * testsuite/18_support/source_location/version.cc: New test.
2020-11-20libstdc++: Add C++2a synchronization supportThomas Rodgers
Add support for - * atomic_flag::wait/notify_one/notify_all * atomic::wait/notify_one/notify_all * counting_semaphore * binary_semaphore * latch libstdc++-v3/ChangeLog: * include/Makefile.am (bits_headers): Add new header. * include/Makefile.in: Regenerate. * include/bits/atomic_base.h (__atomic_flag::wait): Define. (__atomic_flag::notify_one): Likewise. (__atomic_flag::notify_all): Likewise. (__atomic_base<_Itp>::wait): Likewise. (__atomic_base<_Itp>::notify_one): Likewise. (__atomic_base<_Itp>::notify_all): Likewise. (__atomic_base<_Ptp*>::wait): Likewise. (__atomic_base<_Ptp*>::notify_one): Likewise. (__atomic_base<_Ptp*>::notify_all): Likewise. (__atomic_impl::wait): Likewise. (__atomic_impl::notify_one): Likewise. (__atomic_impl::notify_all): Likewise. (__atomic_float<_Fp>::wait): Likewise. (__atomic_float<_Fp>::notify_one): Likewise. (__atomic_float<_Fp>::notify_all): Likewise. (__atomic_ref<_Tp>::wait): Likewise. (__atomic_ref<_Tp>::notify_one): Likewise. (__atomic_ref<_Tp>::notify_all): Likewise. (atomic_wait<_Tp>): Likewise. (atomic_wait_explicit<_Tp>): Likewise. (atomic_notify_one<_Tp>): Likewise. (atomic_notify_all<_Tp>): Likewise. * include/bits/atomic_wait.h: New file. * include/bits/atomic_timed_wait.h: New file. * include/bits/semaphore_base.h: New file. * include/std/atomic (atomic<bool>::wait): Define. (atomic<bool>::wait_one): Likewise. (atomic<bool>::wait_all): Likewise. (atomic<_Tp>::wait): Likewise. (atomic<_Tp>::wait_one): Likewise. (atomic<_Tp>::wait_all): Likewise. (atomic<_Tp*>::wait): Likewise. (atomic<_Tp*>::wait_one): Likewise. (atomic<_Tp*>::wait_all): Likewise. * include/std/latch: New file. * include/std/semaphore: New file. * include/std/version: Add __cpp_lib_semaphore and __cpp_lib_latch defines. * testsuite/29_atomics/atomic/wait_notify/bool.cc: New test. * testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise. * testsuite/29_atomics/atomic/wait_notify/generic.cc: Liekwise. * testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise. * testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise. * testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise. * testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise. * testsuite/30_threads/semaphore/1.cc: New test. * testsuite/30_threads/semaphore/2.cc: Likewise. * testsuite/30_threads/semaphore/least_max_value_neg.cc: Likewise. * testsuite/30_threads/semaphore/try_acquire.cc: Likewise. * testsuite/30_threads/semaphore/try_acquire_for.cc: Likewise. * testsuite/30_threads/semaphore/try_acquire_posix.cc: Likewise. * testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise. * testsuite/30_threads/latch/1.cc: New test. * testsuite/30_threads/latch/2.cc: New test. * testsuite/30_threads/latch/3.cc: New test. * testsuite/util/atomic/wait_notify_util.h: New File.
2020-11-19libstdc++: Move std::thread to a new headerJonathan Wakely
This makes it possible to use std::thread without including the whole of <thread>. It also makes this_thread::get_id() and this_thread::yield() available even when there is no gthreads support (e.g. when GCC is built with --disable-threads or --enable-threads=single). In order for the std::thread::id return type of this_thread::get_id() to be defined, std:thread itself is defined unconditionally. However the constructor that creates new threads is not defined for single-threaded builds. The thread::join() and thread::detach() member functions are defined inline for single-threaded builds and just throw an exception (because we know the thread cannot be joinable if the constructor that creates joinable threads doesn't exit). The thread::hardware_concurrency() member function is also defined inline and returns 0 (as suggested by the standard when the value "is not computable or well-defined"). The main benefit for most targets is that other headers such as <future> do not need to include the whole of <thread> just to be able to create a std::thread. That avoids including <stop_token> and std::jthread where not required. This is another partial fix for PR 92546. This also means we can use this_thread::get_id() and this_thread::yield() in <stop_token> instead of using the gthread functions directly. This removes some preprocessor conditionals, simplifying the code. libstdc++-v3/ChangeLog: PR libstdc++/92546 * include/Makefile.am: Add new <bits/std_thread.h> header. * include/Makefile.in: Regenerate. * include/std/future: Include new header instead of <thread>. * include/std/stop_token: Include new header instead of <bits/gthr.h>. (stop_token::_S_yield()): Use this_thread::yield(). (_Stop_state_t::_M_requester): Change type to std::thread::id. (_Stop_state_t::_M_request_stop()): Use this_thread::get_id(). (_Stop_state_t::_M_remove_callback(_Stop_cb*)): Likewise. Use __is_single_threaded() to decide whether to synchronize. * include/std/thread (thread, operator==, this_thread::get_id) (this_thread::yield): Move to new header. (operator<=>, operator!=, operator<, operator<=, operator>) (operator>=, hash<thread::id>, operator<<): Define even when gthreads not available. * src/c++11/thread.cc: Include <memory>. * include/bits/std_thread.h: New file. (thread, operator==, this_thread::get_id, this_thread::yield): Define even when gthreads not available. [!_GLIBCXX_HAS_GTHREADS] (thread::join, thread::detach) (thread::hardware_concurrency): Define inline.
2020-11-09libstdc++: Remove <debug/array>François Dumont
Add _GLIBCXX_ASSERTIONS assert in normal std::array and remove __gnu_debug::array implementation. libstdc++-v3/ChangeLog: * include/debug/array: Remove. * include/Makefile.am: Remove <debug/array>. * include/Makefile.in: Regenerate. * include/experimental/functional: Adapt. * include/std/array: Move to _GLIBCXX_INLINE_VERSION namespace. * include/std/functional: Adapt. * include/std/span: Adapt. * testsuite/23_containers/array/debug/back1_neg.cc: Remove dg-require-debug-mode. Add -D_GLIBCXX_ASSERTIONS option. * testsuite/23_containers/array/debug/back2_neg.cc: Likewise. * testsuite/23_containers/array/debug/front1_neg.cc: Likewise. * testsuite/23_containers/array/debug/front2_neg.cc: Likewise. * testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc: Likewise. * testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc: Likewise. * testsuite/23_containers/array/element_access/60497.cc * testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: Remove. * testsuite/23_containers/array/tuple_interface/get_neg.cc * testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
2020-11-02libstdc++: Add c++2a <syncstream>Thomas Rodgers
libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (INPUT): Add new header. * include/Makefile.am (std_headers): Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include new header. * include/std/syncstream: New header. * include/std/version: Add __cpp_lib_syncbuf. * testsuite/27_io/basic_syncbuf/1.cc: New test. * testsuite/27_io/basic_syncbuf/2.cc: Likewise. * testsuite/27_io/basic_syncbuf/basic_ops/1.cc: Likewise. * testsuite/27_io/basic_syncbuf/requirements/types.cc: Likewise. * testsuite/27_io/basic_syncbuf/sync_ops/1.cc: Likewise. * testsuite/27_io/basic_syncstream/1.cc: Likewise. * testsuite/27_io/basic_syncstream/2.cc: Likewise. * testsuite/27_io/basic_syncstream/basic_ops/1.cc: Likewise. * testsuite/27_io/basic_syncstream/requirements/types.cc: Likewise.
2020-10-22libstdc++: Reduce header dependencies in and on <memory>Jonathan Wakely
By moving std::make_obj_using_allocator and the related "utility functions for uses-allocator construction" to a new header, we can avoid including the whole of <memory> in <scoped_allocator> and <memory_resource>. In order to simplify the implementation of those utility functions they now use concepts unconditionally. They are no longer defined if __cpp_concepts is not defined. To simplify the code that uses those functions I've introduced a __cpp_lib_make_obj_using_allocator feature test macro (not specified in the standard, which might be an oversight). That allows the code in <memory_resource> and <scoped_allocator> to check the feature test macro to decide whether to use the new utilities, or fall back to the C++17 code. At the same time, this reshuffles some of the headers included by <memory> so that they are (mostly?) self-contained. It should no longer be necessary to include other headers before <bits/shared_ptr.h> when other parts of the library want to use std::shared_ptr without including the whole of <memory>. libstdc++-v3/ChangeLog: * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/bits/shared_ptr.h: Include <iosfwd>. * include/bits/shared_ptr_base.h: Include required headers here directly, instead of in <memory>. * include/bits/uses_allocator_args.h: New file. Move utility functions for uses-allocator construction from <memory> to here. Only define the utility functions when concepts are available. (__cpp_lib_make_obj_using_allocator): Define non-standard feature test macro. * include/std/condition_variable: Remove unused headers. * include/std/future: Likewise. * include/std/memory: Remove headers that are not needed directly, and are now inclkuded where they're needed. Include new <bits/uses_allocator_args.h> header. * include/std/memory_resource: Include only the necessary headers. Use new feature test macro to detect support for the utility functions. * include/std/scoped_allocator: Likewise. * include/std/version (__cpp_lib_make_obj_using_allocator): Define.
2020-09-22libstdc++: Introduce new headers for C++20 ranges componentsJonathan Wakely
This introduces two new headers: <bits/ranges_base.h> defines the minimal components needed for using C++20 ranges (customization point objects such as std::ranges::begin, concepts such as std::ranges::range, etc.) <bits/ranges_util.h> includes <bits/ranges_base.h> and additionally defines subrange, which is needed by <bits/ranges_algo.h>. Most of the content of <bits/ranges_base.h> was previously defined in <bits/range_access.h>, but a few pieces were only defined in <ranges>. This meant the entire <ranges> header was needed in <algorithm> and <memory>, even though they don't use all the range adaptors. By moving the ranges components out of <bits/range_access.h> that file is left defining just the contents of [iterator.range] i.e. std::begin, std::end, std::size etc. and not C++20 ranges components. For consistency with other C++20 ranges headers, <bits/range_cmp.h> is renamed to <bits/ranges_cmp.h>. libstdc++-v3/ChangeLog: * include/Makefile.am: Add new headers and adjust for renamed header. * include/Makefile.in: Regenerate. * include/bits/iterator_concepts.h: Adjust for renamed header. * include/bits/range_access.h (ranges::*): Move to new <bits/ranges_base.h> header. * include/bits/ranges_algobase.h: Include new <bits/ranges_base.h> header instead of <ranges>. * include/bits/ranges_algo.h: Include new <bits/ranges_util.h> header. * include/bits/range_cmp.h: Moved to... * include/bits/ranges_cmp.h: ...here. * include/bits/ranges_base.h: New header. * include/bits/ranges_util.h: New header. * include/experimental/string_view: Include new <bits/ranges_base.h> header. * include/std/functional: Adjust for renamed header. * include/std/ranges (ranges::view_base, ranges::enable_view) (ranges::dangling, ranges::borrowed_iterator_t): Move to new <bits/ranges_base.h> header. (ranges::view_interface, ranges::subrange) (ranges::borrowed_subrange_t): Move to new <bits/ranges_util.h> header. * include/std/span: Include new <bits/ranges_base.h> header. * include/std/string_view: Likewise. * testsuite/24_iterators/back_insert_iterator/pr93884.cc: Add missing <ranges> header. * testsuite/24_iterators/front_insert_iterator/pr93884.cc: Likewise.
2020-09-11libstdc++: Split std::align/assume_aligned to bits/align.hThomas Rodgers
We would like to be able to use std::align and std::assume_aligned without pulling in everything in <memory>. libstdc++-v3/ChangeLog: * include/Makefile.am (bits_headers): Add new header. * include/Makefile.in: Regenerate. * include/bits/align.h: New file. * include/std/memory (align): Move definition to bits/align.h. (assume_aligned): Likewise.
2020-08-19libstdc++: integer-class types as per [iterator.concept.winc]Patrick Palka
This implements signed and unsigned integer-class types, whose width is one bit larger than the widest supported signed and unsigned integral type respectively. In our case this is either __int128 and unsigned __int128, or long long and unsigned long long. Internally, the two integer-class types are represented as a largest supported unsigned integral type plus one extra bit. The signed integer-class type is represented in two's complement form with the extra bit acting as the sign bit. libstdc++-v3/ChangeLog: * include/Makefile.am (bits_headers): Add new header <bits/max_size_type.h>. * include/Makefile.in: Regenerate. * include/bits/iterator_concepts.h (ranges::__detail::__max_diff_type): Remove definition, replace with forward declaration of class __max_diff_type. (__detail::__max_size_type): Remove definition, replace with forward declaration of class __max_size_type. (__detail::__is_unsigned_int128, __is_signed_int128) (__is_int128): New concepts. (__detail::__is_integer_like): Accept __int128 and unsigned __int128. (__detail::__is_signed_integer_like): Accept __int128. * include/bits/max_size_type.h: New header. * include/bits/range_access.h: Include <bits/max_size_type.h>. (__detail::__to_unsigned_like): Two new overloads. * testsuite/std/ranges/iota/difference_type.cc: New test. * testsuite/std/ranges/iota/max_size_type.cc: New test.
2020-07-07libstdc++: Replace __int_limits with __numeric_traits_integerJonathan Wakely
I recently added std::__detail::__int_limits as a lightweight alternative to std::numeric_limits, forgetting that the values it provides (digits, min and max) are already provided by __gnu_cxx::__numeric_traits. This change adds __int_traits as an alias for __numeric_traits_integer. This avoids instantiating __numeric_traits to decide whether to use __numeric_traits_integer or __numeric_traits_floating. Then all uses of __int_limits can be replaced with __int_traits, and __int_limits can be removed. libstdc++-v3/ChangeLog: * include/Makefile.am: Remove bits/int_limits.h. * include/Makefile.in: Regenerate. * include/bits/int_limits.h: Removed. * include/bits/parse_numbers.h (_Select_int_base): Replace __int_limits with __int_traits. * include/bits/range_access.h (_SSize::operator()): Likewise. * include/ext/numeric_traits.h (__numeric_traits_integer): Add static assertion. (__int_traits): New alias template. * include/std/bit (__rotl, __rotr, __countl_zero, __countl_one) (__countr_zero, __countr_one, __popcount, __bit_ceil) (__bit_floor, __bit_width) Replace __int_limits with __int_traits. * include/std/charconv (__to_chars_8, __from_chars_binary) (__from_chars_alpha_to_num, from_chars): Likewise. * include/std/memory_resource (polymorphic_allocator::allocate) (polymorphic_allocator::allocate_object): Likewise. * include/std/string_view (basic_string_view::_S_compare): Likewise. * include/std/utility (cmp_equal, cmp_less, in_range): Likewise.
2020-06-23libstdc++: Regenerate makefilesJonathan Wakely
libstdc++-v3/ChangeLog: * doc/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
2020-02-17libstdc++: Add lightweight replacement for std::numeric_limits (PR 92546)Jonathan Wakely
Many uses of std::numeric_limits in C++17 and C++20 features only really need the min(), max() and digits constants for integral types. By adding __detail::__int_limits we can avoid including the whole <limits> header. The <limits> header isn't especially large, but avoiding it still gives small savings in compilation time and memory usage for the compiler. There are also C++11 features that could benefit from this change (e.g. <bits/hashtable_policy.h> and <bits/uniform_int_dist.h>) but I won't change those until stage 1. The implementation of __int_limits assumes two's complement integers, which is true for all targets supported by GCC. PR libstdc++/92546 (partial) * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/bits/int_limits.h: New header. * include/bits/parse_numbers.h (__select_int::_Select_int): Replace numeric_limits with __detail::__int_limits. * include/std/bit (__rotl, __rotr, __countl_zero, __countl_one) (__countr_zero, __countr_one, __popcount, __ceil2, __floor2, __log2p1): Likewise. * include/std/charconv (__to_chars_8, __from_chars_binary) (__from_chars_alpha_to_num, from_chars): Likewise. * include/std/memory_resource (polymorphic_allocator::allocate) (polymorphic_allocator::allocate_object): Likewise. * include/std/string_view (basic_string_view::_S_compare): Likewise. * include/std/utility (in_range): Likewise. * testsuite/20_util/integer_comparisons/in_range_neg.cc: Adjust for extra error about incomplete type __int_limits<bool>. * testsuite/26_numerics/bit/bit.count/countl_one.cc: Include <limits>. * testsuite/26_numerics/bit/bit.count/countl_zero.cc: Likewise. * testsuite/26_numerics/bit/bit.count/countr_one.cc: Likewise. * testsuite/26_numerics/bit/bit.count/countr_zero.cc: Likewise. * testsuite/26_numerics/bit/bit.count/popcount.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/ceil2_neg.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/floor2.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: Likewise. * testsuite/26_numerics/bit/bit.rotate/rotl.cc: Likewise. * testsuite/26_numerics/bit/bit.rotate/rotr.cc: Likewise.
2020-02-13libstdc++: Implement ranges [specialized.algorithms]Patrick Palka
This implements all the ranges members defined in [specialized.algorithms]: ranges::uninitialized_default_construct ranges::uninitialized_value_construct ranges::uninitialized_copy ranges::uninitialized_copy_n ranges::uninitialized_move ranges::uninitialized_move_n ranges::uninitialized_fill ranges::uninitialized_fill_n ranges::construct_at ranges::destroy_at ranges::destroy It also implements (hopefully correctly) the "obvious" optimizations for these algos, namely that if the output range has a trivial value type and if the appropriate operation won't throw then we can dispatch to the standard ranges version of the algorithm which will then potentially enable further optimizations. libstdc++-v3/ChangeLog: * include/Makefile.am: Add <bits/ranges_uninitialized.h>. * include/Makefile.in: Regenerate. * include/bits/ranges_uninitialized.h: New header. * include/std/memory: Include it. * testsuite/20_util/specialized_algorithms/destroy/constrained.cc: New test. * .../uninitialized_copy/constrained.cc: New test. * .../uninitialized_default_construct/constrained.cc: New test. * .../uninitialized_fill/constrained.cc: New test. * .../uninitialized_move/constrained.cc: New test. * .../uninitialized_value_construct/constrained.cc: New test.
2020-02-13libstdc++: Move some ranges algos to a new header <bits/ranges_algobase.h>Patrick Palka
This roughly mirrors the existing split between <bits/stl_algo.h> and <bits/stl_algobase.h>. The ranges [specialized.algorithms] will use this new header to avoid including all of of <bits/ranges_algo.h>. libstdc++-v3/ChangeLog: * include/Makefile.am: Add bits/ranges_algobase.h * include/Makefile.in: Regenerate. * bits/ranges_algo.h: Include <bits/ranges_algobase.h> and refactor existing #includes. (__detail::__is_normal_iterator, __detail::is_reverse_iterator, __detail::__is_move_iterator, copy_result, move_result, __equal, equal, copy_result, move_result, move_backward_result, copy_backward_result, __copy_or_move_backward, __copy_or_move, copy, move, copy_backward, move_backward, copy_n_result, copy_n, fill_n, fill): Split out into ... * bits/range_algobase.h: ... this new header.
2020-02-06libstdc++: Implement C++20 constrained algorithmsPatrick Palka
This patch implements the C++20 ranges overloads for the algorithms in [algorithms]. Most of the algorithms were reimplemented, with each of their implementations very closely following the existing implementation in bits/stl_algo.h and bits/stl_algobase.h. The reason for reimplementing most of the algorithms instead of forwarding to their STL-style overload is because forwarding cannot be conformantly and efficiently performed for algorithms that operate on non-random-access iterators. But algorithms that operate on random access iterators can safely and efficiently be forwarded to the STL-style implementation, and this patch does so for push_heap, pop_heap, make_heap, sort_heap, sort, stable_sort, nth_element, inplace_merge and stable_partition. What's missing from this patch is debug-iterator and container specializations that are present for some of the STL-style algorithms that need to be ported over to the ranges algos. I marked them missing at TODO comments. There are also some other minor outstanding TODOs. The code that could use the most thorough review is ranges::__copy_or_move, ranges::__copy_or_move_backward, ranges::__equal and ranges::__lexicographical_compare. In the tests, I tried to test the interface of each new overload, as well as the correctness of the new implementation. libstdc++-v3/ChangeLog: Implement C++20 constrained algorithms * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/std/algorithm: Include <bits/ranges_algo.h>. * include/bits/ranges_algo.h: New file. * testsuite/25_algorithms/adjacent_find/constrained.cc: New test. * testsuite/25_algorithms/all_of/constrained.cc: New test. * testsuite/25_algorithms/any_of/constrained.cc: New test. * testsuite/25_algorithms/binary_search/constrained.cc: New test. * testsuite/25_algorithms/copy/constrained.cc: New test. * testsuite/25_algorithms/copy_backward/constrained.cc: New test. * testsuite/25_algorithms/copy_if/constrained.cc: New test. * testsuite/25_algorithms/copy_n/constrained.cc: New test. * testsuite/25_algorithms/count/constrained.cc: New test. * testsuite/25_algorithms/count_if/constrained.cc: New test. * testsuite/25_algorithms/equal/constrained.cc: New test. * testsuite/25_algorithms/equal_range/constrained.cc: New test. * testsuite/25_algorithms/fill/constrained.cc: New test. * testsuite/25_algorithms/fill_n/constrained.cc: New test. * testsuite/25_algorithms/find/constrained.cc: New test. * testsuite/25_algorithms/find_end/constrained.cc: New test. * testsuite/25_algorithms/find_first_of/constrained.cc: New test. * testsuite/25_algorithms/find_if/constrained.cc: New test. * testsuite/25_algorithms/find_if_not/constrained.cc: New test. * testsuite/25_algorithms/for_each/constrained.cc: New test. * testsuite/25_algorithms/generate/constrained.cc: New test. * testsuite/25_algorithms/generate_n/constrained.cc: New test. * testsuite/25_algorithms/heap/constrained.cc: New test. * testsuite/25_algorithms/includes/constrained.cc: New test. * testsuite/25_algorithms/inplace_merge/constrained.cc: New test. * testsuite/25_algorithms/is_partitioned/constrained.cc: New test. * testsuite/25_algorithms/is_permutation/constrained.cc: New test. * testsuite/25_algorithms/is_sorted/constrained.cc: New test. * testsuite/25_algorithms/is_sorted_until/constrained.cc: New test. * testsuite/25_algorithms/lexicographical_compare/constrained.cc: New test. * testsuite/25_algorithms/lower_bound/constrained.cc: New test. * testsuite/25_algorithms/max/constrained.cc: New test. * testsuite/25_algorithms/max_element/constrained.cc: New test. * testsuite/25_algorithms/merge/constrained.cc: New test. * testsuite/25_algorithms/min/constrained.cc: New test. * testsuite/25_algorithms/min_element/constrained.cc: New test. * testsuite/25_algorithms/minmax/constrained.cc: New test. * testsuite/25_algorithms/minmax_element/constrained.cc: New test. * testsuite/25_algorithms/mismatch/constrained.cc: New test. * testsuite/25_algorithms/move/constrained.cc: New test. * testsuite/25_algorithms/move_backward/constrained.cc: New test. * testsuite/25_algorithms/next_permutation/constrained.cc: New test. * testsuite/25_algorithms/none_of/constrained.cc: New test. * testsuite/25_algorithms/nth_element/constrained.cc: New test. * testsuite/25_algorithms/partial_sort/constrained.cc: New test. * testsuite/25_algorithms/partial_sort_copy/constrained.cc: New test. * testsuite/25_algorithms/partition/constrained.cc: New test. * testsuite/25_algorithms/partition_copy/constrained.cc: New test. * testsuite/25_algorithms/partition_point/constrained.cc: New test. * testsuite/25_algorithms/prev_permutation/constrained.cc: New test. * testsuite/25_algorithms/remove/constrained.cc: New test. * testsuite/25_algorithms/remove_copy/constrained.cc: New test. * testsuite/25_algorithms/remove_copy_if/constrained.cc: New test. * testsuite/25_algorithms/remove_if/constrained.cc: New test. * testsuite/25_algorithms/replace/constrained.cc: New test. * testsuite/25_algorithms/replace_copy/constrained.cc: New test. * testsuite/25_algorithms/replace_copy_if/constrained.cc: New test. * testsuite/25_algorithms/replace_if/constrained.cc: New test. * testsuite/25_algorithms/reverse/constrained.cc: New test. * testsuite/25_algorithms/reverse_copy/constrained.cc: New test. * testsuite/25_algorithms/rotate/constrained.cc: New test. * testsuite/25_algorithms/rotate_copy/constrained.cc: New test. * testsuite/25_algorithms/search/constrained.cc: New test. * testsuite/25_algorithms/search_n/constrained.cc: New test. * testsuite/25_algorithms/set_difference/constrained.cc: New test. * testsuite/25_algorithms/set_intersection/constrained.cc: New test. * testsuite/25_algorithms/set_symmetric_difference/constrained.cc: New test. * testsuite/25_algorithms/set_union/constrained.cc: New test. * testsuite/25_algorithms/shuffle/constrained.cc: New test. * testsuite/25_algorithms/sort/constrained.cc: New test. * testsuite/25_algorithms/stable_partition/constrained.cc: New test. * testsuite/25_algorithms/stable_sort/constrained.cc: New test. * testsuite/25_algorithms/swap_ranges/constrained.cc: New test. * testsuite/25_algorithms/transform/constrained.cc: New test. * testsuite/25_algorithms/unique/constrained.cc: New test. * testsuite/25_algorithms/unique_copy/constrained.cc: New test. * testsuite/25_algorithms/upper_bound/constrained.cc: New test.
2020-01-24Add `--with-toolexeclibdir=' configuration optionMaciej W. Rozycki
Provide means, in the form of a `--with-toolexeclibdir=' configuration option, to override the default installation directory for target libraries, otherwise known as $toolexeclibdir. This is so that it is possible to get newly-built libraries, particularly the shared ones, installed in a common place, so that they can be readily used by the target system as their host libraries, possibly over NFS, without a need to manually copy them over from the currently hardcoded location they would otherwise be installed in. In the presence of the `--enable-version-specific-runtime-libs' option and for configurations building native GCC the option is ignored. config/ * toolexeclibdir.m4: New file. gcc/ * doc/install.texi (Cross-Compiler-Specific Options): Document `--with-toolexeclibdir' option. libada/ * Makefile.in (configure_deps): Add `toolexeclibdir.m4'. * configure.ac: Handle `--with-toolexeclibdir='. * configure: Regenerate. libatomic/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. libffi/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * include/Makefile.in: Regenerate. * man/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. libgcc/ * Makefile.in (configure_deps): Add `toolexeclibdir.m4'. * configure.ac: Handle `--with-toolexeclibdir='. * configure: Regenerate. libgfortran/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libgomp/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. libhsail-rt/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libitm/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. libobjc/ * Makefile.in (aclocal_deps): Add `toolexeclibdir.m4'. * aclocal.m4: Include `toolexeclibdir.m4'. * configure.ac: Handle `--with-toolexeclibdir='. * configure: Regenerate. liboffloadmic/ * plugin/configure.ac: Handle `--with-toolexeclibdir='. * plugin/Makefile.in: Regenerate. * plugin/aclocal.m4: Regenerate. * plugin/configure: Regenerate. * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libphobos/ * m4/druntime.m4: Handle `--with-toolexeclibdir='. * m4/Makefile.in: Regenerate. * libdruntime/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libquadmath/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libsanitizer/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * asan/Makefile.in: Regenerate. * interception/Makefile.in: Regenerate. * libbacktrace/Makefile.in: Regenerate. * lsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.in: Regenerate. * tsan/Makefile.in: Regenerate. * ubsan/Makefile.in: Regenerate. libssp/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libstdc++-v3/ * acinclude.m4: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. libvtv/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. zlib/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate.
2020-01-23libstdc++: Simplify makefile rule for largefile-config.h (PR91947)Jonathan Wakely
The previous rule could leave an incomplete file if the build was interrupted, which would then not be remade if make was run again. This makes the rule more robust by writing to a temporary file and only moving it into place as the final step. It also simplifies the rule so that only the essential macro definitions are written to the file, not the explanatory comments and commented out #undef lines. Also, the macro for enabling LFS on Mac OS X 10.5 is now set unconditionally, which is a bug fix from upstream autoconf. PR libstdc++/91947 * include/Makefile.am (${host_builddir}/largefile-config.h): Simplify rule. * include/Makefile.in: Regenerate.
2020-01-18[C++ coroutines] Initial implementation.Iain Sandoe
This is the squashed version of the first 6 patches that were split to facilitate review. The changes to libiberty (7th patch) to support demangling the co_await operator stand alone and are applied separately. The patch series is an initial implementation of a coroutine feature, expected to be standardised in C++20. Standardisation status (and potential impact on this implementation) -------------------------------------------------------------------- The facility was accepted into the working draft for C++20 by WG21 in February 2019. During following WG21 meetings, design and national body comments have been reviewed, with no significant change resulting. The current GCC implementation is against n4835 [1]. At this stage, the remaining potential for change comes from: * Areas of national body comments that were not resolved in the version we have worked to: (a) handling of the situation where aligned allocation is available. (b) handling of the situation where a user wants coroutines, but does not want exceptions (e.g. a GPU). * Agreed changes that have not yet been worded in a draft standard that we have worked to. It is not expected that the resolution to these can produce any major change at this phase of the standardisation process. Such changes should be limited to the coroutine-specific code. ABI --- The various compiler developers 'vendors' have discussed a minimal ABI to allow one implementation to call coroutines compiled by another. This amounts to: 1. The layout of a public portion of the coroutine frame. Coroutines need to preserve state across suspension points, the storage for this is called a "coroutine frame". The ABI mandates that pointers into the coroutine frame point to an area begining with two function pointers (to the resume and destroy functions described below); these are immediately followed by the "promise object" described in the standard. This is sufficient that the builtins can take a coroutine frame pointer and determine the address of the promise (or call the resume/destroy functions). 2. A number of compiler builtins that the standard library might use. These are implemented by this patch series. 3. This introduces a new operator 'co_await' the mangling for which is also agreed between vendors (and has an issue filed for that against the upstream c++abi). Demangling for this is added to libiberty in a separate patch. The ABI has currently no target-specific content (a given psABI might elect to mandate alignment, but the common ABI does not do this). Standard Library impact ----------------------- The current implementations require addition of only a single header to the standard library (no change to the runtime). This header is part of the patch. GCC Implementation outline -------------------------- The standard's design for coroutines does not decorate the definition of a coroutine in any way, so that a function is only known to be a coroutine when one of the keywords (co_await, co_yield, co_return) is encountered. This means that we cannot special-case such functions from the outset, but must process them differently when they are finalised - which we do from "finish_function ()". At a high level, this design of coroutine produces four pieces from the original user's function: 1. A coroutine state frame (taking the logical place of the activation record for a regular function). One item stored in that state is the index of the current suspend point. 2. A "ramp" function This is what the user calls to construct the coroutine frame and start the coroutine execution. This will return some object representing the coroutine's eventual return value (or means to continue it when it it suspended). 3. A "resume" function. This is what gets called when a the coroutine is resumed when suspended. 4. A "destroy" function. This is what gets called when the coroutine state should be destroyed and its memory released. The standard's coroutines involve cooperation of the user's authored function with a provided "promise" class, which includes mandatory methods for handling the state transitions and providing output values. Most realistic coroutines will also have one or more 'awaiter' classes that implement the user's actions for each suspend point. As we parse (or during template expansion) the types of the promise and awaiter classes become known, and can then be verified against the signatures expected by the standard. Once the function is parsed (and templates expanded) we are able to make the transformation into the four pieces noted above. The implementation here takes the approach of a series of AST transforms. The state machine suspend points are encoded in three internal functions (one of which represents an exit from scope without cleanups). These three IFNs are lowered early in the middle end, such that the majority of GCC's optimisers can be run on the resulting output. As a design choice, we have carried out the outlining of the user's function in the front end, and taken advantage of the existing middle end's abilities to inline and DCE where that is profitable. Since the state machine is actually common to both resumer and destroyer functions, we make only a single function "actor" that contains both the resume and destroy paths. The destroy function is represented by a small stub that sets a value to signal the use of the destroy path and calls the actor. The idea is that optimisation of the state machine need only be done once - and then the resume and destroy paths can be identified allowing the middle end's inline and DCE machinery to optimise as profitable as noted above. The middle end components for this implementation are: A pass that: 1. Lowers the coroutine builtins that allow the standard library header to interact with the coroutine frame (these fairly simple logical or numerical substitution of values, given a coroutine frame pointer). 2. Lowers the IFN that represents the exit from state without cleanup. Essentially, this becomes a gimple goto. 3. Sets the final size of the coroutine frame at this stage. A second pass (that requires the revised CFG that results from the lowering of the scope exit IFNs in the first). 1. Lower the IFNs that represent the state machine paths for the resume and destroy cases. Patches squashed into this commit: [C++ coroutines 1] Common code and base definitions. This part of the patch series provides the gating flag, the keywords, cpp defines etc. [C++ coroutines 2] Define builtins and internal functions. This part of the patch series provides the builtin functions used by the standard library code and the internal functions used to implement lowering of the coroutine state machine. [C++ coroutines 3] Front end parsing and transforms. There are two parts to this. 1. Parsing, template instantiation and diagnostics for the standard- mandated class entries. The user authors a function that becomes a coroutine (lazily) by making use of any of the co_await, co_yield or co_return keywords. Unlike a regular function, where the activation record is placed on the stack, and is destroyed on function exit, a coroutine has some state that persists between calls - the 'coroutine frame' (thus analogous to a stack frame). We transform the user's function into three pieces: 1. A so-called ramp function, that establishes the coroutine frame and begins execution of the coroutine. 2. An actor function that contains the state machine corresponding to the user's suspend/resume structure. 3. A stub function that calls the actor function in 'destroy' mode. The actor function is executed: * from "resume point 0" by the ramp. * from resume point N ( > 0 ) for handle.resume() calls. * from the destroy stub for destroy point N for handle.destroy() calls. The C++ coroutine design described in the standard makes use of some helper methods that are authored in a so-called "promise" class provided by the user. At parse time (or post substitution) the type of the coroutine promise will be determined. At that point, we can look up the required promise class methods and issue diagnostics if they are missing or incorrect. To avoid repeating these actions at code-gen time, we make use of temporary 'proxy' variables for the coroutine handle and the promise - which will eventually be instantiated in the coroutine frame. Each of the keywords will expand to a code sequence (although co_yield is just syntactic sugar for a co_await). We defer the analysis and transformatin until template expansion is complete so that we have complete types at that time. 2. AST analysis and transformation which performs the code-gen for the outlined state machine. The entry point here is morph_fn_to_coro () which is called from finish_function () when we have completed any template expansion. This is preceded by helper functions that implement the phases below. The process proceeds in four phases. A Initial framing. The user's function body is wrapped in the initial and final suspend points and we begin building the coroutine frame. We build empty decls for the actor and destroyer functions at this time too. When exceptions are enabled, the user's function body will also be wrapped in a try-catch block with the catch invoking the promise class 'unhandled_exception' method. B Analysis. The user's function body is analysed to determine the suspend points, if any, and to capture local variables that might persist across such suspensions. In most cases, it is not necessary to capture compiler temporaries, since the tree-lowering nests the suspensions correctly. However, in the case of a captured reference, there is a lifetime extension to the end of the full expression - which can mean across a suspend point in which case it must be promoted to a frame variable. At the conclusion of analysis, we have a conservative frame layout and maps of the local variables to their frame entry points. C Build the ramp function. Carry out the allocation for the coroutine frame (NOTE; the actual size computation is deferred until late in the middle end to allow for future optimisations that will be allowed to elide unused frame entries). We build the return object. D Build and expand the actor and destroyer function bodies. The destroyer is a trivial shim that sets a bit to indicate that the destroy dispatcher should be used and then calls into the actor. The actor function is the implementation of the user's state machine. The current suspend point is noted in an index. Each suspend point is encoded as a pair of internal functions, one in the relevant dispatcher, and one representing the suspend point. During this process, the user's local variables and the proxies for the self-handle and the promise class instanceare re-written to their coroutine frame equivalents. The complete bodies for the ramp, actor and destroy function are passed back to finish_function for folding and gimplification. [C++ coroutines 4] Middle end expanders and transforms. The first part of this is a pass that provides: * expansion of the library support builtins, these are simple boolean or numerical substitutions. * The functionality of implementing an exit from scope without cleanup is performed here by lowering an IFN to a gimple goto. This pass has to run for non-coroutine functions, since functions calling the builtins are not necessarily coroutines (i.e. they are implementing the library interfaces which may be called from anywhere). The second part is the expansion of the coroutine IFNs that describe the state machine connections to the dispatchers. This only has to be run for functions that are coroutine components. The work done by this pass is: In the front end we construct a single actor function that contains the coroutine state machine. The actor function has three entry conditions: 1. from the ramp, resume point 0 - to initial-suspend. 2. when resume () is executed (resume point N). 3. from the destroy () shim when that is executed. The actor function begins with two dispatchers; one for resume and one for destroy (where the initial entry from the ramp is a special- case of resume point 0). Each suspend point and each dispatch entry is marked with an IFN such that we can connect the relevant dispatchers to their target labels. So, if we have: CO_YIELD (NUM, FINAL, RES_LAB, DEST_LAB, FRAME_PTR) This is await point NUM, and is the final await if FINAL is non-zero. The resume point is RES_LAB, and the destroy point is DEST_LAB. We expect to find a CO_ACTOR (NUM) in the resume dispatcher and a CO_ACTOR (NUM+1) in the destroy dispatcher. Initially, the intent of keeping the resume and destroy paths together is that the conditionals controlling them are identical, and thus there would be duplication of any optimisation of those paths if the split were earlier. Subsequent inlining of the actor (and DCE) is then able to extract the resume and destroy paths as separate functions if that is found profitable by the optimisers. Once we have remade the connections to their correct postions, we elide the labels that the front end inserted. [C++ coroutines 5] Standard library header. This provides the interfaces mandated by the standard and implements the interaction with the coroutine frame by means of inline use of builtins expanded at compile-time. There should be a 1:1 correspondence with the standard sections which are cross-referenced. There is no runtime content. At this stage, we have the content in an inline namespace "__n4835" for the CD we worked to. [C++ coroutines 6] Testsuite. There are two categories of test: 1. Checks for correctly formed source code and the error reporting. 2. Checks for transformation and code-gen. The second set are run as 'torture' tests for the standard options set, including LTO. These are also intentionally run with no options provided (from the coroutines.exp script). gcc/ChangeLog: 2020-01-18 Iain Sandoe <iain@sandoe.co.uk> * Makefile.in: Add coroutine-passes.o. * builtin-types.def (BT_CONST_SIZE): New. (BT_FN_BOOL_PTR): New. (BT_FN_PTR_PTR_CONST_SIZE_BOOL): New. * builtins.def (DEF_COROUTINE_BUILTIN): New. * coroutine-builtins.def: New file. * coroutine-passes.cc: New file. * function.h (struct GTY function): Add a bit to indicate that the function is a coroutine component. * internal-fn.c (expand_CO_FRAME): New. (expand_CO_YIELD): New. (expand_CO_SUSPN): New. (expand_CO_ACTOR): New. * internal-fn.def (CO_ACTOR): New. (CO_YIELD): New. (CO_SUSPN): New. (CO_FRAME): New. * passes.def: Add pass_coroutine_lower_builtins, pass_coroutine_early_expand_ifns. * tree-pass.h (make_pass_coroutine_lower_builtins): New. (make_pass_coroutine_early_expand_ifns): New. * doc/invoke.texi: Document the fcoroutines command line switch. gcc/c-family/ChangeLog: 2020-01-18 Iain Sandoe <iain@sandoe.co.uk> * c-common.c (co_await, co_yield, co_return): New. * c-common.h (RID_CO_AWAIT, RID_CO_YIELD, RID_CO_RETURN): New enumeration values. (D_CXX_COROUTINES): Bit to identify coroutines are active. (D_CXX_COROUTINES_FLAGS): Guard for coroutine keywords. * c-cppbuiltin.c (__cpp_coroutines): New cpp define. * c.opt (fcoroutines): New command-line switch. gcc/cp/ChangeLog: 2020-01-18 Iain Sandoe <iain@sandoe.co.uk> * Make-lang.in: Add coroutines.o. * cp-tree.h (lang_decl-fn): coroutine_p, new bit. (DECL_COROUTINE_P): New. * lex.c (init_reswords): Enable keywords when the coroutine flag is set, * operators.def (co_await): New operator. * call.c (add_builtin_candidates): Handle CO_AWAIT_EXPR. (op_error): Likewise. (build_new_op_1): Likewise. (build_new_function_call): Validate coroutine builtin arguments. * constexpr.c (potential_constant_expression_1): Handle CO_AWAIT_EXPR, CO_YIELD_EXPR, CO_RETURN_EXPR. * coroutines.cc: New file. * cp-objcp-common.c (cp_common_init_ts): Add CO_AWAIT_EXPR, CO_YIELD_EXPR, CO_RETRN_EXPR as TS expressions. * cp-tree.def (CO_AWAIT_EXPR, CO_YIELD_EXPR, (CO_RETURN_EXPR): New. * cp-tree.h (coro_validate_builtin_call): New. * decl.c (emit_coro_helper): New. (finish_function): Handle the case when a function is found to be a coroutine, perform the outlining and emit the outlined functions. Set a bit to signal that this is a coroutine component. * parser.c (enum required_token): New enumeration RT_CO_YIELD. (cp_parser_unary_expression): Handle co_await. (cp_parser_assignment_expression): Handle co_yield. (cp_parser_statement): Handle RID_CO_RETURN. (cp_parser_jump_statement): Handle co_return. (cp_parser_operator): Handle co_await operator. (cp_parser_yield_expression): New. (cp_parser_required_error): Handle RT_CO_YIELD. * pt.c (tsubst_copy): Handle CO_AWAIT_EXPR. (tsubst_expr): Handle CO_AWAIT_EXPR, CO_YIELD_EXPR and CO_RETURN_EXPRs. * tree.c (cp_walk_subtrees): Likewise. libstdc++-v3/ChangeLog: 2020-01-18 Iain Sandoe <iain@sandoe.co.uk> * include/Makefile.am: Add coroutine to the std set. * include/Makefile.in: Regenerated. * include/std/coroutine: New file. gcc/testsuite/ChangeLog: 2020-01-18 Iain Sandoe <iain@sandoe.co.uk> * g++.dg/coroutines/co-await-syntax-00-needs-expr.C: New test. * g++.dg/coroutines/co-await-syntax-01-outside-fn.C: New test. * g++.dg/coroutines/co-await-syntax-02-outside-fn.C: New test. * g++.dg/coroutines/co-await-syntax-03-auto.C: New test. * g++.dg/coroutines/co-await-syntax-04-ctor-dtor.C: New test. * g++.dg/coroutines/co-await-syntax-05-constexpr.C: New test. * g++.dg/coroutines/co-await-syntax-06-main.C: New test. * g++.dg/coroutines/co-await-syntax-07-varargs.C: New test. * g++.dg/coroutines/co-await-syntax-08-lambda-auto.C: New test. * g++.dg/coroutines/co-return-syntax-01-outside-fn.C: New test. * g++.dg/coroutines/co-return-syntax-02-outside-fn.C: New test. * g++.dg/coroutines/co-return-syntax-03-auto.C: New test. * g++.dg/coroutines/co-return-syntax-04-ctor-dtor.C: New test. * g++.dg/coroutines/co-return-syntax-05-constexpr-fn.C: New test. * g++.dg/coroutines/co-return-syntax-06-main.C: New test. * g++.dg/coroutines/co-return-syntax-07-vararg.C: New test. * g++.dg/coroutines/co-return-syntax-08-bad-return.C: New test. * g++.dg/coroutines/co-return-syntax-09-lambda-auto.C: New test. * g++.dg/coroutines/co-yield-syntax-00-needs-expr.C: New test. * g++.dg/coroutines/co-yield-syntax-01-outside-fn.C: New test. * g++.dg/coroutines/co-yield-syntax-02-outside-fn.C: New test. * g++.dg/coroutines/co-yield-syntax-03-auto.C: New test. * g++.dg/coroutines/co-yield-syntax-04-ctor-dtor.C: New test. * g++.dg/coroutines/co-yield-syntax-05-constexpr.C: New test. * g++.dg/coroutines/co-yield-syntax-06-main.C: New test. * g++.dg/coroutines/co-yield-syntax-07-varargs.C: New test. * g++.dg/coroutines/co-yield-syntax-08-needs-expr.C: New test. * g++.dg/coroutines/co-yield-syntax-09-lambda-auto.C: New test. * g++.dg/coroutines/coro-builtins.C: New test. * g++.dg/coroutines/coro-missing-gro.C: New test. * g++.dg/coroutines/coro-missing-promise-yield.C: New test. * g++.dg/coroutines/coro-missing-ret-value.C: New test. * g++.dg/coroutines/coro-missing-ret-void.C: New test. * g++.dg/coroutines/coro-missing-ueh-1.C: New test. * g++.dg/coroutines/coro-missing-ueh-2.C: New test. * g++.dg/coroutines/coro-missing-ueh-3.C: New test. * g++.dg/coroutines/coro-missing-ueh.h: New test. * g++.dg/coroutines/coro-pre-proc.C: New test. * g++.dg/coroutines/coro.h: New file. * g++.dg/coroutines/coro1-ret-int-yield-int.h: New file. * g++.dg/coroutines/coroutines.exp: New file. * g++.dg/coroutines/torture/alloc-00-gro-on-alloc-fail.C: New test. * g++.dg/coroutines/torture/alloc-01-overload-newdel.C: New test. * g++.dg/coroutines/torture/call-00-co-aw-arg.C: New test. * g++.dg/coroutines/torture/call-01-multiple-co-aw.C: New test. * g++.dg/coroutines/torture/call-02-temp-co-aw.C: New test. * g++.dg/coroutines/torture/call-03-temp-ref-co-aw.C: New test. * g++.dg/coroutines/torture/class-00-co-ret.C: New test. * g++.dg/coroutines/torture/class-01-co-ret-parm.C: New test. * g++.dg/coroutines/torture/class-02-templ-parm.C: New test. * g++.dg/coroutines/torture/class-03-operator-templ-parm.C: New test. * g++.dg/coroutines/torture/class-04-lambda-1.C: New test. * g++.dg/coroutines/torture/class-05-lambda-capture-copy-local.C: New test. * g++.dg/coroutines/torture/class-06-lambda-capture-ref.C: New test. * g++.dg/coroutines/torture/co-await-00-trivial.C: New test. * g++.dg/coroutines/torture/co-await-01-with-value.C: New test. * g++.dg/coroutines/torture/co-await-02-xform.C: New test. * g++.dg/coroutines/torture/co-await-03-rhs-op.C: New test. * g++.dg/coroutines/torture/co-await-04-control-flow.C: New test. * g++.dg/coroutines/torture/co-await-05-loop.C: New test. * g++.dg/coroutines/torture/co-await-06-ovl.C: New test. * g++.dg/coroutines/torture/co-await-07-tmpl.C: New test. * g++.dg/coroutines/torture/co-await-08-cascade.C: New test. * g++.dg/coroutines/torture/co-await-09-pair.C: New test. * g++.dg/coroutines/torture/co-await-10-template-fn-arg.C: New test. * g++.dg/coroutines/torture/co-await-11-forwarding.C: New test. * g++.dg/coroutines/torture/co-await-12-operator-2.C: New test. * g++.dg/coroutines/torture/co-await-13-return-ref.C: New test. * g++.dg/coroutines/torture/co-ret-00-void-return-is-ready.C: New test. * g++.dg/coroutines/torture/co-ret-01-void-return-is-suspend.C: New test. * g++.dg/coroutines/torture/co-ret-03-different-GRO-type.C: New test. * g++.dg/coroutines/torture/co-ret-04-GRO-nontriv.C: New test. * g++.dg/coroutines/torture/co-ret-05-return-value.C: New test. * g++.dg/coroutines/torture/co-ret-06-template-promise-val-1.C: New test. * g++.dg/coroutines/torture/co-ret-07-void-cast-expr.C: New test. * g++.dg/coroutines/torture/co-ret-08-template-cast-ret.C: New test. * g++.dg/coroutines/torture/co-ret-09-bool-await-susp.C: New test. * g++.dg/coroutines/torture/co-ret-10-expression-evaluates-once.C: New test. * g++.dg/coroutines/torture/co-ret-11-co-ret-co-await.C: New test. * g++.dg/coroutines/torture/co-ret-12-co-ret-fun-co-await.C: New test. * g++.dg/coroutines/torture/co-ret-13-template-2.C: New test. * g++.dg/coroutines/torture/co-ret-14-template-3.C: New test. * g++.dg/coroutines/torture/co-yield-00-triv.C: New test. * g++.dg/coroutines/torture/co-yield-01-multi.C: New test. * g++.dg/coroutines/torture/co-yield-02-loop.C: New test. * g++.dg/coroutines/torture/co-yield-03-tmpl.C: New test. * g++.dg/coroutines/torture/co-yield-04-complex-local-state.C: New test. * g++.dg/coroutines/torture/co-yield-05-co-aw.C: New test. * g++.dg/coroutines/torture/co-yield-06-fun-parm.C: New test. * g++.dg/coroutines/torture/co-yield-07-template-fn-param.C: New test. * g++.dg/coroutines/torture/co-yield-08-more-refs.C: New test. * g++.dg/coroutines/torture/co-yield-09-more-templ-refs.C: New test. * g++.dg/coroutines/torture/coro-torture.exp: New file. * g++.dg/coroutines/torture/exceptions-test-0.C: New test. * g++.dg/coroutines/torture/func-params-00.C: New test. * g++.dg/coroutines/torture/func-params-01.C: New test. * g++.dg/coroutines/torture/func-params-02.C: New test. * g++.dg/coroutines/torture/func-params-03.C: New test. * g++.dg/coroutines/torture/func-params-04.C: New test. * g++.dg/coroutines/torture/func-params-05.C: New test. * g++.dg/coroutines/torture/func-params-06.C: New test. * g++.dg/coroutines/torture/lambda-00-co-ret.C: New test. * g++.dg/coroutines/torture/lambda-01-co-ret-parm.C: New test. * g++.dg/coroutines/torture/lambda-02-co-yield-values.C: New test. * g++.dg/coroutines/torture/lambda-03-auto-parm-1.C: New test. * g++.dg/coroutines/torture/lambda-04-templ-parm.C: New test. * g++.dg/coroutines/torture/lambda-05-capture-copy-local.C: New test. * g++.dg/coroutines/torture/lambda-06-multi-capture.C: New test. * g++.dg/coroutines/torture/lambda-07-multi-yield.C: New test. * g++.dg/coroutines/torture/lambda-08-co-ret-parm-ref.C: New test. * g++.dg/coroutines/torture/local-var-0.C: New test. * g++.dg/coroutines/torture/local-var-1.C: New test. * g++.dg/coroutines/torture/local-var-2.C: New test. * g++.dg/coroutines/torture/local-var-3.C: New test. * g++.dg/coroutines/torture/local-var-4.C: New test. * g++.dg/coroutines/torture/mid-suspend-destruction-0.C: New test. * g++.dg/coroutines/torture/pr92933.C: New test.
2019-11-15Support for jthread and stop_tokenThomas Rodgers
* include/Makefile.am: Add <stop_token> header. * include/Makefile.in: Regenerate. * include/std/condition_variable: Add overloads for stop_token support to condition_variable_any. * include/std/stop_token: New file. * include/std/thread: Add jthread type. * include/std/version (__cpp_lib_jthread): New value. * testsuite/30_threads/condition_variable_any/stop_token/1.cc: New test. * testsuite/30_threads/condition_variable_any/stop_token/2.cc: New test. * testsuite/30_threads/condition_variable_any/stop_token/wait_on.cc: New test. * testsuite/30_threads/jthread/1.cc: New test. * testsuite/30_threads/jthread/2.cc: New test. * testsuite/30_threads/jthread/jthread.cc: New test. * testsuite/30_threads/stop_token/1.cc: New test. * testsuite/30_threads/stop_token/2.cc: New test. * testsuite/30_threads/stop_token/stop_token.cc: New test. From-SVN: r278274
2019-11-06libstdc++: Add compare_three_way and install <compare> headerJonathan Wakely
* include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * libsupc++/compare (__3way_builtin_ptr_cmp): Define helper. (compare_three_way): Add missing implementation. From-SVN: r277889
2019-10-31Partial implementation of C++20 of <ranges> headerJonathan Wakely
* doc/doxygen/user.cfg.in: Add new header. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include new header. * include/std/ranges: New header. (ranges::sentinel_t, ranges::range_value_t, ranges::range_reference_t) (ranges::range_rvalue_reference_t, ranges::sized_range) (ranges::output_range, ranges::input_ranges, ranges::forward_range) (ranges::bidirectional_range, ranges::random_access_range) (ranges::contiguous_range, ranges::common::range): Define. * testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: Check that disabled_sized_sentinel can be specialized. * testsuite/std/ranges/access/begin.cc: Include <ranges> instead of <iterator>. * 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/empty.cc: Likewise. * testsuite/std/ranges/access/end.cc: Likewise. * testsuite/std/ranges/access/end_neg.cc: Likewise. * testsuite/std/ranges/access/rbegin.cc: Likewise. * testsuite/std/ranges/access/rend.cc: Likewise. * testsuite/std/ranges/access/size.cc: Likewise. * testsuite/std/ranges/access/size_neg.cc: Likewise. * testsuite/std/ranges/headers/ranges/synopsis.cc: New test. * testsuite/std/ranges/range.cc: New test. * testsuite/std/ranges/refinements.cc: New test. * testsuite/std/ranges/sized.cc: New test. * testsuite/util/testsuite_iterators.h: Add aliases for range types. (output_iterator_wrapper::WritableObject::operator=): Add const qualifier so that output_iterator_wrapper satisfies writable. From-SVN: r277697
2019-10-29Add iterator concepts and range access customization points for C++20Jonathan Wakely
This adds most of the new C++20 features to <iterator>, as well as a few initial pieces of <ranges> (but no actual <ranges> header just yet). * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/bits/iterator_concepts.h: New header. (contiguous_iterator_tag, iter_reference_t, ranges::iter_move) (iter_rvalue_reference_t, incrementable_traits, iter_difference_t) (readable_traits, iter_value_t, readable, iter_common_reference_t) (writable, waekly_incrementable, incrementable) (input_or_output_iterator, sentinel_for, disable_sized_sentinel) (sized_sentinel_for, input_iterator, output_iterator) (forward_iterator, bidirectional_iterator, random_access_iterator) (contiguous_iterator, indirectly_unary_invocable) (indirectly_regular_unary_invocable, indirect_unary_predicate) (indirect_relation, indirect_strict_weak_order, indirect_result_t) (projected, indirectly_movable, indirectly_movable_storable) (indirectly_copyable, indirectly_copyable_storable, ranges::iter_swap) (indirectly_swappable, indirectly_comparable, permutable, mergeable) (sortable, unreachable_sentinel_t, unreachable_sentinel) (default_sentinel_t, default_sentinel): Define. (__detail::__cpp17_iterator, __detail::__cpp17_input_iterator) (__detail::__cpp17_fwd_iterator, __detail::__cpp17_bidi_iterator) (__detail::__cpp17_randacc_iterator): Define. (__iterator_traits): Define constrained specializations. * include/bits/move.h (move): Only use old concept check for C++98. * include/bits/range_access.h (ranges::disable_sized_range) (ranges::begin, ranges::end, ranges::cbegin, ranges::cend) (ranges::rbegin, ranges::rend, ranges::crbegin, ranges::crend) (ranges::size, ranges::empty, ranges::data, ranges::cdata): Define new customization points for C++20. (ranges::range, ranges::sized_range): Define new concepts for C++20. (ranges::advance, ranges::distance, ranges::next, ranges::prev): Define new functions for C++20. (__adl_end, __adl_cdata, __adl_cbegin, __adl_cend, __adl_rbegin) (__adl_rend, __adl_crbegin, __adl_crend, __adl_cdata, __adl_size) (__adl_empty): Remove. * include/bits/stl_iterator.h (disable_sized_sentinel): Specialize for reverse_iterator. * include/bits/stl_iterator_base_types.h (contiguous_iterator_tag): Define new struct for C++20. (iterator_traits<_Tp*>): Constrain partial specialization in C++20. * include/std/concepts (__is_class_or_enum): Move to __detail namespace. * testsuite/20_util/forward/c_neg.cc: Adjust dg-error line number. * testsuite/20_util/forward/f_neg.cc: Likewise. * testsuite/24_iterators/associated_types/incrementable.traits.cc: New test. * testsuite/24_iterators/associated_types/readable.traits.cc: New test. * testsuite/24_iterators/contiguous/concept.cc: New test. * testsuite/24_iterators/contiguous/tag.cc: New test. * testsuite/24_iterators/customization_points/iter_move.cc: New test. * testsuite/24_iterators/customization_points/iter_swap.cc: New test. * testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: New test. * testsuite/24_iterators/range_operations/advance.cc: New test. * testsuite/24_iterators/range_operations/distance.cc: New test. * testsuite/24_iterators/range_operations/next.cc: New test. * testsuite/24_iterators/range_operations/prev.cc: New test. * testsuite/26_numerics/adjacent_difference/requirements/ explicit_instantiation/2.cc: Rename types that conflict with C++20 concepts. * testsuite/26_numerics/adjacent_difference/requirements/ explicit_instantiation/pod.cc: Likewise. * testsuite/26_numerics/partial_sum/requirements/ explicit_instantiation/2.cc: Likewise. * testsuite/26_numerics/partial_sum/requirements/ explicit_instantiation/pod.cc: Likewise. * testsuite/experimental/iterator/requirements.cc: Likewise. * testsuite/std/ranges/access/begin.cc: New test. * testsuite/std/ranges/access/cbegin.cc: New test. * testsuite/std/ranges/access/cdata.cc: New test. * testsuite/std/ranges/access/cend.cc: New test. * testsuite/std/ranges/access/crbegin.cc: New test. * testsuite/std/ranges/access/crend.cc: New test. * testsuite/std/ranges/access/data.cc: New test. * testsuite/std/ranges/access/empty.cc: New test. * testsuite/std/ranges/access/end.cc: New test. * testsuite/std/ranges/access/rbegin.cc: New test. * testsuite/std/ranges/access/rend.cc: New test. * testsuite/std/ranges/access/size.cc: New test. * testsuite/util/testsuite_iterators.h (contiguous_iterator_wrapper) (test_range, test_sized_range): New test utilities. From-SVN: r277579
2019-10-17Define [range.cmp] comparisons for C++20Jonathan Wakely
Define std::identity, std::ranges::equal_to, std::ranges::not_equal_to, std::ranges::greater, std::ranges::less, std::ranges::greater_equal and std::ranges::less_equal. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/bits/range_cmp.h: New header for C++20 function objects. * include/std/functional: Include new header. * testsuite/20_util/function_objects/identity/1.cc: New test. * testsuite/20_util/function_objects/range.cmp/equal_to.cc: New test. * testsuite/20_util/function_objects/range.cmp/greater.cc: New test. * testsuite/20_util/function_objects/range.cmp/greater_equal.cc: New test. * testsuite/20_util/function_objects/range.cmp/less.cc: New test. * testsuite/20_util/function_objects/range.cmp/less_equal.cc: New test. * testsuite/20_util/function_objects/range.cmp/not_equal_to.cc: New test. From-SVN: r277120
2019-10-11Implement <concepts> header for C++20Jonathan Wakely
There are currently no tests for [concepts.compare], but they will be added ASAP. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include <concepts>. * include/std/concepts: New header for C++20. * include/std/version (__cpp_lib_concepts): Define. * scripts/create_testsuite_files: Look for test files in new std directory. * testsuite/libstdc++-dg/conformance.exp: Likewise. * testsuite/std/concepts/concepts.callable/invocable.cc: New test. * testsuite/std/concepts/concepts.callable/regular_invocable.cc: New test. * testsuite/std/concepts/concepts.callable/relation.cc: New test. * testsuite/std/concepts/concepts.callable/strictweakorder.cc: New test. * testsuite/std/concepts/concepts.lang/concept.arithmetic/ floating_point.cc: New test. * testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc: New test. * testsuite/std/concepts/concepts.lang/concept.arithmetic/ signed_integral.cc: New test. * testsuite/std/concepts/concepts.lang/concept.arithmetic/ unsigned_integral.cc: New test. * testsuite/std/concepts/concepts.lang/concept.assignable/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.common/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.commonref/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.constructible/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.convertible/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.copyconstructible/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.defaultconstructible/ 1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.derived/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.destructible/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.moveconstructible/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.same/1.cc: New test. * testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc: New test. * testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc: New test. * testsuite/std/concepts/concepts.lang/concept.swappable/ swappable_with.cc: New test. * testsuite/std/concepts/concepts.object/copyable.cc: New test. * testsuite/std/concepts/concepts.object/movable.cc: New test. * testsuite/std/concepts/concepts.object/regular.cc: New test. * testsuite/std/concepts/concepts.object/semiregular.cc: New test. From-SVN: r276892
2019-10-04Build filesystem library with large file supportJonathan Wakely
Enable AC_SYS_LARGEFILE to set the macros needed for large file APIs to be used by default. We do not want to define those macros in the public headers that users include. The values of the macros are copied to a separate file that is only included by the filesystem sources during the build, and then the macros in <bits/c++config.h> are renamed so that they don't have any effect in user code including our headers. Also use larger type for result of filesystem::file_size to avoid truncation of large values on 32-bit systems (PR 91947). PR libstdc++/81091 PR libstdc++/91947 * configure.ac: Use AC_SYS_LARGEFILE to enable 64-bit file APIs. * config.h.in: Regenerate: * configure: Regenerate: * include/Makefile.am (${host_builddir}/largefile-config.h): New target to generate config header for filesystem library. (${host_builddir}/c++config.h): Rename macros for large file support. * include/Makefile.in: Regenerate. * src/c++17/fs_dir.cc: Include new config header. * src/c++17/fs_ops.cc: Likewise. (filesystem::file_size): Use uintmax_t for size. * src/filesystem/dir.cc: Include new config header. * src/filesystem/ops.cc: Likewise. (experimental::filesystem::file_size): Use uintmax_t for size. From-SVN: r276585
2019-09-05Implement std::span for C++20JeanHeyd Meneide
2019-09-05 JeanHeyd Meneide <phdofthehouse@gmail.com> * include/Makefile.am: Add <span> header. * include/Makefile.in: Regenerate. * include/bits/range_access.h (__adl_begin, __adl_end, __adl_cbegin) (__adl_cend, __adl_rbegin, __adl_rend, __adl_crbegin, __adl_crend) (__adl_data, __adl_cdata, __adl_size, __adl_empty, __adl_to_address): New functions for performing argument-dependent lookup of range customization points. * include/bits/stl_iterator.h (__normal_iterator): Add _GLIBCXX20_CONSTEXPR to all functions. * include/std/span: New header. * include/std/version (__cpp_lib_span): Define feature test macro. * testsuite/23_containers/span/contiguous_range_neg.cc: New test. * testsuite/23_containers/span/everything.cc: New test. * testsuite/23_containers/span/get_neg.cc: New test. * testsuite/23_containers/span/last_neg.cc: New test. * testsuite/23_containers/span/subspan_neg.cc: New test. * testsuite/23_containers/span/tuple_element_dynamic_neg.cc: New test. * testsuite/23_containers/span/tuple_element_oob_neg.cc: New test. * testsuite/23_containers/span/tuple_size_neg.cc: New test. From-SVN: r275403
2019-07-31Implement "P0631R4 Math Constants" for C++20Jonathan Wakely
The values of the constants are taken from Glibc where the equivalent constant exists, or by rounding the actual constant to the same number of digits as the Glibc constants have. P0631R4 Math Constants * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/precompiled/stdc++.h: Include new header. * include/std/numbers: New header. * include/std/version (__cpp_lib_math_constants): Define. * testsuite/26_numerics/numbers/1.cc: New test. * testsuite/26_numerics/numbers/2.cc: New test. * testsuite/26_numerics/numbers/3.cc: New test. * testsuite/26_numerics/numbers/nonfloat_neg.cc: New test. From-SVN: r273940
2019-06-12Replace std::to_string for integers with optimized versionJonathan Wakely
The std::to_chars functions from C++17 can be used to implement std::to_string with much better performance than calling snprintf. Only the __detail::__to_chars_len and __detail::__to_chars_10 functions are needed for to_string, because it always outputs base 10 representations. The return type of __detail::__to_chars_10 should not be declared before C++17, so the function body is extracted into a new function that can be reused by to_string and __detail::__to_chars_10. The existing tests for to_chars rely on to_string to check for correct answers. Now that they use the same code that doesn't actually ensure correctness, so add new tests for std::to_string that compare against printf output. * include/Makefile.am: Add new <bits/charconv.h> header. * include/Makefile.in: Regenerate. * include/bits/basic_string.h (to_string(int), to_string(unsigned)) (to_string(long), to_string(unsigned long), to_string(long long)) (to_string(unsigned long long)): Rewrite to use __to_chars_10_impl. * include/bits/charconv.h: New header. (__detail::__to_chars_len): Move here from <charconv>. (__detail::__to_chars_10_impl): New function extracted from __detail::__to_chars_10. * include/std/charconv (__cpp_lib_to_chars): Add, but comment out. (__to_chars_unsigned_type): New class template that reuses __make_unsigned_selector_base::__select to pick a type. (__unsigned_least_t): Redefine as __to_chars_unsigned_type<T>::type. (__detail::__to_chars_len): Move to new header. (__detail::__to_chars_10): Add inline specifier. Move code doing the output to __detail::__to_chars_10_impl and call that. * include/std/version (__cpp_lib_to_chars): Add, but comment out. * testsuite/21_strings/basic_string/numeric_conversions/char/ to_string.cc: Fix reference in comment. Remove unused variable. * testsuite/21_strings/basic_string/numeric_conversions/char/ to_string_int.cc: New test. From-SVN: r272186
2019-06-07Synchronize libstdc++ PSTL with upstream LLVM PSTLThomas Rodgers
Rename PSTL macro's consistent with libstdc++ (and llvm upstream project) standards. * include/bits/c++config: Rename all macros of the form __PSTL* to _PSTL*. * include/std/algorithm: Likewise. * include/std/execution: Likewise. * include/std/numeric: Likewise. * include/std/memory: Likewise. * include/pstl/glue_memory_impl.h: Likewise. * include/pstl/numeric_impl.h: Likewise. * include/pstl/glue_memory_defs.h: Likewise. * include/pstl/execution_defs.h: Likewise. * include/pstl/utils.h: Likewise. * include/pstl/algorithm_fwd.h: Likewise. * include/pstl/unseq_backend_simd.h: Likewise. * include/pstl/glue_execution_defs.h: Likewise. * include/pstl/algorithm_impl.h: Likewise. * include/pstl/parallel_impl.h: Likewise. * include/pstl/memory_impl.h: Likewise. * include/pstl/glue_numeric_defs.h: Likewise. * include/pstl/parallel_backend_utils.h: Likewise. * include/pstl/glue_algorithm_defs.h: Likewise. * include/pstl/parallel_backend.h: Likewise. * include/pstl/glue_numeric_impl.h: Likewise. * include/pstl/parallel_backend_tbb.h: Likewise. * include/pstl/numeric_fwd.h: Likewise. * include/pstl/glue_algorithm_impl.h: Likewise. * include/pstl/execution_impl.h: Likewise. * include/pstl/pstl_config.h: Likewise. * testsuite/util/pstl/pstl_test_config.h: Likewise. * testsuite/util/pstl/test_utils.h: Likewise. * testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc: Likewise. * testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc: Likewise. * testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc: Likewise. * testsuite/26_numerics/pstl/numeric_ops/scan.cc: Likewise. * testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: Likewise. * testsuite/26_numerics/pstl/numeric_ops/reduce.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc: Likewise. * testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: Likewise. * testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: Likewise. * testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc: Likewise. * testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc: Likewise. * testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: Likewise. * testsuite/25_algorithms/pstl/alg_merge/merge.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc: Likewise. * testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc: Likewise. * testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: Likewise. Rename header guards to be consistent with upstream project's conventions. * include/pstl/glue_memory_impl.h: Rename all macros of the form _PSTL_(.*)_H to _PSTL_\U\1_H. * include/pstl/numeric_impl.h: Likewise. * include/pstl/glue_memory_defs.h: Likewise. * include/pstl/execution_defs.h: Likewise. * include/pstl/utils.h: Likewise. * include/pstl/algorithm_fwd.h: Likewise. * include/pstl/unseq_backend_simd.h: Likewise. * include/pstl/glue_execution_defs.h: Likewise. * include/pstl/algorithm_impl.h: Likewise. * include/pstl/parallel_impl.h: Likewise. * include/pstl/memory_impl.h: Likewise. * include/pstl/glue_numeric_defs.h: Likewise. * include/pstl/parallel_backend_utils.h: Likewise. * include/pstl/glue_algorithm_defs.h: Likewise. * include/pstl/parallel_backend.h: Likewise. * include/pstl/glue_numeric_impl.h: Likewise. * include/pstl/parallel_backend_tbb.h: Likewise. * include/pstl/numeric_fwd.h: Likewise. * include/pstl/glue_algorithm_impl.h: Likewise. * include/pstl/execution_impl.h: Likewise. * include/pstl/pstl_config.h: Likewise. * testsuite/util/pstl/pstl_test_config.h: Likewise. Synchronize libstdc++ parallel algorithms with upstream project. * include/pstl/algorithm_fwd.h: Synchronize with upstream PSTL project. * include/pstl/algorithm_impl.h: Likewise. * include/pstl/execution_defs.h: Likewise. * include/pstl/execution_impl.h: Likewise. * include/pstl/glue_algorithm_impl.h: Likewise. * include/pstl/glue_execution_defs.h: Likewise. * include/pstl/numeric_fwd.h: Likewise. * include/pstl/numeric_impl.h: Likewise. * include/pstl/parallel_backend.h: Likewise. * include/pstl/pstl_config.h: Likewise. * include/pstl/unseq_backend_simd.h: Likewise. * include/pstl/parallel_backend_serial.h: New file. * include/Makefile.am (pstl_headers): Add parallel_backend_serial.h. * include/Makefile.in: Regenerate. Clean up non-conforming names * include/pstl/algorithm_impl.h (__parallel_set_union_op): Uglfiy copy_range1 and copy_range2 (__pattern_walk2_n): Rename local n to __n * include/pstl/parallel_backend_tbb.h (struct __binary_no_op): Rename parameter _T to _Tp. Integrate non-TBB serial backend support * include/bits/c++config: Adjust TBB detection logic to select serial PSTL backend if no TBB present. * testsuite/utils/pstl/test_utils.h: Remove check for _PSTL_USE_PAR_POLICIES From-SVN: r272056
2019-05-13Remove Profile Mode, deprecated since GCC 7.1Jonathan Wakely
The Profile Mode extension is not used by anybody, nor maintained by anybody. The containers do not support the full API specified in recent standards, and so enabling Profile Mode is not source compatible with much modern C++ code. The heuristics that would check the profile information and make useful suggestions never materialized, so it isn't useful. It should be removed. Remove Profile Mode, deprecated since 7.1.0 * doc/Makefile.am: Remove XML file for profile mode docs. * doc/Makefile.in: Regenerate. * doc/xml/authors.xml: Remove authors of profile mode docs. * doc/xml/manual/appendix_contributing.xml: Remove mention of profile mode. * doc/xml/manual/debug.xml: Likewise. * doc/xml/manual/evolution.xml: Document removal of profile mode. * doc/xml/manual/profile_mode.xml: Remove profile mode docs. * doc/xml/manual/spine.xml: Remove profile mode author credit. * doc/xml/manual/test.xml: Remove docs for dg-require-profile-mode directive. * doc/xml/manual/using.xml: Remove docs for profile mode headers and macro. * doc/html/*: Regenerate. * include/Makefile.am: Remove profile mode headers. * include/Makefile.in: Regenerate. * include/bits/c++config (std::__profile): Remove namespace. [_GLIBCXX_PROFILE]: Remove checks for macro. * include/profile/array: Remove. * include/profile/base.h: Remove. * include/profile/bitset: Remove. * include/profile/deque: Remove. * include/profile/forward_list: Remove. * include/profile/impl/profiler.h: Remove. * include/profile/impl/profiler_algos.h: Remove. * include/profile/impl/profiler_container_size.h: Remove. * include/profile/impl/profiler_hash_func.h: Remove. * include/profile/impl/profiler_hashtable_size.h: Remove. * include/profile/impl/profiler_list_to_slist.h: Remove. * include/profile/impl/profiler_list_to_vector.h: Remove. * include/profile/impl/profiler_map_to_unordered_map.h: Remove. * include/profile/impl/profiler_node.h: Remove. * include/profile/impl/profiler_state.h: Remove. * include/profile/impl/profiler_trace.h: Remove. * include/profile/impl/profiler_vector_size.h: Remove. * include/profile/impl/profiler_vector_to_list.h: Remove. * include/profile/iterator_tracker.h: Remove. * include/profile/list: Remove. * include/profile/map: Remove. * include/profile/map.h: Remove. * include/profile/multimap.h: Remove. * include/profile/multiset.h: Remove. * include/profile/ordered_base.h: Remove. * include/profile/set: Remove. * include/profile/set.h: Remove. * include/profile/unordered_base.h: Remove. * include/profile/unordered_map: Remove. * include/profile/unordered_set: Remove. * include/profile/vector: Remove. * scripts/run_doxygen: Do not process profile mode headers. * testsuite/23_containers/array/element_access/60497.cc: Don't use profile mode type. * testsuite/23_containers/array/specialized_algorithms/swap_cxx17.cc: Remove dg-skip-if for profile mode. * testsuite/23_containers/forward_list/capacity/1.cc: Remove preprocessor check for profile mode. * testsuite/23_containers/list/capacity/29134.cc: Likewise. * testsuite/23_containers/map/modifiers/extract.cc: Remove dg-skip-if for profile mode. * testsuite/23_containers/map/modifiers/insert_or_assign/1.cc: Likewise. * testsuite/23_containers/map/modifiers/try_emplace/1.cc: Likewise. * testsuite/23_containers/multimap/modifiers/extract.cc: Likewise. * testsuite/23_containers/multiset/modifiers/extract.cc: Likewise. * testsuite/23_containers/set/modifiers/extract.cc: Likewise. * testsuite/23_containers/unordered_map/modifiers/extract.cc: Likewise. * testsuite/23_containers/unordered_multimap/modifiers/extract.cc: Likewise. * testsuite/23_containers/unordered_multiset/modifiers/extract.cc: Likewise. * testsuite/23_containers/unordered_set/modifiers/extract.cc: Likewise. * testsuite/23_containers/vector/bool/capacity/29134.cc: Remove preprocessor check for profile mode. * testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Likewise. * testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc: Remove dg-skip-if for profile mode. * testsuite/25_algorithms/binary_search/partitioned.cc: Likewise. * testsuite/25_algorithms/equal_range/partitioned.cc: Likewise. * testsuite/25_algorithms/lexicographical_compare/71545.cc: Likewise. * testsuite/25_algorithms/lower_bound/partitioned.cc: Likewise. * testsuite/25_algorithms/upper_bound/partitioned.cc: Likewise. * testsuite/Makefile.am: Remove profile_flags variable and * testsuite/Makefile.am: Remove profile_flags variable and check-profile target. * testsuite/Makefile.in: Regenerate. * testsuite/ext/profile/all.cc: Remove. * testsuite/ext/profile/mutex_extensions_neg.cc: Remove. * testsuite/ext/profile/profiler_algos.cc: Remove. * testsuite/ext/profile/replace_new.cc: Remove. * testsuite/ext/throw_allocator/deallocate_global.cc: Remove preprocessor check for profile mode. * testsuite/ext/throw_allocator/deallocate_local.cc: Likewise. * testsuite/lib/libstdc++.exp (check_v3_target_profile_mode): Remove. (check_v3_target_normal_mode): Do not check for profile mode macro. * testsuite/libstdc++-prettyprinters/80276.cc: Remove dg-skip-if for profile mode. * testsuite/libstdc++-prettyprinters/compat.cc: Likewise. * testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise. * testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise. * testsuite/libstdc++-prettyprinters/debug.cc: Likewise. * testsuite/libstdc++-prettyprinters/debug_cxx11.cc: Likewise. * testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise. * testsuite/libstdc++-prettyprinters/simple.cc: Likewise. * testsuite/libstdc++-prettyprinters/simple11.cc: Likewise. * testsuite/libstdc++-prettyprinters/whatis.cc: Likewise. * testsuite/libstdc++-prettyprinters/whatis2.cc: Likewise. From-SVN: r271120
2019-05-13Remove array_allocator extension, deprecated since 4.9.0Jonathan Wakely
This type is not a conforming allocator, because it cannot be reliably rebound to allocate for a different type. The result of the rebind transformation still uses the same underlying std::tr1::array<T, 1> array, which may not be correctly aligned or even have elements the right size for the value_type of the rebound allocator. It has been deprecated for several years and should now be removed. * doc/xml/manual/allocator.xml: Remove documentation for array_allocator. * doc/xml/manual/evolution.xml: Document array_allocator removal. * doc/xml/manual/using.xml: Remove header from documentation. * include/Makefile.am: Remove <ext/array_allocator.h> header. * include/Makefile.in: Regenerate. * include/ext/array_allocator.h: Remove. * include/precompiled/extc++.h: Do not include removed header. * testsuite/ext/array_allocator/1.cc: Remove. * testsuite/ext/array_allocator/2.cc: Remove. * testsuite/ext/array_allocator/26875.cc: Remove. * testsuite/ext/array_allocator/3.cc: Remove. * testsuite/ext/array_allocator/check_deallocate_null.cc: Remove. * testsuite/ext/array_allocator/check_delete.cc: Remove. * testsuite/ext/array_allocator/check_new.cc: Remove. * testsuite/ext/array_allocator/variadic_construct.cc: Remove. * testsuite/ext/headers.cc: Do not include removed header. From-SVN: r271119