about summary refs log tree commit diff
path: root/sysdeps/libm-ieee754
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-04-30 15:51:34 +0000
committerUlrich Drepper <drepper@redhat.com>1997-04-30 15:51:34 +0000
commit779ae82ecdf88b7ed7c1f00d3ed3a639671c3c8d (patch)
tree287afe5ef732d76109129a142c5840cc42a2b34a /sysdeps/libm-ieee754
parenta12ea214dbc999b98ab5ed4e53fb0089cf5e183a (diff)
downloadglibc-779ae82ecdf88b7ed7c1f00d3ed3a639671c3c8d.tar.gz
glibc-779ae82ecdf88b7ed7c1f00d3ed3a639671c3c8d.tar.xz
glibc-779ae82ecdf88b7ed7c1f00d3ed3a639671c3c8d.zip
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.c16
-rw-r--r--sysdeps/libm-ieee754/s_ccosf.c16
-rw-r--r--sysdeps/libm-ieee754/s_ccosh.c14
-rw-r--r--sysdeps/libm-ieee754/s_ccoshf.c16
-rw-r--r--sysdeps/libm-ieee754/s_ccoshl.c14
-rw-r--r--sysdeps/libm-ieee754/s_ccosl.c16
-rw-r--r--sysdeps/libm-ieee754/s_cexpf.c15
-rw-r--r--sysdeps/libm-ieee754/s_cexpl.c15
-rw-r--r--sysdeps/libm-ieee754/s_cproj.c2
-rw-r--r--sysdeps/libm-ieee754/s_cprojf.c2
-rw-r--r--sysdeps/libm-ieee754/s_cprojl.c2
-rw-r--r--sysdeps/libm-ieee754/s_csin.c104
-rw-r--r--sysdeps/libm-ieee754/s_csinf.c104
-rw-r--r--sysdeps/libm-ieee754/s_csinh.c18
-rw-r--r--sysdeps/libm-ieee754/s_csinhf.c18
-rw-r--r--sysdeps/libm-ieee754/s_csinhl.c17
-rw-r--r--sysdeps/libm-ieee754/s_csinl.c104
-rw-r--r--sysdeps/libm-ieee754/s_ctanh.c6
-rw-r--r--sysdeps/libm-ieee754/s_ctanhf.c6
-rw-r--r--sysdeps/libm-ieee754/s_ctanhl.c6
20 files changed, 441 insertions, 70 deletions
diff --git a/sysdeps/libm-ieee754/s_ccos.c b/sysdeps/libm-ieee754/s_ccos.c
index 8a4b55dd99..f8dfcc8af6 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 9d1a97239c..b090ae5747 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 fa958f491b..1e92f03771 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 aeeacbaed0..573a63367b 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 9937ba1904..feb1351917 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 a41d48b970..fdcc7a63dd 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 99f33dc873..603e78d716 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 1b97dba74d..67fa7a08b9 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 8ad27c0e5b..fb50bb5a88 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 8ee61c727c..b90590835c 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 34298e1f25..13da4b417d 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 4639bcaaa6..6627387d42 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 f7f10e6b6f..31d2f1fd54 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 98f06a558f..29a271fec6 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 c644d3a5e8..9c479bba95 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 4bb9e63680..694b39d670 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 513c144198..bae8648c32 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 eb6ff84817..d8825f35f9 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 aec02fe7c4..fd66648d79 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 8ed131e9a6..5ec06a6fa4 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