aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2012-05-24 23:19:37 +0300
committerJanne Blomqvist <jb@gcc.gnu.org>2012-05-24 23:19:37 +0300
commit44813fe0436d2ad3ef79fcaee52b78f0bddc23e3 (patch)
tree3281f9f7646bce3c0d7504d2d768e20be21b11b3 /libgfortran
parent165ca58dc37d9c10443e5cf1daa836edb355a0f0 (diff)
downloadgcc-44813fe0436d2ad3ef79fcaee52b78f0bddc23e3.zip
gcc-44813fe0436d2ad3ef79fcaee52b78f0bddc23e3.tar.gz
gcc-44813fe0436d2ad3ef79fcaee52b78f0bddc23e3.tar.bz2
PR 53456 CPU timing fallback using clock_gettime.
2012-05-24 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/53456 * intrinsics/time_1.h (gf_cputime): Fallback for clock_gettime. From-SVN: r187846
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog5
-rw-r--r--libgfortran/intrinsics/time_1.h17
2 files changed, 21 insertions, 1 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 3dfde05..e30622f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-24 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/53456
+ * intrinsics/time_1.h (gf_cputime): Fallback for clock_gettime.
+
2012-05-23 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/53456
diff --git a/libgfortran/intrinsics/time_1.h b/libgfortran/intrinsics/time_1.h
index ca5b26b..94f2f3d 100644
--- a/libgfortran/intrinsics/time_1.h
+++ b/libgfortran/intrinsics/time_1.h
@@ -1,5 +1,5 @@
/* Wrappers for platform timing functions.
- Copyright (C) 2003, 2007, 2009, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2007, 2009, 2011, 2012 Free Software Foundation, Inc.
This file is part of the GNU Fortran runtime library (libgfortran).
@@ -166,6 +166,21 @@ gf_cputime (long *user_sec, long *user_usec, long *system_sec, long *system_usec
return -1;
return 0;
+#elif defined(HAVE_CLOCK_GETTIME) && (defined(CLOCK_PROCESS_CPUTIME_ID) \
+ || defined(CLOCK_THREAD_CPUTIME_ID))
+ /* Newer versions of VxWorks have CLOCK_THREAD_CPUTIME_ID giving
+ per-thread CPU time. CLOCK_PROCESS_CPUTIME_ID would be better
+ but is not available. */
+#ifndef CLOCK_PROCESS_CPUTIME_ID
+#define CLOCK_PROCESS_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID
+#endif
+ struct timespec ts;
+ int err = clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts);
+ *user_sec = ts.tv_sec;
+ *user_usecs = ts.tv_nsec / 1000;
+ *system_sec = *system_usec = 0;
+ return err;
+
#else
clock_t c = clock ();
*user_sec = c / CLOCKS_PER_SEC;