powerpc: Fix the compiler mode used with C++ when -mabi=ieeelongdouble

Message ID 20180427171150.28010-1-tuliom@linux.ibm.com
State Superseded
Delegated to: Joseph Myers
Headers

Commit Message

Tulio Magno Quites Machado Filho April 27, 2018, 5:11 p.m. UTC
  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(-)
  

Comments

Joseph Myers April 27, 2018, 7:32 p.m. UTC | #1
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.)
  

Patch

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