RFA: Add implementation of cabsl()
Nick Clifton
nickc@redhat.com
Fri Feb 6 15:12:00 GMT 2015
Hi Guys,
Attached is a patch that adds an implementation of the cabsl()
function to newlib. I foolishly thought that adding a function that
just computes an absolute value would be easy, but boy was I wrong.
It turns out that I had to add a whole lot of supporting functions,
including a long double square root (sqrtl) and a long double
hypotenuse (hypotl) function, as well as definitions of IEEE long
double formats for a whole variety of architectures. So the patch is
actually quite large. The good news is that (if the patch is
acceptable) adding further long double math functions should be easier
now that most of the architectural support is in place.
One thing that might prove problematic is that the sqrtl() function
currently only rounds up to the nearest bit, rather than trying to
figure out the rounding mode currently in use and then applying that.
My hope is that if this is considered to be a problem, it could be
fixed by a follow up patch. (Preferably written by someone who is more
familiar with this kind of math than I am).
Another problem I had was testing the patch. I used an aarch64
toolchain to test compiling code that used the functions, but the
simulator I have is unable to run the code properly. (This is due to
problems with the simulator, which is currently under development).
I tried to build an x86_64-pc-cygwin toolchain, but no matter what I
did I could not get one to compile. If I had more time I would look
into this, but I need to get back to other work.
In the end I build an x86_64-pc-elf toolchain, extracted the maths
library from that and linked it into a test binary built natively on a
x86_64 Linux host. Cumbersome, but it worked, and the code tests
alright, at least for the limited testing I performed.
OK to apply ?
Cheers
Nick
newlib/ChangeLog
2015-02-06 Nick Clifton <nickc@redhat.com>
* libc/include/complex.h (cabsl): Add prototype.
(cimagl): Add prototype.
(creall): Add prototype.
* libc/include/ieeefp.h: Include float.h.
(EXT_EXPBITS, EXT_FRACHBITS, EXT_FRACLBITS)
(EXT_EXP_INFNAN. EXT_EXP_BIAS, EXT_FRACBITS): Define.
(struct ieee_ext, union ieee_ext_u): New types for long double
support.
* libc/include/math.h (finitel): Add prototype.
(hypotl): Add prototype.
(sqrtl): Add prototype.
* libm/common/Makefile.am (lsrc): Add sl_finite.c.
* libm/common/Makefile.in: Regenerate.
* libm/common/fdlibm.h (__ieee754_hypotl): Add prototype.
* libm/common/hypotl.c (hypotl): Add implementation for when long
double is larger than double.
* libm/common/sqrtl.c (sqrtl): Likewise.
* libm/common/sl_finite.c: New file. Adds implementation of the
finitel function.
* libm/complex/Makefile.am (lsrc): Define.
(libcomplex_la_SOURCES): Add lsrc.
(lib_a_SOURCES): Add lsrc.
* libm/complex/Makefile.in: Regenerate.
* libm/complex/cabs.c: Add documentation of cabsl function.
* libm/complex/cimag.c: Add documentation of cimagl function.
* libm/complex/creall.c: Add documentation of creall function.
* libm/complex/cabsl.c: New file. Adds implementation of the
cabsl function.
* libm/complex/cimagl.c: New file. Adds implementation of the
cimagl function.
* libm/complex/creakl.c: New file. Adds implementation of the
creall function.
* libm/math/Makefile.am (lsrc): Define.
(libmath_la_SOURCES): Add lsrc.
(lib_a_SOURCES): Add lsrc.
* libm/math/Makefile.in: Regenerate.
* libm/math/el_hypot.c: New file. Adds implementation of the
__ieee754_hypotl function.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newlib.cabsl.patch.xz
Type: application/x-xz
Size: 5700 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150206/ba0aef2c/attachment.xz>
More information about the Newlib
mailing list