public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
To: libc-alpha@sourceware.org
Cc: Joseph Myers <joseph@codesourcery.com>
Subject: [PATCHv2] powerpc: Fix the compiler type used with C++ when -mabi=ieeelongdouble
Date: Fri, 11 May 2018 19:25:00 -0000	[thread overview]
Message-ID: <20180511192515.30959-1-tuliom@linux.ibm.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1805042105010.23351@digraph.polyomino.org.uk>

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

  reply	other threads:[~2018-05-11 19:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-27 17:12 [PATCH] powerpc: Fix the compiler mode " 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           ` Tulio Magno Quites Machado Filho [this message]
2018-05-11 19:56             ` [PATCHv2] powerpc: Fix the compiler type " Joseph Myers
2018-05-11 23:23               ` Tulio Magno Quites Machado Filho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180511192515.30959-1-tuliom@linux.ibm.com \
    --to=tuliom@linux.ibm.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).