summaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
Commit message (Collapse)AuthorAgeFilesLines
* libstdc++: Disable cacheline alignment for DJGPP [PR109741]Jonathan Wakely2023-05-161-2/+6
| | | | | | | | | | | | | | | | | | | | | | DJGPP (and maybe other targets) uses MAX_OFILE_ALIGNMENT=16 which means that globals (and static objects) can't have alignment greater than 16. This causes an error for the locks defined in src/c++11/shared_ptr.cc because we try to align them to the cacheline size, to avoid false sharing. Add a configure check for the increased alignment, and live with false sharing where we can't increase the alignment. libstdc++-v3/ChangeLog: PR libstdc++/109741 * acinclude.m4 (GLIBCXX_CHECK_ALIGNAS_CACHELINE): Define. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_ALIGNAS_CACHELINE. * src/c++11/shared_ptr.cc (__gnu_internal::get_mutex): Do not align lock table if not supported. use __GCC_DESTRUCTIVE_SIZE instead of hardcoded 64.
* libstdc++: Stop using _GLIBCXX_USE_C99_STDINT_TR1 in <cstdint>Jonathan Wakely2023-05-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The _GLIBCXX_USE_C99_STDINT_TR1 macro (and the comments about it in acinclude.m4 and config.h) are misleading when it is also used for <stdint>, not only <tr1/stdint>. It is also wrong, because the configure checks for TR1 use -std=c++98 and a target might define uint32_t etc. for C++11 but not for C++98. Add a separate configure check for the <stdint.h> types using -std=c++11 for the checks. Use the result of that separate check in <cstdint> and most other places that still depend on the macro (many uses of that macro have been removed already). The remaining uses of the STDINT_TR1 macro are really for TR1, or are in the src/c++11/compatibility-*.cc files, where we don't want/need to change the condition they depend on (if those symbols were only exported when <stdint.h> types were available for -std=c++98, then that's the condition we should continue to use for whether to export the compat symbols now). Make similar changes for the related _GLIBCXX_USE_C99_INTTYPES_TR1 and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 macros, adding new macros for non-TR1 uses. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_USE_C99): Check for <stdint.h> types in C++11 mode and define _GLIBCXX_USE_C99_STDINT. Check for <inttypes.h> features in C++11 mode and define _GLIBCXX_USE_C99_INTTYPES and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T. * config.h.in: Regenerate. * configure: Regenerate. * doc/doxygen/user.cfg.in (PREDEFINED): Add new macros. * include/bits/chrono.h: Check _GLIBCXX_USE_C99_STDINT instead of _GLIBCXX_USE_C99_STDINT_TR1. * include/c_compatibility/inttypes.h: Check _GLIBCXX_USE_C99_INTTYPES and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T instead of _GLIBCXX_USE_C99_INTTYPES_TR1 and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1. * include/c_compatibility/stdatomic.h: Check _GLIBCXX_USE_C99_STDINT instead of _GLIBCXX_USE_C99_STDINT_TR1. * include/c_compatibility/stdint.h: Likewise. * include/c_global/cinttypes: Check _GLIBCXX_USE_C99_INTTYPES and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T instead of _GLIBCXX_USE_C99_INTTYPES_TR1 and _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1. * include/c_global/cstdint: Check _GLIBCXX_USE_C99_STDINT instead of _GLIBCXX_USE_C99_STDINT_TR1. * include/std/atomic: Likewise. * src/c++11/cow-stdexcept.cc: Likewise. * testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: Likewise. * testsuite/lib/libstdc++.exp (check_v3_target_cstdint): Likewise.
* libstdc++: Remove <random> dependency on _GLIBCXX_USE_C99_STDINT_TR1Jonathan Wakely2023-05-122-5/+0
| | | | | | | | | | | | | | | | | | | Since r9-2028-g8ba7f29e3dd064 we've defined most of <cstdint> unconditionally, including uint_least32_t. This means that all of <random> can be defined unconditionally, which means that std::shuffle and std::ranges::shuffle can be too. libstdc++-v3/ChangeLog: * include/bits/algorithmfwd.h (shuffle): Do not depend on _GLIBCXX_USE_C99_STDINT_TR1. * include/bits/ranges_algo.h (shuffle): Likewise. * include/bits/stl_algo.h (shuffle): Likewise. * include/ext/random: Likewise. * include/ext/throw_allocator.h (random_condition): Likewise. * include/std/random: Likewise. * src/c++11/cow-string-inst.cc: Likewise. * src/c++11/random.cc: Likewise.
* libstdc++: Use RAII types in strtod-based std::from_chars implementationJonathan Wakely2023-05-111-19/+69
| | | | | | | | | | | | | | | | | | This adds auto_locale and auto_ferounding types to use RAII for changing and restoring the local and floating-point environment when using strtod to implement std::from_chars. The destructors for the RAII objects run slightly later than the previous statements that restored the locale/fenv, but the differences are just some trivial assignments and an isinf call. Reviewed-by: Patrick Palka <ppalka@redhat.com> libstdc++-v3/ChangeLog: * src/c++17/floating_from_chars.cc [USE_STRTOD_FOR_FROM_CHARS] (auto_locale, auto_ferounding): New class types. (from_chars_impl): Use auto_locale and auto_ferounding.
* libstdc++: Fix up abi.exp FAILs on powerpc64le-linuxJakub Jelinek2023-05-032-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an ABI problem on powerpc64le-linux, introduced in 13.1. When libstdc++ is configured against old glibc, the _ZSt10from_charsPKcS0_RDF128_St12chars_format@@GLIBCXX_3.4.31 _ZSt8to_charsPcS_DF128_@@GLIBCXX_3.4.31 _ZSt8to_charsPcS_DF128_St12chars_format@@GLIBCXX_3.4.31 _ZSt8to_charsPcS_DF128_St12chars_formati@@GLIBCXX_3.4.31 symbols are exported from the library, while when it is configured against new enough glibc, those symbols aren't exported and we export instead _ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format@@GLIBCXX_IEEE128_3.4.29 _ZSt8to_charsPcS_u9__ieee128@@GLIBCXX_IEEE128_3.4.29 _ZSt8to_charsPcS_u9__ieee128St12chars_format@@GLIBCXX_IEEE128_3.4.29 _ZSt8to_charsPcS_u9__ieee128St12chars_formati@@GLIBCXX_IEEE128_3.4.29 together with various other @@GLIBCXX_IEEE128_3.4.{29,30,31} and @@CXXABI_IEEE128_1.3.13 symbols. The idea was that those *IEEE128* symbol versions (similarly to *LDBL* symbol versions) are optional (but if it appears, all symbols from it up to the version of the library appears), but the base appears always. My _Float128 from_chars/to_chars changes unfortunately broke this. I believe nothing really uses those symbols if libstdc++ has been configured against old glibc, so if 13.1 wasn't already released, it might be best to make sure they aren't exported on powerpc64le-linux. But as they were exported, I think the best resolution for this ABI difference is to add those 4 symbols as aliases to the GLIBCXX_IEEE128_3.4.29 *u9__ieee128* symbols, which the following patch does. 2023-05-03 Jakub Jelinek <jakub@redhat.com> * src/c++17/floating_from_chars.cc (_ZSt10from_charsPKcS0_RDF128_St12chars_format): New alias to _ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format. * src/c++17/floating_to_chars.cc (_ZSt8to_charsPcS_DF128_): New alias to _ZSt8to_charsPcS_u9__ieee128. (_ZSt8to_charsPcS_DF128_St12chars_format): New alias to _ZSt8to_charsPcS_u9__ieee128St12chars_format. (_ZSt8to_charsPcS_DF128_St12chars_formati): New alias to _ZSt8to_charsPcS_u9__ieee128St12chars_formati. * config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt: Updated.
* ibstdc++: Shut up -Wattribute-alias warning [PR109694]Jakub Jelinek2023-05-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | I've followed what other files do, using attribute alias with not really matching function type (after all, it isn't really possible when it is a constructor), but seems I've missed it warns: ../../../../../libstdc++-v3/src/c++98/ios_init.cc:203:8: warning: ‘void std::ios_base_library_init()’ alias between functions of incompatible types ‘void()’ and ‘void +(std::ios_base::Init::)()’ [-Wattribute-alias=] 203 | void ios_base_library_init (void) | ^~~~~~~~~~~~~~~~~~~~~ ../../../../../libstdc++-v3/src/c++98/ios_init.cc:78:3: note: aliased declaration here 78 | ios_base::Init::Init() | ^~~~~~~~ The PR talks about clang++ warning there (which I think isn't really supported, libstdc++ sources ought to be built by GCC), but it warns when built with GCC too. The following patch fixes it by doing what other libstdc++ sources do in those cases. 2023-05-02 Jakub Jelinek <jakub@redhat.com> PR libstdc++/109694 * src/c++98/ios_init.cc: Add #pragma GCC diagnostic ignored for -Wattribute-alias.
* libstdc++: Another attempt to ensure g++ 13+ compiled programs enforce gcc ↵Jakub Jelinek2023-04-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 13.2+ libstdc++.so.6 [PR108969] GCC used to emit an instance of an empty ios_base::Init class in every TU which included <iostream> to ensure it is std::cout etc. is initialized, but thanks to Patrick work on some targets (which have init_priority attribute support) it is now initialized only inside of libstdc++.so.6/libstdc++.a. This causes a problem if people do something that has never been supported, try to run GCC 13 compiled C++ code against GCC 12 or earlier libstdc++.so.6 - std::cout etc. are then never initialized because code including <iostream> expects the library to initialize it and the library expects code including <iostream> to do that. The following patch is second attempt to make this work cheaply as the earlier attempt of aliasing the std::cout etc. symbols with another symbol version didn't work out due to copy relocation breaking the aliases appart. The patch forces just a _ZSt21ios_base_library_initv undefined symbol into all *.o files which include <iostream> and while there is no runtime relocation against that, it seems to enforce the right version of libstdc++.so.6. /home/jakub/src/gcc/obj08i/usr/local/ is the install directory of trunk patched with this patch, /home/jakub/src/gcc/obj06/ is builddir of trunk without this patch, system g++ is GCC 12.1.1. $ cat /tmp/hw.C #include <iostream> int main () { std::cout << "Hello, world!" << std::endl; } $ cd /home/jakub/src/gcc/obj08i/usr/local/bin $ ./g++ -o /tmp/hw /tmp/hw.C $ readelf -Wa /tmp/hw 2>/dev/null | grep initv 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _ZSt21ios_base_library_initv@GLIBCXX_3.4.32 (4) 71: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _ZSt21ios_base_library_initv@GLIBCXX_3.4.32 $ /tmp/hw /tmp/hw: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /tmp/hw) $ LD_LIBRARY_PATH=/home/jakub/src/gcc/obj08i/usr/local/lib64/ /tmp/hw Hello, world! $ LD_LIBRARY_PATH=/home/jakub/src/gcc/obj06/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/ /tmp/hw /tmp/hw: /home/jakub/src/gcc/obj06/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /tmp/hw) $ g++ -o /tmp/hw /tmp/hw.C $ /tmp/hw Hello, world! $ LD_LIBRARY_PATH=/home/jakub/src/gcc/obj06/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/ /tmp/hw Hello, world! $ LD_LIBRARY_PATH=/home/jakub/src/gcc/obj08i/usr/local/lib64/ /tmp/hw Hello, world! On sparc-sun-solaris2.11 one I've actually checked a version which had defined(_GLIBCXX_SYMVER_SUN) next to defined(_GLIBCXX_SYMVER_GNU), but init_priority attribute doesn't seem to be supported there and so I couldn't actually test how this works there. Using gas and Sun ld, Rainer, does one need to use gas + gld for init_priority or something else? 2023-04-28 Jakub Jelinek <jakub@redhat.com> PR libstdc++/108969 * config/abi/pre/gnu.ver (GLIBCXX_3.4.32): Export _ZSt21ios_base_library_initv. * testsuite/util/testsuite_abi.cc (check_version): Add GLIBCXX_3.4.32 symver and make it the latestp. * src/c++98/ios_init.cc (ios_base_library_init): New alias. * acinclude.m4 (libtool_VERSION): Change to 6:32:0. * include/std/iostream: If init_priority attribute is supported and _GLIBCXX_SYMVER_GNU, force undefined _ZSt21ios_base_library_initv symbol into the object. * configure: Regenerated.
* libstdc++: Make std::random_device throw std::system_error [PR105081]Jonathan Wakely2023-04-271-6/+12
| | | | | | | | | | | | | | | | | | | | | This changes std::random_device constructors to throw std::system_error (with EINVAL as the error code) when the constructor argument is invalid. We can also throw std::system_error when read(2) fails so that the exception includes the additional information provided by errno. As noted in the PR, this is consistent with libc++, and doesn't break any existing code which catches std::runtime_error, because those handlers will still catch std::system_error. libstdc++-v3/ChangeLog: PR libstdc++/105081 * src/c++11/random.cc (__throw_syserr): New function. (random_device::_M_init, random_device::_M_init_pretr1): Use new function for bad tokens. (random_device::_M_getval): Use new function for read errors. * testsuite/util/testsuite_random.h (random_device_available): Change catch handler to use std::system_error.
* Revert "libstdc++: Export global iostreams with GLIBCXX_3.4.31 symver ↵Jonathan Wakely2023-04-195-34/+19
| | | | | | | | | | | | | | | | | | | | | | | | | [PR108969]" This reverts commit b7c54e3f48086c29179f7765a35c381de5109a0a. libstdc++-v3/ChangeLog: * config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: * config/abi/post/i486-linux-gnu/baseline_symbols.txt: * config/abi/post/m68k-linux-gnu/baseline_symbols.txt: * config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt: * config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: * config/abi/post/s390x-linux-gnu/baseline_symbols.txt: * config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: * config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: * config/abi/pre/gnu.ver: * src/Makefile.am: * src/Makefile.in: * src/c++98/Makefile.am: * src/c++98/Makefile.in: * src/c++98/globals_io.cc (defined): (_GLIBCXX_IO_GLOBAL):
* libstdc++: Export global iostreams with GLIBCXX_3.4.31 symver [PR108969]Jonathan Wakely2023-04-185-19/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since GCC 13 the global iostream objects are only initialized once in libstdc++, and not by a std::ios::Init object in every translation unit that includes <iostream>. To avoid using uninitialized streams defined in an older libstdc++.so, translation units using the global iostreams should depend on the GLIBCXX_3.4.31 symver. Define std::cin as std::__io::cin and then export it as std::cin@@GLIBCXX_3.4.31 so that references to std::cin bind to the new symver. Also export it as @GLIBCXX_3.4 for backwards compatibility libstdc++-v3/ChangeLog: PR libstdc++/108969 * src/Makefile.am: Move globals_io.cc to here. * src/Makefile.in: Regenerate. * src/c++98/Makefile.am: Remove globals_io.cc from here. * src/c++98/Makefile.in: Regenerate. * src/c++98/globals_io.cc [_GLIBCXX_SYMVER_GNU] (cin): Adjust symbol name and then export with GLIBCXX_3.4.31 symver. (cout, cerr, clog, wcin, wcout, wcerr, wclog): Likewise. * config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Regenerate. * config/abi/post/i486-linux-gnu/baseline_symbols.txt: Regenerate. * config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Regenerate. * config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt: Regenerate. * config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Regenerate. * config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: Regenerate. * config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Regenerate. * config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Regenerate. * config/abi/pre/gnu.ver: Add iostream objects to new symver.
* libstdc++: Ensure headers used by fast_float are includedPatrick Palka2023-04-121-0/+4
| | | | | | | | | | | | | | | | | | | | | This makes floating_from_chars.cc explicitly include all headers that are used by the original fast_float amalgamation according to r12-6647-gf5c8b82512f9d3, except: 1. <cctype> since fast_float doesn't seem to use anything from it 2. <cinttypes> since fast_float doesn't seem to use anything directly from it (this header also pulls in <cstdint>) 3. <system_error> since std::errc is naturally already available from <charconv> This avoids potential fast_float build failures on platforms for which some required headers (in particular <cstdint>) end up not getting transitively included from elsewhere. libstdc++-v3/ChangeLog: * src/c++17/floating_from_chars.cc: Include <algorithm>, <iterator>, <limits> and <cstdint>.
* libstdc++: Update tzdata to 2023cJonathan Wakely2023-04-121-4/+2
| | | | | | | | Import the new 2023c tzdata.zi file. libstdc++-v3/ChangeLog: * src/c++20/tzdata.zi: Import new file from 2023c release.
* libstdc++: Update tzdata to 2023a [PR109288]Jonathan Wakely2023-03-282-30/+110
| | | | | | | | | | | | | | | | | | | | | Import the new 2023a tzdata.zi file and update the expiry dates of the hardcoded lists of leapseconds to 2023-12-28. With the new data, Africa/Egypt no longer has a single unbroken sys_info from 2014-09-25 to chrono::year::max(). Only check up to 2014-09-01 so that the test isn't sensitive to differences between 2022g and 2023a data. libstdc++-v3/ChangeLog: PR libstdc++/109288 * include/std/chrono (__detail::__get_leap_second_info): Update expiry date of hardcoded leapseconds list. * src/c++20/tzdb.cc (tzdb_list::_Node::_S_read_leap_seconds()): Likewise. * src/c++20/tzdata.zi: Import new file from 2023a release. * testsuite/std/time/time_zone/get_info_local.cc: Only check transitions for Egypt up to 2014.
* libstdc++: Fix formatting in std::filesystem helper functionJonathan Wakely2023-03-201-1/+2
| | | | | | | libstdc++-v3/ChangeLog: * src/filesystem/ops-common.h (get_temp_directory_from_env): Fix formatting.
* libstdc++: Add comment about symver linker scripts to makefileJonathan Wakely2023-03-142-0/+2
| | | | | | | libstdc++-v3/ChangeLog: * src/Makefile.am: Add comment about linker script fragments. * src/Makefile.in: Regenerate.
* link pthread_join from std::thread ctorAlexandre Oliva2023-03-031-2/+8
| | | | | | | | | | | | | | | | | | Like pthread_create, pthread_join may fail to be statically linked in absent strong uses, so add to user code strong references to both when std::thread objects are created. for libstdc++-v3/ChangeLog PR libstdc++/104852 PR libstdc++/95989 PR libstdc++/52590 * include/bits/std_thread.h (thread::_M_thread_deps): New static implicitly-inline member function. (std::thread template ctor): Pass it to _M_start_thread. * src/c++11/thread.cc (thread::_M_start_thread): Name depend parameter, force it live on entry.
* libstdc++: Make std::chrono::current_zone() default to UTCJonathan Wakely2023-03-011-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | This is consistent with the behaviour of glibc, which assumes UTC when /etc/localtime and TZ do not identify a valid time zone. The fallback tzdb used when no valid tzdata exists always contains the UTC zone, so this change means we have a valid tzdb and valid current zone even in the degenerate case. With this default we no longer need the AIX-specific kluge to try and identify TZ values specifying a 0-offset zone. We can just use the UTC default for those, as it has the same effect. It's still possible for chrono::current_zone() to fail, because the user could have provided a custom tzdata.zi file which doesn't contain the UTC time zone, so the "UTC" default would fail to find a valid zone, and throw an exception. That's just user error, they should not provide bad data and expect reasonable behaviour. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (chrono::tzdb::current_zone()) Use "UTC" if current time zone cannot be determined. * testsuite/std/time/tzdb/1.cc: Remove conditions based on HAVE_TZDB macro and test all members unconditionally.
* libstdc++: Add likely/unlikely attributes to <codecvt> implementationJonathan Wakely2023-02-281-46/+46
| | | | | | | | | | For the common case of converting valid text this improves performance significantly. libstdc++-v3/ChangeLog: * src/c++11/codecvt.cc: Add [[likely]] and [[unlikely]] attributes.
* [libstdc++] do not destruct mutex_pool mutexesAlexandre Oliva2023-02-221-1/+5
| | | | | | | | | | | | | | | | | | | | | | On vxworks, after destroying the semaphore used to implement a mutex, __gthread_mutex_lock fails and __gnu_cxx::__mutex::lock calls __throw_concurrence_lock_error. Nothing ensures the mutex_pool mutexes survive init-once objects containing _Safe_sequence_base. If such an object completes construction before mutex_pool initialization, it will be registered for atexit destruction after the mutex_pool mutexes, so the _M_detach_all() call in the _Safe_sequence_base dtor will use already-destructed mutexes, and basic_string/requirements/citerators_cc fails calling terminate. This patch fixes this problem by ensuring the mutex pool mutexes are constructed on demand, on a statically-allocated buffer, but never destructed. for libstdc++-v3/ChangeLog * src/c++11/shared_ptr.cc (__gnu_internal::get_mutex): Avoid destruction of the mutex pool.
* libstdc++: Enable building libstdc++.{a,so} when !HOSTEDArsen Arsenović2023-02-0610-24/+73
| | | | | | | | | | | | | | | | | | | | | | | | This enables us to provide symbols for placeholders and numeric limits, and allows users to mess about with linker flags less. libstdc++-v3/ChangeLog: * Makefile.am [!_GLIBCXX_HOSTED]: Enable src/ subdirectory. * Makefile.in: Regenerate. * src/Makefile.am [!_GLIBCXX_HOSTED]: Omit compatibility files. There's no history to be compatible with. * src/c++11/Makefile.am [!_GLIBCXX_HOSTED]: Omit hosted-only source files from the build. * src/c++17/Makefile.am [!_GLIBCXX_HOSTED]: Likewise. * src/c++20/Makefile.am [!_GLIBCXX_HOSTED]: Likewise. * src/c++98/Makefile.am [!_GLIBCXX_HOSTED]: Likewise. * 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. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
* libstdc++: Disable building additional archives for freestandingJonathan Wakely2023-02-062-6/+18
| | | | | | | | | | | | This doesn't have any effect yet as we never build anything under libstdc++-v3/src for freestanding, but that will change in the next commit. libstdc++-v3/ChangeLog: * src/Makefile.am [GLIBCXX_HOSTED] (SUBDIRS): Do not add filesystem, libbacktrace and experimental. * src/Makefile.in: Regenerate.
* libstdc++: Use ENOSYS for unsupported filesystem ops on AVRJonathan Wakely2023-02-021-1/+6
| | | | | | | | | | | | Because avr-libc <errno.h> defines most error numbers with duplicate values it's not sufficient to check #ifdef ENOTSUP when deciding which std::errc constant to use for the filesystem library's __unsupported() helper. Add a special case for AVR to always use the ENOSYS value. libstdc++-v3/ChangeLog: * src/filesystem/ops-common.h [AVR] (__unsupported): Always use errc::function_not_supported instead of errc::not_supported.
* libstdc++: Fix std::filesystem errors with -fkeep-inline-functions [PR108636]Jonathan Wakely2023-02-021-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With -fkeep-inline-functions there are linker errors when including <filesystem>. This happens because there are some filesystem::path constructors defined inline which call non-exported functions defined in the library. That's usually not a problem, because those constructors are only called by code that's also inside the library. But when the header is compiled with -fkeep-inline-functions those inline functions are emitted even though they aren't called. That then creates an undefined reference to the other library internsl. The fix is to just move the private constructors into the library where they are called. That way they are never even seen by users, and so not compiled even if -fkeep-inline-functions is used. On trunk there is a second problem, which is that the new equality operators for comparing directory iterators with default_sentinel use the shared_ptr::operator bool() conversion operator. The shared_ptr specializations used by directory iterators are explicitly instantiated in the library, but the bool conversion operators are not exported. This causes linker errors at -O0 or with -fkeep-inline-functions. That just requires the conversion operators to be exported. libstdc++-v3/ChangeLog: PR libstdc++/108636 * config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Export shared_ptr conversion operators for directory iterator comparisons with std::default_sentinel_t. * include/bits/fs_path.h (path::path(string_view, _Type)) (path::_Cmpt::_Cmpt(string_view, _Type, size_t)): Move inline definitions to ... * src/c++17/fs_path.cc: ... here. * testsuite/27_io/filesystem/path/108636.cc: New test.
* libstdc++: Fix std::random_device for avrJonathan Wakely2023-02-011-0/+2
| | | | | | | | | | | | | This fixes a build failure that affects avr, but could affect other targets in theory. The _M_fini function should not try to use ::open or ::fopen if _GLIBCXX_USE_DEV_RANDOM is not defined, because no file can ever have been opened. libstdc++-v3/ChangeLog: * src/c++11/random.cc (random_device::_M_fini): Do not try to close the file handle if the target doesn't support the /dev/random and /dev/urandom files.
* libstdc++: Fix build failures for avrJonathan Wakely2023-02-013-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The abr-libc <errno.h> does not define EOVERFLOW, which means that std::errc::value_too_large is not defined, and so <charconv> cannot be compiled. Define value_too_large for avr with a value that does not clash with any that is defined in <errno.h>. This is a kluge to fix bootstrap for avr; it can be removed after PR libstdc++/104883 is resolved. The avr-libc <errno.h> fails to meet the C and POSIX requirements that each error macro has a distinct integral value, and is usable in #if directives. Add a special case for avr to system_error.cc so that only the valid errors are recognized. Also disable the errno checks in std::filesystem::remove_all that assume a meaningful value for errno. On avr-libc <unistd.h> exists but does not define the POSIX functions needed by std::filesystem, so _GLIBCXX_HAVE_UNISTD_H is not sufficient to check for basic POSIX APIs. Check !defined __AVR__ as well as _GLIBCXX_HAVE_UNISTD_H before using those functions. This is a kluge and we should really have a specific macro that says the required functions are available. libstdc++-v3/ChangeLog: * config/os/generic/error_constants.h (errc::value_too_large) [__AVR__]: Define. * src/c++11/system_error.cc (system_category::default_error_condition) [__AVR__]: Only match recognize values equal to EDOM, ERANGE, ENOSYS and EINTR. * src/c++17/fs_ops.cc (fs::current_path) [__AVR__]: Do not check for ENOENT etc. in switch. (fs::remove_all) [__AVR__]: Likewise. * src/filesystem/ops-common.h [__AVR__]: Do not use POSIX open, close etc.
* libstdc++: Use constant for name of tzdata fileJonathan Wakely2023-01-271-1/+1
| | | | | | | | | | There's a string_view with this filename, which should have been used instead of a string literal. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (tzdata_stream): Use constant instead of string literal.
* libstdc++: Add workaround for old tzdata.zi filesJonathan Wakely2023-01-261-15/+34
| | | | | | | | | | | | | | | | | | The tzdata.zi file in the RHEL 6 tzdata-2018e-3.el6 package (with version "unknown") does not conform to the current rules described in the zic(8) man page. Specifically, a Rule name must not start with the character '+' in the current rules, but the older tzdata.zi file used "+" as the name of rules for the "Europe/Sofia" zone. Add a special case to the logic that detects whether a RULES field refers to a named rule or is an offset from standard time. For a string matching exactly "+" treat it as a named Rule, but for any other string starting with '+' treat it as an offset. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (operator>>(istream&, ZoneInfo&)): Allow rules named "+" for compatibility with older tzdata.zi files.
* libstdc++: Fix strings read from /etc/sysconfig/clock [PR108530]Jonathan Wakely2023-01-261-14/+16
| | | | | | | | | | | | | In r13-5339-ge00d5cafbe1a77 I made std::chrono::current_zone() look for DEFAULT_TIMEZONE in /etc/sysconfig/clock but that is the wrong variable. Old Suse systems use TIMEZONE to determine which zone /etc/localtime is a copy of, and old RHEL system use ZONE. libstdc++-v3/ChangeLog: PR libstdc++/108530 * src/c++20/tzdb.cc (current_zone): Look for TIMEZONE or ZONE in /etc/sysconfig/clock, not DEFAULT_TIMEZONE.
* libstdc++: Use /etc/sysconfig/clock for std::chrono::current_zone() [PR108530]Jonathan Wakely2023-01-241-2/+22
| | | | | | | | | | | | On some systems /etc/localtime is a tzfile, not a symlink to one. We cannot use it to determine the current time zone in that case. See if /etc/sysconfig/clock sets the variable DEFAULT_TIMEZONE instead. libstdc++-v3/ChangeLog: PR libstdc++/108530 * src/c++20/tzdb.cc (current_zone): Look for DEFAULT_TIMEZONE in /etc/sysconfig/clock.
* libstdc++: [_GLIBCXX_DEBUG] Remove useless constructor checksFrançois Dumont2023-01-231-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | Creating a safe iterator from a normal iterator is done within the library where we already know that it is done correctly. The rare situation where a user would use safe iterators for his own purpose is non-Standard code so outside _GLIBCXX_DEBUG scope. For those reasons the __msg_init_singular is useless and can be removed. Additionally in the copy constructor used for post-increment and post-decrement operators the __msg_init_copy_singular check can also be ommitted because of the preliminary __msg_bad_incr and __msg_bad_decr checks. libstdc++-v3/ChangeLog: * include/debug/safe_iterator.h (_Safe_iterator<>::_Unchecked): New. (_Safe_iterator(const _Safe_iterator&, _Unchecked)): New. (_Safe_iterator::operator++(int)): Use latter. (_Safe_iterator::operator--(int)): Likewise. (_Safe_iterator(_Iterator, const _Safe_sequence_base*)): Remove !_M_insular() check. * include/debug/safe_local_iterator.h (_Safe_local_iterator<>::_Unchecked): New. (_Safe_local_iterator(const _Safe_local_iterator&, _Unchecked)): New. (_Safe_local_iterator::operator++(int)): Use latter. * src/c++11/debug.cc (_S_debug_messages): Add as comment the _Debug_msg_id entry associated to the array entry.
* Regenerate Makefile.in files.Martin Liska2023-01-171-1/+1
| | | | | | | | | | | | | | | | | | | | libbacktrace/ChangeLog: * Makefile.in: Regenerate. libgomp/ChangeLog: * Makefile.in: Regenerate. * configure: Regenerate. libphobos/ChangeLog: * Makefile.in: Regenerate. * libdruntime/Makefile.in: Regenerate. libstdc++-v3/ChangeLog: * src/libbacktrace/Makefile.in: Regenerate.
* libstdc++: Fix --with-default-libstdcxx-abi=gcc4-compatible buildJonathan Wakely2023-01-161-0/+3
| | | | | | | | | | | | | | | When building src/c++20/tzdb.cc we currently get a build error for --with-default-libstdcxx-abi=gcc4-compatible because std::chrono::tzdb and related types are not declared for the gcc4-compatible ABI (unless --disable-libstdcxx-dual-abi is also used, so that the gcc4-compatible ABI is the only one built). Define _GLIBCXX_USE_CXX11_ABI in tzdb.cc so that for a dual-abi build we always build it for the cxx11 ABI. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (_GLIBCXX_USE_CXX11_ABI): Define to 1.
* Update copyright years.Jakub Jelinek2023-01-16136-136/+136
|
* libstdc++: Fix copyright notice to use usual form [PR108413]Jonathan Wakely2023-01-161-1/+1
| | | | | | | | | | libstdc++-v3/ChangeLog: PR libstdc++/108413 * include/c_compatibility/stdatomic.h: Change copyright line to be consistent with other headers contributed under DCO terms. * include/std/expected: Add full stop to copyright line. * src/c++20/tzdb.cc: Likewise.
* libstdc++: enable <stacktrace> on windowsBjörn Schäpers2023-01-142-0/+5
| | | | | | | | | | | | | libstdc++-v3/Changelog * acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): Add check for windows.h. Add pecoff as FORMAT_FILE. * config.h.in: Regenerate. * configure: Regenerate. * src/libbacktrace/Makefile.am: Regenerate. * src/libbacktrace/Makefile.in: Add pecoff.c as FORMAT_FILE. Signed-off-by: Björn Schäpers <bjoern@hazardy.de>
* libstdc++: Implement std::chrono::current_zone() for AIX [PR108409]Jonathan Wakely2023-01-141-2/+21
| | | | | | | | libstdc++-v3/ChangeLog: PR libstdc++/108409 * src/c++20/tzdb.cc (current_zone()) [_AIX]: Use TZ environment variable.
* libstdc++: Disable unwanted code for --with-libstdcxx-zoneinfo=noJonathan Wakely2023-01-141-11/+53
| | | | | | | | | | | | | | This allows most of the tzdb functionality to be disabled by configuring with --with-libstdcxx-zoneinfo=no. This might be desirable for small targets that don't need the time zone support. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (TZDB_DISABLED): Disable all code for loading tzdb. * testsuite/std/time/tzdb/leap_seconds.cc: Require tzdb effective target. * testsuite/std/time/tzdb_list/1.cc: Likewise.
* libstdc++: Embed a static copy of tzdata.ziJonathan Wakely2023-01-144-29/+4318
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a copy of the tzdata.zi file to the library, and allows configuring to use it instead of a copy read from disk at runtime. The content of the file is in the public domain, but will need to be updated to the latest upstream file before making GCC releases. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_ZONEINFO_DIR): Replace the --with-libstdcxx-zoneinfo-dir configure option with --with-libstdcxx-zoneinfo with yes/no/static choices as well as a directory. * config.h.in: Regenerate. * configure: Regenerate. * doc/xml/manual/configure.xml: Document configure option. * doc/html/manual/configure.html: Regenerate. * src/c++20/Makefile.am: Generate tzdata.zi.h header. * src/c++20/Makefile.in: Regenerate. * src/c++20/tzdb.cc (__gnu_cxx::zoneinfo_dir_override): Return a null pointer if no directory is configured. (zoneinfo_dir): Replace with ... (zoneinfo_file): New function. (tzdata_stream): New istream class. (remote_version, reload_tzdb): Use tzdata_stream. * testsuite/lib/libstdc++.exp (check_effective_target_tzdb): Check new _GLIBCXX_STATIC_TZDATA macro and ignore presence of tzdata.zi file in default location. * src/c++20/tzdata.zi: New file.
* libstdc++: Fix Unicode codecvt and add tests [PR86419]Dimitrij Mijoski2023-01-131-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes the conversion from UTF-8 to UTF-16 to properly return partial instead ok. Fixes the conversion from UTF-16 to UTF-8 to properly return partial instead ok. Fixes the conversion from UTF-8 to UCS-2 to properly return partial instead error. Fixes the conversion from UTF-8 to UCS-2 to treat 4-byte UTF-8 sequences as error just by seeing the leading byte. Fixes UTF-8 decoding for all codecvts so they detect error at the end of the input range when the last code point is also incomplete. libstdc++-v3/ChangeLog: PR libstdc++/86419 * src/c++11/codecvt.cc (read_utf8_code_point): Correctly detect errors in incomplete multibyte sequences. (utf16_in): Remove surrogates parameter. Fix conditions for returning partial. (utf16_out): Fix condition for returning partial. (ucs2_in): Do not pass surrogates argument to utf16_in. * testsuite/22_locale/codecvt/codecvt_unicode.cc: New test. * testsuite/22_locale/codecvt/codecvt_unicode.h: New header for tests. * testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: New test.
* libstdc++: Fix tzdb.cc to compile with -fno-exceptionsJonathan Wakely2023-01-101-2/+2
| | | | | | | libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (tzdb_list::_S_init_tzdb): Use __try and __catch macros for exception handling.
* Always define `WIN32_LEAN_AND_MEAN` before <windows.h>LIU Hao2023-01-074-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recently, mingw-w64 has got updated <msxml.h> from Wine which is included indirectly by <windows.h> if `WIN32_LEAN_AND_MEAN` is not defined. The `IXMLDOMDocument` class has a member function named `abort()`, which gets affected by our `abort()` macro in "system.h". `WIN32_LEAN_AND_MEAN` should, nevertheless, always be defined. This can exclude 'APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets' [1], and speed up compilation of these files a bit. [1] https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers gcc/ PR middle-end/108300 * config/xtensa/xtensa-dynconfig.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * diagnostic-color.cc: Likewise. * plugin.cc: Likewise. * prefix.cc: Likewise. gcc/ada/ PR middle-end/108300 * adaint.c: Define `WIN32_LEAN_AND_MEAN` before `#include <windows.h>`. * cio.c: Likewise. * ctrl_c.c: Likewise. * expect.c: Likewise. * gsocket.h: Likewise. * mingw32.h: Likewise. * mkdir.c: Likewise. * rtfinal.c: Likewise. * rtinit.c: Likewise. * seh_init.c: Likewise. * sysdep.c: Likewise. * terminals.c: Likewise. * tracebak.c: Likewise. gcc/jit/ PR middle-end/108300 * jit-w32.h: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libatomic/ PR middle-end/108300 * config/mingw/lock.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libffi/ PR middle-end/108300 * src/aarch64/ffi.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libgcc/ PR middle-end/108300 * config/i386/enable-execute-stack-mingw32.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * libgcc2.c: Likewise. * unwind-generic.h: Likewise. libgfortran/ PR middle-end/108300 * intrinsics/sleep.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libgomp/ PR middle-end/108300 * config/mingw32/proc.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libiberty/ PR middle-end/108300 * make-temp-file.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * pex-win32.c: Likewise. libssp/ PR middle-end/108300 * ssp.c: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. libstdc++-v3/ PR middle-end/108300 * src/c++11/system_error.cc: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * src/c++11/thread.cc: Likewise. * src/c++17/fs_ops.cc: Likewise. * src/filesystem/ops.cc: Likewise. libvtv/ PR middle-end/108300 * vtv_malloc.cc: Define `WIN32_LEAN_AND_MEAN` before <windows.h>. * vtv_rts.cc: Likewise. * vtv_utils.cc: Likewise.
* libstdc++: Suppress -Waddress warning in tzdb.cc [PR108228]Jonathan Wakely2023-01-061-0/+3
| | | | | | | | | | | For some tarets the weak symbol is always defined, so we get a warning that its address is never null. The warning isn't useful in this case, so suppress it. libstdc++-v3/ChangeLog: PR libstdc++/108228 * src/c++20/tzdb.cc (zoneinfo_dir): Add diagnostic pragma.
* libstdc++: Refactor time_zone::_Impl::rules_counter [PR108235]Jonathan Wakely2023-01-061-53/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | Abstract the atomic counter used to synchronize access to time_zone infos behind a Lockable class API, and use atomic_signed_lock_free instead of atomic<int_least32_t>, as that should be the most efficient type. (For futex-supporting targets it makes no difference, but might benefit other targets in future.) The new API allows the calling code to be simpler, without needing to repeat the same error prone preprocessor conditions in multiple places. It also allows using template metaprogramming to decide whether to use the atomic or a mutex, which gives us more flexibility than only using preprocessor conditions. That allows us to choose the mutex implementation for targets such as hppa-hp-hpux11.11 where 32-bit atomics are not lock-free and so would introduce an unwanted dependency on libatomic. libstdc++-v3/ChangeLog: PR libstdc++/108235 * src/c++20/tzdb.cc (time_zone::_Impl::RulesCounter): New class template and partial specialization for synchronizing access to time_zone::_Impl::infos. (time_zone::_M_get_sys_info, reload_tzdb): Adjust uses of rules_counter.
* libstdc++: Support single components in name of chrono::current_zone() ↵Jonathan Wakely2023-01-051-2/+5
| | | | | | | | | | | | | [PR108211] We currently only handle the case where /etc/localtime is a symlink to a path like ".../Etc/UTC" and fail for ".../UTC". This makes both work. libstdc++-v3/ChangeLog: PR libstdc++/108211 * src/c++20/tzdb.cc (chrono::current_zone()): Check for zone using only last component of the name.
* libstdc++: Only use std::atomic<tzdb_list::_Node*> if lock free [PR108228]Jonathan Wakely2023-01-051-34/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes linker errors for hppa-hp-hpux11.11 due to an undefined weak symbol and the use of atomic operations that require libatomic. The weak symbol can simply be defined, which we already do for darwin. The std::atomic<_Node*> is only an optimization, so can be avoided for targets where the underlying atomic ops aren't available without help from libatomic. The accesses to the std::atomic<_Node*> can be abstracted behind a new API for getting and setting the cached value, and then the atomics can be used conditionally. libstdc++-v3/ChangeLog: PR libstdc++/108228 PR libstdc++/108235 * config/abi/pre/gnu.ver: Move zoneinfo_dir_override export to the latest symbol version. * src/c++20/tzdb.cc (USE_ATOMIC_SHARED_PTR): Define to 0 if atomic<_Node*> is not always lock free. (USE_ATOMIC_LIST_HEAD): New macro. [__hpux__] (__gnu_cxx::zoneinfo_dir_override()): Provide definition of weak symbol. (tzdb_list::_Node::_S_head): Rename to _S_head_cache. (tzdb_list::_Node::_S_list_head): New function for accessing list head efficiently. (tzdb_list::_Node::_S_cache_list_head): New function for updating _S_list_head.
* libstdc++: Test for tzdata.zi before fallback version files.Iain Sandoe2022-12-241-7/+10
| | | | | | | | | | | | | | | | Several systems/distributions do not provide the raw tzdata.zi file in their zoneinfo installation. However, we might provide an alternate installation path at configure time, so that we should check for the tzdata.zi file first and then fall back to system-specific files like +VERSION etc. on those systems. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (remote_version): Look for the tzdata.zi file before falling back to system-specific ones on Darwin and BSD.
* Reimplement GNU threads library on native WindowsEric Botcazou2022-12-231-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reimplements the GNU threads library on native Windows (except for the Objective-C specific subset) using direct Win32 API calls, in lieu of the implementation based on semaphores. This base implementations requires Windows XP/Server 2003, which was the default minimal setting of MinGW-W64 until end of 2020. This also adds the support required for the C++11 threads, using again direct Win32 API calls; this additional layer requires Windows Vista/Server 2008 and is enabled only if _WIN32_WINNT >= 0x0600. This also changes libstdc++ to pass -D_WIN32_WINNT=0x0600 but only when the switch --enable-libstdcxx-threads is passed, which means that C++11 threads are still disabled by default *unless* MinGW-W64 itself is configured for Windows Vista/Server 2008 or later by default (this has been the case in the development version since end of 2020, for earlier versions you can configure it --with-default-win32-winnt=0x0600 to get the same effect). I only manually tested it on i686-w64-mingw32 and x86_64-w64-mingw32 but AdaCore has used it in their C/C++/Ada compilers for 3 years now and the 30_threads chapter of the libstdc++ testsuite was clean at the time. 2022-10-31 Eric Botcazou <ebotcazou@adacore.com> libgcc/ * config.host (i[34567]86-*-mingw*): Add thread fragment after EH one as well as new i386/t-slibgcc-mingw fragment. (x86_64-*-mingw*): Likewise. * config/i386/gthr-win32.h: If _WIN32_WINNT is at least 0x0600, define both __GTHREAD_HAS_COND and __GTHREADS_CXX0X to 1. Error out if _GTHREAD_USE_MUTEX_TIMEDLOCK is 1. Include stdlib.h instead of errno.h and do not include _mingw.h. (CONST_CAST2): Add specific definition for C++. (ATTRIBUTE_UNUSED): New macro. (__UNUSED_PARAM): Delete. Define WIN32_LEAN_AND_MEAN before including windows.h. (__gthread_objc_data_tls): Use TLS_OUT_OF_INDEXES instead of (DWORD)-1. (__gthread_objc_init_thread_system): Likewise. (__gthread_objc_thread_get_data): Minor tweak. (__gthread_objc_condition_allocate): Use ATTRIBUTE_UNUSED. (__gthread_objc_condition_deallocate): Likewise. (__gthread_objc_condition_wait): Likewise. (__gthread_objc_condition_broadcast): Likewise. (__gthread_objc_condition_signal): Likewise. Include sys/time.h. (__gthr_win32_DWORD): New typedef. (__gthr_win32_HANDLE): Likewise. (__gthr_win32_CRITICAL_SECTION): Likewise. (__gthr_win32_CONDITION_VARIABLE): Likewise. (__gthread_t): Adjust. (__gthread_key_t): Likewise. (__gthread_mutex_t): Likewise. (__gthread_recursive_mutex_t): Likewise. (__gthread_cond_t): New typedef. (__gthread_time_t): Likewise. (__GTHREAD_MUTEX_INIT_DEFAULT): Delete. (__GTHREAD_RECURSIVE_MUTEX_INIT_DEFAULT): Likewise. (__GTHREAD_COND_INIT_FUNCTION): Define. (__GTHREAD_TIME_INIT): Likewise. (__gthr_i486_lock_cmp_xchg): Delete. (__gthr_win32_create): Declare. (__gthr_win32_join): Likewise. (__gthr_win32_self): Likewise. (__gthr_win32_detach): Likewise. (__gthr_win32_equal): Likewise. (__gthr_win32_yield): Likewise. (__gthr_win32_mutex_destroy): Likewise. (__gthr_win32_cond_init_function): Likewise if __GTHREADS_HAS_COND is 1. (__gthr_win32_cond_broadcast): Likewise. (__gthr_win32_cond_signal): Likewise. (__gthr_win32_cond_wait): Likewise. (__gthr_win32_cond_timedwait): Likewise. (__gthr_win32_recursive_mutex_init_function): Delete. (__gthr_win32_recursive_mutex_lock): Likewise. (__gthr_win32_recursive_mutex_unlock): Likewise. (__gthr_win32_recursive_mutex_destroy): Likewise. (__gthread_create): New inline function. (__gthread_join): Likewise. (__gthread_self): Likewise. (__gthread_detach): Likewise. (__gthread_equal): Likewise. (__gthread_yield): Likewise. (__gthread_cond_init_function): Likewise if __GTHREADS_HAS_COND is 1. (__gthread_cond_broadcast): Likewise. (__gthread_cond_signal): Likewise. (__gthread_cond_wait): Likewise. (__gthread_cond_timedwait): Likewise. (__GTHREAD_WIN32_INLINE): New macro. (__GTHREAD_WIN32_COND_INLINE): Likewise. (__GTHREAD_WIN32_ACTIVE_P): Likewise. Define WIN32_LEAN_AND_MEAN before including windows.h. (__gthread_once): Minor tweaks. (__gthread_key_create): Use ATTRIBUTE_UNUSED and TLS_OUT_OF_INDEXES. (__gthread_key_delete): Minor tweak. (__gthread_getspecific): Likewise. (__gthread_setspecific): Likewise. (__gthread_mutex_init_function): Reimplement. (__gthread_mutex_destroy): Likewise. (__gthread_mutex_lock): Likewise. (__gthread_mutex_trylock): Likewise. (__gthread_mutex_unlock): Likewise. (__gthr_win32_abs_to_rel_time): Declare. (__gthread_recursive_mutex_init_function): Reimplement. (__gthread_recursive_mutex_destroy): Likewise. (__gthread_recursive_mutex_lock): Likewise. (__gthread_recursive_mutex_trylock): Likewise. (__gthread_recursive_mutex_unlock): Likewise. (__gthread_cond_destroy): New inline function. (__gthread_cond_wait_recursive): Likewise. * config/i386/gthr-win32.c: Delete everything. Include gthr-win32.h to get the out-of-line version of inline routines. Add compile-time checks for the local version of the Win32 types. * config/i386/gthr-win32-cond.c: New file. * config/i386/gthr-win32-thread.c: Likewise. * config/i386/t-gthr-win32: Add config/i386/gthr-win32-thread.c to the EH part, config/i386/gthr-win32-cond.c and config/i386/gthr-win32.c to the static version of libgcc. * config/i386/t-slibgcc-mingw: New file. * config/i386/libgcc-mingw.ver: Likewise. libstdc++-v3/ * acinclude.m4 (GLIBCXX_EXPORT_FLAGS): Substitute CPPFLAGS. (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Set ac_has_sched_yield and ac_has_win32_sleep to yes for MinGW. Change HAVE_WIN32_SLEEP into _GLIBCXX_USE_WIN32_SLEEP. (GLIBCXX_CHECK_GTHREADS): Add _WIN32_THREADS to compilation flags for Win32 threads and force _GTHREAD_USE_MUTEX_TIMEDLOCK to 0 for them. Add -D_WIN32_WINNT=0x0600 to compilation flags if yes was configured and add it to CPPFLAGS on success. * config.h.in: Regenerate. * configure: Likewise. * config/os/mingw32-w64/os_defines.h (_GLIBCXX_USE_GET_NPROCS_WIN32): Define to 1. * config/os/mingw32/os_defines.h (_GLIBCXX_USE_GET_NPROCS_WIN32): Ditto * src/c++11/thread.cc (get_nprocs): Provide Win32 implementation if _GLIBCXX_USE_GET_NPROCS_WIN32 is defined. Replace HAVE_WIN32_SLEEP with USE_WIN32_SLEEP. * testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc: Add missing conditional compilation. * testsuite/lib/libstdc++.exp (check_v3_target_sleep): Add support for _GLIBCXX_USE_WIN32_SLEEP. (check_v3_target_nprocs): Likewise for _GLIBCXX_USE_GET_NPROCS_WIN32. Signed-off-by: Eric Botcazou <ebotcazou@adacore.com> Signed-off-by: Jonathan Yong <10walls@gmail.com>
* libstdc++: Fix Darwin bootstrap error in src/c++20/tzdb.ccJonathan Wakely2022-12-231-3/+10
| | | | | | | | | | Mach-O requires weak symbols to have a definition, so add a default implementation of __gnu_cxx::zoneinfo_dir_override. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc [__APPLE__] (zoneinfo_dir_override): Add definition.
* libstdc++: Remove problematic static_assert from src/c++20/tzdb.ccJonathan Wakely2022-12-231-1/+0
| | | | | | | | | | | This assertion fails for cris-elf where sizeof(datetime) is only 7, due to lower alignment requirements. The assertion was used while I was writing the code to check that the objects were as compact as I wanted, but it doesn't need to be kept now. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc: Remove static_assert.
* libstdc++: Improve output of default contract violation handler [PR107792]Arsen Arsenović2022-12-221-11/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the output more readable. Don't output anything unless verbose termination is enabled at configure-time. The testsuite change was almost entirely mechanical. Save for two files which had very short matches, these changes were produced by two seds and a Perl script, for the more involved cases. The latter will be added in a subsequent commit. The former are as follows: sed -E -i "/dg-output/s/default std::handle_contract_violation called: \ (\S+) (\S+) (\S+(<[A-Za-z0-9, ]*)?>?)\ /contract violation in function \3 at \1:\2: /" *.C sed -i '/dg-output/s/ */ /g' Whichever files remained failing after the above changes were checked-out, re-ran, with output extracted, and ran through dg-out-generator.pl. Co-Authored-By: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/107792 PR libstdc++/107778 * src/experimental/contract.cc (handle_contract_violation): Make output more readable. gcc/testsuite/ChangeLog: * g++.dg/contracts/contracts-access1.C: Convert to new default violation handler. * g++.dg/contracts/contracts-assume2.C: Ditto. * g++.dg/contracts/contracts-config1.C: Ditto. * g++.dg/contracts/contracts-constexpr1.C: Ditto. * g++.dg/contracts/contracts-ctor-dtor1.C: Ditto. * g++.dg/contracts/contracts-deduced2.C: Ditto. * g++.dg/contracts/contracts-friend1.C: Ditto. * g++.dg/contracts/contracts-multiline1.C: Ditto. * g++.dg/contracts/contracts-post3.C: Ditto. * g++.dg/contracts/contracts-pre10.C: Ditto. * g++.dg/contracts/contracts-pre2.C: Ditto. * g++.dg/contracts/contracts-pre2a2.C: Ditto. * g++.dg/contracts/contracts-pre3.C: Ditto. * g++.dg/contracts/contracts-pre4.C: Ditto. * g++.dg/contracts/contracts-pre5.C: Ditto. * g++.dg/contracts/contracts-pre7.C: Ditto. * g++.dg/contracts/contracts-pre9.C: Ditto. * g++.dg/contracts/contracts-redecl3.C: Ditto. * g++.dg/contracts/contracts-redecl4.C: Ditto. * g++.dg/contracts/contracts-redecl6.C: Ditto. * g++.dg/contracts/contracts-redecl7.C: Ditto. * g++.dg/contracts/contracts-tmpl-spec1.C: Ditto. * g++.dg/contracts/contracts-tmpl-spec2.C: Ditto. * g++.dg/contracts/contracts-tmpl-spec3.C: Ditto. * g++.dg/contracts/contracts10.C: Ditto. * g++.dg/contracts/contracts14.C: Ditto. * g++.dg/contracts/contracts15.C: Ditto. * g++.dg/contracts/contracts16.C: Ditto. * g++.dg/contracts/contracts17.C: Ditto. * g++.dg/contracts/contracts19.C: Ditto. * g++.dg/contracts/contracts25.C: Ditto. * g++.dg/contracts/contracts3.C: Ditto. * g++.dg/contracts/contracts35.C: Ditto. * g++.dg/contracts/contracts5.C: Ditto. * g++.dg/contracts/contracts7.C: Ditto. * g++.dg/contracts/contracts9.C: Ditto.