summaryrefslogtreecommitdiffstats
path: root/libgfortran
diff options
context:
space:
mode:
authorkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>2009-08-25 01:47:23 +0000
committerkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>2009-08-25 01:47:23 +0000
commit783a946e966217d6571aeee006e6884e55e1becb (patch)
treea9de4f2eefae9e965c3d593a680a684a0d19f20e /libgfortran
parentb089570f6ea07cbdfaf9e6575304d23844c96767 (diff)
downloadppe42-gcc-783a946e966217d6571aeee006e6884e55e1becb.tar.gz
ppe42-gcc-783a946e966217d6571aeee006e6884e55e1becb.zip
2009-08-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/41157 * dtime.c (dtime_sub): Fix computing time increment. * time_1.h: Add <sys/types.h> header. Use RUSAGE_SELF macro instead of a hardcoded 0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151072 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/intrinsics/dtime.c17
-rw-r--r--libgfortran/intrinsics/time_1.h6
3 files changed, 23 insertions, 7 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 848fc51e711..b1494ca0c50 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-24 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/41157
+ * dtime.c (dtime_sub): Fix computing time increment.
+ * time_1.h: Add <sys/types.h> header. Use RUSAGE_SELF macro instead
+ of a hardcoded 0.
+
2009-08-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* configure.ac (AC_PREREQ): Bump to 2.64.
diff --git a/libgfortran/intrinsics/dtime.c b/libgfortran/intrinsics/dtime.c
index 4b7000b4466..d1eb9121ab8 100644
--- a/libgfortran/intrinsics/dtime.c
+++ b/libgfortran/intrinsics/dtime.c
@@ -38,9 +38,10 @@ iexport_proto(dtime_sub);
void
dtime_sub (gfc_array_r4 *t, GFC_REAL_4 *result)
{
- static GFC_REAL_4 tu = 0.0, ts = 0.0, tt = 0.0;
GFC_REAL_4 *tp;
long user_sec, user_usec, system_sec, system_usec;
+ static long us = 0, uu = 0, ss = 0 , su = 0;
+ GFC_REAL_4 tu, ts, tt;
if (((GFC_DESCRIPTOR_EXTENT(t,0))) < 2)
runtime_error ("Insufficient number of elements in TARRAY.");
@@ -48,15 +49,19 @@ dtime_sub (gfc_array_r4 *t, GFC_REAL_4 *result)
__gthread_mutex_lock (&dtime_update_lock);
if (__time_1 (&user_sec, &user_usec, &system_sec, &system_usec) == 0)
{
- tu = (GFC_REAL_4)(user_sec + 1.e-6 * user_usec) - tu;
- ts = (GFC_REAL_4)(system_sec + 1.e-6 * system_usec) - ts;
+ tu = (GFC_REAL_4) ((user_sec - us) + 1.e-6 * (user_usec - uu));
+ ts = (GFC_REAL_4) ((system_sec - ss) + 1.e-6 * (system_usec - su));
tt = tu + ts;
+ us = user_sec;
+ uu = user_usec;
+ ss = system_sec;
+ su = system_usec;
}
else
{
- tu = (GFC_REAL_4)-1.0;
- ts = (GFC_REAL_4)-1.0;
- tt = (GFC_REAL_4)-1.0;
+ tu = -1;
+ ts = -1;
+ tt = -1;
}
tp = t->data;
diff --git a/libgfortran/intrinsics/time_1.h b/libgfortran/intrinsics/time_1.h
index a93b7e0202a..03e14edc414 100644
--- a/libgfortran/intrinsics/time_1.h
+++ b/libgfortran/intrinsics/time_1.h
@@ -51,6 +51,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# endif
#endif
+#ifdef HAVE_SYS_TYPES_H
+ #include <sys/types.h>
+#endif
+
/* The most accurate way to get the CPU time is getrusage (). */
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
# include <sys/resource.h>
@@ -112,7 +116,7 @@ __time_1 (long *user_sec, long *user_usec, long *system_sec, long *system_usec)
{
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
struct rusage usage;
- getrusage (0, &usage);
+ getrusage (RUSAGE_SELF, &usage);
*user_sec = usage.ru_utime.tv_sec;
*user_usec = usage.ru_utime.tv_usec;
OpenPOWER on IntegriCloud