[RFC,3/5] Do not declare __mpn_extract_float128 when long double has binary128 format

Message ID 20180524043553.23569-4-gabriel@inconstante.eti.br
State Superseded
Headers

Commit Message

Gabriel F. T. Gomes May 24, 2018, 4:35 a.m. UTC
  In the internal header include/gmp.h, __mpn_extract_float128 is declared
whenever the float128 API is being built, but only when long double is
not ABI-compatible with _Float128 (i.e.: when __HAVE_DISTINCT_FLOAT128).

Checking for __HAVE_DISTINCT_FLOAT128 is currently enough for building
glibc for all platforms.  However, when powerpc64le adds support for
long double with a third format (binary128), __mpn_extract_float128 will
be used by the implementation of some long double functions, such as
vfprintf/__printf_fp (at a first glance, it could seem illogical to use
a float128 function for long double, but this design choice reduces the
changes to the ABI, by reusing functions that are already exported).

The reuse of this internal function will be achieve (in a later patch)
with the redefinition of __mpn_extract_long_double to
__mpn_extract_float128, similarly to what float128_private.h does.
However, since __mpn_extract_long_double is redefined, it would get
declared twice by include/gmp.h, with mismatching parameters.  This
patch adds a check for __HAVE_FLOAT128_UNLIKE_LDBL, which avoids the
second declaration of __mpn_extract_float128.

Tested for powerpc64le.

	* include/gmp.h (__mpn_extract_float128): Only declare when
	__HAVE_DISTINCT_FLOAT128 and __HAVE_FLOAT128_UNLIKE_LDBL.
---
 include/gmp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/include/gmp.h b/include/gmp.h
index 657c7a0148..aa9299c67e 100644
--- a/include/gmp.h
+++ b/include/gmp.h
@@ -19,7 +19,7 @@  extern mp_size_t __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
 					    long double value)
      attribute_hidden;
 
-#if __HAVE_DISTINCT_FLOAT128
+#if __HAVE_DISTINCT_FLOAT128 && __HAVE_FLOAT128_UNLIKE_LDBL
 extern mp_size_t __mpn_extract_float128 (mp_ptr res_ptr, mp_size_t size,
 					 int *expt, int *is_neg,
 					 _Float128 value)