public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble
@ 2018-04-27 17:12 Tulio Magno Quites Machado Filho
  2018-04-27 19:32 ` Joseph Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-04-27 17:12 UTC (permalink / raw)
  To: libc-alpha; +Cc: meissner

When compiling C++  code with -mabi=ieeelongdouble, KCtype is
unavailable and TCtype should be used instead.

2018-04-27  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>

	* sysdeps/powerpc/bits/floatn.h [__HAVE_FLOAT128
	&& (!__GNUC_PREREQ (7, 0) || defined __cplusplus)
	&& __LDBL_MANT_DIG__ == 113] (__cfloat128): Use compiler mode __TC__.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
---
 sysdeps/powerpc/bits/floatn.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sysdeps/powerpc/bits/floatn.h b/sysdeps/powerpc/bits/floatn.h
index c3834096e3..9ba1b81380 100644
--- a/sysdeps/powerpc/bits/floatn.h
+++ b/sysdeps/powerpc/bits/floatn.h
@@ -66,10 +66,14 @@
 
 /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1.  */
 # if __HAVE_FLOAT128
+/* Add a typedef for older GCC and C++ compilers which don't natively support
+   _Complex _Float128..  */
 #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
-/* Add a typedef for older GCC compilers which don't natively support
-   _Complex _Float128.  */
+#   if __LDBL_MANT_DIG__ == 113
+typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
+#   else
 typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__)));
+#   endif
 #   define __CFLOAT128 __cfloat128
 #  else
 #   define __CFLOAT128 _Complex _Float128
-- 
2.14.3

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

* Re: [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble
  2018-04-27 17:12 [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble Tulio Magno Quites Machado Filho
@ 2018-04-27 19:32 ` Joseph Myers
  2018-04-30 14:02   ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Myers @ 2018-04-27 19:32 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, meissner

On Fri, 27 Apr 2018, Tulio Magno Quites Machado Filho wrote:

> When compiling C++  code with -mabi=ieeelongdouble, KCtype is
> unavailable and TCtype should be used instead.

In that case (-mabi=ieeelongdouble), I'd expect you to use "typedef long 
double _Float128;" for C++, and _Complex long double as the definition of 
__CFLOAT128 for C++, and x##l as the definition of __f128 for C++, as it's 
essentially the case implemented by 
sysdeps/ieee754/ldbl-128/bits/floatn.h.  You shouldn't need to use mode 
attributes at all.

(Uses of __HAVE_DISTINCT_FLOAT128 and __HAVE_FLOAT64X_LONG_DOUBLE will 
need careful review to see if additional macros are needed to cover this 
-mabi=ieeelongdouble case, but the general rule is that they relate to the 
*default* long double type for that glibc binary - meaning the one with 
__*l symbols, as selection of such implementation-namespace one-per-format 
symbols is generally what they are used for in installed headers - meaning 
the existing definitions for powerpc remain correct even with 
-mabi=ieeelongdouble and you should not copy the 
sysdeps/ieee754/ldbl-128/bits/floatn.h definitions of those macros.)

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble
  2018-04-27 19:32 ` Joseph Myers
@ 2018-04-30 14:02   ` Tulio Magno Quites Machado Filho
  2018-04-30 14:05     ` Tulio Magno Quites Machado Filho
  2018-04-30 14:52     ` Joseph Myers
  0 siblings, 2 replies; 10+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-04-30 14:02 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, meissner

Joseph Myers <joseph@codesourcery.com> writes:

> On Fri, 27 Apr 2018, Tulio Magno Quites Machado Filho wrote:
>
>> When compiling C++  code with -mabi=ieeelongdouble, KCtype is
>> unavailable and TCtype should be used instead.
>
> In that case (-mabi=ieeelongdouble), I'd expect you to use "typedef long 
> double _Float128;" for C++, and _Complex long double as the definition of 
> __CFLOAT128 for C++, and x##l as the definition of __f128 for C++, as it's 
> essentially the case implemented by 
> sysdeps/ieee754/ldbl-128/bits/floatn.h.  You shouldn't need to use mode 
> attributes at all.

Agreed.

> (Uses of __HAVE_DISTINCT_FLOAT128 and __HAVE_FLOAT64X_LONG_DOUBLE will 
> need careful review to see if additional macros are needed to cover this 
> -mabi=ieeelongdouble case, but the general rule is that they relate to the 
> *default* long double type for that glibc binary - meaning the one with 
> __*l symbols, as selection of such implementation-namespace one-per-format 
> symbols is generally what they are used for in installed headers - meaning 
> the existing definitions for powerpc remain correct even with 
> -mabi=ieeelongdouble and you should not copy the 
> sysdeps/ieee754/ldbl-128/bits/floatn.h definitions of those macros.)

Ack.

I haven't seen requirement for additional macros yet, but when _Float128 is
typedef'ed to long double, the following changes are also necessary:

diff --git a/math/math.h b/math/math.h
index 9b6cdce431..1f1ae6014f 100644
--- a/math/math.h
+++ b/math/math.h
@@ -1025,7 +1025,11 @@ issignaling (long double __val)
   return __issignalingl (__val);
 #  endif
 }
-#  if __HAVE_DISTINCT_FLOAT128
+#  if __HAVE_DISTINCT_FLOAT128 \
+      && (!defined __cplusplus \
+	  || defined __cplusplus && __LDBL_MANT_DIG__ != 113)
+/* When using an IEEE 128-bit long double, _Float128 is defined as long double
+   in C++.  */
 inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
 #  endif
 } /* extern C++ */

Is it architecturally-agnostic OK?

-- 
Tulio Magno

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

* Re: [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble
  2018-04-30 14:02   ` Tulio Magno Quites Machado Filho
@ 2018-04-30 14:05     ` Tulio Magno Quites Machado Filho
  2018-04-30 14:52     ` Joseph Myers
  1 sibling, 0 replies; 10+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-04-30 14:05 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, meissner

Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> writes:

> [ text/plain ]
> Joseph Myers <joseph@codesourcery.com> writes:
>
>> On Fri, 27 Apr 2018, Tulio Magno Quites Machado Filho wrote:
>>
>>> When compiling C++  code with -mabi=ieeelongdouble, KCtype is
>>> unavailable and TCtype should be used instead.
>>
>> (Uses of __HAVE_DISTINCT_FLOAT128 and __HAVE_FLOAT64X_LONG_DOUBLE will 
>> need careful review to see if additional macros are needed to cover this 
>> -mabi=ieeelongdouble case, but the general rule is that they relate to the 
>> *default* long double type for that glibc binary - meaning the one with 
>> __*l symbols, as selection of such implementation-namespace one-per-format 
>> symbols is generally what they are used for in installed headers - meaning 
>> the existing definitions for powerpc remain correct even with 
>> -mabi=ieeelongdouble and you should not copy the 
>> sysdeps/ieee754/ldbl-128/bits/floatn.h definitions of those macros.)
>
> Ack.
>
> I haven't seen requirement for additional macros yet, but when _Float128 is
> typedef'ed to long double, the following changes are also necessary:

I should have said "kind of changes".  We have to make the same changes to a
few other places in math/math.h.

> diff --git a/math/math.h b/math/math.h
> index 9b6cdce431..1f1ae6014f 100644
> --- a/math/math.h
> +++ b/math/math.h
> @@ -1025,7 +1025,11 @@ issignaling (long double __val)
>    return __issignalingl (__val);
>  #  endif
>  }
> -#  if __HAVE_DISTINCT_FLOAT128
> +#  if __HAVE_DISTINCT_FLOAT128 \
> +      && (!defined __cplusplus \
> +	  || defined __cplusplus && __LDBL_MANT_DIG__ != 113)
> +/* When using an IEEE 128-bit long double, _Float128 is defined as long double
> +   in C++.  */
>  inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
>  #  endif
>  } /* extern C++ */
>
> Is it architecturally-agnostic OK?

-- 
Tulio Magno

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

* Re: [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble
  2018-04-30 14:02   ` Tulio Magno Quites Machado Filho
  2018-04-30 14:05     ` Tulio Magno Quites Machado Filho
@ 2018-04-30 14:52     ` Joseph Myers
  2018-05-04 20:21       ` Tulio Magno Quites Machado Filho
  1 sibling, 1 reply; 10+ messages in thread
From: Joseph Myers @ 2018-04-30 14:52 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, meissner

On Mon, 30 Apr 2018, Tulio Magno Quites Machado Filho wrote:

> I haven't seen requirement for additional macros yet, but when _Float128 is
> typedef'ed to long double, the following changes are also necessary:
> 
> diff --git a/math/math.h b/math/math.h
> index 9b6cdce431..1f1ae6014f 100644
> --- a/math/math.h
> +++ b/math/math.h
> @@ -1025,7 +1025,11 @@ issignaling (long double __val)
>    return __issignalingl (__val);
>  #  endif
>  }
> -#  if __HAVE_DISTINCT_FLOAT128
> +#  if __HAVE_DISTINCT_FLOAT128 \
> +      && (!defined __cplusplus \
> +	  || defined __cplusplus && __LDBL_MANT_DIG__ != 113)
> +/* When using an IEEE 128-bit long double, _Float128 is defined as long double
> +   in C++.  */
>  inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
>  #  endif
>  } /* extern C++ */
> 
> Is it architecturally-agnostic OK?

I think that suggests the need for a new macro.

__HAVE_DISTINCT_FLOAT128 means that _Float128 has a different format from 
the *default* long double in this glibc - so that it's necessary to call 
__issignalingf128 rather than __issignalingl for a _Float128 argument, for 
example (if the format is the same as the default long double, 
__issignalingf128 doesn't exist, on the principle of having such 
implementation-namespace functions only exported once per floating-point 
format, not once per floating-point type).

In this C++ case (and this whole piece of code is only for C++, so 
__cplusplus conditionals certainly aren't needed within there), what 
you've found is that you want a conditional for whether _Float128 is 
different from long double for the present compilation - not from the 
default long double.

So that indicates having a new macro meaning that _Float128 exists and is 
different in format from long double for the present compilation, which 
could be defined in bits/floatn-common.h (based on 
__HAVE_DISTINCT_FLOAT128 and __LDBL_MANT_DIG__) rather than needing 
duplicating in different bits/floatn.h files.

Then, this would need using for issignaling and iszero and iseqsig in 
math.h.  Those C++ definitions would *also* need changes to the inlines 
for long double, because those inlines call either the unsuffixed or 
l-suffixed functions depending on __NO_LONG_DOUBLE_MATH, but would need to 
be able to call the f128-suffixed functions in the new case where long 
double uses such functions.  So maybe some new macro would be needed to 
indicate that case (and would then no doubt be used in other cases such as 
to control which functions are used by bits/math-finite.h for long 
double).

Something would also need doing for iscanonical, where 
sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h would need to know that in 
the case where long double is binary128, the same trivial definition used 
for __NO_LONG_DOUBLE_MATH suffices (presuming you don't try to support 
__ibm128 arguments to these macros in the case where long double is 
binary128).

The definitions of __MATH_TG using _Generic may also need updating to 
handle this case, since the uses in math.h are to select such 
once-per-format functions and thus long double selecting l-suffixed 
functions is inappropriate for -mabi=ieeelongdouble.  (The definitions 
using __builtin_types_compatible_p should only be applicate with old 
compilers with insufficient -mabi=ieeelongdouble support, so you probably 
don't need to change those.)  Note however that __MATH_TG is used in 
math_private.h in a way for which the types used in the current 
compilation are the relevant ones - so if any bits of glibc using 
math_private.h get built with -mabi=ieeelongdouble, you have an issue with 
different __MATH_TG definitions being appropriate for the different uses.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble
  2018-04-30 14:52     ` Joseph Myers
@ 2018-05-04 20:21       ` Tulio Magno Quites Machado Filho
  2018-05-04 21:06         ` Joseph Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-05-04 20:21 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, meissner

Joseph Myers <joseph@codesourcery.com> writes:

> On Mon, 30 Apr 2018, Tulio Magno Quites Machado Filho wrote:
>
>> I haven't seen requirement for additional macros yet, but when _Float128 is
>> typedef'ed to long double, the following changes are also necessary:
>> 
>> diff --git a/math/math.h b/math/math.h
>> index 9b6cdce431..1f1ae6014f 100644
>> --- a/math/math.h
>> +++ b/math/math.h
>> @@ -1025,7 +1025,11 @@ issignaling (long double __val)
>>    return __issignalingl (__val);
>>  #  endif
>>  }
>> -#  if __HAVE_DISTINCT_FLOAT128
>> +#  if __HAVE_DISTINCT_FLOAT128 \
>> +      && (!defined __cplusplus \
>> +	  || defined __cplusplus && __LDBL_MANT_DIG__ != 113)
>> +/* When using an IEEE 128-bit long double, _Float128 is defined as long double
>> +   in C++.  */
>>  inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
>>  #  endif
>>  } /* extern C++ */
>> 
>> Is it architecturally-agnostic OK?
>
> I think that suggests the need for a new macro.
>
> __HAVE_DISTINCT_FLOAT128 means that _Float128 has a different format from 
> the *default* long double in this glibc - so that it's necessary to call 
> __issignalingf128 rather than __issignalingl for a _Float128 argument, for 
> example (if the format is the same as the default long double, 
> __issignalingf128 doesn't exist, on the principle of having such 
> implementation-namespace functions only exported once per floating-point 
> format, not once per floating-point type).

OK.

> In this C++ case (and this whole piece of code is only for C++, so 
> __cplusplus conditionals certainly aren't needed within there),

Aaargh!

> what you've found is that you want a conditional for whether _Float128 is 
> different from long double for the present compilation - not from the 
> default long double.
>
> So that indicates having a new macro meaning that _Float128 exists and is 
> different in format from long double for the present compilation, which 
> could be defined in bits/floatn-common.h (based on 
> __HAVE_DISTINCT_FLOAT128 and __LDBL_MANT_DIG__) rather than needing 
> duplicating in different bits/floatn.h files.

Agreed.
We need a good name and explanation to avoid the confusion with
__HAVE_DISTINCT_FLOAT*.

What about this?

/* Defined to 1 if the corresponding _FloatN type is not binary compatible
   with the corresponding ISO C type.  */
#define __HAVE_FLOAT128_UNLIKE_LDBL __HAVE_DISTINCT_FLOAT128 \
				    && __LDBL_MANT_DIG__ != 113

> Then, this would need using for issignaling and iszero and iseqsig in 
> math.h.  Those C++ definitions would *also* need changes to the inlines 
> for long double, because those inlines call either the unsuffixed or 
> l-suffixed functions depending on __NO_LONG_DOUBLE_MATH, but would need to 
> be able to call the f128-suffixed functions in the new case where long 
> double uses such functions.  So maybe some new macro would be needed to 
> indicate that case (and would then no doubt be used in other cases such as 
> to control which functions are used by bits/math-finite.h for long 
> double).

Ack.

> Something would also need doing for iscanonical, where 
> sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h would need to know that in 
> the case where long double is binary128, the same trivial definition used 
> for __NO_LONG_DOUBLE_MATH suffices (presuming you don't try to support 
> __ibm128 arguments to these macros in the case where long double is 
> binary128).

OK.

> The definitions of __MATH_TG using _Generic may also need updating to 
> handle this case, since the uses in math.h are to select such 
> once-per-format functions and thus long double selecting l-suffixed 
> functions is inappropriate for -mabi=ieeelongdouble.  (The definitions 
> using __builtin_types_compatible_p should only be applicate with old 
> compilers with insufficient -mabi=ieeelongdouble support, so you probably 
> don't need to change those.)  Note however that __MATH_TG is used in 
> math_private.h in a way for which the types used in the current 
> compilation are the relevant ones - so if any bits of glibc using 
> math_private.h get built with -mabi=ieeelongdouble, you have an issue with 
> different __MATH_TG definitions being appropriate for the different uses.

Ack.

-- 
Tulio Magno

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

* Re: [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble
  2018-05-04 20:21       ` Tulio Magno Quites Machado Filho
@ 2018-05-04 21:06         ` Joseph Myers
  2018-05-11 19:25           ` [PATCHv2] powerpc: Fix the compiler type " Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Myers @ 2018-05-04 21:06 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha, meissner

On Fri, 4 May 2018, Tulio Magno Quites Machado Filho wrote:

> /* Defined to 1 if the corresponding _FloatN type is not binary compatible
>    with the corresponding ISO C type.  */
> #define __HAVE_FLOAT128_UNLIKE_LDBL __HAVE_DISTINCT_FLOAT128 \
> 				    && __LDBL_MANT_DIG__ != 113

Yes, something like that (but the comment should say explicitly this is 
about the types in the current compilation rather than the default types 
for this glibc, and that that's how this is distinguished from 
__HAVE_DISTINCT_FLOAT128 - and the expansion should be in parentheses).

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* [PATCHv2] powerpc: Fix the compiler type used with C++ when -mabi=ieeelongdouble
  2018-05-04 21:06         ` Joseph Myers
@ 2018-05-11 19:25           ` Tulio Magno Quites Machado Filho
  2018-05-11 19:56             ` Joseph Myers
  0 siblings, 1 reply; 10+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-05-11 19:25 UTC (permalink / raw)
  To: libc-alpha; +Cc: Joseph Myers

Changes since v1:
 - Introduced macro __HAVE_FLOAT128_UNLIKE_LDBL;
 - Fixed the definition of __f128();
 - Used long double instead of attributes;

Note:
 - There are many other places that will use __HAVE_FLOAT128_UNLIKE_LDBL.
   They will appear in other patches that are already changing those places.

---8<---

When compiling C++  code with -mabi=ieeelongdouble, KCtype is
unavailable and the long double type should be used instead.

This is also providing macro __HAVE_FLOAT128_UNLIKE_LDBL in order to
identify the kind of long double type is being used in the current
compilation unit.
Notice that bits/floatn.h cannot benefit from the new macro due to order
of header inclusion.

2018-05-10  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>

	* bits/floatn-common.h: Define __HAVE_FLOAT128_UNLIKE_LDBL.
	* math/math.h: Restrict the prototype definition for the functions
	issignaling(_Float128) and iszero(_Float128); and template
	__iseqsig_type<_Float128>, from __HAVE_DISTINCT_FLOAT128 to
	__HAVE_FLOAT128_UNLIKE_LDBL.
	* sysdeps/powerpc/bits/floatn.h [__HAVE_FLOAT128
	&& (!__GNUC_PREREQ (7, 0) || defined __cplusplus)
	&& __LDBL_MANT_DIG__ == 113]: Use long double suffix for
	__f128() constants; define the type _Float128 as long double;
	and reuse long double in __CFLOAT128.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
---
 bits/floatn-common.h          |  7 +++++++
 math/math.h                   | 12 +++++++++---
 sysdeps/powerpc/bits/floatn.h | 24 ++++++++++++++----------
 3 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/bits/floatn-common.h b/bits/floatn-common.h
index 070cdd0247..1d8958a193 100644
--- a/bits/floatn-common.h
+++ b/bits/floatn-common.h
@@ -56,6 +56,13 @@
 #define __HAVE_DISTINCT_FLOAT64X 0
 #define __HAVE_DISTINCT_FLOAT128X __HAVE_FLOAT128X
 
+/* Defined to 1 if the corresponding _FloatN type is not binary compatible
+   with the corresponding ISO C type in the current compilation unit as
+   opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built
+   in glibc.  */
+#define __HAVE_FLOAT128_UNLIKE_LDBL (__HAVE_DISTINCT_FLOAT128	\
+				     && __LDBL_MANT_DIG__ != 113)
+
 /* Defined to 1 if any _FloatN or _FloatNx types that are not
    ABI-distinct are however distinct types at the C language level (so
    for the purposes of __builtin_types_compatible_p and _Generic).  */
diff --git a/math/math.h b/math/math.h
index 2e2696854b..87240336e0 100644
--- a/math/math.h
+++ b/math/math.h
@@ -989,7 +989,9 @@ issignaling (long double __val)
   return __issignalingl (__val);
 #  endif
 }
-#  if __HAVE_DISTINCT_FLOAT128
+#  if __HAVE_FLOAT128_UNLIKE_LDBL
+/* When using an IEEE 128-bit long double, _Float128 is defined as long double
+   in C++.  */
 inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
 #  endif
 } /* extern C++ */
@@ -1027,7 +1029,9 @@ iszero (long double __val)
   return __fpclassifyl (__val) == FP_ZERO;
 #   endif
 }
-#   if __HAVE_DISTINCT_FLOAT128
+#   if __HAVE_FLOAT128_UNLIKE_LDBL
+  /* When using an IEEE 128-bit long double, _Float128 is defined as long double
+     in C++.  */
 inline int
 iszero (_Float128 __val)
 {
@@ -1517,7 +1521,9 @@ template<> struct __iseqsig_type<long double>
   }
 };
 
-#  if __HAVE_DISTINCT_FLOAT128
+#  if __HAVE_FLOAT128_UNLIKE_LDBL
+  /* When using an IEEE 128-bit long double, _Float128 is defined as long double
+     in C++.  */
 template<> struct __iseqsig_type<_Float128>
 {
   static int __call (_Float128 __x, _Float128 __y) throw ()
diff --git a/sysdeps/powerpc/bits/floatn.h b/sysdeps/powerpc/bits/floatn.h
index c3834096e3..c6d8b9b9b3 100644
--- a/sysdeps/powerpc/bits/floatn.h
+++ b/sysdeps/powerpc/bits/floatn.h
@@ -33,7 +33,8 @@
 #endif
 
 /* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct
-   from the default float, double and long double types in this glibc.  */
+   from the default float, double and long double types in this glibc, i.e.
+   calls to the binary128 functions go to *f128 symbols instead of *l.  */
 #if __HAVE_FLOAT128
 # define __HAVE_DISTINCT_FLOAT128 1
 #else
@@ -58,7 +59,11 @@
 # if __HAVE_FLOAT128
 #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
 /* The literal suffix (f128) exist for powerpc only since GCC 7.0.  */
-#   define __f128(x) x##q
+#   if __LDBL_MANT_DIG__ == 113
+#    define __f128(x) x##l
+#   else
+#    define __f128(x) x##q
+#   endif
 #  else
 #   define __f128(x) x##f128
 #  endif
@@ -66,8 +71,13 @@
 
 /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1.  */
 # if __HAVE_FLOAT128
-#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
-/* Add a typedef for older GCC compilers which don't natively support
+#  if __LDBL_MANT_DIG__ == 113 && defined __cplusplus
+typedef long double _Float128;
+#   define __CFLOAT128 _Complex long double
+#  elif !__GNUC_PREREQ (7, 0) || defined __cplusplus
+/* The type _Float128 exist for powerpc only since GCC 7.0.  */
+typedef __float128 _Float128;
+/* Add a typedef for older GCC and C++ compilers which don't natively support
    _Complex _Float128.  */
 typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__)));
 #   define __CFLOAT128 __cfloat128
@@ -78,12 +88,6 @@ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__)));
 
 /* The remaining of this file provides support for older compilers.  */
 # if __HAVE_FLOAT128
-
-/* The type _Float128 exist for powerpc only since GCC 7.0.  */
-#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
-typedef __float128 _Float128;
-#  endif
-
 /* Builtin __builtin_huge_valf128 doesn't exist before GCC 7.0.  */
 #  if !__GNUC_PREREQ (7, 0)
 #   define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
-- 
2.14.3

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

* Re: [PATCHv2] powerpc: Fix the compiler type used with C++ when -mabi=ieeelongdouble
  2018-05-11 19:25           ` [PATCHv2] powerpc: Fix the compiler type " Tulio Magno Quites Machado Filho
@ 2018-05-11 19:56             ` Joseph Myers
  2018-05-11 23:23               ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 10+ messages in thread
From: Joseph Myers @ 2018-05-11 19:56 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: libc-alpha

On Fri, 11 May 2018, Tulio Magno Quites Machado Filho wrote:

> 2018-05-10  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
> 
> 	* bits/floatn-common.h: Define __HAVE_FLOAT128_UNLIKE_LDBL.
> 	* math/math.h: Restrict the prototype definition for the functions
> 	issignaling(_Float128) and iszero(_Float128); and template
> 	__iseqsig_type<_Float128>, from __HAVE_DISTINCT_FLOAT128 to
> 	__HAVE_FLOAT128_UNLIKE_LDBL.
> 	* sysdeps/powerpc/bits/floatn.h [__HAVE_FLOAT128
> 	&& (!__GNUC_PREREQ (7, 0) || defined __cplusplus)
> 	&& __LDBL_MANT_DIG__ == 113]: Use long double suffix for
> 	__f128() constants; define the type _Float128 as long double;
> 	and reuse long double in __CFLOAT128.

This version is OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCHv2] powerpc: Fix the compiler type used with C++ when -mabi=ieeelongdouble
  2018-05-11 19:56             ` Joseph Myers
@ 2018-05-11 23:23               ` Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; 10+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2018-05-11 23:23 UTC (permalink / raw)
  To: libc-alpha

Joseph Myers <joseph@codesourcery.com> writes:

> On Fri, 11 May 2018, Tulio Magno Quites Machado Filho wrote:
>
>> 2018-05-10  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
>> 
>> 	* bits/floatn-common.h: Define __HAVE_FLOAT128_UNLIKE_LDBL.
>> 	* math/math.h: Restrict the prototype definition for the functions
>> 	issignaling(_Float128) and iszero(_Float128); and template
>> 	__iseqsig_type<_Float128>, from __HAVE_DISTINCT_FLOAT128 to
>> 	__HAVE_FLOAT128_UNLIKE_LDBL.
>> 	* sysdeps/powerpc/bits/floatn.h [__HAVE_FLOAT128
>> 	&& (!__GNUC_PREREQ (7, 0) || defined __cplusplus)
>> 	&& __LDBL_MANT_DIG__ == 113]: Use long double suffix for
>> 	__f128() constants; define the type _Float128 as long double;
>> 	and reuse long double in __CFLOAT128.
>
> This version is OK.

Pushed as 5db7d705db472.

Thanks!

-- 
Tulio Magno

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

end of thread, other threads:[~2018-05-11 23:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27 17:12 [PATCH] powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble Tulio Magno Quites Machado Filho
2018-04-27 19:32 ` Joseph Myers
2018-04-30 14:02   ` Tulio Magno Quites Machado Filho
2018-04-30 14:05     ` Tulio Magno Quites Machado Filho
2018-04-30 14:52     ` Joseph Myers
2018-05-04 20:21       ` Tulio Magno Quites Machado Filho
2018-05-04 21:06         ` Joseph Myers
2018-05-11 19:25           ` [PATCHv2] powerpc: Fix the compiler type " Tulio Magno Quites Machado Filho
2018-05-11 19:56             ` Joseph Myers
2018-05-11 23:23               ` Tulio Magno Quites Machado Filho

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).