public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* shared_ptr's reference counter thread safety on ARM Cortex-M
@ 2018-02-19 10:58 karel pavlata
  2018-02-19 15:07 ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: karel pavlata @ 2018-02-19 10:58 UTC (permalink / raw)
  To: libstdc++

As per
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_concurrency.html
libstdc++ does not guarantee thread safety with gcc built with
--enable-threads=single, which is a case for all baremetal toolchains for
ARM (Cortex-M) I've come across (which makes sense).
When I examined  the dependencies for shared_ptr's reference counter it
came down to __default_lock_policy being set to _S_single in concurrence.h
which propagates to class _Sp_counted_base in shared_ptr_base.h. Also is
_GLIBCXX_ATOMIC_BUILTINS not being set even when __atomic_fetch_add is
available on the target platform and compiles into a pair of LDREX/STREX
instructions which could be used to implement _S_atomic lock policy

Why is _S_atomic not used? Is there a way to build/configure gcc/libstdc++
and/or the application to get thread safe shared_ptr on this (bare-metal
ARM) platform?

If I understand it correctly there's technically nothing that should
prevent it.

regards
karel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-20 20:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 10:58 shared_ptr's reference counter thread safety on ARM Cortex-M karel pavlata
2018-02-19 15:07 ` Jonathan Wakely
2018-02-19 15:38   ` Oleg Endo
2018-02-19 15:45     ` Jonathan Wakely
2018-02-19 19:33       ` karel pavlata
2018-02-20 20:05         ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).