aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
AgeCommit message (Collapse)AuthorFilesLines
2021-09-23libstdc++: Make std::system_category() recognize Windows error codesJonathan Wakely1-0/+156
The std::system_category error category should be used for system-specific error codes, which means on Windows it should be used for Windows error codes. Currently that category assumes that the error numbers it deals with are errno numbers, which means that ERROR_ACCESS_DENIED (which has value 0x5) gets treated as whichever errno number happens to have that value (EIO on mingw32-w64). This adds a mapping from known Windows error codes to generic errno ones. This means we correctly treat ERROR_ACCESS_DENIED as corresponding to EACCES. Also make std::system_category().message(int) return the right message for Windows errors, by using FormatMessage instead of strerror. The output of FormatMessage includes ".\r\n" at the end, so we strip that off to allow the message to be used in contexts where that would be problematic. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/c++11/system_error.cc (system_error_category) [_WIN32]: Map Windows error codes to generic POSIX error numbers. Use FormatMessage instead of strerror. * testsuite/19_diagnostics/error_category/system_category.cc: Adjust for new behaviour on Windows.
2021-09-23libstdc++: Improvements to standard error category objectsJonathan Wakely1-20/+43
This ensures that the objects returned by std::generic_category() and std::system_category() are initialized before any code starts executing, and are not destroyed at the end of the program. This means it is always safe to access them, even during startup and termination. See LWG 2992 and P1195R0 for further discussion of this. Additionally, make the types of those objects final, which might potentially allow additional devirtualization opportunities. The types are not visible to users, so there is no way they can derive from them, so making them final has no semantic change. Finally, add overrides for equivalent(int, const error_condition&) to those types, to avoid the second virtual call that would be performed by the base class definition of the function. Because we know what default_error_condition(int) does for the derived type, we don't need to make a virtual call. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/c++11/system_error.cc (generic_error_category): Define class and virtual functions as 'final'. (generic_error_category::equivalent(int, const error_condition&)): Override. (system_error_category): Define class and virtual functions as 'final'. (system_error_category::equivalent(int, const error_condition&)): Override. (generic_category_instance, system_category_instance): Use constinit union to make the objects immortal.
2021-09-23libstdc++: std::system_category should know meaning of zero [PR102425]Jonathan Wakely1-0/+3
Although 0 is not an errno value, it should still be recognized as corresponding to a value belonging to the generic_category(). Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/102425 * src/c++11/system_error.cc (system_error_category::default_error_condition): Add 0 to switch. * testsuite/19_diagnostics/error_category/102425.cc: New test.
2021-09-16libstdc++: Regenerate the src/debug Makefiles as neededJonathan Wakely2-2/+2
When the build configuration changes and Makefiles are recreated, the src/debug/Makefile and src/debug/*/Makefile files are not recreated, because they're not managed in the usual way by automake. This can lead to build failures or surprising inconsistencies between the main and debug versions of the library when doing incremental builds. This causes them to be regenerated if any of the corresponding non-debug makefiles is newer. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/Makefile.am (stamp-debug): Add all Makefiles as prerequisites. * src/Makefile.in: Regenerate.
2021-09-16libstdc++: Fix recipes for C++11-compiled files in src/c++98Jonathan Wakely2-4/+4
Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/c++98/Makefile.am: Use CXXCOMPILE not LTCXXCOMPILE. * src/c++98/Makefile.in: Regenerate.
2021-08-31libstdc++: Remove redundant noexcept-specifier on definitionsJonathan Wakely1-2/+2
These destructors are noexcept anyway. I removed the redundant noexcept from the error_category destructor's declaration in r0-123475, but didn't remove it from the defaulted definition in system_error.cc. That causes warnings if the library is built with Clang. This removes the redundant noexcept from ~error_category and ~system_error and adds tests to ensure they really are noexcept. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/c++11/system_error.cc (error_category::~error_category()): Remove noexcept-specifier. (system_error::~system_error()): Likewise. * testsuite/19_diagnostics/error_category/noexcept.cc: New test. * testsuite/19_diagnostics/system_error/noexcept.cc: New test.
2021-08-28libstdc++: Fix inefficiency in filesystem::absolute [PR99876]Jonathan Wakely1-7/+0
When the path is already absolute, the call to current_path() is wasteful, because operator/ will ignore the left operand anyway. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/99876 * src/c++17/fs_ops.cc (fs::absolute): Call non-throwing form, to avoid unnecessary current_path() call.
2021-08-24libstdc++: Fix mismatched class-key tagsJonathan Wakely1-14/+14
Clang warns about this, but GCC doesn't (see PR c++/102036). Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/c++11/cxx11-shim_facets.cc: Fix mismatched class-key in explicit instantiation definitions.
2021-08-19libstdc++: Improve overflow check for file timestampsJonathan Wakely1-1/+1
The current code assumes that system_clock::duration is nanoseconds, and also performs a value-changing conversion from nanoseconds::max() to double (which doesn't matter after dividing by 1e9, but triggers a warning with Clang nonetheless). A better solution is to use system_clock::duration::max() and perform the comparison entirely using the std::chrono types, rather than with dimensionless arithmetic types. This doesn't address the FIXME in the function, so the overflow check still rejects some values that could be represented by the file_clock. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/filesystem/ops-common.h (filesystem::file_time): Improve overflow check by using system_clock::duration::max().
2021-08-16libstdc++: Use qualified-id for class member constant [PR101937]Jonathan Wakely1-4/+4
The expression ctx._M_indent is not a constant expression when ctx is a reference parameter, even though _M_indent is an enumerator. Rename it to _S_indent to be consistent with our conventions, and refer to it as PrintContext::_S_indent to be valid C++ code (at least until P2280 is accepted as a DR). Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/101937 * src/c++11/debug.cc (PrintContext::_M_indent): Replace with a static data member. (print_word): Use qualified-id to access it.
2021-08-12libstdc++: Add #error to some files that depend on a specific standard modeJonathan Wakely3-0/+12
Give more explicit errors if these files are not built with the correct -std options. libstdc++-v3/ChangeLog: * src/c++98/locale_init.cc: Require C++11. * src/c++98/localename.cc: Likewise. * src/c++98/misc-inst.cc: Require C++98.
2021-08-02libstdc++: Fix filesystem::temp_directory_path [PR101709]Jonathan Wakely3-8/+13
Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/101709 * src/filesystem/ops-common.h (get_temp_directory_from_env): Add error_code parameter. * src/c++17/fs_ops.cc (fs::temp_directory_path): Pass error_code argument to get_temp_directory_from_env and check it. * src/filesystem/ops.cc (fs::temp_directory_path): Likewise.
2021-07-30libstdc++: Use secure_getenv for filesystem::temp_directory_path() [PR65018]Jonathan Wakely3-53/+50
This adds a configure check for the GNU extension secure_getenv and then uses it for looking up TMPDIR and similar variables. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/65018 * configure.ac: Check for secure_getenv. * config.h.in: Regenerate. * configure: Regenerate. * src/filesystem/ops-common.h (get_temp_directory_from_env): New helper function to obtain path from the environment. * src/c++17/fs_ops.cc (fs::temp_directory_path): Use new helper. * src/filesystem/ops.cc (fs::temp_directory_path): Likewise. * testsuite/27_io/filesystem/operations/temp_directory_path.cc: Print messages if test cannot be run. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Likewise. Fix incorrect condition. Use "TMP" to work with Windows as well as POSIX.
2021-07-30fix breakage from "libstdc++: Remove unnecessary uses of <utility>"Hans-Peter Nilsson1-3/+3
Commit r12-2534 was incomplete and (by inspection derived from an MMIX build) failing for targets without an insn for compare_and_swap for pointer-size objects, IOW for targets for which "ATOMIC_POINTER_LOCK_FREE != 2" is true: x/gcc/libstdc++-v3/src/c++17/memory_resource.cc: In member function 'std::pmr::memory_resource* std::pmr::{anonymous}::atomic_mem_res::exchange(std::pmr::memory_resource*)': x/gcc/libstdc++-v3/src/c++17/memory_resource.cc:140:21: error: 'exchange' is not a member of 'std' 140 | return std::exchange(val, r); | ^~~~~~~~ make[5]: *** [Makefile:577: memory_resource.lo] Error 1 make[5]: Leaving directory '/home/hp/tmp/newmmix-r12-2579-p3/gccobj/mmix/libstdc++-v3/src/c++17' This fix was derived from edits elsewhere in that patch. Tested mmix-knuth-mmixware, restoring build (together with target-reviving patches as MMIX is currently and at that commit broken for target-specific reasons). libstdc++-v3/: * src/c++17/memory_resource.cc: Use __exchange instead of std::exchange.
2021-07-27libstdc++: Remove unnecessary uses of <utility>Jonathan Wakely1-1/+2
The <algorithm> header includes <utility>, with a comment referring to UK-300, a National Body comment on the C++11 draft. That comment proposed to move std::swap to <utility> and then require <algorithm> to include <utility>. The comment was rejected, so we do not need to implement the suggestion. For backwards compatibility with C++03 we do want <algorithm> to define std::swap, but it does so anyway via <bits/move.h>. We don't need the whole of <utility> to do that. A few other headers that need std::swap can include <bits/move.h> to get it, instead of <utility>. There are several headers that include <utility> to get std::pair, but they can use <bits/stl_pair.h> to get it without also including the rel_ops namespace and other contents of <utility>. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/algorithm: Do not include <utility>. * include/std/functional: Likewise. * include/std/regex: Include <bits/stl_pair.h> instead of <utility>. * include/debug/map.h: Likewise. * include/debug/multimap.h: Likewise. * include/debug/multiset.h: Likewise. * include/debug/set.h: Likewise. * include/debug/vector: Likewise. * include/bits/fs_path.h: Likewise. * include/bits/unique_ptr.h: Do not include <utility>. * include/experimental/any: Likewise. * include/experimental/executor: Likewise. * include/experimental/memory: Likewise. * include/experimental/optional: Likewise. * include/experimental/socket: Use __exchange instead of std::exchange. * src/filesystem/ops-common.h: Likewise. * testsuite/20_util/default_delete/48631_neg.cc: Adjust expected errors to not use a hardcoded line number. * testsuite/20_util/default_delete/void_neg.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc: Include <utility> for std::as_const. * testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc: Likewise. * testsuite/23_containers/vector/cons/destructible_debug_neg.cc: Adjust dg-error line number.
2021-07-20libstdc++: Fix create_directories to resolve symlinks [PR101510]Jonathan Wakely2-2/+2
When filesystem__create_directories checks to see if the path already exists and resovles to a directory, it uses filesystem::symlink_status, which means it reports an error if the path is a symlink. It should use filesystem::status, so that the target directory is detected, and no error is reported. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/101510 * src/c++17/fs_ops.cc (fs::create_directories): Use status instead of symlink_status. * src/filesystem/ops.cc (fs::create_directories): Likewise. * testsuite/27_io/filesystem/operations/create_directories.cc: * testsuite/27_io/filesystem/operations/create_directory.cc: Do not test with symlinks on Windows. * testsuite/experimental/filesystem/operations/create_directories.cc: * testsuite/experimental/filesystem/operations/create_directory.cc: Do not test with symlinks on Windows.
2021-07-20libstdc++: Add more tests for filesystem::create_directory [PR101510]Jonathan Wakely1-2/+1
Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/101510 * src/c++17/fs_ops.cc (create_dir): Adjust whitespace. * testsuite/27_io/filesystem/operations/create_directory.cc: Test creating directory with name of existing symlink to directory. * testsuite/experimental/filesystem/operations/create_directory.cc: Likewise.
2021-06-28libstdc++: Remove redundant explicit instantiationsJonathan Wakely1-10/+0
These function templates are explicitly specialized for char and wchar_t streambufs, so the explicit instantiations do nothing. Remove them, to avoid confusion. libstdc++-v3/ChangeLog: * include/bits/streambuf.tcc (__copy_streambufs_eof): Remove explicit instantiation declarations. * src/c++11/streambuf-inst.cc (__copy_streambufs_eof): Remove explicit instantiation definitions.
2021-05-26libstdc++: [_GLIBCXX_DEBUG] Enhance rendering of assert messageFrançois Dumont1-227/+256
Avoid building an intermediate buffer to print to stderr, push directly to stderr. libstdc++-v3/ChangeLog: * include/debug/formatter.h (_Error_formatter::_Parameter::_Named): New. (_Error_formatter::_Parameter::_Type): Inherit latter. (_Error_formatter::_Parameter::_M_integer): Likewise. (_Error_formatter::_Parameter::_M_string): Likewise. * src/c++11/debug.cc: Include <cstring>. (_Print_func_t): New. (print_raw(PrintContext&, const char*, ptrdiff_t)): New. (print_word): Use '%.*s' format in fprintf to render only expected number of chars. (pretty_print(PrintContext&, const char*, _Print_func_t)): New. (print_type): Rename in... (print_type_info): ...this. Use pretty_print. (print_address, print_integer): New. (print_named_name, print_iterator_constness, print_iterator_state): New. (print_iterator_seq_type): New. (print_named_field, print_type_field, print_instance_field, print_iterator_field): New. (print_field): Use latters. (print_quoted_named_name, print_type_type, print_type, print_instance): New. (print_string(PrintContext&, const char*, const _Parameter*, size_t)): Change signature to... (print_string(PrintContext&, const char*, ptrdiff_t, const _Parameter*, size_t)): ...this and adapt. Remove intermediate buffer to render input string. (print_string(PrintContext&, const char*, ptrdiff_t)): New.
2021-05-20libstdc++: Disable floating_to_chars.cc on 16 bit targetsJoern Rennecke1-1/+3
This patch conditionally disables the compilation of floating_to_chars.cc on 16 bit targets, thus fixing a build failure for these targets as the POW10_SPLIT_2 array exceeds the maximum object size. libstdc++-v3/ PR libstdc++/100361 * include/std/charconv (to_chars): Hide the overloads for floating-point types for 16 bit targets. * src/c++17/floating_to_chars.cc: Don't compile for 16 bit targets. * testsuite/20_util/to_chars/double.cc: Run this test only on size32plus targets. * testsuite/20_util/to_chars/float.cc: Likewise. * testsuite/20_util/to_chars/long_double.cc: Likewise.
2021-05-11libstdc++: Remove extern "C" from Ryu sourcesPatrick Palka2-18/+4
floating_to_chars.cc includes the Ryu sources into an anonymous namespace as a convenient way to give all its symbols internal linkage. But an entity declared extern "C" always has external linkage even from within an anonymous namespace, so this trick doesn't work in the presence of extern "C", and it causes the Ryu function generic_to_chars to be visible from libstdc++.a. This patch removes the only use of extern "C" from our local copy of Ryu along with some declarations for never-defined functions that GCC now warns about. libstdc++-v3/ChangeLog: * src/c++17/ryu/LOCAL_PATCHES: Update. * src/c++17/ryu/ryu_generic_128.h: Remove extern "C". Remove declarations for never-defined functions. * testsuite/20_util/to_chars/4.cc: New test.
2021-04-15libstdc++: Move atomic functions to libsupc++ [PR 96657]Jonathan Wakely2-12/+3
The changes for PR libstdc++/64735 mean that libsupc++ function might now depend on the __exchange_and_add and __atomic_add functions defined in config/cpu/*/atomicity.h which is not compiled into libsupc++. This causes a link failure for some targets when trying to use libsupc++ without the rest of libstdc++. This patch simply moves the definitions of those functions into libsupc++ so that they are available there. libstdc++-v3/ChangeLog: PR libstdc++/96657 * libsupc++/Makefile.am: Add atomicity.cc here. * src/c++98/Makefile.am: Remove it from here. * libsupc++/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * testsuite/18_support/exception_ptr/96657.cc: New test.
2021-04-07libstdc++: Fix filesystem::path construction from COW string [PR 99805]Jonathan Wakely1-6/+4
Calling the non-const data() member on a COW string makes it "leaked", possibly resulting in reallocating the string to ensure a unique owner. The path::_M_split_cmpts() member parses its _M_pathname string using string_view objects and then calls _M_pathname.data() to find the offset of each string_view from the start of the string. However because _M_pathname is non-const that will cause a COW string to reallocate if it happens to be shared with another string object. This results in the offsets calculated for each component being wrong (i.e. undefined) because the string views no longer refer to substrings of the _M_pathname member. The fix is to use the parse.offset(c) member which gets the offset safely. The bug only happens for the path(string_type&&) constructor and only for COW strings. When constructed from an lvalue string the string's contents are copied rather than just incrementing the refcount, so there's no reallocation when calling the non-const data() member. The testsuite changes check the lvalue case anyway, because we should probably change the deep copying to just be a refcount increment (by adding a path(const string_type&) constructor or an overload for __effective_range(const string_type&), for COW strings only). libstdc++-v3/ChangeLog: PR libstdc++/99805 * src/c++17/fs_path.cc (path::_M_split_cmpts): Do not call non-const member on _M_pathname, to avoid copy-on-write. * testsuite/27_io/filesystem/path/decompose/parent_path.cc: Check construction from strings that might be shared.
2021-03-26libstdc++: Add PRNG fallback to std::random_deviceJonathan Wakely1-94/+158
This makes std::random_device usable on VxWorks when running on older x86 hardware. Since the r10-728 fix for PR libstdc++/85494 the library will use the new code unconditionally on x86, but the cpuid checks for RDSEED and RDRAND can fail at runtime, depending on the hardware where the code is executing. If the OS does not provide /dev/urandom then this means the std::random_device constructor always fails. In previous releases if /dev/urandom is unavailable then std::mt19937 was used unconditionally. This patch adds a fallback for the case where the runtime cpuid checks for x86 hardware instructions fail, and no /dev/urandom is available. When this happens a std::linear_congruential_engine object will be used, with a seed based on hashing the engine's address and the current time. Distinct std::random_device objects will use different seeds, unless an object is created and destroyed and a new object created at the same memory location within the clock tick. This is not great, but is better than always throwing from the constructor, and better than always using std::mt19937 with the same seed (as GCC 9 and earlier do). libstdc++-v3/ChangeLog: * src/c++11/random.cc (USE_LCG): Define when a pseudo-random fallback is needed. [USE_LCG] (bad_seed, construct_lcg_at, destroy_lcg_at, __lcg): New helper functions and callback. (random_device::_M_init): Add 'prng' and 'all' enumerators. Replace switch with fallthrough with a series of 'if' statements. [USE_LCG]: Construct an lcg_type engine and use __lcg when cpuid checks fail. (random_device::_M_init_pretr1) [USE_MT19937]: Accept "prng" token. (random_device::_M_getval): Check for callback unconditionally and always pass _M_file pointer. * testsuite/26_numerics/random/random_device/85494.cc: Remove effective-target check. Use new random_device_available helper. * testsuite/26_numerics/random/random_device/94087.cc: Likewise. * testsuite/26_numerics/random/random_device/cons/default-cow.cc: Remove effective-target check. * testsuite/26_numerics/random/random_device/cons/default.cc: Likewise. * testsuite/26_numerics/random/random_device/cons/token.cc: Use new random_device_available helper. Test "prng" token. * testsuite/util/testsuite_random.h (random_device_available): New helper function.
2021-03-16libstdc++: Remove symbols for new std::call_once implementation [PR 99341]Jonathan Wakely1-84/+0
This removes the new symbols added for the new futex-based std::call_once implementation. These symbols were new on trunk, so not in any released version. However, they are already present in some beta distro releases (Fedora Linux 34) and in Fedora Linux rawhide. This change can be locally reverted by distros that need to keep the symbols present until affected packages have been rebuilt. libstdc++-v3/ChangeLog: PR libstdc++/99341 * config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Remove std::once_flag symbols. * config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Likewise. * config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Likewise. * config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Likewise. * config/abi/pre/gnu.ver: Likewise. * src/c++11/mutex.cc [_GLIBCXX_HAVE_LINUX_FUTEX] (struct __once_flag_compat): Remove. (_ZNSt9once_flag11_M_activateEv): Remove. (_ZNSt9once_flag9_M_finishEb): Remove.
2021-03-16libstdc++: Revert to old std::call_once implementation [PR 99341]Jonathan Wakely1-6/+31
The new std::call_once implementation is not backwards compatible, contrary to my intention. Because std::once_flag::_M_active() doesn't write glibc's "fork generation" into the pthread_once_t object, it's possible for glibc and libstdc++ to run two active executions concurrently. This violates the primary invariant of the feature! This patch reverts std::once_flag and std::call_once to the old implementation that uses pthread_once. This means PR 66146 is a problem again, but glibc has been changed to solve that. A new API similar to pthread_once but supporting failure and resetting the pthread_once_t will be proposed for inclusion in glibc and other C libraries. This change doesn't simply revert r11-4691 because I want to retain the new implementation for non-ghtreads targets (which didn't previously support std::call_once at all, so there's no backwards compatibility concern). This also leaves the new std::call_once::_M_activate() and std::call_once::_M_finish(bool) symbols present in libstdc++.so.6 so that code already compiled against GCC 11 can still use them. Those symbols will be removed in a subsequent commit (which distros can choose to temporarily revert if needed). libstdc++-v3/ChangeLog: PR libstdc++/99341 * include/std/mutex [_GLIBCXX_HAVE_LINUX_FUTEX] (once_flag): Revert to pthread_once_t implementation. [_GLIBCXX_HAVE_LINUX_FUTEX] (call_once): Likewise. * src/c++11/mutex.cc [_GLIBCXX_HAVE_LINUX_FUTEX] (struct __once_flag_compat): New type matching the reverted implementation of once_flag using futexes. (once_flag::_M_activate): Remove, replace with ... (_ZNSt9once_flag11_M_activateEv): ... alias symbol. (once_flag::_M_finish): Remove, replace with ... (_ZNSt9once_flag9_M_finishEb): ... alias symbol. * testsuite/30_threads/call_once/66146.cc: Removed.
2021-03-15libstdc++-v3: Update VTV vars for libtool link commands [PR99172]Caroline Tice2-2/+5
This fixes PR 99172 Currently when GCC is configured with --enable-vtable-verify, the libstdc++-v3 Makefiles add "-fvtable-verify=std -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end" to libtool link commands. The "-fvtable-verify=std" piece causes alternate versions of libtool (such as slibtool) to fail, unable to find "-lvtv" (GNU libtool just removes that piece). This patch updates the libstdc++-v3 Makefiles to not pass "-fvtable-verify=std" to the libtool link commands.
2021-03-11libstdc++: Add a fallback 128-bit integer class type and use itPatrick Palka2-23/+332
This implements a minimal integer class type that emulates 128-bit unsigned arithmetic using a pair of 64-bit integers, which the floating-point std::to_chars implementation then uses as a drop-in replacement for unsigned __int128 on targets that lack the latter. After this patch, we now fully support formatting of large long double types on such targets. Since Ryu performs 128-bit division/modulus only by 2, 5 and 10, this integer class type supports only these divisors rather than general division/modulus. libstdc++-v3/ChangeLog: * src/c++17/floating_to_chars.cc: Simplify the file as if __SIZEOF_INT128__ is always defined. [!defined __SIZEOF_INT128__]: Include "uint128_t.h". Define a base-10 to_chars overload for the uint128_t class type. * src/c++17/uint128_t.h: New file. * testsuite/20_util/to_chars/long_double.cc: No longer expect an execution FAIL on targets that have a large long double type but lack __int128.
2021-03-11libstdc++: Remove Ryu's uint128_t aliasesPatrick Palka4-9/+3
This makes Ryu consistently use the uint128_t alias that's defined in floating_to_chars.cc. libstdc++-v3/ChangeLog: * src/c++17/ryu/LOCAL_PATCHES: Update. * src/c++17/ryu/d2s_intrinsics.h: Don't define uint128_t. * src/c++17/ryu/generic_128.h: Likewise. * src/c++17/ryu/ryu_generic_128.h (struct floating_decimal_128): Use uint128_t instead of __uint128_t. (generic_binary_to_decimal): Likewise.
2021-03-11libstdc++: Add a LOCAL_PATCHES file to Ryu source directoryPatrick Palka1-0/+1
This file keeps track of the local modifications we've made to our copy of Ryu. libstdc++-v3/ChangeLog: * src/c++17/ryu/LOCAL_PATCHES: New file.
2021-03-11libstdc++: Factor out uses of __int128 into a type aliasPatrick Palka1-9/+16
Since Ryu has the alias uint128_t for this same purpose, it seems best for us to use this name as well, so as to minimize the amount of local modifications we'd need to make to our copy of Ryu. (In a subsequent patch, we're going to remove Ryu's aliases so that it uses this one defined in floating_to_chars.cc.) libstdc++-v3/ChangeLog: * src/c++17/floating_to_chars.cc (uint128_t): New conditionally defined alias of unsigned __int128. (floating_type_traits_binary128::mantissa_t): Use uint128_t instead of unsigned __int128. (floating_type_traits<long double>::mantissa_t) [LONG_DOUBLE_KIND == LDK_IBM128]: Likewise. (get_ieee_repr): Likewise. Make casts from uint_t to mantissa_t and uint32_t explicit. Simplify the extraction of mantissa, exponent and sign bit.
2021-03-11libstdc++: Handle EPERM for filesystem access errors on MacOS [PR 99537]Jonathan Wakely3-2/+14
Contrary to what POSIX says, some directory operations on MacOS can fail with EPERM instead of EACCES, so we need to handle both. libstdc++-v3/ChangeLog: PR libstdc++/99537 * src/c++17/fs_dir.cc (recursive_directory_iterator): Use new helper function to check for permission denied errors. * src/filesystem/dir.cc (recursive_directory_iterator): Likewise. * src/filesystem/dir-common.h (is_permission_denied_error): New helper function.
2021-02-24libstdc++: Fix order of arguments to sprintf [PR 99261]Jonathan Wakely1-2/+2
libstdc++-v3/ChangeLog: PR libstdc++/99261 * src/c++17/floating_to_chars.cc (sprintf_ld): Add extra args before value to be printed.
2021-02-24libstdc++: Fix __floating_to_chars_precision for __float128Patrick Palka1-1/+1
The code path in __floating_to_chars_precision for handling long double by going through printf now also handles __float128, so the condition that guards this code path needs to get updated accordingly. libstdc++-v3/ChangeLog: * src/c++17/floating_to_chars.cc (__floating_to_chars_precision): Relax the condition that guards the printf code path to accept F128_type as well as long double.
2021-02-24libstdc++: Define std::to_chars overloads for __ieee128 [PR 98389]Jonathan Wakely3-113/+195
This adds overloads of std::to_chars for powerpc64's __ieee128, so that std::to_chars can be used for long double when -mabi=ieeelongdouble is in used. Eventually we'll want to extend these new overloads to work for __float128 on all targets that support that type. For now, we're only doing it for powerpc64 when the new long double type is supported in parallel to the old long double type. Additionally the existing std::to_chars overloads for long double are given the right symbol version, resolving PR libstdc++/98389. libstdc++-v3/ChangeLog: PR libstdc++/98389 * config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Do not match to_chars symbols for long double arguments mangled as 'g'. * config/os/gnu-linux/ldbl-extra.ver: Likewise. * config/os/gnu-linux/ldbl-ieee128-extra.ver: Likewise. * src/c++17/Makefile.am [GLIBCXX_LDBL_ALT128_COMPAT_TRUE]: Use -mabi=ibmlongdouble for floating_to_chars.cc. * src/c++17/Makefile.in: Regenerate. * src/c++17/floating_to_chars.cc (floating_type_traits_binary128): New type defining type traits of IEEE binary128 format. (floating_type_traits<__float128>): Define specialization. (floating_type_traits<long double>): Define in terms of floating_type_traits_binary128 when appropriate. (floating_to_shortest_scientific): Handle __float128. (sprintf_ld): New function template for printing a long double or __ieee128 value using sprintf. (__floating_to_chars_shortest, __floating_to_chars_precision): Use sprintf_ld. (to_chars): Define overloads for __float128.
2021-02-22libstdc++: Fix endianness issue with IBM long double [PR98384]Patrick Palka1-4/+4
The code in std::to_chars for extracting the high- and low-order parts of an IBM long double value does the right thing on powerpc64le, but not on powerpc64be. This patch makes the extraction endian-agnostic, which fixes the execution FAIL of to_chars/long_double.cc on powerpc64be. libstdc++-v3/ChangeLog: PR libstdc++/98384 * src/c++17/floating_to_chars.cc (get_ieee_repr): Extract the high- and low-order parts from an IBM long double value in an endian-agnostic way.
2021-02-12libstdc++: Re-enable workaround for _wstat64 bug, again [PR 88881]Jonathan Wakely1-2/+0
I forgot that the workaround is present in both filesystem::status and filesystem::symlink_status. This restores it in the latter. libstdc++-v3/ChangeLog: PR libstdc++/88881 * src/c++17/fs_ops.cc (fs::symlink_status): Re-enable workaround.
2021-02-12libstdc++: Fix filesystem::rename on Windows [PR 98985]Jonathan Wakely2-1/+40
The _wrename function won't overwrite an existing file, so use MoveFileEx instead. That allows renaming directories over files, which POSIX doesn't allow, so check for that case explicitly and report an error. Also document the deviation from the expected behaviour, and add a test for filesystem::rename which was previously missing. The Filesystem TS experimental::filesystem::rename doesn't have that extra code to handle directories correctly, so the relevant parts of the new test are not run on Windows. libstdc++-v3/ChangeLog: * doc/xml/manual/status_cxx2014.xml: Document implementation specific properties of std::experimental::filesystem::rename. * doc/xml/manual/status_cxx2017.xml: Document implementation specific properties of std::filesystem::rename. * doc/html/*: Regenerate. * src/c++17/fs_ops.cc (fs::rename): Implement correct behaviour for directories on Windows. * src/filesystem/ops-common.h (__gnu_posix::rename): Use MoveFileExW on Windows. * testsuite/27_io/filesystem/operations/rename.cc: New test. * testsuite/experimental/filesystem/operations/rename.cc: New test.
2021-02-12libstdc++: Add unused attributes to shared_ptr functionsJonathan Wakely1-1/+1
This avoids some warnings when building with -fno-rtti because the function parameters are only used when RTTI is enabled. libstdc++-v3/ChangeLog: * include/bits/shared_ptr_base.h (__shared_ptr::_M_get_deleter): Add unused attribute to parameter. * src/c++11/shared_ptr.cc (_Sp_make_shared_tag::_S_eq): Likewise.
2021-02-12libstdc++: Fix bootstrap with -fno-rtti [PR 99077]Jonathan Wakely1-6/+5
When libstdc++ is built without RTTI the __ios_failure type is just an alias for std::ios_failure, so trying to construct it from an int won't compile. This changes the RTTI-enabled __ios_failure type to have the same constructor parameters as std::ios_failure, so that the constructor takes the same arguments whether RTTI is enabled or not. The __throw_ios_failure function now constructs the error_code, instead of the __ios_failure constructor. As a drive-by fix that error_code is constructed with std::generic_category() not std::system_category(), because the int comes from errno which corresponds to the generic category. libstdc++-v3/ChangeLog: PR libstdc++/99077 * src/c++11/cxx11-ios_failure.cc (__ios_failure(const char*, int)): Change int parameter to error_code, to match std::ios_failure. (__throw_ios_failure(const char*, int)): Construct error_code from int parameter.
2021-02-10libstdc++: Re-enable workaround for _wstat64 bug [PR 88881]Jonathan Wakely1-2/+0
This wasn't fixed upstream for mingw-w64 so we still need the workaround. libstdc++-v3/ChangeLog: PR libstdc++/88881 * src/c++17/fs_ops.cc (fs::status): Re-enable workaround.
2021-02-10libstdc++: Use correct error category for Windows error codesJonathan Wakely2-6/+6
When the result of GetLastError() is stored in a std::error_code it should use std::system_category(), not std::generic_category() that is used for POSIX errno values. libstdc++-v3/ChangeLog: * src/c++17/fs_ops.cc (fs::create_hard_link, fs::equivalent) (fs::remove): Use std::system_category() for error codes from GetLastError(). * src/filesystem/ops.cc (fs::create_hard_link, fs::remove): Likewise.
2021-02-09libstdc++: Fix build failure for targets without unistd.hVladimir Vishnevsky1-1/+1
The patch fixes build issues occurring if build parameter "--enable-cstdio=stdio_pure" is specified and no unistd.h is present in the environment. libstdc++-v3/ChangeLog: * include/ext/stdio_sync_filebuf.h: Remove unused <unistd.h>. * src/c++17/fs_ops.cc (fs::permissions): Qualify mode_t.
2021-01-21libstdc++: Regenerate Makefile.inJonathan Wakely1-2/+2
This removes a trivial whitespace difference between the currently committed file and the one regenerated by autotools. libstdc++-v3/ChangeLog: * src/c++17/Makefile.in: Regenerate.
2021-01-18libstd++: : Add workaround for as Error: file number less than one error ↵Jakub Jelinek2-4/+4
[PR98708] As mentioned in the PR, since the switch to DWARF5 by default instead of DWARF4, gcc fails to build when configured against recent binutils. The problem is that cxx11-ios_failure* is built in separate steps, -S compilation (with -g -O2) followed by some sed and followed by -c -g -O2 -g0 assembly. When gcc is configured against recent binutils and DWARF5 is the default, we emit .file 0 "..." directive on which the assembler then fails (unless --gdwarf-5 is passed to it, but we don't want that generally because on the other side older assemblers don't like -g* passed to it when invoked on *.s file with compiler generated debug info. I hope the bug will be fixed soon on the binutils side, but it would be nice to have a workaround. The following patch is one of the possibilities, another one is to do that but add configure check for whether it is needed, essentially echo 'int main () { return 0; }' > conftest.c ${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s ${CXX} ${CXXFLAGS} -g -O2 -g0 -c conftest.s -o conftest.o and if the last command fails, we need that -gno-as-loc-support. Or yet another option would be I think do a different check, whether ${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s ${CXX} ${CXXFLAGS} -g -O2 -c conftest.s -o conftest.o works and if yes, don't add the -g0 to cxx11-ios_failure*.s assembly. 2021-01-18 Jakub Jelinek <jakub@redhat.com> PR debug/98708 * src/c++11/Makefile.am (cxx11-ios_failure-lt.s, cxx11-ios_failure.s): Compile with -gno-as-loc-support. * src/c++11/Makefile.in: Regenerated.
2021-01-14libstdc++: Implement N3644 for _GLIBCXX_DEBUG iteratorsFrançois Dumont1-4/+1
libstdc++-v3/ChangeLog: PR libstdc++/98466 * include/bits/hashtable_policy.h (_Node_iterator_base()): Set _M_cur to nullptr. (_Node_iterator()): Make default. (_Node_const_iterator()): Make default. * include/debug/macros.h (__glibcxx_check_erae_range_after): Add _M_singular iterator checks. * include/debug/safe_iterator.h (_GLIBCXX_DEBUG_VERIFY_OPERANDS): Accept if both iterator are value initialized. * include/debug/safe_local_iterator.h (_GLIBCXX_DEBUG_VERIFY_OPERANDS): Likewise. * include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_valid_range): Add _M_singular checks on input iterators. * src/c++11/debug.cc (_Safe_iterator_base::_M_can_compare): Remove _M_singular checks. * testsuite/23_containers/deque/debug/98466.cc: New test. * testsuite/23_containers/unordered_map/debug/98466.cc: New test.
2021-01-04Update copyright years.Jakub Jelinek130-130/+130
2020-12-21libstdc++: Disable floating-point std::to_chars on unsupported targetsPatrick Palka1-4/+6
This patch conditionally disables the floating-point std::to_chars implementation on targets whose float and double aren't IEEE binary32 and binary64, until a proper fallback can be added for such targets. This fixes a bootstrap failure on non-IEEE-754 FP targets such as vax-netbsdelf. The new preprocessor tests in c++config that detect the binary32 and binary64 formats were copied from gcc/testsuite/gcc.dg/float-exact-1.c. libstdc++-v3/ChangeLog: * include/bits/c++config (_GLIBCXX_FLOAT_IS_IEEE_BINARY_32): Define this macro. (_GLIBCXX_DOUBLE_IS_IEEE_BINARY_64): Likewise. * include/std/charconv (to_chars): Use these macros to conditionally hide the overloads for floating-point types. * src/c++17/floating_to_chars.cc: Use the macros to conditionally disable this file. (floating_type_traits<float>): Remove redundant static assert. (floating_type_traits<double>): Likewise. * testsuite/20_util/to_chars/double.cc: Run this test only on ieee-floats effective targets. * testsuite/20_util/to_chars/float.cc: Likewise. * testsuite/20_util/to_chars/long_double.cc: Likewise. * testsuite/lib/libstdc++.exp (check_effective_target_ieee-floats): Define new proc for detecting whether float and double have the IEEE binary32 and binary64 formats.
2020-12-18libstdc++: Fix mistake in PR98374 change [PR98377]Patrick Palka1-1/+1
The #ifdef RADIXCHAR directive should be moved one line up so that it also guards the outer if statement, or else when RADIXCHAR is not defined the outer if statement will end up nonsensically guarding the declaration of output_length_upper_bound a few lines below it. libstdc++-v3/ChangeLog: PR libstdc++/98377 * src/c++17/floating_to_chars.cc (__floating_to_chars_precision): Fix mistake.
2020-12-18libstdc++: Fix build failure on AArch64 ILP32 [PR98370]Patrick Palka1-1/+1
This should fix a build failure on AArch64 ILP32 due to int32_t mapping to long int instead of int on this platform, which causes type deduction to fail in the below call to std::max as reported in the PR. libstdc++-v3/ChangeLog: PR libstdc++/98370 * src/c++17/floating_to_chars.cc (__floating_to_chars_shortest): Provide explicit template arguments to the call to std::max.