Message ID | 000801d0947e$3af04780$b0d0d680$@com |
---|---|
State | New |
Headers | show |
On Fri, 22 May 2015, Wilco Dijkstra wrote: > OK, I tried that and it works fine without having to change all the targets if > I define __signbit at the end of math.h. If a target's inline __signbit definitions are completely obsolete with this change, they should be removed as part of it. That means at least removing sysdeps/tile/bits/mathinline.h, since it only uses __builtin_signbit* and GCC versions before 4.0 don't support Tile. (ColdFire bits/mathinline.h confuses things by not having a GCC version conditional and so potentially using the builtins with GCC versions before 4.0 that had ColdFire support. But since 3.4 didn't support __builtin_signbit, I think that can be considered a clear bug and so the patch should also remove sysdeps/m68k/coldfire/fpu/bits/mathinline.h as obsoleted by the generic changes.) > +# if __GNUC_PREREQ (4,0) > +# undef __signbitl Why the #undef? I don't see any headers with macro definitions of __signbitl that need to be removed in math.h.
> Joseph wrote: > On Fri, 22 May 2015, Wilco Dijkstra wrote: > > > OK, I tried that and it works fine without having to change all the targets if > > I define __signbit at the end of math.h. > > If a target's inline __signbit definitions are completely obsolete with > this change, they should be removed as part of it. That means at least > removing sysdeps/tile/bits/mathinline.h, since it only uses > __builtin_signbit* and GCC versions before 4.0 don't support Tile. > (ColdFire bits/mathinline.h confuses things by not having a GCC version > conditional and so potentially using the builtins with GCC versions before > 4.0 that had ColdFire support. But since 3.4 didn't support > __builtin_signbit, I think that can be considered a clear bug and so the > patch should also remove sysdeps/m68k/coldfire/fpu/bits/mathinline.h as > obsoleted by the generic changes.) OK, I'll update the patch to remove those. > > +# if __GNUC_PREREQ (4,0) > > +# undef __signbitl > > Why the #undef? I don't see any headers with macro definitions of > __signbitl that need to be removed in math.h. Unless nldbl support is dead we need it as sysdeps/ldbl-opt/nldbl-signbit.c does: #define __signbitl __signbitl_XXX #include "nldbl-compat.h" nldbl-compat.h includes math/math.h, which would define __signbitl again. I couldn't force nldbl to build but replacing sysdeps/ieee754/ldbl-128/s_signbitl.c with nldlb-signbit.c confirmed the #undef fixes the issue. Wilco
On Fri, 22 May 2015, Wilco Dijkstra wrote: > > Why the #undef? I don't see any headers with macro definitions of > > __signbitl that need to be removed in math.h. > > Unless nldbl support is dead we need it as > sysdeps/ldbl-opt/nldbl-signbit.c does: > > #define __signbitl __signbitl_XXX > #include "nldbl-compat.h" > > nldbl-compat.h includes math/math.h, which would define __signbitl > again. I couldn't force nldbl to build but replacing > sysdeps/ieee754/ldbl-128/s_signbitl.c with nldlb-signbit.c confirmed the > #undef fixes the issue. Thanks - I was only looking in headers for a #define. I think the nldbl code is for linking -mlong-double-64 objects with libm, although I'm not aware of any documentation for it. Having a #undef in an installed header that's only relevant for building glibc seems unfortunate. Maybe it would be cleaner to (a) convert all glibc-internal calls to __signbit* into calls to the signbit macro (which should make no difference to the code generated at all), then (b) conditionally change the definition of the signbit macro to use __builtin_signbit*, rather than ever defining __signbit* as macros.
diff --git a/math/math.h b/math/math.h index 7e959fc..1262f49 100644 --- a/math/math.h +++ b/math/math.h @@ -493,6 +493,13 @@ extern int matherr (struct exception *__exc); fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; })) # endif +# if __GNUC_PREREQ (4,0) +# undef __signbitl +# define __signbit(x) __builtin_signbit(x) +# define __signbitf(x) __builtin_signbitf(x) +# define __signbitl(x) __builtin_signbitl(x) +# endif + #endif __END_DECLS diff --git a/sysdeps/ieee754/dbl-64/s_signbit.c b/sysdeps/ieee754/dbl-64/s_signbit.c index 764f11a..e78e998 100644 --- a/sysdeps/ieee754/dbl-64/s_signbit.c +++ b/sysdeps/ieee754/dbl-64/s_signbit.c @@ -18,9 +18,10 @@ <http://www.gnu.org/licenses/>. */ #include <math.h> - #include <math_private.h> +#undef __signbit + int __signbit (double x) { diff --git a/sysdeps/ieee754/flt-32/s_signbitf.c b/sysdeps/ieee754/flt-32/s_signbitf.c index 169820e..dccf0c7 100644 --- a/sysdeps/ieee754/flt-32/s_signbitf.c +++ b/sysdeps/ieee754/flt-32/s_signbitf.c @@ -18,9 +18,10 @@ <http://www.gnu.org/licenses/>. */ #include <math.h> - #include <math_private.h> +#undef __signbitf + int __signbitf (float x) { diff --git a/sysdeps/ieee754/ldbl-128/s_signbitl.c b/sysdeps/ieee754/ldbl-128/s_signbitl.c index acfe859..25c0bc7 100644 --- a/sysdeps/ieee754/ldbl-128/s_signbitl.c +++ b/sysdeps/ieee754/ldbl-128/s_signbitl.c @@ -18,9 +18,10 @@ <http://www.gnu.org/licenses/>. */ #include <math.h> - #include <math_private.h> +#undef __signbitl + int __signbitl (long double x) { diff --git a/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c b/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c index e95ad55..39102d2 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c @@ -21,6 +21,8 @@ #include <math_private.h> #include <math_ldbl_opt.h> +#undef __signbitl + int ___signbitl (long double x) { diff --git a/sysdeps/ieee754/ldbl-64-128/s_signbitl.c b/sysdeps/ieee754/ldbl-64-128/s_signbitl.c index 850db73..9955ecf 100644 --- a/sysdeps/ieee754/ldbl-64-128/s_signbitl.c +++ b/sysdeps/ieee754/ldbl-64-128/s_signbitl.c @@ -1,6 +1,7 @@ #include <math_ldbl_opt.h> #undef weak_alias #define weak_alias(n,a) +#undef __signbitl #define __signbitl(arg) ___signbitl(arg) #include <sysdeps/ieee754/ldbl-128/s_signbitl.c> #undef __signbitl diff --git a/sysdeps/ieee754/ldbl-96/s_signbitl.c b/sysdeps/ieee754/ldbl-96/s_signbitl.c index bbe72a6..5e7a0d7 100644 --- a/sysdeps/ieee754/ldbl-96/s_signbitl.c +++ b/sysdeps/ieee754/ldbl-96/s_signbitl.c @@ -18,9 +18,10 @@ <http://www.gnu.org/licenses/>. */ #include <math.h> - #include <math_private.h> +#undef __signbitl + int __signbitl (long double x) {