_ZNSt6chrono9gps_clock3nowEv;
_ZNSt6chrono9tai_clock3nowEv;
+ # mutex& __syncbuf_get_mutex(void*)
+ _ZSt19__syncbuf_get_mutexPv;
+
# __gnu_debug::_Safe_iterator_base and _Safe_sequence_base const
_ZN11__gnu_debug19_Safe_iterator_base9_M_attachEPKNS_19_Safe_sequence_baseEb;
_ZN11__gnu_debug19_Safe_iterator_base16_M_attach_singleEPKNS_19_Safe_sequence_baseEb;
#include <bits/alloc_traits.h>
#include <bits/allocator.h>
#include <bits/functexcept.h>
-#include <bits/functional_hash.h>
#include <bits/std_mutex.h>
namespace std _GLIBCXX_VISIBILITY(default)
struct __mutex
{
#if _GLIBCXX_HAS_GTHREADS
- mutex* _M_mtx;
+ mutex* _M_mtx = nullptr;
- __mutex(void* __t)
- : _M_mtx(__t ? &_S_get_mutex(__t) : nullptr)
- { }
+ __mutex(void* __t) // __t is the underlying sbuf, as hash seed.
+ {
+ extern mutex& __syncbuf_get_mutex(void*); // in src/c++20/syncbuf.cc
+ if (__t) _M_mtx = &__syncbuf_get_mutex(__t);
+ }
void
swap(__mutex& __other) noexcept
{
_M_mtx->unlock();
}
-
- // FIXME: This should be put in the .so
- static mutex&
- _S_get_mutex(void* __t)
- {
- const unsigned char __mask = 0xf;
- static mutex __m[__mask + 1];
-
- auto __key = _Hash_impl::hash(__t) & __mask;
- return __m[__key];
- }
#else
__mutex(void*) { }
void swap(__mutex&&) noexcept { }
inst_sources =
endif
-sources = tzdb.cc format.cc atomic.cc clock.cc
+sources = tzdb.cc format.cc atomic.cc clock.cc syncbuf.cc
vpath % $(top_srcdir)/src/c++20
@ENABLE_EXTERN_TEMPLATE_TRUE@inst_sources = \
@ENABLE_EXTERN_TEMPLATE_TRUE@ sstream-inst.cc
-sources = tzdb.cc format.cc atomic.cc clock.cc
+sources = tzdb.cc format.cc atomic.cc clock.cc syncbuf.cc
@GLIBCXX_HOSTED_FALSE@libc__20convenience_la_SOURCES =
@GLIBCXX_HOSTED_TRUE@libc__20convenience_la_SOURCES = $(sources) $(inst_sources)
--- /dev/null
+// Explicit instantiation file.
+
+// Copyright (C) 2020-2025 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+#include <syncstream>
+#include <bits/functional_hash.h>
+
+#if _GLIBCXX_HAS_GTHREADS
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+mutex&
+__syncbuf_get_mutex(void* __t)
+ {
+ const unsigned char __mask = 0xf;
+ static mutex __m[__mask + 1];
+
+ auto __key = _Hash_impl::hash(__t) & __mask;
+ return __m[__key];
+ }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+}
+#endif // GTHREADS