* [PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for is_same
@ 2024-02-08 10:20 Ken Matsui
2024-02-09 16:01 ` Patrick Palka
0 siblings, 1 reply; 3+ messages in thread
From: Ken Matsui @ 2024-02-08 10:20 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Ken Matsui
Since is_same has a fallback native implementation, and
_GLIBCXX_HAVE_BUILTIN_IS_SAME does not support toggling which
implementation to use, we remove the _GLIBCXX_HAVE_BUILTIN_IS_SAME
definition and use _GLIBCXX_USE_BUILTIN_TRAIT instead.
libstdc++-v3/ChangeLog:
* include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_SAME):
Removed.
* include/std/type_traits (is_same): Use
_GLIBCXX_USE_BUILTIN_TRAIT instead of
_GLIBCXX_HAVE_BUILTIN_IS_SAME.
(is_same_v): Likewise.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
libstdc++-v3/include/bits/c++config | 4 ----
libstdc++-v3/include/std/type_traits | 9 +++++----
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index ad07ce92d5f..b57e3f338e9 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -845,10 +845,6 @@ namespace __gnu_cxx
# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
#endif
-#if _GLIBCXX_HAS_BUILTIN(__is_same)
-# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1
-#endif
-
#if _GLIBCXX_HAS_BUILTIN(__builtin_launder)
# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
#endif
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index a9bb2806ca9..21402fd8c13 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -1470,16 +1470,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Type relations.
/// is_same
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
template<typename _Tp, typename _Up>
struct is_same
-#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME
: public __bool_constant<__is_same(_Tp, _Up)>
+ { };
#else
+ template<typename _Tp, typename _Up>
+ struct is_same
: public false_type
-#endif
{ };
-#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME
template<typename _Tp>
struct is_same<_Tp, _Tp>
: public true_type
@@ -3496,7 +3497,7 @@ template <typename _Tp>
template <typename _Tp, unsigned _Idx>
inline constexpr size_t extent_v<_Tp[], _Idx> = extent_v<_Tp, _Idx - 1>;
-#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
template <typename _Tp, typename _Up>
inline constexpr bool is_same_v = __is_same(_Tp, _Up);
#else
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for is_same
2024-02-08 10:20 [PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for is_same Ken Matsui
@ 2024-02-09 16:01 ` Patrick Palka
2024-02-09 18:06 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2024-02-09 16:01 UTC (permalink / raw)
To: Ken Matsui; +Cc: gcc-patches, libstdc++
On Thu, 8 Feb 2024, Ken Matsui wrote:
> Since is_same has a fallback native implementation, and
> _GLIBCXX_HAVE_BUILTIN_IS_SAME does not support toggling which
> implementation to use, we remove the _GLIBCXX_HAVE_BUILTIN_IS_SAME
> definition and use _GLIBCXX_USE_BUILTIN_TRAIT instead.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_SAME):
> Removed.
> * include/std/type_traits (is_same): Use
> _GLIBCXX_USE_BUILTIN_TRAIT instead of
> _GLIBCXX_HAVE_BUILTIN_IS_SAME.
> (is_same_v): Likewise.
LGTM
>
> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> ---
> libstdc++-v3/include/bits/c++config | 4 ----
> libstdc++-v3/include/std/type_traits | 9 +++++----
> 2 files changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> index ad07ce92d5f..b57e3f338e9 100644
> --- a/libstdc++-v3/include/bits/c++config
> +++ b/libstdc++-v3/include/bits/c++config
> @@ -845,10 +845,6 @@ namespace __gnu_cxx
> # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
> #endif
>
> -#if _GLIBCXX_HAS_BUILTIN(__is_same)
> -# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1
> -#endif
> -
> #if _GLIBCXX_HAS_BUILTIN(__builtin_launder)
> # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> #endif
> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
> index a9bb2806ca9..21402fd8c13 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -1470,16 +1470,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> // Type relations.
>
> /// is_same
> +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
> template<typename _Tp, typename _Up>
> struct is_same
> -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME
> : public __bool_constant<__is_same(_Tp, _Up)>
> + { };
> #else
> + template<typename _Tp, typename _Up>
> + struct is_same
> : public false_type
> -#endif
> { };
>
> -#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME
> template<typename _Tp>
> struct is_same<_Tp, _Tp>
> : public true_type
> @@ -3496,7 +3497,7 @@ template <typename _Tp>
> template <typename _Tp, unsigned _Idx>
> inline constexpr size_t extent_v<_Tp[], _Idx> = extent_v<_Tp, _Idx - 1>;
>
> -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME
> +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
> template <typename _Tp, typename _Up>
> inline constexpr bool is_same_v = __is_same(_Tp, _Up);
> #else
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for is_same
2024-02-09 16:01 ` Patrick Palka
@ 2024-02-09 18:06 ` Jonathan Wakely
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2024-02-09 18:06 UTC (permalink / raw)
To: Patrick Palka; +Cc: Ken Matsui, gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 2800 bytes --]
On Fri, 9 Feb 2024 at 16:02, Patrick Palka <ppalka@redhat.com> wrote:
> On Thu, 8 Feb 2024, Ken Matsui wrote:
>
> > Since is_same has a fallback native implementation, and
> > _GLIBCXX_HAVE_BUILTIN_IS_SAME does not support toggling which
> > implementation to use, we remove the _GLIBCXX_HAVE_BUILTIN_IS_SAME
> > definition and use _GLIBCXX_USE_BUILTIN_TRAIT instead.
> >
> > libstdc++-v3/ChangeLog:
> >
> > * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_SAME):
> > Removed.
> > * include/std/type_traits (is_same): Use
> > _GLIBCXX_USE_BUILTIN_TRAIT instead of
> > _GLIBCXX_HAVE_BUILTIN_IS_SAME.
> > (is_same_v): Likewise.
>
> LGTM
>
Me too, OK for trunk, thanks.
+Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
>
> >
> > Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> > ---
> > libstdc++-v3/include/bits/c++config | 4 ----
> > libstdc++-v3/include/std/type_traits | 9 +++++----
> > 2 files changed, 5 insertions(+), 8 deletions(-)
> >
> > diff --git a/libstdc++-v3/include/bits/c++config
> b/libstdc++-v3/include/bits/c++config
> > index ad07ce92d5f..b57e3f338e9 100644
> > --- a/libstdc++-v3/include/bits/c++config
> > +++ b/libstdc++-v3/include/bits/c++config
> > @@ -845,10 +845,6 @@ namespace __gnu_cxx
> > # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
> > #endif
> >
> > -#if _GLIBCXX_HAS_BUILTIN(__is_same)
> > -# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1
> > -#endif
> > -
> > #if _GLIBCXX_HAS_BUILTIN(__builtin_launder)
> > # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> > #endif
> > diff --git a/libstdc++-v3/include/std/type_traits
> b/libstdc++-v3/include/std/type_traits
> > index a9bb2806ca9..21402fd8c13 100644
> > --- a/libstdc++-v3/include/std/type_traits
> > +++ b/libstdc++-v3/include/std/type_traits
> > @@ -1470,16 +1470,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> > // Type relations.
> >
> > /// is_same
> > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
> > template<typename _Tp, typename _Up>
> > struct is_same
> > -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME
> > : public __bool_constant<__is_same(_Tp, _Up)>
> > + { };
> > #else
> > + template<typename _Tp, typename _Up>
> > + struct is_same
> > : public false_type
> > -#endif
> > { };
> >
> > -#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME
> > template<typename _Tp>
> > struct is_same<_Tp, _Tp>
> > : public true_type
> > @@ -3496,7 +3497,7 @@ template <typename _Tp>
> > template <typename _Tp, unsigned _Idx>
> > inline constexpr size_t extent_v<_Tp[], _Idx> = extent_v<_Tp, _Idx -
> 1>;
> >
> > -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME
> > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same)
> > template <typename _Tp, typename _Up>
> > inline constexpr bool is_same_v = __is_same(_Tp, _Up);
> > #else
> > --
> > 2.43.0
> >
> >
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-09 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-08 10:20 [PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for is_same Ken Matsui
2024-02-09 16:01 ` Patrick Palka
2024-02-09 18:06 ` 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).