+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.
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.");
__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;
# 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>
{
#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;