]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Remove unconditional use of atomics in Debug Mode
authorJonathan Wakely <jwakely@redhat.com>
Mon, 11 Sep 2023 15:42:54 +0000 (16:42 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 9 Nov 2023 08:04:29 +0000 (08:04 +0000)
commit0fc5cc6e5a2dfd7dbdd20bc27f975eed155ffb91
treecb69fa1aa9ae4380a4f7b402814f9737586fef42
parentc867a6e5527eb0c109fd53276bcb9cbcf3d8c254
libstdc++: Remove unconditional use of atomics in Debug Mode

The fix for PR 91910 (r10-3426-gf7a3a382279585) introduced unconditional
uses of atomics into src/c++11/debug.cc, which causes linker errors for
arm4t where GCC emits an unresolved reference to __sync_synchronize.

By making the uses of atomics depend on _GLIBCXX_HAS_GTHREADS we can
avoid those unconditional references to __sync_synchronize for targets
where the atomics are unnecessary. As a minor performance optimization
we can also check the __gnu_cxx::__is_single_threaded function to avoid
atomics for single-threaded programs even where they don't cause linker
errors.

libstdc++-v3/ChangeLog:

* src/c++11/debug.cc (acquire_sequence_ptr_for_lock): New
function.
(reset_sequence_ptr): New function.
(_Safe_iterator_base::_M_detach)
(_Safe_local_iterator_base::_M_detach): Replace bare atomic_load
with acquire_sequence_ptr_for_lock.
(_Safe_iterator_base::_M_reset): Replace bare atomic_store with
reset_sequence_ptr.

(cherry picked from commit 4a2766ed00a47904dc8b85bf0538aa116d8e658b)
libstdc++-v3/src/c++11/debug.cc