This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: libstdc++-v3/config/cpu/m68k/atomicity.h
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Fri, 9 Sep 2016 14:14:50 +0100
- Subject: Re: libstdc++-v3/config/cpu/m68k/atomicity.h
- Authentication-results: sourceware.org; auth=none
- References: <57D272A7.8070402@embedded-brains.de>
On 09/09/16 10:28 +0200, Sebastian Huber wrote:
Hello,
for RTEMS there is a special case in:
libstdc++-v3/config/cpu/m68k/atomicity.h
[...]
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
[...]
#elif defined(__rtems__)
// TAS/JBNE is unsafe on systems with strict priority-based scheduling.
// Disable interrupts, which we can do only from supervisor mode.
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
_Atomic_word __result;
short __level, __tmpsr;
__asm__ __volatile__ ("move%.w %%sr,%0\n\tor%.l %0,%1\n\tmove%.w
%1,%%sr"
: "=d"(__level), "=d"(__tmpsr) : "1"(0x700));
__result = *__mem;
*__mem = __result + __val;
__asm__ __volatile__ ("move%.w %0,%%sr" : : "d"(__level));
return __result;
}
#else
[...]
Since C++14 is the default for GCC 6, would it be possible to use the
standard atomic operations instead? For targets that don't support the
operations in hardware, this would lead to a libatomic dependency.
C++14 isn't relevant, since the std::atomic_* operations only work on
std::atomic<T> objects, not _Atomic_word objects.
The code could use the same __atomic_* built-ins that are used by
std::atomic<T>, but they are always available, so C++14 isn't needed
for that.
As you say, that introduces a dependency on libatomic, so would be a
decision for the target maintainer to make.