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

Corinna Vinschen vinschen@redhat.com
Fri Dec 14 12:31:00 GMT 2018


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20181214/3e08b4b6/attachment.sig>


More information about the Newlib mailing list