summaryrefslogtreecommitdiffstats
path: root/libgfortran/intrinsics/etime.c
diff options
context:
space:
mode:
authordfranke <dfranke@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-25 10:41:44 +0000
committerdfranke <dfranke@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-25 10:41:44 +0000
commitdd6c1457b279f399a5cbecbce067851a494e954f (patch)
tree4b9ff08a07e57806321780593e88a8b23ebe3846 /libgfortran/intrinsics/etime.c
parent83fc1a28ee38afd5df7e7c87939d5a32e17fee96 (diff)
downloadppe42-gcc-dd6c1457b279f399a5cbecbce067851a494e954f.tar.gz
ppe42-gcc-dd6c1457b279f399a5cbecbce067851a494e954f.zip
gcc/fortran:
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. libgfortran: 2007-12-25 Daniel Franke <franke.daniel@gmail.com> PR fortran/34533 * intrinsics/cpu_time.c: Moved code commonly usable for CPU_TIME, DTIME and ETIME to ... * intrinsics/time_1.h: ... here. * intrinsics/dtime.c: New file. * intrinsics/etime.c: Newly implemented using the common time-aquisition function from time_1.h. * gfortran.map (_gfortran_dtime, _gfortran_dtime_sub): New. * Makefile.am: Added new file. * Makefile.in: Regenerated. * configure: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131168 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/etime.c')
-rw-r--r--libgfortran/intrinsics/etime.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/libgfortran/intrinsics/etime.c b/libgfortran/intrinsics/etime.c
index c4d25c4160a..0ecba26359a 100644
--- a/libgfortran/intrinsics/etime.c
+++ b/libgfortran/intrinsics/etime.c
@@ -29,11 +29,7 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
#include "libgfortran.h"
-
-#if defined (HAVE_SYS_TIME_H) && defined (HAVE_SYS_RESOURCE_H)
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
+#include "time_1.h"
extern void etime_sub (gfc_array_r4 *t, GFC_REAL_4 *result);
iexport_proto(etime_sub);
@@ -42,30 +38,23 @@ void
etime_sub (gfc_array_r4 *t, GFC_REAL_4 *result)
{
GFC_REAL_4 tu, ts, tt, *tp;
+ long user_sec, user_usec, system_sec, system_usec;
-#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
- struct rusage rt;
+ if (((t->dim[0].ubound + 1 - t->dim[0].lbound)) < 2)
+ runtime_error ("Insufficient number of elements in TARRAY.");
- if (getrusage(RUSAGE_SELF, &rt) == 0)
+ if (__time_1 (&user_sec, &user_usec, &system_sec, &system_usec) == 0)
{
- tu = (GFC_REAL_4)(rt.ru_utime.tv_sec + 1.e-6 * rt.ru_utime.tv_usec);
- ts = (GFC_REAL_4)(rt.ru_stime.tv_sec + 1.e-6 * rt.ru_stime.tv_usec);
+ tu = (GFC_REAL_4)(user_sec + 1.e-6 * user_usec);
+ ts = (GFC_REAL_4)(system_sec + 1.e-6 * system_usec);
tt = tu + ts;
}
else
{
- tu = -1.;
- ts = -1.;
- tt = -1.;
+ tu = (GFC_REAL_4)-1.0;
+ ts = (GFC_REAL_4)-1.0;
+ tt = (GFC_REAL_4)-1.0;
}
-#else
- tu = -1.;
- ts = -1.;
- tt = -1.;
-#endif
-
- if (((t->dim[0].ubound + 1 - t->dim[0].lbound)) < 2)
- runtime_error ("Insufficient number of elements in TARRAY.");
tp = t->data;
OpenPOWER on IntegriCloud