Re: [PATCH] PR libstdc++/84654 Do not use __float128 if it is disabled by the compiler

2018-03-01 Thread Jonathan Wakely
On 1 March 2018 at 18:54, Marc Glisse wrote:
> On Thu, 1 Mar 2018, Tulio Magno Quites Machado Filho wrote:
>
>> In order to use the __float128 in C++ it's necessary to check if
>> it is supported in libstdc++ (i.e. via _GLIBCXX_USE_FLOAT128) and if the
>> compiler enabled its support too, e.g. -mfloat128 or -mno-float128.
>
>
> Shouldn't we ensure that _GLIBCXX_USE_FLOAT128 is undefined instead?

Yes, a better approach might be to add this to
libstdc++-v3/include/bits/c++config.h:

#define _GLIBCXX_USE_FLOAT128
#if !defined(__FLOAT128__) && !defined(__SIZEOF_FLOAT128__)
#undef _GLIBCXX_USE_FLOAT128
#endif

Then change libstdc++-v3/acinclude.m4 so that instead of defining
_GLIBCXX_USE_FLOAT128 it does:

GLIBCXX_CONDITIONAL(ENABLE_FLOAT128, ...)

and then have libstdc++-v3/include/Makefile modify 
based on that, setting _GLIBCXX_USE_FLOAT128 to 0 or 1


Re: [PATCH] PR libstdc++/84654 Do not use __float128 if it is disabled by the compiler

2018-03-01 Thread Marc Glisse

On Thu, 1 Mar 2018, Jakub Jelinek wrote:


Note ia64, pa and powerpcspe likely need to be fixed too to predefine
__SIZEOF_FLOAT128__=16 if they provide __float128.


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56540
(it only mentions ia64)

--
Marc Glisse


Re: [PATCH] PR libstdc++/84654 Do not use __float128 if it is disabled by the compiler

2018-03-01 Thread Jakub Jelinek
On Thu, Mar 01, 2018 at 08:10:03PM +0100, Jakub Jelinek wrote:
> On Thu, Mar 01, 2018 at 03:47:19PM -0300, Tulio Magno Quites Machado Filho 
> wrote:
> > In order to use the __float128 in C++ it's necessary to check if
> > it is supported in libstdc++ (i.e. via _GLIBCXX_USE_FLOAT128) and if the
> > compiler enabled its support too, e.g. -mfloat128 or -mno-float128.
> > 
> > 2018-03-01 Tulio Magno Quites Machado Filho 
> 
> Two spaces between date and name and name and email address.
> 
> > PR libstdc++/84654
> > * include/bits/std_abs.h: Avoid to use __float128 when the
> > compiler disabled it.
> > * include/std/type_traits: Likewise.
> 
> That is incorrect.  Only powerpc* defines __FLOAT128__ macro, but it isn't
> the only one with __float128 type, e.g. x86_64-linux provides __float128
> too, but doesn't define __FLOAT128__.
> 
> On x86_64-linux one can check for defined(__SIZEOF_FLOAT128__) instead.
> 
> One could argue that what powerpc does is wrong, defining __SIZEOF_*__ is
> consistent with all the other __SIZEOF_*__ macros.
> 
> Also (up to libstdc++ maintainers) I'd say that _GLIBCXX_USE_FLOAT128
> macro should depend on this macro, rather than uglifying all the uses.
> So, #undef somewhere _GLIBCXX_USE_FLOAT128 if __SIZEOF_FLOAT128__ is
> not defined.

Note ia64, pa and powerpcspe likely need to be fixed too to predefine
__SIZEOF_FLOAT128__=16 if they provide __float128.

Jakub


Re: [PATCH] PR libstdc++/84654 Do not use __float128 if it is disabled by the compiler

2018-03-01 Thread Jakub Jelinek
On Thu, Mar 01, 2018 at 03:47:19PM -0300, Tulio Magno Quites Machado Filho 
wrote:
> In order to use the __float128 in C++ it's necessary to check if
> it is supported in libstdc++ (i.e. via _GLIBCXX_USE_FLOAT128) and if the
> compiler enabled its support too, e.g. -mfloat128 or -mno-float128.
> 
> 2018-03-01 Tulio Magno Quites Machado Filho 

Two spaces between date and name and name and email address.

>   PR libstdc++/84654
>   * include/bits/std_abs.h: Avoid to use __float128 when the
>   compiler disabled it.
>   * include/std/type_traits: Likewise.

That is incorrect.  Only powerpc* defines __FLOAT128__ macro, but it isn't
the only one with __float128 type, e.g. x86_64-linux provides __float128
too, but doesn't define __FLOAT128__.

On x86_64-linux one can check for defined(__SIZEOF_FLOAT128__) instead.

One could argue that what powerpc does is wrong, defining __SIZEOF_*__ is
consistent with all the other __SIZEOF_*__ macros.

Also (up to libstdc++ maintainers) I'd say that _GLIBCXX_USE_FLOAT128
macro should depend on this macro, rather than uglifying all the uses.
So, #undef somewhere _GLIBCXX_USE_FLOAT128 if __SIZEOF_FLOAT128__ is
not defined.

Jakub


Re: [PATCH] PR libstdc++/84654 Do not use __float128 if it is disabled by the compiler

2018-03-01 Thread Marc Glisse

On Thu, 1 Mar 2018, Tulio Magno Quites Machado Filho wrote:


In order to use the __float128 in C++ it's necessary to check if
it is supported in libstdc++ (i.e. via _GLIBCXX_USE_FLOAT128) and if the
compiler enabled its support too, e.g. -mfloat128 or -mno-float128.


Shouldn't we ensure that _GLIBCXX_USE_FLOAT128 is undefined instead?

By the way, __FLOAT128__ is power-only. x86 has __SIZEOF_FLOAT128__ 
instead (why did power pick a different name?).


--
Marc Glisse


[PATCH] PR libstdc++/84654 Do not use __float128 if it is disabled by the compiler

2018-03-01 Thread Tulio Magno Quites Machado Filho
In order to use the __float128 in C++ it's necessary to check if
it is supported in libstdc++ (i.e. via _GLIBCXX_USE_FLOAT128) and if the
compiler enabled its support too, e.g. -mfloat128 or -mno-float128.

2018-03-01 Tulio Magno Quites Machado Filho 

PR libstdc++/84654
* include/bits/std_abs.h: Avoid to use __float128 when the
compiler disabled it.
* include/std/type_traits: Likewise.
---
 libstdc++-v3/include/bits/std_abs.h  | 3 ++-
 libstdc++-v3/include/std/type_traits | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/std_abs.h 
b/libstdc++-v3/include/bits/std_abs.h
index 6e4551d..3ad1c2b 100644
--- a/libstdc++-v3/include/bits/std_abs.h
+++ b/libstdc++-v3/include/bits/std_abs.h
@@ -96,7 +96,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; }
 #endif
 
-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
+#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) \
+&& defined(__FLOAT128__)
   inline _GLIBCXX_CONSTEXPR
   __float128
   abs(__float128 __x)
diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index 711d6c5..4e2e4f7 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -342,7 +342,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 struct __is_floating_point_helper
 : public true_type { };
 
-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
+#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) \
+&& defined(__FLOAT128__)
   template<>
 struct __is_floating_point_helper<__float128>
 : public true_type { };
-- 
2.9.5