This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Change libgfortran from scalbn to ldexp
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 03 Oct 2004 11:48:06 +0200
- Subject: [gfortran] Change libgfortran from scalbn to ldexp
We're seeing some system dependency in whether set_exponent works or not, more
precisely intrinsic_set_exponent.f90 fails on powerpc-linux and maybe other
platforms. Since I don't know the exact failure mode, I had a brief look at
the implementation, and saw that we use the 'scalbn' library function, which
seems to be non-standard according to the documentation I have available.
Furthermore, there is a standard function which is supposed to do exactly the
same, namely 'ldexp'. So I replaced all occurences of scalbn{f} with ldexp{f}
and verified that the library still builds and passes its tests on i686-linux.
OK?
- Tobi
2004-10-02 Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
* configure.ac: Check for ldexpf, remove check for scalbnf.
* intrinsics/c99-functions.c (ldexpf): New function.
(nextafterf): Use 'ldexpf' instead of 'scalbnf'.
(scalbnf): Remove.
* m4/set_exponent.m4: Replace 'scalbn' by 'ldexp'.
Index: configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/configure.ac,v
retrieving revision 1.11
diff -u -p -r1.11 configure.ac
--- configure.ac 26 Sep 2004 14:52:03 -0000 1.11
+++ configure.ac 3 Oct 2004 09:32:49 -0000
@@ -180,6 +180,7 @@ AC_CHECK_LIB([m],[expf],[AC_DEFINE([HAVE
AC_CHECK_LIB([m],[floorf],[AC_DEFINE([HAVE_FLOORF],[1],[libm includes floorf])])
AC_CHECK_LIB([m],[frexpf],[AC_DEFINE([HAVE_FREXPF],[1],[libm includes frexpf])])
AC_CHECK_LIB([m],[hypotf],[AC_DEFINE([HAVE_HYPOTF],[1],[libm includes hypotf])])
+AC_CHECK_LIB([m],[ldexpf],[AC_DEFINE([HAVE_LDEXPF],[1],[libm includes ldexpf])])
AC_CHECK_LIB([m],[logf],[AC_DEFINE([HAVE_LOGF],[1],[libm includes logf])])
AC_CHECK_LIB([m],[log10f],[AC_DEFINE([HAVE_LOG10F],[1],[libm includes log10f])])
AC_CHECK_LIB([m],[nextafter],[AC_DEFINE([HAVE_NEXTAFTER],[1],[libm includes nextafter])])
@@ -187,7 +188,6 @@ AC_CHECK_LIB([m],[nextafterf],[AC_DEFINE
AC_CHECK_LIB([m],[powf],[AC_DEFINE([HAVE_POWF],[1],[libm includes powf])])
AC_CHECK_LIB([m],[round],[AC_DEFINE([HAVE_ROUND],[1],[libm includes round])])
AC_CHECK_LIB([m],[roundf],[AC_DEFINE([HAVE_ROUNDF],[1],[libm includes roundf])])
-AC_CHECK_LIB([m],[scalbnf],[AC_DEFINE([HAVE_SCALBNF],[1],[libm includes scalbnf])])
AC_CHECK_LIB([m],[sinf],[AC_DEFINE([HAVE_SINF],[1],[libm includes sinf])])
AC_CHECK_LIB([m],[sinhf],[AC_DEFINE([HAVE_SINHF],[1],[libm includes sinhf])])
AC_CHECK_LIB([m],[sqrtf],[AC_DEFINE([HAVE_SQRTF],[1],[libm includes sqrtf])])
Index: intrinsics/c99_functions.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/intrinsics/c99_functions.c,v
retrieving revision 1.5
diff -u -p -r1.5 c99_functions.c
--- intrinsics/c99_functions.c 26 Sep 2004 14:52:04 -0000 1.5
+++ intrinsics/c99_functions.c 3 Oct 2004 09:32:50 -0000
@@ -121,6 +121,14 @@ hypotf(float x, float y)
}
#endif
+#ifndef HAVE_LDEXPF
+float
+ldexpf(float x, int n)
+{
+ return (float) ldexp(x, n);
+}
+#endif
+
#ifndef HAVE_LOGF
float
logf(float x)
@@ -137,14 +145,6 @@ log10f(float x)
}
#endif
-#ifndef HAVE_SCALBNF
-float
-scalbnf(float x, int y)
-{
- return (float) scalbn(x, y);
-}
-#endif
-
#ifndef HAVE_SINF
float
sinf(float x)
@@ -220,7 +220,7 @@ nextafterf(float x, float y)
/* Discard the fraction from x. */
frac = frexpf (absx, &exp);
- delta = scalbnf (0.5f, exp);
+ delta = ldexpf (0.5f, exp);
/* Scale x by the epsilon of the representation. By rights we should
have been able to combine this with scalbnf, but some targets don't
Index: m4/set_exponent.m4
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/m4/set_exponent.m4,v
retrieving revision 1.2
diff -u -p -r1.2 set_exponent.m4
--- m4/set_exponent.m4 13 May 2004 06:41:03 -0000 1.2
+++ m4/set_exponent.m4 3 Oct 2004 09:32:50 -0000
@@ -1,5 +1,5 @@
`/* Implementation of the SET_EXPONENT intrinsic
- Copyright 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU Fortran 95 runtime library (libgfor).
@@ -27,5 +27,5 @@ real_type
prefix(set_exponent_r`'kind) (real_type s, GFC_INTEGER_4 i)
{
int dummy_exp;
- return scalbn`'q (frexp`'q (s, &dummy_exp), i);
+ return ldexp`'q (frexp`'q (s, &dummy_exp), i);
}