aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2012-05-23 21:52:47 +0300
committerJanne Blomqvist <jb@gcc.gnu.org>2012-05-23 21:52:47 +0300
commitc5a6cbd4bacd65046a1ee50e858737e1f5784fe8 (patch)
tree939c29b65fb6d8f9a04479fb71b2535c9f8b2927 /libgfortran
parente8257960f082cebe7ae514a11e13d9ea4c47233f (diff)
downloadgcc-c5a6cbd4bacd65046a1ee50e858737e1f5784fe8.zip
gcc-c5a6cbd4bacd65046a1ee50e858737e1f5784fe8.tar.gz
gcc-c5a6cbd4bacd65046a1ee50e858737e1f5784fe8.tar.bz2
PR 53456 clock_gettime fallback for gf_gettime
2012-05-23 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/53456 * intrinsics/time_1.h (gf_gettime): Fallback for clock_gettime. From-SVN: r187806
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog5
-rw-r--r--libgfortran/intrinsics/time_1.h10
2 files changed, 13 insertions, 2 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index e5f79e0..3dfde05 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-23 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/53456
+ * intrinsics/time_1.h (gf_gettime): Fallback for clock_gettime.
+
2012-05-23 Robert Mason <rbmj@verizon.net>
Tobias Burnus <burnus@net-b.de>
diff --git a/libgfortran/intrinsics/time_1.h b/libgfortran/intrinsics/time_1.h
index aaca56a..ca5b26b 100644
--- a/libgfortran/intrinsics/time_1.h
+++ b/libgfortran/intrinsics/time_1.h
@@ -181,8 +181,8 @@ gf_cputime (long *user_sec, long *user_usec, long *system_sec, long *system_usec
#endif
-/* Realtime clock with microsecond resolution, falling back to less
- precise functions if the target does not support gettimeofday().
+/* Realtime clock with microsecond resolution, falling back to other
+ functions if the target does not support gettimeofday().
Arguments:
secs - OUTPUT, seconds
@@ -204,6 +204,12 @@ gf_gettime (time_t * secs, long * usecs)
*secs = tv.tv_sec;
*usecs = tv.tv_usec;
return err;
+#elif defined(HAVE_CLOCK_GETTIME)
+ struct timespec ts;
+ int err = clock_gettime (CLOCK_REALTIME, &ts);
+ *secs = ts.tv_sec;
+ *usecs = ts.tv_nsec / 1000;
+ return err;
#else
time_t t = time (NULL);
*secs = t;