From patchwork Fri Feb 14 22:54:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 38091 Received: (qmail 130290 invoked by alias); 14 Feb 2020 22:54:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 130282 invoked by uid 89); 14 Feb 2020 22:54:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=6474 X-HELO: mx0a-001b2d01.pphosted.com From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCH] Improve __LONG_DOUBLE_USES_FLOAT128 commentary Date: Fri, 14 Feb 2020 16:54:16 -0600 Message-Id: <20200214225416.28284-1-murphyp@linux.vnet.ibm.com> MIME-Version: 1.0 Per the feedback from Joseph [1]. Good comments and a more self-explanatory macro name will be very helpful when this macro or its successor are able to assume a non-zero value. [1] ---8<--- As noted, this is not the most ideal name for the conditional used to determine whether long double ABI should be redirected to _Float128 ABI. Once the development effort settles down, I will rename it. Improve the commentary to aid future developers who will stumble upon this novel, yet not always perfect, mechanism to support alternative formats for long double. --- bits/long-double.h | 15 ++++++++++++ .../ldbl-128ibm-compat/bits/long-double.h | 24 +++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/bits/long-double.h b/bits/long-double.h index 6e16447e65..29ba2506a2 100644 --- a/bits/long-double.h +++ b/bits/long-double.h @@ -37,4 +37,19 @@ #ifndef __NO_LONG_DOUBLE_MATH # define __NO_LONG_DOUBLE_MATH 1 #endif + +/* The macro __LONG_DOUBLE_USES_FLOAT128 is used to determine the + choice of the underlying ABI of long double during a single compilation. + + If the value is non-zero, any API which is parameterized by the long + double type (i.e the scanf/printf family of functions or the explicitly + parameterized math.h functions) will be redirected to a compatible + implementation using _Float128 ABI via symbols suffixed with ieee128. + + These redirections usually take the form of an "ASM Label" as called out + int Chapter 6.47.4 in the GCC 9 manual. And in very rare cases, a + macro. They do not alter or otherwise change the ABI stability of glibc. + + The mechanism this macro uses to acquire it's value is specific both a + function of architecture, and options used to invoke compilation. */ #define __LONG_DOUBLE_USES_FLOAT128 0 diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h b/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h index 91dddbdc8b..6bec7d82a3 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h +++ b/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h @@ -22,8 +22,24 @@ # define __NO_LONG_DOUBLE_MATH 1 # endif #endif -/* On platforms that reuse the _Float128 implementation for IEEE long - double, access to the correct long double functions is selected based - on the long double mode being used during the compilation. On - powerpc64le, this is true when -mabi=ieeelongdouble is in use. */ + +/* The macro __LONG_DOUBLE_USES_FLOAT128 is used to determine the + choice of the underlying ABI of long double during a single compilation. + + If the value is non-zero, any API which is parameterized by the long + double type (i.e the scanf/printf family of functions or the explicitly + parameterized math.h functions) will be redirected to a compatible + implementation using _Float128 ABI via symbols suffixed with ieee128. + + These redirections usually take the form of an "ASM Label" as called out + int Chapter 6.47.4 in the GCC 9 manual. And in very rare cases, a + macro. They do not alter or otherwise change the ABI stability of glibc. + + The mechanism this macro uses to acquire it's value is specific both a + function of architecture, and options used to invoke compilation. + + On powerpc64le, the GCC >=7 compiler option -mabi=ieeelongdouble will + change the underlying format of long double to IEEE 128 binary floating + point. We enable the redirects based how many mantissa digits GCC + reports for long double. For older GCC and non-IEEE, this is 106. */ #define __LONG_DOUBLE_USES_FLOAT128 (__LDBL_MANT_DIG__ == 113)