public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 8/8] libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103]
@ 2024-02-27 11:42 Jonathan Wakely
  2024-02-27 14:33 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2024-02-27 11:42 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested x86_64-linux. I think we should make this change, because
otherwise we define the typedefs for platforms with no lock-free
atomics, like hppa-hpux. Instead of lying, those typedefs should be
absent on that target.

-- >8 --

libstdc++-v3/ChangeLog:

	PR libstdc++/114103
	* include/bits/version.def (atomic_lock_free_type_aliases): Add
	extra_cond to check for at least one always-lock-free type.
	* include/bits/version.h: Regenerate.
	* include/std/atomic (atomic_signed_lock_free)
	(atomic_unsigned_lock_free): Only use always-lock-free types.
---
 libstdc++-v3/include/bits/version.def | 1 +
 libstdc++-v3/include/bits/version.h   | 2 +-
 libstdc++-v3/include/std/atomic       | 6 +++---
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index 502961eb269..d298420121b 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -739,6 +739,7 @@ ftms = {
   values = {
     v = 201907;
     cxxmin = 20;
+    extra_cond = "(__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2";
   };
 };
 
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 7a6fbd35e2e..9107b45a484 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -819,7 +819,7 @@
 #undef __glibcxx_want_atomic_float
 
 #if !defined(__cpp_lib_atomic_lock_free_type_aliases)
-# if (__cplusplus >= 202002L)
+# if (__cplusplus >= 202002L) && ((__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2)
 #  define __glibcxx_atomic_lock_free_type_aliases 201907L
 #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_atomic_lock_free_type_aliases)
 #   define __cpp_lib_atomic_lock_free_type_aliases 201907L
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 559f8370459..1462cf5ec23 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -1774,13 +1774,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     = atomic<make_signed_t<__detail::__platform_wait_t>>;
   using atomic_unsigned_lock_free
     = atomic<make_unsigned_t<__detail::__platform_wait_t>>;
-# elif ATOMIC_INT_LOCK_FREE || !(ATOMIC_LONG_LOCK_FREE || ATOMIC_CHAR_LOCK_FREE)
+# elif ATOMIC_INT_LOCK_FREE == 2
   using atomic_signed_lock_free = atomic<signed int>;
   using atomic_unsigned_lock_free = atomic<unsigned int>;
-# elif ATOMIC_LONG_LOCK_FREE
+# elif ATOMIC_LONG_LOCK_FREE == 2
   using atomic_signed_lock_free = atomic<signed long>;
   using atomic_unsigned_lock_free = atomic<unsigned long>;
-# elif ATOMIC_CHAR_LOCK_FREE
+# elif ATOMIC_CHAR_LOCK_FREE == 2
   using atomic_signed_lock_free = atomic<signed char>;
   using atomic_unsigned_lock_free = atomic<unsigned char>;
 # else
-- 
2.43.0


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

* Re: [PATCH 8/8] libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103]
  2024-02-27 11:42 [PATCH 8/8] libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103] Jonathan Wakely
@ 2024-02-27 14:33 ` Jonathan Wakely
  2024-02-27 14:43   ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2024-02-27 14:33 UTC (permalink / raw)
  To: libstdc++, gcc-patches

On Tue, 27 Feb 2024 at 11:49, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> Tested x86_64-linux. I think we should make this change, because
> otherwise we define the typedefs for platforms with no lock-free
> atomics, like hppa-hpux. Instead of lying, those typedefs should be
> absent on that target.
>
> -- >8 --
>
> libstdc++-v3/ChangeLog:
>
>         PR libstdc++/114103
>         * include/bits/version.def (atomic_lock_free_type_aliases): Add
>         extra_cond to check for at least one always-lock-free type.
>         * include/bits/version.h: Regenerate.
>         * include/std/atomic (atomic_signed_lock_free)
>         (atomic_unsigned_lock_free): Only use always-lock-free types.
> ---
>  libstdc++-v3/include/bits/version.def | 1 +
>  libstdc++-v3/include/bits/version.h   | 2 +-
>  libstdc++-v3/include/std/atomic       | 6 +++---
>  3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
> index 502961eb269..d298420121b 100644
> --- a/libstdc++-v3/include/bits/version.def
> +++ b/libstdc++-v3/include/bits/version.def
> @@ -739,6 +739,7 @@ ftms = {
>    values = {
>      v = 201907;
>      cxxmin = 20;
> +    extra_cond = "(__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2";

Maybe this should be > 1 instead of & 2 in case there are targets that
define it to 4 or something. I think those are only supposed to be
defined to 0, 1, or 2 though.


>    };
>  };
>
> diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
> index 7a6fbd35e2e..9107b45a484 100644
> --- a/libstdc++-v3/include/bits/version.h
> +++ b/libstdc++-v3/include/bits/version.h
> @@ -819,7 +819,7 @@
>  #undef __glibcxx_want_atomic_float
>
>  #if !defined(__cpp_lib_atomic_lock_free_type_aliases)
> -# if (__cplusplus >= 202002L)
> +# if (__cplusplus >= 202002L) && ((__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2)
>  #  define __glibcxx_atomic_lock_free_type_aliases 201907L
>  #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_atomic_lock_free_type_aliases)
>  #   define __cpp_lib_atomic_lock_free_type_aliases 201907L
> diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
> index 559f8370459..1462cf5ec23 100644
> --- a/libstdc++-v3/include/std/atomic
> +++ b/libstdc++-v3/include/std/atomic
> @@ -1774,13 +1774,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      = atomic<make_signed_t<__detail::__platform_wait_t>>;
>    using atomic_unsigned_lock_free
>      = atomic<make_unsigned_t<__detail::__platform_wait_t>>;
> -# elif ATOMIC_INT_LOCK_FREE || !(ATOMIC_LONG_LOCK_FREE || ATOMIC_CHAR_LOCK_FREE)
> +# elif ATOMIC_INT_LOCK_FREE == 2

Similarly, this could be > 1 but again, I think == 2 is OK.

>    using atomic_signed_lock_free = atomic<signed int>;
>    using atomic_unsigned_lock_free = atomic<unsigned int>;
> -# elif ATOMIC_LONG_LOCK_FREE
> +# elif ATOMIC_LONG_LOCK_FREE == 2
>    using atomic_signed_lock_free = atomic<signed long>;
>    using atomic_unsigned_lock_free = atomic<unsigned long>;
> -# elif ATOMIC_CHAR_LOCK_FREE
> +# elif ATOMIC_CHAR_LOCK_FREE == 2
>    using atomic_signed_lock_free = atomic<signed char>;
>    using atomic_unsigned_lock_free = atomic<unsigned char>;
>  # else
> --
> 2.43.0
>


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

* Re: [PATCH 8/8] libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103]
  2024-02-27 14:33 ` Jonathan Wakely
@ 2024-02-27 14:43   ` Jonathan Wakely
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2024-02-27 14:43 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Ooops, I forgot to add --no-numbered so these were eight unrelated
patches, not PATCH 1/8 .. PATCH 8/8. Sorry for any confusion.

On Tue, 27 Feb 2024 at 14:33, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Tue, 27 Feb 2024 at 11:49, Jonathan Wakely <jwakely@redhat.com> wrote:
> >
> > Tested x86_64-linux. I think we should make this change, because
> > otherwise we define the typedefs for platforms with no lock-free
> > atomics, like hppa-hpux. Instead of lying, those typedefs should be
> > absent on that target.
> >
> > -- >8 --
> >
> > libstdc++-v3/ChangeLog:
> >
> >         PR libstdc++/114103
> >         * include/bits/version.def (atomic_lock_free_type_aliases): Add
> >         extra_cond to check for at least one always-lock-free type.
> >         * include/bits/version.h: Regenerate.
> >         * include/std/atomic (atomic_signed_lock_free)
> >         (atomic_unsigned_lock_free): Only use always-lock-free types.
> > ---
> >  libstdc++-v3/include/bits/version.def | 1 +
> >  libstdc++-v3/include/bits/version.h   | 2 +-
> >  libstdc++-v3/include/std/atomic       | 6 +++---
> >  3 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
> > index 502961eb269..d298420121b 100644
> > --- a/libstdc++-v3/include/bits/version.def
> > +++ b/libstdc++-v3/include/bits/version.def
> > @@ -739,6 +739,7 @@ ftms = {
> >    values = {
> >      v = 201907;
> >      cxxmin = 20;
> > +    extra_cond = "(__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2";
>
> Maybe this should be > 1 instead of & 2 in case there are targets that
> define it to 4 or something. I think those are only supposed to be
> defined to 0, 1, or 2 though.
>
>
> >    };
> >  };
> >
> > diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
> > index 7a6fbd35e2e..9107b45a484 100644
> > --- a/libstdc++-v3/include/bits/version.h
> > +++ b/libstdc++-v3/include/bits/version.h
> > @@ -819,7 +819,7 @@
> >  #undef __glibcxx_want_atomic_float
> >
> >  #if !defined(__cpp_lib_atomic_lock_free_type_aliases)
> > -# if (__cplusplus >= 202002L)
> > +# if (__cplusplus >= 202002L) && ((__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2)
> >  #  define __glibcxx_atomic_lock_free_type_aliases 201907L
> >  #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_atomic_lock_free_type_aliases)
> >  #   define __cpp_lib_atomic_lock_free_type_aliases 201907L
> > diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
> > index 559f8370459..1462cf5ec23 100644
> > --- a/libstdc++-v3/include/std/atomic
> > +++ b/libstdc++-v3/include/std/atomic
> > @@ -1774,13 +1774,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >      = atomic<make_signed_t<__detail::__platform_wait_t>>;
> >    using atomic_unsigned_lock_free
> >      = atomic<make_unsigned_t<__detail::__platform_wait_t>>;
> > -# elif ATOMIC_INT_LOCK_FREE || !(ATOMIC_LONG_LOCK_FREE || ATOMIC_CHAR_LOCK_FREE)
> > +# elif ATOMIC_INT_LOCK_FREE == 2
>
> Similarly, this could be > 1 but again, I think == 2 is OK.
>
> >    using atomic_signed_lock_free = atomic<signed int>;
> >    using atomic_unsigned_lock_free = atomic<unsigned int>;
> > -# elif ATOMIC_LONG_LOCK_FREE
> > +# elif ATOMIC_LONG_LOCK_FREE == 2
> >    using atomic_signed_lock_free = atomic<signed long>;
> >    using atomic_unsigned_lock_free = atomic<unsigned long>;
> > -# elif ATOMIC_CHAR_LOCK_FREE
> > +# elif ATOMIC_CHAR_LOCK_FREE == 2
> >    using atomic_signed_lock_free = atomic<signed char>;
> >    using atomic_unsigned_lock_free = atomic<unsigned char>;
> >  # else
> > --
> > 2.43.0
> >


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

end of thread, other threads:[~2024-02-27 14:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 11:42 [PATCH 8/8] libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103] Jonathan Wakely
2024-02-27 14:33 ` Jonathan Wakely
2024-02-27 14:43   ` 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).