https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122172
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We could also just do this:
--- a/libstdc++-v3/config/cpu/cris/atomic_word.h
+++ b/libstdc++-v3/config/cpu/cris/atomic_word.h
@@ -27,5 +27,6 @@
// This entity must not cross a page boundary.
typedef int _Atomic_word __attribute__ ((__aligned__ (4)));
+typedef unsigned int _Atomic_word_unsigned __attribute__ ((__aligned__ (4)));
#endif
--- a/libstdc++-v3/config/cpu/generic/atomic_word.h
+++ b/libstdc++-v3/config/cpu/generic/atomic_word.h
@@ -30,6 +30,7 @@
#define _GLIBCXX_ATOMIC_WORD_H 1
typedef int _Atomic_word;
+typedef unsigned int _Atomic_word_unsigned;
// This is a memory order acquire fence.
--- a/libstdc++-v3/config/cpu/sparc/atomic_word.h
+++ b/libstdc++-v3/config/cpu/sparc/atomic_word.h
@@ -27,8 +27,10 @@
#ifdef __arch64__
typedef long _Atomic_word;
+ typedef unsigned long _Atomic_word_unsigned;
#else
typedef int _Atomic_word;
+ typedef unsigned int _Atomic_word_unsigned;
#endif
#if defined(__sparc_v9__)
--- a/libstdc++-v3/include/ext/atomicity.h
+++ b/libstdc++-v3/include/ext/atomicity.h
@@ -39,9 +39,6 @@
#if __has_include(<sys/single_threaded.h>)
# include <sys/single_threaded.h>
#endif
-#if __cplusplus >= 201103L
-# include <type_traits> // make_unsigned_t
-#endif
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
@@ -96,14 +93,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
_Atomic_word __result = *__mem;
// Do the addition with an unsigned type so that overflow is well defined.
-#if __cplusplus >= 201103L
- std::make_unsigned<_Atomic_word>::type __u;
-#else
- // For most targets make_unsigned_t<_Atomic_word> is unsigned int,
- // but 64-bit sparc uses long for _Atomic_word.
- // Sign-extending to unsigned long works for both cases.
- unsigned long __u;
-#endif
+ _Atomic_word_unsigned __u;
__u = __result;
__u += __val;
*__mem = __u;
@@ -114,11 +104,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__attribute__((__always_inline__))
__atomic_add_single(_Atomic_word* __mem, int __val)
{
-#if __cplusplus >= 201103L
- std::make_unsigned<_Atomic_word>::type __u;
-#else
- unsigned long __u; // see above
-#endif
+ _Atomic_word_unsigned __u;
__u = *__mem;
__u += __val;
*__mem = __u;
Any private ports with custom atomic_word.h files would need to update them,
but that would be fine, I think.