This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[PATCH] Fix unresolved symbols on non-C99 platforms
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: fortran at gcc dot gnu dot org
- Date: Fri, 20 May 2005 21:39:36 +0200
- Subject: [PATCH] Fix unresolved symbols on non-C99 platforms
Hi,
The patch
2005-05-18 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_TRUNC
and BUILT_IN_TRUNCF instead of BUILT_IN_FLOOR and BUILT_IN_FLOORF.
* trans-intrinsic.c (build_fix_expr): Change 'op' argument
to correct enum type.
(gfc_conv_intrinsic_aint): Likewise. Clarify comment in front of
function. Add default case to switch, deal with FIX_TRUNC_EXPR
instead of FIX_FLOOR_EXPR.
has broken the F95 compiler on non-C99 platforms because of the new
dependencies on C99's 'trunc' and 'truncf'.
The attached patch adds 'trunc' and 'truncf' to intrinsics/c99_functions.c and
tweak the configure machinery accordingly. Built and tested on SPARC/Solaris
2.5.1, 2.6, 7, 8, 9 (non-C99) and 10 (C99). OK for mainline?
2005-05-20 Eric Botcazou <ebotcazou@libertysurf.fr>
* configure.ac: Check for trunc and truncf in libm.
* configure: Regenerate.
* config.h.in: Likewise.
* intrinsics/c99_functions.c (trunc, truncf): New functions.
* c99_protos.h (trunc, truncf): Declare them.
--
Eric Botcazou
Index: c99_protos.h
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/c99_protos.h,v
retrieving revision 1.2
diff -u -r1.2 c99_protos.h
--- c99_protos.h 12 Jan 2005 21:27:29 -0000 1.2
+++ c99_protos.h 20 May 2005 13:34:09 -0000
@@ -113,6 +113,14 @@
extern float tanhf(float);
#endif
+#ifndef HAVE_TRUNC
+extern double trunc(double x);
+#endif
+
+#ifndef HAVE_TRUNCF
+extern float truncf(float x);
+#endif
+
#ifndef HAVE_NEXTAFTERF
extern float nextafterf(float, float);
#endif
Index: configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/configure.ac,v
retrieving revision 1.26
diff -u -r1.26 configure.ac
--- configure.ac 17 May 2005 16:54:58 -0000 1.26
+++ configure.ac 20 May 2005 13:34:11 -0000
@@ -206,6 +206,8 @@
AC_CHECK_LIB([m],[sqrtf],[AC_DEFINE([HAVE_SQRTF],[1],[libm includes sqrtf])])
AC_CHECK_LIB([m],[tanf],[AC_DEFINE([HAVE_TANF],[1],[libm includes tanf])])
AC_CHECK_LIB([m],[tanhf],[AC_DEFINE([HAVE_TANHF],[1],[libm includes tanhf])])
+AC_CHECK_LIB([m],[trunc],[AC_DEFINE([HAVE_TRUNC],[1],[libm includes trunc])])
+AC_CHECK_LIB([m],[truncf],[AC_DEFINE([HAVE_TRUNCF],[1],[libm includes truncf])])
AC_CHECK_LIB([m],[erf],[AC_DEFINE([HAVE_ERF],[1],[libm includes erf])])
AC_CHECK_LIB([m],[erfc],[AC_DEFINE([HAVE_ERFC],[1],[libm includes erfc])])
AC_CHECK_LIB([m],[erfcf],[AC_DEFINE([HAVE_ERFCF],[1],[libm includes erfcf])])
Index: intrinsics/c99_functions.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/intrinsics/c99_functions.c,v
retrieving revision 1.10
diff -u -r1.10 c99_functions.c
--- intrinsics/c99_functions.c 21 Feb 2005 21:39:33 -0000 1.10
+++ intrinsics/c99_functions.c 20 May 2005 13:34:11 -0000
@@ -202,6 +202,28 @@
}
#endif
+#ifndef HAVE_TRUNC
+double
+trunc(double x)
+{
+ if (!isfinite (x))
+ return x;
+
+ if (x < 0.0)
+ return - floor (-x);
+ else
+ return floor (x);
+}
+#endif
+
+#ifndef HAVE_TRUNCF
+float
+truncf(float x)
+{
+ return (float) trunc (x);
+}
+#endif
+
#ifndef HAVE_NEXTAFTERF
/* This is a portable implementation of nextafterf that is intended to be
independent of the floating point format or its in memory representation.