My r16-3810-g6456da6bab8a2c changes broke bootstrap for targets that use
the mutex-based atomic helpers. This fixes it by casting away the
unnecessary volatile-qualification on the _Atomic_word* before passing
it to __exchange_and_add_single.

libstdc++-v3/ChangeLog:

        * config/cpu/generic/atomicity_mutex/atomicity.h
        (__exchange_and_add): Use const_cast to remove volatile.
---

Tested powerpc64le-linux, bootstrapped on msp430-elf and
pru-unknown-elf.

Pushed to trunk.

 libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h 
b/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h
index 7d5772d54840..d088f69fe9a4 100644
--- a/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h
+++ b/libstdc++-v3/config/cpu/generic/atomicity_mutex/atomicity.h
@@ -44,7 +44,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
   {
     __gnu_cxx::__scoped_lock sentry(get_atomic_mutex());
-    return __gnu_cxx::__exchange_and_add_single(__mem, __val);
+    // The volatile qualification is meaningless. All changes to the memory
+    // location happen while this mutex is locked so it's not volatile at all.
+    auto __mem2 = const_cast<_Atomic_word*>(__mem);
+    return __gnu_cxx::__exchange_and_add_single(__mem2, __val);
   }
 
   void
-- 
2.51.0

Reply via email to