[PATCH] Remove matherr, and SVID and X/Open math library configurations
Jozef Lawrynowicz
jozef.l@mittosystems.com
Tue Dec 11 22:08:00 GMT 2018
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,
Jozef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Newlib-Remove-matherr-and-SVID-and-X-Open-math-libra.patch
Type: text/x-patch
Size: 137878 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20181211/ff7cead8/attachment.bin>
More information about the Cygwin-patches
mailing list