This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Allow EXTERNAL declaration of ETIME
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: François-Xavier Coudert <Francois-Xavier dot Coudert at lcp dot u-psud dot fr>
- Cc: fortran at gcc dot gnu dot org, patch <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 24 Sep 2004 14:07:56 +0200
- Subject: [gfortran] Allow EXTERNAL declaration of ETIME
- References: <41519B40.5080400@lcp.u-psud.fr> <41519F87.90401@physik.uni-muenchen.de> <4151A156.6030105@lcp.u-psud.fr>
ETIME is declared EXTERNAL in LAPACK. g77 calls the intrinsic nonetheless, so
we have to fix this. example code looks like this:
François-Xavier Coudert wrote:
> Here is a minimal example, working well with g77.
>
> pc31 ~ $ cat sec.f
> PROGRAM MAIN
>
> REAL SECOND
> REAL T1
> REAL TARRAY( 2 )
> REAL ETIME
> EXTERNAL ETIME
>
> T1 = ETIME( TARRAY )
> SECOND = TARRAY( 1 )
>
> END
We use different calling ocnventions for intrinsics and extrernal functions
(because we want to evade copying of arrays where possible), so I propose this
workaround.
I assume that g77 works with most of its intrinsics declared EXTERNAL, but
instead of trying to fix all of them, I suggest fixing them one at a time as
they appear. If we want to fix all at a time, we should have a field
indicating "this intrinsic takes its arguments in the g77 way", and not use
prefix on their implementations.
Anyway, patch below. Built and verified that it works as expected.
- Tobi
2004-09-24 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* etime.c (etime_): New function.
Index: etime.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/intrinsics/etime.c,v
retrieving revision 1.2
diff -u -p -r1.2 etime.c
--- etime.c 21 Jun 2004 22:25:12 -0000 1.2
+++ etime.c 24 Sep 2004 12:07:38 -0000
@@ -78,3 +78,22 @@ prefix(etime) (gfc_array_r4 *t)
prefix(etime_sub) (t, &val);
return val;
}
+
+/* LAPACK's test programs declares ETIME external, therefore we
+ need this. */
+
+GFC_REAL_4
+etime_ (GFC_REAL_4 *t)
+{
+ gfc_array_r4 desc;
+ GFC_REAL_4 val;
+
+ /* We only fill in the fields that are used in etime_sub. */
+ desc.dim[0].lbound = 0;
+ desc.dim[0].ubound = 1;
+ desc.dim[0].stride = 1;
+ desc.data = t;
+
+ prefix(etime_sub) (&desc, &val);
+ return val;
+}