diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-04-30 15:51:34 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-04-30 15:51:34 +0000 |
commit | 779ae82ecdf88b7ed7c1f00d3ed3a639671c3c8d (patch) | |
tree | 287afe5ef732d76109129a142c5840cc42a2b34a /sysdeps/libm-ieee754 | |
parent | a12ea214dbc999b98ab5ed4e53fb0089cf5e183a (diff) | |
download | glibc-779ae82ecdf88b7ed7c1f00d3ed3a639671c3c8d.zip glibc-779ae82ecdf88b7ed7c1f00d3ed3a639671c3c8d.tar.gz glibc-779ae82ecdf88b7ed7c1f00d3ed3a639671c3c8d.tar.bz2 |
Update.cvs/libc-ud-970430cvs/libc-970619cvs/libc-970618cvs/libc-970617cvs/libc-970616cvs/libc-970615cvs/libc-970614cvs/libc-970613cvs/libc-970612cvs/libc-970611cvs/libc-970610cvs/libc-970609cvs/libc-970608cvs/libc-970607cvs/libc-970606cvs/libc-970605cvs/libc-970604cvs/libc-970603cvs/libc-970602cvs/libc-970601cvs/libc-970531cvs/libc-970530cvs/libc-970529cvs/libc-970528cvs/libc-970527cvs/libc-970526cvs/libc-970525cvs/libc-970524cvs/libc-970523cvs/libc-970522cvs/libc-970521cvs/libc-970520cvs/libc-970519cvs/libc-970518cvs/libc-970517cvs/libc-970516cvs/libc-970515cvs/libc-970514cvs/libc-970513cvs/libc-970512cvs/libc-970511cvs/libc-970510cvs/libc-970509cvs/libc-970508cvs/libc-970507cvs/libc-970506cvs/libc-970505cvs/libc-970504cvs/libc-970503cvs/libc-970502cvs/libc-970501
1997-04-30 17:35 Ulrich Drepper <drepper@cygnus.com>
* math/libm-test.c: Implement test for exceptions.
Partly due to Andreas Jaeger.
(csin_test): New function.
* sysdeps/libm-i387/s_cexp.S: Raise correct exceptions.
* sysdeps/libm-i387/s_cexpf.S: Likewise.
* sysdeps/libm-i387/s_cexpl.S: Likewise.
* sysdeps/libm-ieee754/s_ccos.c: Likewise.
* sysdeps/libm-ieee754/s_ccosf.c: Likewise.
* sysdeps/libm-ieee754/s_ccosl.c: Likewise.
* sysdeps/libm-ieee754/s_ccosh.c: Likewise.
* sysdeps/libm-ieee754/s_ccoshf.c: Likewise.
* sysdeps/libm-ieee754/s_ccoshl.c: Likewise.
* sysdeps/libm-ieee754/s_cexp.c: Likewise.
* sysdeps/libm-ieee754/s_cexpf.c: Likewise.
* sysdeps/libm-ieee754/s_cexpl.c: Likewise.
* sysdeps/libm-ieee754/s_csinh.c: Likewise.
* sysdeps/libm-ieee754/s_csinhf.c: Likewise.
* sysdeps/libm-ieee754/s_csinhl.c: Likewise.
* sysdeps/libm-ieee754/s_ctanh.c: Likewise.
* sysdeps/libm-ieee754/s_ctanhf.c: Likewise.
* sysdeps/libm-ieee754/s_ctanhl.c: Likewise.
* sysdeps/libm-ieee754/s_ccosh.c: Correct computation.
* sysdeps/libm-ieee754/s_ccoshf.c: Likewise.
* sysdeps/libm-ieee754/s_ccoshl.c: Likewise.
* sysdeps/libm-ieee754/s_csinh.c: Likewise.
* sysdeps/libm-ieee754/s_csinhf.c: Likewise.
* sysdeps/libm-ieee754/s_csinhl.c: Likewise.
* sysdeps/libm-ieee754/s_csin.c: Rewrite.
* sysdeps/libm-ieee754/s_csinf.c: Likewise.
* sysdeps/libm-ieee754/s_csinl.c: Likewise.
* stdlib/random_r.c (__srandom_r): Don't use seed 0. Use 1 in this
case.
* sysdeps/i386/dl-machine.h (elf_machine_load_address): Use notation
for local label.
* time/strftime.c (add): Respect `0' padding flag.
Reported by Richard Stallman <rms@gnu.ai.mit.edu>.
1997-04-30 15:46 Ulrich Drepper <drepper@cygnus.com>
* Makeconfig (start-installed-name): Define here, not in csu/Makefile.
Use in +link macro.
* csu/Makefile (distribute): Add abi-note.S and abi-tag.h.
(start-installed-name): Don't define here.
When ELF generate file named by start-installed-name from start.o
and abi-note.o.
* csu/abi-note.S: New file.
* sysdeps/stub/abi-tag.h: New file.
* sysdpes/unix/sysv/linux/abi-tag.h: New file.
Patches by Roland McGrath <roland@gnu.ai.mit.edu>.
1997-04-30 01:32 Ulrich Drepper <drepper@cygnus.com>
* manual/stdio.texi: Use @vtable where possible.
Add TeX version of @multitable since texi2dvi cannot handle them
correct in the moment.
* po/de.po: Update.
1997-04-29 21:06 Ulrich Drepper <drepper@cygnus.com>
* Makeconfig: Don't set cross-compiling based on $(BUILD_CC) != $(CC).
* config.make.in: Set cross-compiling from configure result.
* configure.in: Emit definition of `cross_compiling'.
Patches by Marcus G. Daniels <marcus@cathcart.sysc.pdx.edu>.
1997-04-27 21:50 Philip Blundell <pjb27@cam.ac.uk>
* sysdeps/unix/sysv/linux/net/route.h (struct in6_rtmsg): Use
correct `int' sizes for struct members.
1997-04-29 19:14 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/libm-i387/e_powf.S Generate invalid exception correctly.
* sysdeps/libm-i387/e_pow.S: Likewise.
* sysdeps/libm-i387/e_powl.S: Likewise.
1997-04-23 10:08 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* math/fenv.h: Correct typos.
1997-04-28 10:04 Richard Henderson <rth@tamu.edu>
* sysdeps/unix/sysv/linux/alpha/clone.S: Save the function argument
in t0 rather than a4 to avoid it being clobbered.
1997-04-27 23:52 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* manual/summary.awk: Recognize @defmumblex.
* manual/signal.texi (Miscellaneous Signals): Use @deftypevrx for
second description header.
1997-04-27 23:29 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* manual/arith.texi (Floating-Point Classes): Don't indent text,
makeinfo doesn't like that.
1997-04-27 20:52 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* malloc/obstack.h (obstack_specify_allocation_with_arg,
obstack_chunkfun, obstack_freefun): Fix casts.
1997-04-27 18:21 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* manual/xtract-typefun.awk: Allow names with only one character.
1997-04-26 14:16 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/netinet/ip_fw.h: Use <netinet/ip_icmp.h>
not <netinet/icmp.h>.
Reported by Michael Deutschmann <ldeutsch@mail.netshop.net>.
1997-04-25 12:31 Ulrich Drepper <drepper@cygnus.com>
* csu/Makefile ($(objpfx)initfini.s): Add CPPFLAGS, CFLAGS and -g0
to command line of compiler.
Patch by Marcus G. Daniels <marcus@sysc.pdx.edu>.
* sysdeps/generic/sigset.h (__sigandset, __sigorset): Fix typos.
Patch by Marcus G. Daniels <marcus@sysc.pdx.edu>.
* signal/signal.h (_sys_siglist, sys_siglist): Use _NSIG, not NSIG
in declaration.
Patch by Michael Widenius <monty@tcx.se>.
* time/strptime.c (strptime_internal): Fix %I format specifier
being off by one.
Patch by Mark Kettenis <kettenis@phys.uva.nl>.
1997-04-24 12:18 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* stdlib/lcong48_r.c: Include <limits.h>.
* stdlib/seed48_r.c: Likewise.
* stdio-common/printf_size.c (printf_size): Correct type of
`units' and make robust against future changes.
1997-04-23 18:58 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/libm-ieee754/s_cproj.c: Use isfinite instead of finite.
* sysdeps/libm-ieee754/s_cprojl.c: Likewise.
* sysdeps/libm-ieee754/s_cprojf.c: Likewise.
1997-04-23 18:53 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* manual/arith.texi, manual/math.texi: Use @defmumblex for
additional description headers.
* manual/xtract-typefun.awk: Recognize them.
1997-04-22 15:58 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* stdio-common/printf_size.c (printf_size): Correct size of array
units.
Diffstat (limited to 'sysdeps/libm-ieee754')
-rw-r--r-- | sysdeps/libm-ieee754/s_ccos.c | 16 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_ccosf.c | 16 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_ccosh.c | 14 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_ccoshf.c | 16 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_ccoshl.c | 14 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_ccosl.c | 16 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_cexpf.c | 15 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_cexpl.c | 15 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_cproj.c | 2 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_cprojf.c | 2 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_cprojl.c | 2 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_csin.c | 104 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_csinf.c | 104 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_csinh.c | 18 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_csinhf.c | 18 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_csinhl.c | 17 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_csinl.c | 104 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_ctanh.c | 6 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_ctanhf.c | 6 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_ctanhl.c | 6 |
20 files changed, 441 insertions, 70 deletions
diff --git a/sysdeps/libm-ieee754/s_ccos.c b/sysdeps/libm-ieee754/s_ccos.c index 8a4b55d..f8dfcc8 100644 --- a/sysdeps/libm-ieee754/s_ccos.c +++ b/sysdeps/libm-ieee754/s_ccos.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> @@ -33,16 +34,31 @@ __ccos (__complex__ double x) { __real__ res = __nan (""); __imag__ res = 0.0; + +#ifdef FE_INVALID + if (__isinf (__real__ x)) + feraiseexcept (FE_INVALID); +#endif } else if (__isinf (__imag__ x)) { __real__ res = HUGE_VAL; __imag__ res = __nan (""); + +#ifdef FE_INVALID + if (__isinf (__real__ x)) + feraiseexcept (FE_INVALID); +#endif } else { __real__ res = __nan (""); __imag__ res = __nan (""); + +#ifdef FE_INVALID + if (isfinite (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_ccosf.c b/sysdeps/libm-ieee754/s_ccosf.c index 9d1a972..b090ae5 100644 --- a/sysdeps/libm-ieee754/s_ccosf.c +++ b/sysdeps/libm-ieee754/s_ccosf.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> @@ -33,16 +34,31 @@ __ccosf (__complex__ float x) { __real__ res = __nanf (""); __imag__ res = 0.0; + +#ifdef FE_INVALID + if (__isinff (__real__ x)) + feraiseexcept (FE_INVALID); +#endif } else if (__isinff (__imag__ x)) { __real__ res = HUGE_VALF; __imag__ res = __nanf (""); + +#ifdef FE_INVALID + if (__isinff (__real__ x)) + feraiseexcept (FE_INVALID); +#endif } else { __real__ res = __nanf (""); __imag__ res = __nanf (""); + +#ifdef FE_INVALID + if (isfinite (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_ccosh.c b/sysdeps/libm-ieee754/s_ccosh.c index fa958f4..1e92f03 100644 --- a/sysdeps/libm-ieee754/s_ccosh.c +++ b/sysdeps/libm-ieee754/s_ccosh.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -39,18 +40,24 @@ __ccosh (__complex__ double x) if (icls >= FP_ZERO) { /* Imaginary part is finite. */ + double sinh_val = __ieee754_sinh (__real__ x); double cosh_val = __ieee754_cosh (__real__ x); double sinix, cosix; __sincos (__imag__ x, &sinix, &cosix); __real__ retval = cosh_val * cosix; - __imag__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * sinix; } else { __imag__ retval = __real__ x == 0.0 ? 0.0 : __nan (""); __real__ retval = __nan ("") + __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else if (rcls == FP_INFINITE) @@ -77,6 +84,11 @@ __ccosh (__complex__ double x) /* The addition raises the invalid exception. */ __real__ retval = HUGE_VAL; __imag__ retval = __nan ("") + __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_ccoshf.c b/sysdeps/libm-ieee754/s_ccoshf.c index aeeacba..573a633 100644 --- a/sysdeps/libm-ieee754/s_ccoshf.c +++ b/sysdeps/libm-ieee754/s_ccoshf.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -39,18 +40,24 @@ __ccoshf (__complex__ float x) if (icls >= FP_ZERO) { /* Imaginary part is finite. */ + float sinh_val = __ieee754_sinhf (__real__ x); float cosh_val = __ieee754_coshf (__real__ x); float sinix, cosix; __sincosf (__imag__ x, &sinix, &cosix); __real__ retval = cosh_val * cosix; - __imag__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * sinix; } else { __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanf (""); - __real__ retval = __nanf ("") + __nanf (""); + __real__ retval = __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else if (rcls == FP_INFINITE) @@ -77,6 +84,11 @@ __ccoshf (__complex__ float x) /* The addition raises the invalid exception. */ __real__ retval = HUGE_VALF; __imag__ retval = __nanf ("") + __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_ccoshl.c b/sysdeps/libm-ieee754/s_ccoshl.c index 9937ba1..feb1351 100644 --- a/sysdeps/libm-ieee754/s_ccoshl.c +++ b/sysdeps/libm-ieee754/s_ccoshl.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -39,18 +40,24 @@ __ccoshl (__complex__ long double x) if (icls >= FP_ZERO) { /* Imaginary part is finite. */ + long double sinh_val = __ieee754_sinhl (__real__ x); long double cosh_val = __ieee754_coshl (__real__ x); long double sinix, cosix; __sincosl (__imag__ x, &sinix, &cosix); __real__ retval = cosh_val * cosix; - __imag__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * sinix; } else { __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanl (""); __real__ retval = __nanl ("") + __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else if (rcls == FP_INFINITE) @@ -77,6 +84,11 @@ __ccoshl (__complex__ long double x) /* The addition raises the invalid exception. */ __real__ retval = HUGE_VALL; __imag__ retval = __nanl ("") + __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_ccosl.c b/sysdeps/libm-ieee754/s_ccosl.c index a41d48b..fdcc7a6 100644 --- a/sysdeps/libm-ieee754/s_ccosl.c +++ b/sysdeps/libm-ieee754/s_ccosl.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> @@ -33,16 +34,31 @@ __ccosl (__complex__ long double x) { __real__ res = __nanl (""); __imag__ res = 0.0; + +#ifdef FE_INVALID + if (__isinfl (__real__ x)) + feraiseexcept (FE_INVALID); +#endif } else if (__isinfl (__imag__ x)) { __real__ res = HUGE_VALL; __imag__ res = __nanl (""); + +#ifdef FE_INVALID + if (__isinfl (__real__ x)) + feraiseexcept (FE_INVALID); +#endif } else { __real__ res = __nanl (""); __imag__ res = __nanl (""); + +#ifdef FE_INVALID + if (isfinite (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_cexpf.c b/sysdeps/libm-ieee754/s_cexpf.c index 99f33dc..603e78d 100644 --- a/sysdeps/libm-ieee754/s_cexpf.c +++ b/sysdeps/libm-ieee754/s_cexpf.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -59,6 +60,10 @@ __cexpf (__complex__ float x) is not +-inf the result is NaN + iNaN. */ __real__ retval = __nanf (""); __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif } } else if (rcls == FP_INFINITE) @@ -89,6 +94,11 @@ __cexpf (__complex__ float x) { __real__ retval = HUGE_VALF; __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } else { @@ -101,6 +111,11 @@ __cexpf (__complex__ float x) /* If the real part is NaN the result is NaN + iNaN. */ __real__ retval = __nanf (""); __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + if (rcls != FP_NAN || icls != FP_NAN) + feraiseexcept (FE_INVALID); +#endif } return retval; diff --git a/sysdeps/libm-ieee754/s_cexpl.c b/sysdeps/libm-ieee754/s_cexpl.c index 1b97dba..67fa7a0 100644 --- a/sysdeps/libm-ieee754/s_cexpl.c +++ b/sysdeps/libm-ieee754/s_cexpl.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -59,6 +60,10 @@ __cexpl (__complex__ long double x) is not +-inf the result is NaN + iNaN. */ __real__ retval = __nanl (""); __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif } } else if (rcls == FP_INFINITE) @@ -89,6 +94,11 @@ __cexpl (__complex__ long double x) { __real__ retval = HUGE_VALL; __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } else { @@ -101,6 +111,11 @@ __cexpl (__complex__ long double x) /* If the real part is NaN the result is NaN + iNaN. */ __real__ retval = __nanl (""); __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + if (rcls != FP_NAN || icls != FP_NAN) + feraiseexcept (FE_INVALID); +#endif } return retval; diff --git a/sysdeps/libm-ieee754/s_cproj.c b/sysdeps/libm-ieee754/s_cproj.c index 8ad27c0..fb50bb5 100644 --- a/sysdeps/libm-ieee754/s_cproj.c +++ b/sysdeps/libm-ieee754/s_cproj.c @@ -27,7 +27,7 @@ __cproj (__complex__ double x) { __complex__ double res; - if (!finite (__real__ x) || !finite (__imag__ x)) + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) { __real__ res = INFINITY; __imag__ res = __copysign (0.0, __imag__ x); diff --git a/sysdeps/libm-ieee754/s_cprojf.c b/sysdeps/libm-ieee754/s_cprojf.c index 8ee61c7..b905908 100644 --- a/sysdeps/libm-ieee754/s_cprojf.c +++ b/sysdeps/libm-ieee754/s_cprojf.c @@ -27,7 +27,7 @@ __cprojf (__complex__ float x) { __complex__ float res; - if (!finite (__real__ x) || !finite (__imag__ x)) + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) { __real__ res = INFINITY; __imag__ res = __copysignf (0.0, __imag__ x); diff --git a/sysdeps/libm-ieee754/s_cprojl.c b/sysdeps/libm-ieee754/s_cprojl.c index 34298e1..13da4b4 100644 --- a/sysdeps/libm-ieee754/s_cprojl.c +++ b/sysdeps/libm-ieee754/s_cprojl.c @@ -27,7 +27,7 @@ __cprojl (__complex__ long double x) { __complex__ long double res; - if (!finite (__real__ x) || !finite (__imag__ x)) + if (!isfinite (__real__ x) || !isfinite (__imag__ x)) { __real__ res = INFINITY; __imag__ res = __copysignl (0.0, __imag__ x); diff --git a/sysdeps/libm-ieee754/s_csin.c b/sysdeps/libm-ieee754/s_csin.c index 4639bca..6627387 100644 --- a/sysdeps/libm-ieee754/s_csin.c +++ b/sysdeps/libm-ieee754/s_csin.c @@ -19,46 +19,110 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> +#include "math_private.h" + __complex__ double __csin (__complex__ double x) { - __complex__ double res; + __complex__ double retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabs (__real__ x); - if (!isfinite (__real__ x) || isnan (__imag__ x)) + if (icls >= FP_ZERO) { - if (__real__ x == 0.0 || __imag__ x == 0.0) - { - __real__ res = __nan (""); - __imag__ res = 0.0; - } - else if (__isinf (__imag__ x)) + /* Imaginary part is finite. */ + if (rcls >= FP_ZERO) { - __real__ res = __nan (""); - __imag__ res = __imag__ x; + /* Real part is finite. */ + double sinh_val = __ieee754_sinh (__imag__ x); + double cosh_val = __ieee754_cosh (__imag__ x); + double sinix, cosix; + + __sincos (__real__ x, &sinix, &cosix); + + __real__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * cosix; + + if (negate) + __real__ retval = -__real__ retval; } else { - __real__ res = __nan (""); - __imag__ res = __nan (""); + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = __nan (""); + __imag__ retval = __imag__ x; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nan (""); + __imag__ retval = __nan (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } } } - else + else if (icls == FP_INFINITE) { - __complex__ double y; + /* Imaginary part is infinite. */ + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __imag__ x; + } + else if (rcls > FP_ZERO) + { + /* Real part is finite. */ + double sinix, cosix; + + __sincos (__real__ x, &sinix, &cosix); - __real__ y = -__imag__ x; - __imag__ y = __real__ x; + __real__ retval = __copysign (HUGE_VAL, sinix); + __imag__ retval = __copysign (HUGE_VAL, cosix); - y = __csinh (y); + if (negate) + __real__ retval = -__real__ retval; + if (signbit (__imag__ x)) + __imag__ retval = -__imag__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = __nan (""); + __imag__ retval = HUGE_VAL; - __real__ res = __imag__ y; - __imag__ res = -__real__ y; +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + if (rcls == FP_ZERO) + __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0); + else + __real__ retval = __nan (""); + __imag__ retval = __nan (""); } - return res; + return retval; } weak_alias (__csin, csin) #ifdef NO_LONG_DOUBLE diff --git a/sysdeps/libm-ieee754/s_csinf.c b/sysdeps/libm-ieee754/s_csinf.c index f7f10e6..31d2f1f 100644 --- a/sysdeps/libm-ieee754/s_csinf.c +++ b/sysdeps/libm-ieee754/s_csinf.c @@ -19,45 +19,109 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> +#include "math_private.h" + __complex__ float __csinf (__complex__ float x) { - __complex__ float res; + __complex__ float retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabsf (__real__ x); - if (!isfinite (__real__ x) || isnan (__imag__ x)) + if (icls >= FP_ZERO) { - if (__real__ x == 0.0 || __imag__ x == 0.0) - { - __real__ res = __nanf (""); - __imag__ res = 0.0; - } - else if (__isinff (__imag__ x)) + /* Imaginary part is finite. */ + if (rcls >= FP_ZERO) { - __real__ res = __nanf (""); - __imag__ res = __imag__ x; + /* Real part is finite. */ + float sinh_val = __ieee754_sinhf (__imag__ x); + float cosh_val = __ieee754_coshf (__imag__ x); + float sinix, cosix; + + __sincosf (__real__ x, &sinix, &cosix); + + __real__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * cosix; + + if (negate) + __real__ retval = -__real__ retval; } else { - __real__ res = __nanf (""); - __imag__ res = __nanf (""); + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = __nanf (""); + __imag__ retval = __imag__ x; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nanf (""); + __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } } } - else + else if (icls == FP_INFINITE) { - __complex__ float y; + /* Imaginary part is infinite. */ + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __imag__ x; + } + else if (rcls > FP_ZERO) + { + /* Real part is finite. */ + float sinix, cosix; + + __sincosf (__real__ x, &sinix, &cosix); - __real__ y = -__imag__ x; - __imag__ y = __real__ x; + __real__ retval = __copysignf (HUGE_VALF, sinix); + __imag__ retval = __copysignf (HUGE_VALF, cosix); - y = __csinhf (y); + if (negate) + __real__ retval = -__real__ retval; + if (signbit (__imag__ x)) + __imag__ retval = -__imag__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = __nanf (""); + __imag__ retval = HUGE_VALF; - __real__ res = __imag__ y; - __imag__ res = -__real__ y; +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + if (rcls == FP_ZERO) + __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0); + else + __real__ retval = __nanf (""); + __imag__ retval = __nanf (""); } - return res; + return retval; } weak_alias (__csinf, csinf) diff --git a/sysdeps/libm-ieee754/s_csinh.c b/sysdeps/libm-ieee754/s_csinh.c index 98f06a5..29a271f 100644 --- a/sysdeps/libm-ieee754/s_csinh.c +++ b/sysdeps/libm-ieee754/s_csinh.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -41,12 +42,13 @@ __csinh (__complex__ double x) { /* Imaginary part is finite. */ double sinh_val = __ieee754_sinh (__real__ x); + double cosh_val = __ieee754_cosh (__real__ x); double sinix, cosix; __sincos (__imag__ x, &sinix, &cosix); __real__ retval = sinh_val * cosix; - __imag__ retval = sinh_val * sinix; + __imag__ retval = cosh_val * sinix; if (negate) __real__ retval = -__real__ retval; @@ -58,11 +60,20 @@ __csinh (__complex__ double x) /* Real part is 0.0. */ __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0); __imag__ retval = __nan ("") + __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } else { __real__ retval = __nan (""); __imag__ retval = __nan (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif } } } @@ -93,6 +104,11 @@ __csinh (__complex__ double x) /* The addition raises the invalid exception. */ __real__ retval = HUGE_VAL; __imag__ retval = __nan ("") + __nan (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_csinhf.c b/sysdeps/libm-ieee754/s_csinhf.c index c644d3a..9c479bb 100644 --- a/sysdeps/libm-ieee754/s_csinhf.c +++ b/sysdeps/libm-ieee754/s_csinhf.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -41,12 +42,13 @@ __csinhf (__complex__ float x) { /* Imaginary part is finite. */ float sinh_val = __ieee754_sinhf (__real__ x); + float cosh_val = __ieee754_coshf (__real__ x); float sinix, cosix; __sincosf (__imag__ x, &sinix, &cosix); __real__ retval = sinh_val * cosix; - __imag__ retval = sinh_val * sinix; + __imag__ retval = cosh_val * sinix; if (negate) __real__ retval = -__real__ retval; @@ -58,11 +60,20 @@ __csinhf (__complex__ float x) /* Real part is 0.0. */ __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0); __imag__ retval = __nanf ("") + __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } else { __real__ retval = __nanf (""); __imag__ retval = __nanf (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif } } } @@ -93,6 +104,11 @@ __csinhf (__complex__ float x) /* The addition raises the invalid exception. */ __real__ retval = HUGE_VALF; __imag__ retval = __nanf ("") + __nanf (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_csinhl.c b/sysdeps/libm-ieee754/s_csinhl.c index 4bb9e63..694b39d 100644 --- a/sysdeps/libm-ieee754/s_csinhl.c +++ b/sysdeps/libm-ieee754/s_csinhl.c @@ -41,12 +41,13 @@ __csinhl (__complex__ long double x) { /* Imaginary part is finite. */ long double sinh_val = __ieee754_sinhl (__real__ x); + long double cosh_val = __ieee754_coshl (__real__ x); long double sinix, cosix; __sincosl (__imag__ x, &sinix, &cosix); __real__ retval = sinh_val * cosix; - __imag__ retval = sinh_val * sinix; + __imag__ retval = cosh_val * sinix; if (negate) __real__ retval = -__real__ retval; @@ -58,11 +59,20 @@ __csinhl (__complex__ long double x) /* Real part is 0.0. */ __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0); __imag__ retval = __nanl ("") + __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } else { __real__ retval = __nanl (""); __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif } } } @@ -93,6 +103,11 @@ __csinhl (__complex__ long double x) /* The addition raises the invalid exception. */ __real__ retval = HUGE_VALL; __imag__ retval = __nanl ("") + __nanl (""); + +#ifdef FE_INVALID + if (icls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_csinl.c b/sysdeps/libm-ieee754/s_csinl.c index 513c144..bae8648 100644 --- a/sysdeps/libm-ieee754/s_csinl.c +++ b/sysdeps/libm-ieee754/s_csinl.c @@ -19,45 +19,109 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> +#include "math_private.h" + __complex__ long double __csinl (__complex__ long double x) { - __complex__ long double res; + __complex__ long double retval; + int negate = signbit (__real__ x); + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + __real__ x = fabsl (__real__ x); - if (!isfinite (__real__ x) || isnan (__imag__ x)) + if (icls >= FP_ZERO) { - if (__real__ x == 0.0 || __imag__ x == 0.0) - { - __real__ res = __nanl (""); - __imag__ res = 0.0; - } - else if (__isinfl (__imag__ x)) + /* Imaginary part is finite. */ + if (rcls >= FP_ZERO) { - __real__ res = __nanl (""); - __imag__ res = __imag__ x; + /* Real part is finite. */ + long double sinh_val = __ieee754_sinhl (__imag__ x); + long double cosh_val = __ieee754_coshl (__imag__ x); + long double sinix, cosix; + + __sincosl (__real__ x, &sinix, &cosix); + + __real__ retval = cosh_val * sinix; + __imag__ retval = sinh_val * cosix; + + if (negate) + __real__ retval = -__real__ retval; } else { - __real__ res = __nanl (""); - __imag__ res = __nanl (""); + if (icls == FP_ZERO) + { + /* Imaginary part is 0.0. */ + __real__ retval = __nanl (""); + __imag__ retval = __imag__ x; + +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + else + { + __real__ retval = __nanl (""); + __imag__ retval = __nanl (""); + +#ifdef FE_INVALID + feraiseexcept (FE_INVALID); +#endif + } } } - else + else if (icls == FP_INFINITE) { - __complex__ long double y; + /* Imaginary part is infinite. */ + if (rcls == FP_ZERO) + { + /* Real part is 0.0. */ + __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0); + __imag__ retval = __imag__ x; + } + else if (rcls > FP_ZERO) + { + /* Real part is finite. */ + long double sinix, cosix; + + __sincosl (__real__ x, &sinix, &cosix); - __real__ y = -__imag__ x; - __imag__ y = __real__ x; + __real__ retval = __copysignl (HUGE_VALL, sinix); + __imag__ retval = __copysignl (HUGE_VALL, cosix); - y = __csinhl (y); + if (negate) + __real__ retval = -__real__ retval; + if (signbit (__imag__ x)) + __imag__ retval = -__imag__ retval; + } + else + { + /* The addition raises the invalid exception. */ + __real__ retval = __nanl (""); + __imag__ retval = HUGE_VALL; - __real__ res = __imag__ y; - __imag__ res = -__real__ y; +#ifdef FE_INVALID + if (rcls == FP_INFINITE) + feraiseexcept (FE_INVALID); +#endif + } + } + else + { + if (rcls == FP_ZERO) + __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0); + else + __real__ retval = __nanl (""); + __imag__ retval = __nanl (""); } - return res; + return retval; } weak_alias (__csinl, csinl) diff --git a/sysdeps/libm-ieee754/s_ctanh.c b/sysdeps/libm-ieee754/s_ctanh.c index eb6ff84..d8825f3 100644 --- a/sysdeps/libm-ieee754/s_ctanh.c +++ b/sysdeps/libm-ieee754/s_ctanh.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -44,6 +45,11 @@ __ctanh (__complex__ double x) { __real__ res = __nan (""); __imag__ res = __nan (""); + +#ifdef FE_INVALID + if (__isinf (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_ctanhf.c b/sysdeps/libm-ieee754/s_ctanhf.c index aec02fe..fd66648 100644 --- a/sysdeps/libm-ieee754/s_ctanhf.c +++ b/sysdeps/libm-ieee754/s_ctanhf.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -44,6 +45,11 @@ __ctanhf (__complex__ float x) { __real__ res = __nanf (""); __imag__ res = __nanf (""); + +#ifdef FE_INVALID + if (__isinff (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif } } else diff --git a/sysdeps/libm-ieee754/s_ctanhl.c b/sysdeps/libm-ieee754/s_ctanhl.c index 8ed131e..5ec06a6 100644 --- a/sysdeps/libm-ieee754/s_ctanhl.c +++ b/sysdeps/libm-ieee754/s_ctanhl.c @@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <complex.h> +#include <fenv.h> #include <math.h> #include "math_private.h" @@ -44,6 +45,11 @@ __ctanhl (__complex__ long double x) { __real__ res = __nanl (""); __imag__ res = __nanl (""); + +#ifdef FE_INVALID + if (__isinfl (__imag__ x)) + feraiseexcept (FE_INVALID); +#endif } } else |