diff options
author | Nick Clifton <nickc@redhat.com> | 2015-02-06 16:14:04 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2015-02-06 16:14:04 +0000 |
commit | b9e7cd9a846cf584049a719bbd0e4cabe3c50bea (patch) | |
tree | 33bb86b0a39693a67106d740062bc5975285b87f /newlib/libm/common/hypotl.c | |
parent | db004c5d7af31d9a56321d7780621b1df6a1559e (diff) | |
download | cygnal-b9e7cd9a846cf584049a719bbd0e4cabe3c50bea.tar.gz cygnal-b9e7cd9a846cf584049a719bbd0e4cabe3c50bea.tar.bz2 cygnal-b9e7cd9a846cf584049a719bbd0e4cabe3c50bea.zip |
* 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/creall.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.
Diffstat (limited to 'newlib/libm/common/hypotl.c')
-rw-r--r-- | newlib/libm/common/hypotl.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/newlib/libm/common/hypotl.c b/newlib/libm/common/hypotl.c index 3934b8ecc..cf67ccf58 100644 --- a/newlib/libm/common/hypotl.c +++ b/newlib/libm/common/hypotl.c @@ -29,14 +29,61 @@ POSSIBILITY OF SUCH DAMAGE. */ #include <math.h> -#include "local.h" +#include <errno.h> +#include "fdlibm.h" -/* On platforms where long double is as wide as double. */ -#ifdef _LDBL_EQ_DBL long double hypotl (long double x, long double y) { +#ifdef _LDBL_EQ_DBL + + /* On platforms where long double is as wide as double. */ return hypot(x, y); -} + +#else + + long double z; + + z = __ieee754_hypotl (x, y); + + if (_LIB_VERSION == _IEEE_) + return z; + + if ((! finitel (z)) && finitel (x) && finitel (y)) + { + /* hypot (finite, finite) overflow. */ + struct exception exc; + + exc.type = OVERFLOW; + exc.name = "hypotl"; + exc.err = 0; + exc.arg1 = x; + exc.arg2 = y; + + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE; + else + { +#ifndef HUGE_VAL +#define HUGE_VAL inf + double inf = 0.0; + + SET_HIGH_WORD (inf, 0x7ff00000); /* Set inf to infinite. */ #endif + exc.retval = HUGE_VAL; + } + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (! matherr (& exc)) + errno = ERANGE; + + if (exc.err != 0) + errno = exc.err; + + return (long double) exc.retval; + } + + return z; +#endif /* ! _LDBL_EQ_DBL */ +} |