aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-06-29 11:40:32 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-06-29 16:17:23 +0100
commit5dfdf0ae4dca44a4f572c346d322fd6244598190 (patch)
treeb808ea0b56d6bc520e53c7bcef06fe675d5c0912 /gcc
parentff29ee6af88f709e08ee467869d8c1b13889a724 (diff)
downloadgcc-5dfdf0ae4dca44a4f572c346d322fd6244598190.zip
gcc-5dfdf0ae4dca44a4f572c346d322fd6244598190.tar.gz
gcc-5dfdf0ae4dca44a4f572c346d322fd6244598190.tar.bz2
libstdc++: Fix src/c++20/tzdb.cc for non-constexpr std::mutex
Building libstdc++ reportedly fails for targets without lock-free std::atomic<T*> which don't define __GTHREAD_MUTEX_INIT: src/c++20/tzdb.cc:110:21: error: 'constinit' variable 'std::chrono::{anonymous}::list_mutex' does not have a constant initializer src/c++20/tzdb.cc:110:21: error: call to non-'constexpr' function 'std::mutex::mutex()' The solution implemented by this commit is to use a local static mutex when it can't be constinit, so that it's constructed on first use. With this change, we can also simplify the preprocessor logic for defining USE_ATOMIC_SHARED_PTR. It now depends on the same conditions as USE_ATOMIC_LIST_HEAD, so in theory we could have a single macro. Keeping them separate would allow us to replace the use of atomic<shared_ptr<T>> with a mutex if that performs better, without having to give up on the lock-free cache for fast access to the list head. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (USE_ATOMIC_SHARED_PTR): Define consistently with USE_ATOMIC_LIST_HEAD. (list_mutex): Replace global object with function. Use local static object when std::mutex constructor isn't constexpr.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions