summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog23
-rw-r--r--gcc/fortran/check.c4
-rw-r--r--gcc/fortran/intrinsic.c14
-rw-r--r--gcc/fortran/intrinsic.h5
-rw-r--r--gcc/fortran/intrinsic.texi23
-rw-r--r--gcc/fortran/iresolve.c10
-rw-r--r--gcc/fortran/trans-intrinsic.c1
7 files changed, 69 insertions, 11 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 9db44b24da5..7ffa51d1516 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,26 @@
+2007-12-25 Daniel Franke <franke.daniel@gmail.com>
+
+ PR fortran/34533
+ * intrinsic.h (gfc_check_etime): Renamed to ...
+ (gfc_check_dtime_etime): ... this.
+ (gfc_check_etime_sub): Renamed to ...
+ (gfc_check_dtime_etime_sub): ... this.
+ (gfc_resolve_dtime_sub): New prototype.
+ * check.c (gfc_check_etime): Renamed to ...
+ (gfc_check_dtime_etime): ... this.
+ (gfc_check_etime_sub): Renamed to ...
+ (gfc_check_dtime_etime_sub): ... this.
+ * iresolve.c (gfc_resolve_dtime_sub): New implementation.
+ * intrinsic.c (add_functions): Removed alias from ETIME to DTIME,
+ added stand-alone intrinsic DTIME.
+ (add_subroutines): Adjusted check and resolve function names for
+ DTIME and ETIME.
+ * trans-intrinsic.c (gfc_conv_intrinsic_function): Added DTIME
+ to known functions in switch.
+ * intrinsic.texi (DTIME): Added paragraph about thread-safety,
+ fixed return value section.
+ (CPU_TIME): Clarified intent and added implementation notes.
+
2007-12-23 Tobias Burnus <burnus@net-b.de>
PR fortran/34421
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 9cc4d8570de..ba7bcf295bd 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -3230,7 +3230,7 @@ gfc_check_ctime_sub (gfc_expr *time, gfc_expr *result)
try
-gfc_check_etime (gfc_expr *x)
+gfc_check_dtime_etime (gfc_expr *x)
{
if (array_check (x, 0) == FAILURE)
return FAILURE;
@@ -3252,7 +3252,7 @@ gfc_check_etime (gfc_expr *x)
try
-gfc_check_etime_sub (gfc_expr *values, gfc_expr *time)
+gfc_check_dtime_etime_sub (gfc_expr *values, gfc_expr *time)
{
if (array_check (values, 0) == FAILURE)
return FAILURE;
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 039e2288cd6..227c5ec1c6e 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -1360,11 +1360,15 @@ add_functions (void)
make_generic ("erfc", GFC_ISYM_ERFC, GFC_STD_GNU);
/* G77 compatibility */
- add_sym_1 ("etime", GFC_ISYM_ETIME, NO_CLASS, ACTUAL_NO, BT_REAL, 4, GFC_STD_GNU,
- gfc_check_etime, NULL, NULL,
+ add_sym_1 ("dtime", GFC_ISYM_DTIME, NO_CLASS, ACTUAL_NO, BT_REAL, 4, GFC_STD_GNU,
+ gfc_check_dtime_etime, NULL, NULL,
x, BT_REAL, 4, REQUIRED);
- make_alias ("dtime", GFC_STD_GNU);
+ make_generic ("dtime", GFC_ISYM_DTIME, GFC_STD_GNU);
+
+ add_sym_1 ("etime", GFC_ISYM_ETIME, NO_CLASS, ACTUAL_NO, BT_REAL, 4, GFC_STD_GNU,
+ gfc_check_dtime_etime, NULL, NULL,
+ x, BT_REAL, 4, REQUIRED);
make_generic ("etime", GFC_ISYM_ETIME, GFC_STD_GNU);
@@ -2437,11 +2441,11 @@ add_subroutines (void)
/* More G77 compatibility garbage. */
add_sym_2s ("etime", GFC_ISYM_ETIME, NO_CLASS, BT_UNKNOWN, 0, GFC_STD_GNU,
- gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
+ gfc_check_dtime_etime_sub, NULL, gfc_resolve_etime_sub,
vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED);
add_sym_2s ("dtime", GFC_ISYM_DTIME, NO_CLASS, BT_UNKNOWN, 0, GFC_STD_GNU,
- gfc_check_etime_sub, NULL, gfc_resolve_etime_sub,
+ gfc_check_dtime_etime_sub, NULL, gfc_resolve_dtime_sub,
vl, BT_REAL, 4, REQUIRED, tm, BT_REAL, 4, REQUIRED);
add_sym_1s ("fdate", GFC_ISYM_FDATE, NO_CLASS, BT_UNKNOWN, 0, GFC_STD_GNU,
diff --git a/gcc/fortran/intrinsic.h b/gcc/fortran/intrinsic.h
index 59cdfb14eeb..dc544890e49 100644
--- a/gcc/fortran/intrinsic.h
+++ b/gcc/fortran/intrinsic.h
@@ -55,7 +55,7 @@ try gfc_check_digits (gfc_expr *);
try gfc_check_dot_product (gfc_expr *, gfc_expr *);
try gfc_check_dprod (gfc_expr *, gfc_expr *);
try gfc_check_eoshift (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
-try gfc_check_etime (gfc_expr *);
+try gfc_check_dtime_etime (gfc_expr *);
try gfc_check_fgetputc (gfc_expr *, gfc_expr *);
try gfc_check_fgetput (gfc_expr *);
try gfc_check_fstat (gfc_expr *, gfc_expr *);
@@ -165,7 +165,7 @@ try gfc_check_mvbits (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *,
gfc_expr *);
try gfc_check_random_number (gfc_expr *);
try gfc_check_random_seed (gfc_expr *, gfc_expr *, gfc_expr *);
-try gfc_check_etime_sub (gfc_expr *, gfc_expr *);
+try gfc_check_dtime_etime_sub (gfc_expr *, gfc_expr *);
try gfc_check_fgetputc_sub (gfc_expr *, gfc_expr *, gfc_expr *);
try gfc_check_fgetput_sub (gfc_expr *, gfc_expr *);
try gfc_check_fseek_sub (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
@@ -345,6 +345,7 @@ void gfc_resolve_dble (gfc_expr *, gfc_expr *);
void gfc_resolve_dim (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_dot_product (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_dprod (gfc_expr *, gfc_expr *, gfc_expr *);
+void gfc_resolve_dtime_sub (gfc_code *);
void gfc_resolve_eoshift (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *,
gfc_expr *);
void gfc_resolve_etime_sub (gfc_code *);
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index f31ca25a11c..8b177087080 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -2717,6 +2717,16 @@ Returns a @code{REAL(*)} value representing the elapsed CPU time in
seconds. This is useful for testing segments of code to determine
execution time.
+If a time source is available, time will be reported with microsecond
+resolution. If no time source is available, @var{TIME} is set to
+@code{-1.0}.
+
+Note that @var{TIME} may contain a, system dependent, arbitrary offset
+and may not start with @code{0.0}. For @code{CPU_TIME}, the absolute
+value is meaningless, only differences between subsequent calls to
+this subroutine, as shown in the example below, should be used.
+
+
@item @emph{Standard}:
F95 and later
@@ -3321,6 +3331,12 @@ sufficiently small limits that overflows (wrap around) are possible, such as
become, negative, or numerically less than previous values, during a single
run of the compiled program.
+Please note, that this implementation is thread safe if used within OpenMP
+directives, i. e. its state will be consistent while called from multiple
+threads. However, if @code{DTIME} is called from multiple threads, the result
+is still the time since the last invocation. This may not give the intended
+results. If possible, use @code{CPU_TIME} instead.
+
This intrinsic is provided in both subroutine and function forms; however,
only one form can be used in any given program unit.
@@ -3351,7 +3367,8 @@ Subroutine, function
@end multitable
@item @emph{Return value}:
-Elapsed time in seconds since the start of program execution.
+Elapsed time in seconds since the last invocation or since the start of program
+execution if not called before.
@item @emph{Example}:
@smallexample
@@ -3372,6 +3389,10 @@ program test_dtime
print *, tarray(2)
end program test_dtime
@end smallexample
+
+@item @emph{See also}:
+@ref{CPU_TIME}
+
@end table
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index cdc4ac176dd..8a09efcfcb5 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -2676,7 +2676,15 @@ gfc_resolve_symlnk_sub (gfc_code *c)
}
-/* G77 compatibility subroutines etime() and dtime(). */
+/* G77 compatibility subroutines dtime() and etime(). */
+
+void
+gfc_resolve_dtime_sub (gfc_code *c)
+{
+ const char *name;
+ name = gfc_get_string (PREFIX ("dtime_sub"));
+ c->resolved_sym = gfc_get_intrinsic_sub_symbol (name);
+}
void
gfc_resolve_etime_sub (gfc_code *c)
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 63c56040eb2..c10d44a1410 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -4097,6 +4097,7 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr)
case GFC_ISYM_ACCESS:
case GFC_ISYM_CHDIR:
case GFC_ISYM_CHMOD:
+ case GFC_ISYM_DTIME:
case GFC_ISYM_ETIME:
case GFC_ISYM_FGET:
case GFC_ISYM_FGETC:
OpenPOWER on IntegriCloud