diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-05-04 13:34:23 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-05-04 13:37:31 +0100 |
commit | ec40967f1323069da3a5a45286f71fa4f80926df (patch) | |
tree | 6f9c1c6e4015570d63161c8aa85461487135bd5f /libstdc++-v3/ChangeLog | |
parent | f9e1ea10e657af9fb02fafecf1a600740fd34409 (diff) | |
download | gcc-ec40967f1323069da3a5a45286f71fa4f80926df.zip gcc-ec40967f1323069da3a5a45286f71fa4f80926df.tar.gz gcc-ec40967f1323069da3a5a45286f71fa4f80926df.tar.bz2 |
libstdc++: Make pmr::synchronized_pool_resource work without libpthread (PR 94936)
I implicitly assumed that programs using pmr::synchronized_pool_resource
would also be using multiple threads, and so the weak symbols in
gthr-posix.h would be resolved by linking to libpthread. If that isn't
true then it crashes when trying to use pthread_key_create.
This commit makes the pool resource check __gthread_active_p() before
using thread-specific data, and just use a single set of memory pools
when there's only a single thread.
PR libstdc++/94936
* src/c++17/memory_resource.cc (synchronized_pool_resource::_TPools):
Add comment about single-threaded behaviour.
(synchronized_pool_resource::_TPools::move_nonempty_chunks()): Hoist
class member access out of loop.
(synchronized_pool_resource::synchronized_pool_resource())
(synchronized_pool_resource::~synchronized_pool_resource())
(synchronized_pool_resource::release()): Check __gthread_active_p
before creating and/or deleting the thread-specific data key.
(synchronized_pool_resource::_M_thread_specific_pools()): Adjust
assertions.
(synchronized_pool_resource::do_allocate(size_t, size_t)): Add fast
path for single-threaded case.
(synchronized_pool_resource::do_deallocate(void*, size_t, size_t)):
Likewise. Return if unable to find a pool that owns the allocation.
* testsuite/20_util/synchronized_pool_resource/allocate_single.cc:
New test.
* testsuite/20_util/synchronized_pool_resource/cons_single.cc: New
test.
* testsuite/20_util/synchronized_pool_resource/release_single.cc: New
test.
Diffstat (limited to 'libstdc++-v3/ChangeLog')
-rw-r--r-- | libstdc++-v3/ChangeLog | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7f11117..0624bb7 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,27 @@ +2020-05-04 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/94936 + * src/c++17/memory_resource.cc (synchronized_pool_resource::_TPools): + Add comment about single-threaded behaviour. + (synchronized_pool_resource::_TPools::move_nonempty_chunks()): Hoist + class member access out of loop. + (synchronized_pool_resource::synchronized_pool_resource()) + (synchronized_pool_resource::~synchronized_pool_resource()) + (synchronized_pool_resource::release()): Check __gthread_active_p + before creating and/or deleting the thread-specific data key. + (synchronized_pool_resource::_M_thread_specific_pools()): Adjust + assertions. + (synchronized_pool_resource::do_allocate(size_t, size_t)): Add fast + path for single-threaded case. + (synchronized_pool_resource::do_deallocate(void*, size_t, size_t)): + Likewise. Return if unable to find a pool that owns the allocation. + * testsuite/20_util/synchronized_pool_resource/allocate_single.cc: + New test. + * testsuite/20_util/synchronized_pool_resource/cons_single.cc: New + test. + * testsuite/20_util/synchronized_pool_resource/release_single.cc: New + test. + 2020-05-03 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/94933 |