This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
_GLIBCXX_ATOMIC_BUILTINS too coarse
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 4 Apr 2012 21:40:35 +0100
- Subject: _GLIBCXX_ATOMIC_BUILTINS too coarse
While debugging PR 52839 I discovered that on 32-bit powerpc
_GLIBCXX_ATOMIC_BUILTINS is not defined because there are no 8-byte
atomics:
configure:15247: checking for atomic builtins for long long
[...]
/home/jwakely/build/powerpc64-unknown-linux-gnu/32/libstdc++-v3/conftest.cpp:30:
undefined reference to `__atomic_fetch_add_8'
/home/jwakely/build/powerpc64-unknown-linux-gnu/32/libstdc++-v3/conftest.cpp:32:
undefined reference to `__atomic_compare_exchange_8'
[...]
configure:15286: result: no
configure:15463: WARNING: No native atomic operations are provided for
this platform.
configure:15471: WARNING: They will be faked using a mutex.
configure:15473: WARNING: Performance of certain classes will degrade
as a result.
This means that target uses the version of __exchange_and_add in
config/cpu/generic/atomicity_mutex/atomicity.h
That seems unfortunate, when __exchange_and_add only needs to work
with a 4-byte _Atomic_word and the platform does support the required
operations on 4-byte types. We might not be able to completely support
<atomic> on that platform but the library's own reference counting
needs are pretty basic. We're unnecessarily making basic_string,
shared_ptr, locales etc. use a global mutex when they could use atomic
ops. This is a Bad Thing.
We could have a new config macro such as _GLIBCXX_ATOMIC_BUILTINS_WORD
to say that atomics are available for _Atomic_word, but I don't think
the definition of _Atomic_word is available at configure-time, so it's
not quite that simple.