libm/glibc-2.3.6 issue (was - Re: libstdc++ issue?)

Dan Nicholson dbn.lists at gmail.com
Tue Nov 13 11:30:47 PST 2007


On Tue, Nov 13, 2007 at 08:12:42PM +0100, juras wrote:
> Dan Nicholson napisał(a):
> > Yeah, it works on glibc-2.5.1.
> Thank you.
> So I'll have to upgrade the glibc.
> I know, that it may make my system unusable, but I will try.

Just a sec. I found some bug reports and the upstream commits.

https://bugzilla.redhat.com/show_bug.cgi?id=160759
http://www.mail-archive.com/debian-glibc@lists.debian.org/msg28193.html
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/ChangeLog.diff?cvsroot=glibc&r1=1.9409&r2=1.9410

Try the attached patch.

--
Dan
-------------- next part --------------
diff -pNur glibc-2.3.6.orig/sysdeps/generic/s_ctan.c glibc-2.3.6/sysdeps/generic/s_ctan.c
--- glibc-2.3.6.orig/sysdeps/generic/s_ctan.c	2001-07-05 21:55:49.000000000 -0700
+++ glibc-2.3.6/sysdeps/generic/s_ctan.c	2007-11-13 11:25:12.000000000 -0800
@@ -1,5 +1,5 @@
 /* Complex tangent function for double.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper at cygnus.com>, 1997.
 
@@ -61,8 +61,18 @@ __ctan (__complex__ double x)
 
       den = cos2rx + __ieee754_cosh (2.0 * __imag__ x);
 
-      __real__ res = sin2rx / den;
-      __imag__ res = __ieee754_sinh (2.0 * __imag__ x) / den;
+      if (den == 0.0)
+	{
+	  __complex__ double ez = __cexp (1.0i * x);
+	  __complex__ double emz = __cexp (-1.0i * x);
+
+	  res = (ez - emz) / (ez + emz) * -1.0i;
+	}
+      else
+	{
+	  __real__ res = sin2rx / den;
+	  __imag__ res = __ieee754_sinh (2.0 * __imag__ x) / den;
+	}
     }
 
   return res;
diff -pNur glibc-2.3.6.orig/sysdeps/generic/s_ctanf.c glibc-2.3.6/sysdeps/generic/s_ctanf.c
--- glibc-2.3.6.orig/sysdeps/generic/s_ctanf.c	2004-01-13 01:08:04.000000000 -0800
+++ glibc-2.3.6/sysdeps/generic/s_ctanf.c	2007-11-13 11:25:20.000000000 -0800
@@ -1,5 +1,5 @@
 /* Complex tangent function for float.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper at cygnus.com>, 1997.
 
@@ -61,8 +61,19 @@ __ctanf (__complex__ float x)
 
       den = cos2rx + __ieee754_coshf (2.0 * __imag__ x);
 
-      __real__ res = sin2rx / den;
-      __imag__ res = __ieee754_sinhf (2.0 * __imag__ x) / den;
+
+      if (den == 0.0)
+	{
+	  __complex__ float ez = __cexpf (1.0i * x);
+	  __complex__ float emz = __cexpf (-1.0i * x);
+
+	  res = (ez - emz) / (ez + emz) * -1.0i;
+	}
+      else
+	{
+	  __real__ res = sin2rx / den;
+	  __imag__ res = __ieee754_sinhf (2.0 * __imag__ x) / den;
+	}
     }
 
   return res;
diff -pNur glibc-2.3.6.orig/sysdeps/generic/s_ctanh.c glibc-2.3.6/sysdeps/generic/s_ctanh.c
--- glibc-2.3.6.orig/sysdeps/generic/s_ctanh.c	2001-07-05 21:55:49.000000000 -0700
+++ glibc-2.3.6/sysdeps/generic/s_ctanh.c	2007-11-13 11:25:26.000000000 -0800
@@ -1,5 +1,5 @@
 /* Complex hyperbole tangent for double.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper at cygnus.com>, 1997.
 
@@ -61,8 +61,18 @@ __ctanh (__complex__ double x)
 
       den = (__ieee754_cosh (2.0 * __real__ x) + cos2ix);
 
-      __real__ res = __ieee754_sinh (2.0 * __real__ x) / den;
-      __imag__ res = sin2ix / den;
+      if (den == 0.0)
+	{
+	  __complex__ double ez = __cexp (x);
+	  __complex__ double emz = __cexp (-x);
+
+	  res = (ez - emz) / (ez + emz);
+	}
+      else
+	{
+	  __real__ res = __ieee754_sinh (2.0 * __real__ x) / den;
+	  __imag__ res = sin2ix / den;
+	}
     }
 
   return res;
diff -pNur glibc-2.3.6.orig/sysdeps/generic/s_ctanhf.c glibc-2.3.6/sysdeps/generic/s_ctanhf.c
--- glibc-2.3.6.orig/sysdeps/generic/s_ctanhf.c	2004-01-13 01:08:04.000000000 -0800
+++ glibc-2.3.6/sysdeps/generic/s_ctanhf.c	2007-11-13 11:25:29.000000000 -0800
@@ -1,5 +1,5 @@
 /* Complex hyperbole tangent for float.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper at cygnus.com>, 1997.
 
@@ -61,8 +61,18 @@ __ctanhf (__complex__ float x)
 
       den = (__ieee754_coshf (2.0 * __real__ x) + cos2ix);
 
-      __real__ res = __ieee754_sinhf (2.0 * __real__ x) / den;
-      __imag__ res = sin2ix / den;
+      if (den == 0.0f)
+	{
+	  __complex__ float ez = __cexpf (x);
+	  __complex__ float emz = __cexpf (-x);
+
+	  res = (ez - emz) / (ez + emz);
+	}
+      else
+	{
+	  __real__ res = __ieee754_sinhf (2.0 * __real__ x) / den;
+	  __imag__ res = sin2ix / den;
+	}
     }
 
   return res;
diff -pNur glibc-2.3.6.orig/sysdeps/generic/s_ctanhl.c glibc-2.3.6/sysdeps/generic/s_ctanhl.c
--- glibc-2.3.6.orig/sysdeps/generic/s_ctanhl.c	2001-07-05 21:55:49.000000000 -0700
+++ glibc-2.3.6/sysdeps/generic/s_ctanhl.c	2007-11-13 11:25:33.000000000 -0800
@@ -1,5 +1,5 @@
 /* Complex hyperbole tangent for long double.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper at cygnus.com>, 1997.
 
@@ -61,8 +61,18 @@ __ctanhl (__complex__ long double x)
 
       den = (__ieee754_coshl (2.0 * __real__ x) + cos2ix);
 
-      __real__ res = __ieee754_sinhl (2.0 * __real__ x) / den;
-      __imag__ res = sin2ix / den;
+      if (den == 0.0L)
+	{
+	  __complex__ long double ez = __cexpl (x);
+	  __complex__ long double emz = __cexpl (-x);
+
+	  res = (ez - emz) / (ez + emz);
+	}
+      else
+	{
+	  __real__ res = __ieee754_sinhl (2.0 * __real__ x) / den;
+	  __imag__ res = sin2ix / den;
+	}
     }
 
   return res;
diff -pNur glibc-2.3.6.orig/sysdeps/generic/s_ctanl.c glibc-2.3.6/sysdeps/generic/s_ctanl.c
--- glibc-2.3.6.orig/sysdeps/generic/s_ctanl.c	2001-07-05 21:55:49.000000000 -0700
+++ glibc-2.3.6/sysdeps/generic/s_ctanl.c	2007-11-13 11:25:37.000000000 -0800
@@ -1,5 +1,5 @@
 /* Complex tangent function for long double.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper at cygnus.com>, 1997.
 
@@ -61,8 +61,19 @@ __ctanl (__complex__ long double x)
 
       den = cos2rx + __ieee754_coshl (2.0 * __imag__ x);
 
-      __real__ res = sin2rx / den;
-      __imag__ res = __ieee754_sinhl (2.0 * __imag__ x) / den;
+
+      if (den == 0.0)
+	{
+	  __complex__ long double ez = __cexpl (1.0i * x);
+	  __complex__ long double emz = __cexpl (-1.0i * x);
+
+	  res = (ez - emz) / (ez + emz) * -1.0i;
+	}
+      else
+	{
+	  __real__ res = sin2rx / den;
+	  __imag__ res = __ieee754_sinhl (2.0 * __imag__ x) / den;
+	}
     }
 
   return res;


More information about the blfs-support mailing list