* [PATCH] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
@ 2023-07-18 22:32 Ken Matsui
2023-07-19 18:48 ` Patrick Palka
2023-07-19 19:32 ` [PATCH v2] " Ken Matsui
0 siblings, 2 replies; 13+ messages in thread
From: Ken Matsui @ 2023-07-18 22:32 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Ken Matsui
This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT, which will be used as a
flag to toggle built-in traits in the type_traits header. Through this
macro function and _GLIBCXX_NO_BUILTIN_TRAITS macro, we can switch the
use of built-in traits without needing to modify the source code.
libstdc++-v3/ChangeLog:
* include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
libstdc++-v3/include/bits/c++config | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index dd47f274d5f..de13f61db71 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -854,7 +854,11 @@ namespace __gnu_cxx
# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
#endif
-#undef _GLIBCXX_HAS_BUILTIN
+// Returns true if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
+// has a corresponding built-in type trait. _GLIBCXX_NO_BUILTIN_TRAITS is
+// defined to disable the use of built-in traits.
+#define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) \
+ (!defined(_GLIBCXX_NO_BUILTIN_TRAITS) && _GLIBCXX_HAS_BUILTIN(BT))
// Mark code that should be ignored by the compiler, but seen by Doxygen.
#define _GLIBCXX_DOXYGEN_ONLY(X)
--
2.41.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-18 22:32 [PATCH] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT Ken Matsui
@ 2023-07-19 18:48 ` Patrick Palka
2023-07-19 19:31 ` Ken Matsui
2023-08-08 20:22 ` Jonathan Wakely
2023-07-19 19:32 ` [PATCH v2] " Ken Matsui
1 sibling, 2 replies; 13+ messages in thread
From: Patrick Palka @ 2023-07-19 18:48 UTC (permalink / raw)
To: Ken Matsui; +Cc: gcc-patches, libstdc++
On Tue, 18 Jul 2023, Ken Matsui via Libstdc++ wrote:
> This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT, which will be used as a
> flag to toggle built-in traits in the type_traits header. Through this
> macro function and _GLIBCXX_NO_BUILTIN_TRAITS macro, we can switch the
> use of built-in traits without needing to modify the source code.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
The ChangeLog entry should also mention the change to _GLIBCXX_HAS_BUILTIN,
e.g.
(_GLIBCXX_HAS_BUILTIN): Keep defined.
>
> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> ---
> libstdc++-v3/include/bits/c++config | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> index dd47f274d5f..de13f61db71 100644
> --- a/libstdc++-v3/include/bits/c++config
> +++ b/libstdc++-v3/include/bits/c++config
> @@ -854,7 +854,11 @@ namespace __gnu_cxx
> # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> #endif
>
> -#undef _GLIBCXX_HAS_BUILTIN
> +// Returns true if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
> +// has a corresponding built-in type trait. _GLIBCXX_NO_BUILTIN_TRAITS is
> +// defined to disable the use of built-in traits.
> +#define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) \
> + (!defined(_GLIBCXX_NO_BUILTIN_TRAITS) && _GLIBCXX_HAS_BUILTIN(BT))
Since we don't expect _GLIBCXX_NO_BUILTIN_TRAITS to get
defined/undefined in the middle of preprocessing, perhaps we should
factor out the _GLIBCXX_NO_BUILTIN_TRAITS test from the macro function
and instead conditionally define the macro function to 0 according
_GLIBCXX_NO_BUILTIN_TRAITS?
>
> // Mark code that should be ignored by the compiler, but seen by Doxygen.
> #define _GLIBCXX_DOXYGEN_ONLY(X)
> --
> 2.41.0
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-19 18:48 ` Patrick Palka
@ 2023-07-19 19:31 ` Ken Matsui
2023-08-08 20:22 ` Jonathan Wakely
1 sibling, 0 replies; 13+ messages in thread
From: Ken Matsui @ 2023-07-19 19:31 UTC (permalink / raw)
To: Patrick Palka; +Cc: Ken Matsui, gcc-patches, libstdc++
On Wed, Jul 19, 2023 at 11:48 AM Patrick Palka <ppalka@redhat.com> wrote:
>
> On Tue, 18 Jul 2023, Ken Matsui via Libstdc++ wrote:
>
> > This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT, which will be used as a
> > flag to toggle built-in traits in the type_traits header. Through this
> > macro function and _GLIBCXX_NO_BUILTIN_TRAITS macro, we can switch the
> > use of built-in traits without needing to modify the source code.
> >
> > libstdc++-v3/ChangeLog:
> >
> > * include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
>
> The ChangeLog entry should also mention the change to _GLIBCXX_HAS_BUILTIN,
> e.g.
>
> (_GLIBCXX_HAS_BUILTIN): Keep defined.
>
> >
> > Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> > ---
> > libstdc++-v3/include/bits/c++config | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> > index dd47f274d5f..de13f61db71 100644
> > --- a/libstdc++-v3/include/bits/c++config
> > +++ b/libstdc++-v3/include/bits/c++config
> > @@ -854,7 +854,11 @@ namespace __gnu_cxx
> > # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> > #endif
> >
> > -#undef _GLIBCXX_HAS_BUILTIN
> > +// Returns true if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
> > +// has a corresponding built-in type trait. _GLIBCXX_NO_BUILTIN_TRAITS is
> > +// defined to disable the use of built-in traits.
> > +#define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) \
> > + (!defined(_GLIBCXX_NO_BUILTIN_TRAITS) && _GLIBCXX_HAS_BUILTIN(BT))
>
> Since we don't expect _GLIBCXX_NO_BUILTIN_TRAITS to get
> defined/undefined in the middle of preprocessing, perhaps we should
> factor out the _GLIBCXX_NO_BUILTIN_TRAITS test from the macro function
> and instead conditionally define the macro function to 0 according
> _GLIBCXX_NO_BUILTIN_TRAITS?
>
Hi, thank you for your review! I totally agree with your ideas and
will update this patch.
> >
> > // Mark code that should be ignored by the compiler, but seen by Doxygen.
> > #define _GLIBCXX_DOXYGEN_ONLY(X)
> > --
> > 2.41.0
> >
> >
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-18 22:32 [PATCH] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT Ken Matsui
2023-07-19 18:48 ` Patrick Palka
@ 2023-07-19 19:32 ` Ken Matsui
2023-07-20 16:05 ` Patrick Palka
` (2 more replies)
1 sibling, 3 replies; 13+ messages in thread
From: Ken Matsui @ 2023-07-19 19:32 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Ken Matsui
This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT macro, which will be used
as a flag to toggle the use of built-in traits in the type_traits header
through _GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
source code.
libstdc++-v3/ChangeLog:
* include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
(_GLIBCXX_HAS_BUILTIN): Keep defined.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
libstdc++-v3/include/bits/c++config | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index dd47f274d5f..984985d6fff 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -854,7 +854,15 @@ namespace __gnu_cxx
# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
#endif
-#undef _GLIBCXX_HAS_BUILTIN
+// Returns 1 if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
+// has a corresponding built-in type trait, 0 otherwise.
+// _GLIBCXX_NO_BUILTIN_TRAITS can be defined to disable the use of built-in
+// traits.
+#ifndef _GLIBCXX_NO_BUILTIN_TRAITS
+# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) _GLIBCXX_HAS_BUILTIN(BT)
+#else
+# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) 0
+#endif
// Mark code that should be ignored by the compiler, but seen by Doxygen.
#define _GLIBCXX_DOXYGEN_ONLY(X)
--
2.41.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-19 19:32 ` [PATCH v2] " Ken Matsui
@ 2023-07-20 16:05 ` Patrick Palka
2023-07-28 3:57 ` [PATCH v3 1/2] " Ken Matsui
2023-08-08 20:23 ` [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT Jonathan Wakely
2 siblings, 0 replies; 13+ messages in thread
From: Patrick Palka @ 2023-07-20 16:05 UTC (permalink / raw)
To: Ken Matsui; +Cc: gcc-patches, libstdc++
On Wed, Jul 19, 2023 at 3:33 PM Ken Matsui via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT macro, which will be used
> as a flag to toggle the use of built-in traits in the type_traits header
> through _GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
> source code.
LGTM!
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
> (_GLIBCXX_HAS_BUILTIN): Keep defined.
>
> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> ---
> libstdc++-v3/include/bits/c++config | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> index dd47f274d5f..984985d6fff 100644
> --- a/libstdc++-v3/include/bits/c++config
> +++ b/libstdc++-v3/include/bits/c++config
> @@ -854,7 +854,15 @@ namespace __gnu_cxx
> # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> #endif
>
> -#undef _GLIBCXX_HAS_BUILTIN
> +// Returns 1 if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
> +// has a corresponding built-in type trait, 0 otherwise.
> +// _GLIBCXX_NO_BUILTIN_TRAITS can be defined to disable the use of built-in
> +// traits.
> +#ifndef _GLIBCXX_NO_BUILTIN_TRAITS
> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) _GLIBCXX_HAS_BUILTIN(BT)
> +#else
> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) 0
> +#endif
>
> // Mark code that should be ignored by the compiler, but seen by Doxygen.
> #define _GLIBCXX_DOXYGEN_ONLY(X)
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 1/2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-19 19:32 ` [PATCH v2] " Ken Matsui
2023-07-20 16:05 ` Patrick Palka
@ 2023-07-28 3:57 ` Ken Matsui
2023-07-28 3:57 ` [PATCH v3 2/2] libstdc++: Use _GLIBCXX_HAS_BUILTIN_TRAIT Ken Matsui
2023-08-08 20:23 ` [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT Jonathan Wakely
2 siblings, 1 reply; 13+ messages in thread
From: Ken Matsui @ 2023-07-28 3:57 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Ken Matsui
This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT macro, which will be used
as a flag to toggle the use of built-in traits in the type_traits header
through _GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
source code.
libstdc++-v3/ChangeLog:
* include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
(_GLIBCXX_HAS_BUILTIN): Keep defined.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
libstdc++-v3/include/bits/c++config | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index dd47f274d5f..984985d6fff 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -854,7 +854,15 @@ namespace __gnu_cxx
# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
#endif
-#undef _GLIBCXX_HAS_BUILTIN
+// Returns 1 if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
+// has a corresponding built-in type trait, 0 otherwise.
+// _GLIBCXX_NO_BUILTIN_TRAITS can be defined to disable the use of built-in
+// traits.
+#ifndef _GLIBCXX_NO_BUILTIN_TRAITS
+# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) _GLIBCXX_HAS_BUILTIN(BT)
+#else
+# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) 0
+#endif
// Mark code that should be ignored by the compiler, but seen by Doxygen.
#define _GLIBCXX_DOXYGEN_ONLY(X)
--
2.41.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 2/2] libstdc++: Use _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-28 3:57 ` [PATCH v3 1/2] " Ken Matsui
@ 2023-07-28 3:57 ` Ken Matsui
2023-08-01 17:24 ` Patrick Palka
0 siblings, 1 reply; 13+ messages in thread
From: Ken Matsui @ 2023-07-28 3:57 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Ken Matsui
This patch uses _GLIBCXX_HAS_BUILTIN_TRAIT macro instead of
__has_builtin in the type_traits header. This macro supports to toggle
the use of built-in traits in the type_traits header through
_GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
source code.
libstdc++-v3/ChangeLog:
* include/std/type_traits (__has_builtin): Replace with ...
(_GLIBCXX_HAS_BUILTIN): ... this.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
---
libstdc++-v3/include/std/type_traits | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 9f086992ebc..12423361b6e 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -1411,7 +1411,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public __bool_constant<__is_base_of(_Base, _Derived)>
{ };
-#if __has_builtin(__is_convertible)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__is_convertible)
template<typename _From, typename _To>
struct is_convertible
: public __bool_constant<__is_convertible(_From, _To)>
@@ -1462,7 +1462,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 202002L
#define __cpp_lib_is_nothrow_convertible 201806L
-#if __has_builtin(__is_nothrow_convertible)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__is_nothrow_convertible)
/// is_nothrow_convertible_v
template<typename _From, typename _To>
inline constexpr bool is_nothrow_convertible_v
@@ -1537,7 +1537,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ using type = _Tp; };
/// remove_cv
-#if __has_builtin(__remove_cv)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__remove_cv)
template<typename _Tp>
struct remove_cv
{ using type = __remove_cv(_Tp); };
@@ -1606,7 +1606,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Reference transformations.
/// remove_reference
-#if __has_builtin(__remove_reference)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__remove_reference)
template<typename _Tp>
struct remove_reference
{ using type = __remove_reference(_Tp); };
@@ -2963,7 +2963,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp,
bool _Nothrow = noexcept(_S_conv<_Tp>(_S_get())),
typename = decltype(_S_conv<_Tp>(_S_get())),
-#if __has_builtin(__reference_converts_from_temporary)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__reference_converts_from_temporary)
bool _Dangle = __reference_converts_from_temporary(_Tp, _Res_t)
#else
bool _Dangle = false
@@ -3420,7 +3420,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
*/
#define __cpp_lib_remove_cvref 201711L
-#if __has_builtin(__remove_cvref)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__remove_cvref)
template<typename _Tp>
struct remove_cvref
{ using type = __remove_cvref(_Tp); };
@@ -3515,7 +3515,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
: public bool_constant<is_unbounded_array_v<_Tp>>
{ };
-#if __has_builtin(__is_layout_compatible)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__is_layout_compatible)
/// @since C++20
template<typename _Tp, typename _Up>
@@ -3529,7 +3529,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
constexpr bool is_layout_compatible_v
= __is_layout_compatible(_Tp, _Up);
-#if __has_builtin(__builtin_is_corresponding_member)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__builtin_is_corresponding_member)
#define __cpp_lib_is_layout_compatible 201907L
/// @since C++20
@@ -3540,7 +3540,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
#endif
#endif
-#if __has_builtin(__is_pointer_interconvertible_base_of)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__is_pointer_interconvertible_base_of)
/// True if `_Derived` is standard-layout and has a base class of type `_Base`
/// @since C++20
template<typename _Base, typename _Derived>
@@ -3554,7 +3554,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
constexpr bool is_pointer_interconvertible_base_of_v
= __is_pointer_interconvertible_base_of(_Base, _Derived);
-#if __has_builtin(__builtin_is_pointer_interconvertible_with_class)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__builtin_is_pointer_interconvertible_with_class)
#define __cpp_lib_is_pointer_interconvertible 201907L
/// True if `__mp` points to the first member of a standard-layout type
@@ -3590,8 +3590,8 @@ template<typename _Ret, typename _Fn, typename... _Args>
template<typename _Tp>
inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
-#if __has_builtin(__reference_constructs_from_temporary) \
- && __has_builtin(__reference_converts_from_temporary)
+#if _GLIBCXX_HAS_BUILTIN_TRAIT(__reference_constructs_from_temporary) \
+ && _GLIBCXX_HAS_BUILTIN_TRAIT(__reference_converts_from_temporary)
#define __cpp_lib_reference_from_temporary 202202L
@@ -3632,7 +3632,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
template<typename _Tp, typename _Up>
inline constexpr bool reference_converts_from_temporary_v
= reference_converts_from_temporary<_Tp, _Up>::value;
-#endif // __has_builtin for reference_from_temporary
+#endif // _GLIBCXX_HAS_BUILTIN_TRAIT for reference_from_temporary
#endif // C++23
#if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
--
2.41.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/2] libstdc++: Use _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-28 3:57 ` [PATCH v3 2/2] libstdc++: Use _GLIBCXX_HAS_BUILTIN_TRAIT Ken Matsui
@ 2023-08-01 17:24 ` Patrick Palka
0 siblings, 0 replies; 13+ messages in thread
From: Patrick Palka @ 2023-08-01 17:24 UTC (permalink / raw)
To: Ken Matsui; +Cc: gcc-patches, libstdc++
On Thu, 27 Jul 2023, Ken Matsui via Gcc-patches wrote:
> This patch uses _GLIBCXX_HAS_BUILTIN_TRAIT macro instead of
> __has_builtin in the type_traits header. This macro supports to toggle
> the use of built-in traits in the type_traits header through
> _GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
> source code.
>
> libstdc++-v3/ChangeLog:
>
> * include/std/type_traits (__has_builtin): Replace with ...
> (_GLIBCXX_HAS_BUILTIN): ... this.
>
> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> ---
> libstdc++-v3/include/std/type_traits | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
> index 9f086992ebc..12423361b6e 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -1411,7 +1411,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> : public __bool_constant<__is_base_of(_Base, _Derived)>
> { };
>
> -#if __has_builtin(__is_convertible)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__is_convertible)
> template<typename _From, typename _To>
> struct is_convertible
> : public __bool_constant<__is_convertible(_From, _To)>
> @@ -1462,7 +1462,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> #if __cplusplus >= 202002L
> #define __cpp_lib_is_nothrow_convertible 201806L
>
> -#if __has_builtin(__is_nothrow_convertible)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__is_nothrow_convertible)
> /// is_nothrow_convertible_v
> template<typename _From, typename _To>
> inline constexpr bool is_nothrow_convertible_v
> @@ -1537,7 +1537,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> { using type = _Tp; };
>
> /// remove_cv
> -#if __has_builtin(__remove_cv)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__remove_cv)
> template<typename _Tp>
> struct remove_cv
> { using type = __remove_cv(_Tp); };
> @@ -1606,7 +1606,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> // Reference transformations.
>
> /// remove_reference
> -#if __has_builtin(__remove_reference)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__remove_reference)
> template<typename _Tp>
> struct remove_reference
> { using type = __remove_reference(_Tp); };
> @@ -2963,7 +2963,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> template<typename _Tp,
> bool _Nothrow = noexcept(_S_conv<_Tp>(_S_get())),
> typename = decltype(_S_conv<_Tp>(_S_get())),
> -#if __has_builtin(__reference_converts_from_temporary)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__reference_converts_from_temporary)
> bool _Dangle = __reference_converts_from_temporary(_Tp, _Res_t)
> #else
> bool _Dangle = false
> @@ -3420,7 +3420,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
> */
> #define __cpp_lib_remove_cvref 201711L
>
> -#if __has_builtin(__remove_cvref)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__remove_cvref)
> template<typename _Tp>
> struct remove_cvref
> { using type = __remove_cvref(_Tp); };
> @@ -3515,7 +3515,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
> : public bool_constant<is_unbounded_array_v<_Tp>>
> { };
>
> -#if __has_builtin(__is_layout_compatible)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__is_layout_compatible)
Hmm, I was thinking we'd use this macro only for traits that have a
fallback non-built-in implementation so that we could easily use/test
their fallback implementation. For traits that don't have such a
fallback, using this macro would mean that trait would no longer get
defined at all, which doesn't seem as useful. Perhaps let's initially
adjust only the traits that have a fallback implementation?
We could then verify that using the fallback implementation for all such
traits works as expected by running the testsuite with:
make check RUNTESTFLAGS="conformance.exp --target_board=unix/-D_GLIBCXX_NO_BUILTIN_TRAITS"
>
> /// @since C++20
> template<typename _Tp, typename _Up>
> @@ -3529,7 +3529,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
> constexpr bool is_layout_compatible_v
> = __is_layout_compatible(_Tp, _Up);
>
> -#if __has_builtin(__builtin_is_corresponding_member)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__builtin_is_corresponding_member)
> #define __cpp_lib_is_layout_compatible 201907L
>
> /// @since C++20
> @@ -3540,7 +3540,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
> #endif
> #endif
>
> -#if __has_builtin(__is_pointer_interconvertible_base_of)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__is_pointer_interconvertible_base_of)
> /// True if `_Derived` is standard-layout and has a base class of type `_Base`
> /// @since C++20
> template<typename _Base, typename _Derived>
> @@ -3554,7 +3554,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
> constexpr bool is_pointer_interconvertible_base_of_v
> = __is_pointer_interconvertible_base_of(_Base, _Derived);
>
> -#if __has_builtin(__builtin_is_pointer_interconvertible_with_class)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__builtin_is_pointer_interconvertible_with_class)
> #define __cpp_lib_is_pointer_interconvertible 201907L
>
> /// True if `__mp` points to the first member of a standard-layout type
> @@ -3590,8 +3590,8 @@ template<typename _Ret, typename _Fn, typename... _Args>
> template<typename _Tp>
> inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
>
> -#if __has_builtin(__reference_constructs_from_temporary) \
> - && __has_builtin(__reference_converts_from_temporary)
> +#if _GLIBCXX_HAS_BUILTIN_TRAIT(__reference_constructs_from_temporary) \
> + && _GLIBCXX_HAS_BUILTIN_TRAIT(__reference_converts_from_temporary)
>
> #define __cpp_lib_reference_from_temporary 202202L
>
> @@ -3632,7 +3632,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
> template<typename _Tp, typename _Up>
> inline constexpr bool reference_converts_from_temporary_v
> = reference_converts_from_temporary<_Tp, _Up>::value;
> -#endif // __has_builtin for reference_from_temporary
> +#endif // _GLIBCXX_HAS_BUILTIN_TRAIT for reference_from_temporary
> #endif // C++23
>
> #if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
> --
> 2.41.0
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-19 18:48 ` Patrick Palka
2023-07-19 19:31 ` Ken Matsui
@ 2023-08-08 20:22 ` Jonathan Wakely
1 sibling, 0 replies; 13+ messages in thread
From: Jonathan Wakely @ 2023-08-08 20:22 UTC (permalink / raw)
To: Patrick Palka; +Cc: Ken Matsui, gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 2150 bytes --]
On Wed, 19 Jul 2023 at 19:48, Patrick Palka via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:
> On Tue, 18 Jul 2023, Ken Matsui via Libstdc++ wrote:
>
> > This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT, which will be used as a
> > flag to toggle built-in traits in the type_traits header. Through this
> > macro function and _GLIBCXX_NO_BUILTIN_TRAITS macro, we can switch the
> > use of built-in traits without needing to modify the source code.
> >
> > libstdc++-v3/ChangeLog:
> >
> > * include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
>
> The ChangeLog entry should also mention the change to _GLIBCXX_HAS_BUILTIN,
> e.g.
>
> (_GLIBCXX_HAS_BUILTIN): Keep defined.
>
> >
> > Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> > ---
> > libstdc++-v3/include/bits/c++config | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/libstdc++-v3/include/bits/c++config
> b/libstdc++-v3/include/bits/c++config
> > index dd47f274d5f..de13f61db71 100644
> > --- a/libstdc++-v3/include/bits/c++config
> > +++ b/libstdc++-v3/include/bits/c++config
> > @@ -854,7 +854,11 @@ namespace __gnu_cxx
> > # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> > #endif
> >
> > -#undef _GLIBCXX_HAS_BUILTIN
> > +// Returns true if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the
> compiler
> > +// has a corresponding built-in type trait. _GLIBCXX_NO_BUILTIN_TRAITS
> is
> > +// defined to disable the use of built-in traits.
> > +#define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) \
> > + (!defined(_GLIBCXX_NO_BUILTIN_TRAITS) && _GLIBCXX_HAS_BUILTIN(BT))
>
> Since we don't expect _GLIBCXX_NO_BUILTIN_TRAITS to get
> defined/undefined in the middle of preprocessing, perhaps we should
> factor out the _GLIBCXX_NO_BUILTIN_TRAITS test from the macro function
> and instead conditionally define the macro function to 0 according
> _GLIBCXX_NO_BUILTIN_TRAITS?
>
Also a macro that expands to a use of `defined` is undefined, see
[cpp.cond] p10.
GCC allows it, but Clang warns.
> >
> > // Mark code that should be ignored by the compiler, but seen by
> Doxygen.
> > #define _GLIBCXX_DOXYGEN_ONLY(X)
> > --
> > 2.41.0
> >
> >
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-07-19 19:32 ` [PATCH v2] " Ken Matsui
2023-07-20 16:05 ` Patrick Palka
2023-07-28 3:57 ` [PATCH v3 1/2] " Ken Matsui
@ 2023-08-08 20:23 ` Jonathan Wakely
2023-08-31 12:32 ` Ken Matsui
2 siblings, 1 reply; 13+ messages in thread
From: Jonathan Wakely @ 2023-08-08 20:23 UTC (permalink / raw)
To: Ken Matsui; +Cc: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 1734 bytes --]
On Wed, 19 Jul 2023 at 20:33, Ken Matsui via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:
> This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT macro, which will be used
> as a flag to toggle the use of built-in traits in the type_traits header
> through _GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
> source code.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
> (_GLIBCXX_HAS_BUILTIN): Keep defined.
>
I think this would be a little better as:
* include/bits/c++config (_GLIBCXX_HAS_BUILTIN): Do not undef.
(_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
OK for trunk with that change, thanks.
>
> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> ---
> libstdc++-v3/include/bits/c++config | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/bits/c++config
> b/libstdc++-v3/include/bits/c++config
> index dd47f274d5f..984985d6fff 100644
> --- a/libstdc++-v3/include/bits/c++config
> +++ b/libstdc++-v3/include/bits/c++config
> @@ -854,7 +854,15 @@ namespace __gnu_cxx
> # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> #endif
>
> -#undef _GLIBCXX_HAS_BUILTIN
> +// Returns 1 if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
> +// has a corresponding built-in type trait, 0 otherwise.
> +// _GLIBCXX_NO_BUILTIN_TRAITS can be defined to disable the use of
> built-in
> +// traits.
> +#ifndef _GLIBCXX_NO_BUILTIN_TRAITS
> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) _GLIBCXX_HAS_BUILTIN(BT)
> +#else
> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) 0
> +#endif
>
> // Mark code that should be ignored by the compiler, but seen by Doxygen.
> #define _GLIBCXX_DOXYGEN_ONLY(X)
> --
> 2.41.0
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-08-08 20:23 ` [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT Jonathan Wakely
@ 2023-08-31 12:32 ` Ken Matsui
2023-09-11 14:50 ` Jonathan Wakely
0 siblings, 1 reply; 13+ messages in thread
From: Ken Matsui @ 2023-08-31 12:32 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Ken Matsui, gcc-patches, libstdc++
On Tue, Aug 8, 2023 at 1:23 PM Jonathan Wakely <jwakely@redhat.com> wrote:
>
>
>
> On Wed, 19 Jul 2023 at 20:33, Ken Matsui via Libstdc++ <libstdc++@gcc.gnu.org> wrote:
>>
>> This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT macro, which will be used
>> as a flag to toggle the use of built-in traits in the type_traits header
>> through _GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
>> source code.
>>
>> libstdc++-v3/ChangeLog:
>>
>> * include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
>> (_GLIBCXX_HAS_BUILTIN): Keep defined.
>
>
> I think this would be a little better as:
>
> * include/bits/c++config (_GLIBCXX_HAS_BUILTIN): Do not undef.
> (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
>
> OK for trunk with that change, thanks.
>
Thank you for your review! Patrick and I were discussing the naming
conventions for the macros _GLIBCXX_HAS_BUILTIN_TRAIT and
_GLIBCXX_NO_BUILTIN_TRAITS. It was brought to our attention that these
namings might be ambiguous, as there are implementations that have
corresponding built-ins but do not have fallback. Therefore, we
believe that using _GLIBCXX_USE_BUILTIN_TRAIT instead of
_GLIBCXX_HAS_BUILTIN_TRAIT would be more appropriate. Similarly, we
think that _GLIBCXX_AVOID_BUILTIN_TRAITS would be a better choice than
_GLIBCXX_NO_BUILTIN_TRAITS, as the latter implies that there are no
built-ins, when in fact it is meant to express that the use of
built-ins should be avoided when defining this macro. Could you please
let me know your thoughts on these updated namings?
>
>>
>>
>> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
>> ---
>> libstdc++-v3/include/bits/c++config | 10 +++++++++-
>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
>> index dd47f274d5f..984985d6fff 100644
>> --- a/libstdc++-v3/include/bits/c++config
>> +++ b/libstdc++-v3/include/bits/c++config
>> @@ -854,7 +854,15 @@ namespace __gnu_cxx
>> # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
>> #endif
>>
>> -#undef _GLIBCXX_HAS_BUILTIN
>> +// Returns 1 if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
>> +// has a corresponding built-in type trait, 0 otherwise.
>> +// _GLIBCXX_NO_BUILTIN_TRAITS can be defined to disable the use of built-in
>> +// traits.
>> +#ifndef _GLIBCXX_NO_BUILTIN_TRAITS
>> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) _GLIBCXX_HAS_BUILTIN(BT)
>> +#else
>> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) 0
>> +#endif
>>
>> // Mark code that should be ignored by the compiler, but seen by Doxygen.
>> #define _GLIBCXX_DOXYGEN_ONLY(X)
>> --
>> 2.41.0
>>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-08-31 12:32 ` Ken Matsui
@ 2023-09-11 14:50 ` Jonathan Wakely
2023-09-11 14:58 ` Ken Matsui
0 siblings, 1 reply; 13+ messages in thread
From: Jonathan Wakely @ 2023-09-11 14:50 UTC (permalink / raw)
To: Ken Matsui; +Cc: Ken Matsui, gcc-patches, libstdc++
On Thu, 31 Aug 2023 at 13:33, Ken Matsui <kmatsui@cs.washington.edu> wrote:
>
> On Tue, Aug 8, 2023 at 1:23 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> >
> >
> >
> > On Wed, 19 Jul 2023 at 20:33, Ken Matsui via Libstdc++ <libstdc++@gcc.gnu.org> wrote:
> >>
> >> This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT macro, which will be used
> >> as a flag to toggle the use of built-in traits in the type_traits header
> >> through _GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
> >> source code.
> >>
> >> libstdc++-v3/ChangeLog:
> >>
> >> * include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
> >> (_GLIBCXX_HAS_BUILTIN): Keep defined.
> >
> >
> > I think this would be a little better as:
> >
> > * include/bits/c++config (_GLIBCXX_HAS_BUILTIN): Do not undef.
> > (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
> >
> > OK for trunk with that change, thanks.
> >
> Thank you for your review! Patrick and I were discussing the naming
> conventions for the macros _GLIBCXX_HAS_BUILTIN_TRAIT and
> _GLIBCXX_NO_BUILTIN_TRAITS. It was brought to our attention that these
> namings might be ambiguous, as there are implementations that have
> corresponding built-ins but do not have fallback. Therefore, we
> believe that using _GLIBCXX_USE_BUILTIN_TRAIT instead of
> _GLIBCXX_HAS_BUILTIN_TRAIT would be more appropriate. Similarly, we
> think that _GLIBCXX_AVOID_BUILTIN_TRAITS would be a better choice than
> _GLIBCXX_NO_BUILTIN_TRAITS, as the latter implies that there are no
> built-ins, when in fact it is meant to express that the use of
> built-ins should be avoided when defining this macro. Could you please
> let me know your thoughts on these updated namings?
Yes, I agree that makes sense. I think personally I'd go with
"DISABLE" instead of "AVOID", or even "DO_NOT_USE" (to mirror "USE" in
the macro for individual traits), but either is OK.
> >
> >>
> >>
> >> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> >> ---
> >> libstdc++-v3/include/bits/c++config | 10 +++++++++-
> >> 1 file changed, 9 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> >> index dd47f274d5f..984985d6fff 100644
> >> --- a/libstdc++-v3/include/bits/c++config
> >> +++ b/libstdc++-v3/include/bits/c++config
> >> @@ -854,7 +854,15 @@ namespace __gnu_cxx
> >> # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> >> #endif
> >>
> >> -#undef _GLIBCXX_HAS_BUILTIN
> >> +// Returns 1 if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
> >> +// has a corresponding built-in type trait, 0 otherwise.
> >> +// _GLIBCXX_NO_BUILTIN_TRAITS can be defined to disable the use of built-in
> >> +// traits.
> >> +#ifndef _GLIBCXX_NO_BUILTIN_TRAITS
> >> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) _GLIBCXX_HAS_BUILTIN(BT)
> >> +#else
> >> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) 0
> >> +#endif
> >>
> >> // Mark code that should be ignored by the compiler, but seen by Doxygen.
> >> #define _GLIBCXX_DOXYGEN_ONLY(X)
> >> --
> >> 2.41.0
> >>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT
2023-09-11 14:50 ` Jonathan Wakely
@ 2023-09-11 14:58 ` Ken Matsui
0 siblings, 0 replies; 13+ messages in thread
From: Ken Matsui @ 2023-09-11 14:58 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Ken Matsui, gcc-patches, libstdc++
On Mon, Sep 11, 2023 at 7:51 AM Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Thu, 31 Aug 2023 at 13:33, Ken Matsui <kmatsui@cs.washington.edu> wrote:
> >
> > On Tue, Aug 8, 2023 at 1:23 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> > >
> > >
> > >
> > > On Wed, 19 Jul 2023 at 20:33, Ken Matsui via Libstdc++ <libstdc++@gcc.gnu.org> wrote:
> > >>
> > >> This patch defines _GLIBCXX_HAS_BUILTIN_TRAIT macro, which will be used
> > >> as a flag to toggle the use of built-in traits in the type_traits header
> > >> through _GLIBCXX_NO_BUILTIN_TRAITS macro, without needing to modify the
> > >> source code.
> > >>
> > >> libstdc++-v3/ChangeLog:
> > >>
> > >> * include/bits/c++config (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
> > >> (_GLIBCXX_HAS_BUILTIN): Keep defined.
> > >
> > >
> > > I think this would be a little better as:
> > >
> > > * include/bits/c++config (_GLIBCXX_HAS_BUILTIN): Do not undef.
> > > (_GLIBCXX_HAS_BUILTIN_TRAIT): Define.
> > >
> > > OK for trunk with that change, thanks.
> > >
> > Thank you for your review! Patrick and I were discussing the naming
> > conventions for the macros _GLIBCXX_HAS_BUILTIN_TRAIT and
> > _GLIBCXX_NO_BUILTIN_TRAITS. It was brought to our attention that these
> > namings might be ambiguous, as there are implementations that have
> > corresponding built-ins but do not have fallback. Therefore, we
> > believe that using _GLIBCXX_USE_BUILTIN_TRAIT instead of
> > _GLIBCXX_HAS_BUILTIN_TRAIT would be more appropriate. Similarly, we
> > think that _GLIBCXX_AVOID_BUILTIN_TRAITS would be a better choice than
> > _GLIBCXX_NO_BUILTIN_TRAITS, as the latter implies that there are no
> > built-ins, when in fact it is meant to express that the use of
> > built-ins should be avoided when defining this macro. Could you please
> > let me know your thoughts on these updated namings?
>
> Yes, I agree that makes sense. I think personally I'd go with
> "DISABLE" instead of "AVOID", or even "DO_NOT_USE" (to mirror "USE" in
> the macro for individual traits), but either is OK.
I like the idea of mirroring "USE", so I would choose "DO_NOT_USE".
Thank you for your response!
> > >
> > >>
> > >>
> > >> Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
> > >> ---
> > >> libstdc++-v3/include/bits/c++config | 10 +++++++++-
> > >> 1 file changed, 9 insertions(+), 1 deletion(-)
> > >>
> > >> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> > >> index dd47f274d5f..984985d6fff 100644
> > >> --- a/libstdc++-v3/include/bits/c++config
> > >> +++ b/libstdc++-v3/include/bits/c++config
> > >> @@ -854,7 +854,15 @@ namespace __gnu_cxx
> > >> # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
> > >> #endif
> > >>
> > >> -#undef _GLIBCXX_HAS_BUILTIN
> > >> +// Returns 1 if _GLIBCXX_NO_BUILTIN_TRAITS is not defined and the compiler
> > >> +// has a corresponding built-in type trait, 0 otherwise.
> > >> +// _GLIBCXX_NO_BUILTIN_TRAITS can be defined to disable the use of built-in
> > >> +// traits.
> > >> +#ifndef _GLIBCXX_NO_BUILTIN_TRAITS
> > >> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) _GLIBCXX_HAS_BUILTIN(BT)
> > >> +#else
> > >> +# define _GLIBCXX_HAS_BUILTIN_TRAIT(BT) 0
> > >> +#endif
> > >>
> > >> // Mark code that should be ignored by the compiler, but seen by Doxygen.
> > >> #define _GLIBCXX_DOXYGEN_ONLY(X)
> > >> --
> > >> 2.41.0
> > >>
> >
>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-09-11 14:59 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 22:32 [PATCH] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT Ken Matsui
2023-07-19 18:48 ` Patrick Palka
2023-07-19 19:31 ` Ken Matsui
2023-08-08 20:22 ` Jonathan Wakely
2023-07-19 19:32 ` [PATCH v2] " Ken Matsui
2023-07-20 16:05 ` Patrick Palka
2023-07-28 3:57 ` [PATCH v3 1/2] " Ken Matsui
2023-07-28 3:57 ` [PATCH v3 2/2] libstdc++: Use _GLIBCXX_HAS_BUILTIN_TRAIT Ken Matsui
2023-08-01 17:24 ` Patrick Palka
2023-08-08 20:23 ` [PATCH v2] libstdc++: Define _GLIBCXX_HAS_BUILTIN_TRAIT Jonathan Wakely
2023-08-31 12:32 ` Ken Matsui
2023-09-11 14:50 ` Jonathan Wakely
2023-09-11 14:58 ` Ken Matsui
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).