Message ID | 20170907104352.7748-3-gabriel@inconstante.eti.br |
---|---|
State | New |
Headers | show |
Series | Fixes for -mfloat128 being enabled by default on gcc for power | expand |
On Thu, 7 Sep 2017, Gabriel F. T. Gomes wrote: > This patch defines __finitef128 as __redirect___finitef128 in > sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c, similarly to what's > done for the float, double, and long double versions of these functions, > to get rid of the build error. Likewise for isinff128 and isnanf128. What is the build error? Why should s_finite.c need to redirect __finitef128, or to redirect __finitef or __finitel for that matter? s_finitef.c manages to redirect only __finitef, not any of the other versions, after all.
On Thu, 7 Sep 2017 14:39:42 +0000 Joseph Myers <joseph@codesourcery.com> wrote: >On Thu, 7 Sep 2017, Gabriel F. T. Gomes wrote: > >> This patch defines __finitef128 as __redirect___finitef128 in >> sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c, similarly to what's >> done for the float, double, and long double versions of these functions, >> to get rid of the build error. Likewise for isinff128 and isnanf128. > >What is the build error? Why should s_finite.c need to redirect >__finitef128, or to redirect __finitef or __finitel for that matter? >s_finitef.c manages to redirect only __finitef, not any of the other >versions, after all. I'm sorry for not making this clear in the patch itself. I'll try to explain what was my rationale and if that sounds OK, I'll add that to the commit message and comments. This is the build error: In file included from <command-line>:0:0: ../include/math.h:29:15: error: ‘__finitef128’ undeclared here (not in a function); did you mean ‘__rintf128’? hidden_proto (__finitef128) ^~~~~~~~~~~~ ./../include/libc-symbols.h:518:27: note: in definition of macro ‘__hidden_proto’ extern thread __typeof (name) name __hidden_proto_hiddenattr (attrs); ^~~~ ../include/math.h:29:1: note: in expansion of macro ‘hidden_proto’ hidden_proto (__finitef128) ^~~~~~~~~~~~ The output of the preprocessor has the following lines (snippets): # 21 "../math/bits/mathcalls-helper-functions.h" [...] extern int __redirect___finite (double __value) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); [...] extern int __redirect___finitef (float __value) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); [...] extern int __redirect___finitel (long double __value) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); [...] extern int __redirect___finitef128 (_Float128 __value) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); (from the multiple inclusions of mathcalls-helper-functions.h (see comment about the differences between s_finite.c and s_finitef.c further down this message)) But include/math.h declares hidden prototypes for them (snippet): # 9 "../include/math.h" 2 [...] extern __typeof (__redirect___finite) __redirect___finite __attribute__ ((visibility ("hidden"))); [...] extern __typeof (__redirect___finitef) __redirect___finitef __attribute__ ((visibility ("hidden"))); [...] extern __typeof (__redirect___finitel) __redirect___finitel __attribute__ ((visibility ("hidden"))); [...] extern __typeof (__finitef128) __finitef128 __attribute__ ((visibility ("hidden"))); ~~~~~~~~~~~ Here's the source of the error. As for the difference between s_finite.c and s_finitef.c, that happens because include/math.h includes math/math.h before creating the hidden prototypes. On top of that, math/math.h includes bits/mathcalls-helper-functions.h (once for each floating-point type). However, the declarations in bits/mathcalls-helper-functions.h are macroized using __MATHDECL_1. __MATHDECL_1 receives the suffix (f, l, f128, or nothing) as a parameter and expands the base name (e.g.: __finite). When s_finite.c defines __finite as __redirect_finite, all declarations in bits/mathcalls-helper-functions.h are also redefined. That doesn't happen with s_finitef.c because it only defines __finitef, which does not match with anything in bits/mathcalls-helper-functions.h.
On Fri, 8 Sep 2017, Gabriel F. T. Gomes wrote: > On top of that, math/math.h includes bits/mathcalls-helper-functions.h > (once for each floating-point type). However, the declarations in > bits/mathcalls-helper-functions.h are macroized using __MATHDECL_1. > __MATHDECL_1 receives the suffix (f, l, f128, or nothing) as a parameter > and expands the base name (e.g.: __finite). > > When s_finite.c defines __finite as __redirect_finite, all declarations in > bits/mathcalls-helper-functions.h are also redefined. That doesn't happen > with s_finitef.c because it only defines __finitef, which does not match > with anything in bits/mathcalls-helper-functions.h. I think that this key point - that the function name gets macro expanded before the concatenation - needs explaining in comments in all three affected source files to justify why they are defining the macros for other types.
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c index a5ec36b72f..19fc36e32d 100644 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c @@ -19,6 +19,7 @@ #define __finite __redirect___finite #define __finitef __redirect___finitef #define __finitel __redirect___finitel +#define __finitef128 __redirect___finitef128 #include <math.h> #include <math_ldbl_opt.h> #include <shlib-compat.h> diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c index 9c6789c7bd..18c23c5884 100644 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c @@ -19,6 +19,7 @@ #define __isinf __redirect___isinf #define __isinff __redirect___isinff #define __isinfl __redirect___isinfl +#define __isinff128 __redirect___isinff128 #include <math.h> #include <math_ldbl_opt.h> #include <shlib-compat.h> diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c index 3cfe1793da..e193670b0e 100644 --- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c +++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c @@ -19,6 +19,7 @@ #define __isnan __redirect___isnan #define __isnanf __redirect___isnanf #define __isnanl __redirect___isnanl +#define __isnanf128 __redirect___isnanf128 #include <math.h> #include <math_ldbl_opt.h> #include <shlib-compat.h>