Re: [PATCH] Remove matherr, and SVID and X/Open math library configurations

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Hi Josef,

On Dec 11 22:08, Jozef Lawrynowicz wrote:
> The attached patch removes support for the "matherr" error handling function
> from the floating-point arithmetic routines in libm.
> 
> matherr is a relic of SVID and has been obsolete in glibc for a while (at least
> a few years as far as I can tell), and was removed completely earlier this
> year.
> 
> With the removal of matherr, "struct exception" (defined in
> libc/include/math.h) can also be removed, along with the enums for exception
> types (DOMAIN, SING, OVERFLOW etc.). Furthermore, the SVID and X/Open math
> library configurations are now redundant, so these have also been removed.
> IEEE and POSIX are now the two choices for the math library configuration, with
> IEEE being the default.
> I've updated the documentation in libm.texinfo and math.tex accordingly.
> 
> In addition to simplified wrapper functions for floating-point arithmetic in
> libm, the changes also significantly reduce code size for the single-precision
> float versions of the arithmetic functions. Members of "struct exception" were
> defined as doubles, so casting from the float values in the artihmetic
> function to the double values in "struct exception" required double conversion
> routines to be linked in.
> 
> For example, in a simple C program calling
>   powf (float_var, 2.42f)
> the following size reductions were observed:
> 
> msp430-elf text size
> before: 11448
> after: 9256
> 
> arm cortex-m4 text size
> before: 13188
> after: 11348
> 
> (flags used were -Os -Wl,-gc-sections)
> 
> A further trivial change I made in some of the math functions was to replace
> instances of floating-point constants being cast to float, with the float
> version of the constant e.g.
> -       if (float_var <= (float)0.0)
> +       if (float_var <= 0.0f)
> Also fixed double divides in float arithmetic functions e.g.
> -       return 0.0/0.0;
> +       return 0.0f/0.0f;
> 
> There are further cases of double constants being used in float functions (e.g.
> HUGE_VAL instead of HUGE_VALF) which I'll try and fix soon.
> 
> Successfully regtested the GCC, G++, libstdc++-v3 and Newlib testsuites for
> arm-unknown-eabi and msp430-elf.
> Successfully regtested the Newlib testsuite for Cygwin also.
> 
> If this patch is acceptable I would appreciate if someone would apply it for
> me, as I do not have write access. I guess the body of this email would suffice
> for the commit message, but let me know if a more concise one is required.

Thanks for the patch, it's highly appreciated.  There's just one
problem, hopefully requiring some minor rework only:

We have to keep matherr as exported symbol from Cygwin to maintain
backward compatibility.  In contrast to embedded, we can't afford
applications using this function to stop working with a new Cygwin
release just because there's no matherr symbol anymore.

However, I agree with the general sentiment that matherr is old stuff
and should go away.

So, would it be feasible to convert the matherr functions to a stub
which just returns 0 and otherwise just go ahead?  I'm pretty fuzzy on
the implications this change has on old apps actually using matherr...


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlwSVv0ACgkQ9TYGna5E
T6Bdqg/9Hb/EtiTg67foxsd8lXc6GldZg78RryQvL7vaTQAmTfpCHkIuRGSAa9VL
mogY8B3VF2DSUQtQpidLLgQfok2zBEad5BET4pP+ROcQdxk45dTGvSIr/Uoak0+Q
tSz86PCvLzxHljx2sQsA7QgsKH4cp1bOZ2k7Wautuzo0jcLgF0qK3oFi1dvRWIOg
aLETOQ/Z4UKEAgZPI1Xy5tsNcmLC6Mtsr3865tUpTcfyxco7MyV1KfEHf4sdcWjY
+9AY5Wr36yvBWR/lepujOQh7vWMPVmpp8kVl6jOreZ4decwdXy9rBf+QLCLrVPm7
JLt5B1ofjjyOkdQL6gS9tuUyDzTpw2fmRCMCaLmt3Q7GRT5nWlL69DUQMKYvP83z
4nnhVvDBRuuWSfgfJ8x6n4cg1703bs/GXwtr6uZzKtDDyWxgyU0f2IH+RwGD/eh+
HK5GbJeBOdk+Ji+wUn6vWO8/x8bPvxrqNWF3lAhqKoD/t+VBWFMXVuF9N/h8a1Zq
Fylz1LBSC2Xef/5Wc+cBbj5YvOikWp6S/XrG8txdj3J/D7eG4ObiImyvHxtXEBvL
AbFRD9SiUd+DppE8gz4/6o6b3uudZQDrNy9MWQNu8lgTvo0UN7wbkBjF9JoJG3Gk
+a9Hjs/8yhfKQWX8IAzHng9yhEfPyhcLV/3cZ+UnR9AV/iGUV60=
=7Rob
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.