diff options
author | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-01-31 20:52:00 +0000 |
---|---|---|
committer | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-01-31 20:52:00 +0000 |
commit | a2c0dc0f1141b57c2bbd2c6ce8ca6f4bed3f2b00 (patch) | |
tree | 218eeedfb68b9af80b02714d695e24e0effb0fbc /libgfortran/intrinsics/date_and_time.c | |
parent | f58707cd85257fb6095cd0bceed1882f348f78d0 (diff) | |
download | gcc-a2c0dc0f1141b57c2bbd2c6ce8ca6f4bed3f2b00.tar.gz |
Use clock_gettime in libgfortran timing intrinsics, cleanup
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169449 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/date_and_time.c')
-rw-r--r-- | libgfortran/intrinsics/date_and_time.c | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/libgfortran/intrinsics/date_and_time.c b/libgfortran/intrinsics/date_and_time.c index dea835b36f0..714df14c8f1 100644 --- a/libgfortran/intrinsics/date_and_time.c +++ b/libgfortran/intrinsics/date_and_time.c @@ -1,5 +1,5 @@ /* Implementation of the DATE_AND_TIME intrinsic. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010 + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Steven Bosscher. @@ -29,21 +29,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include <assert.h> #include <stdlib.h> -#undef HAVE_NO_DATE_TIME -#if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -#else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# ifdef HAVE_TIME_H -# include <time.h> -# else -# define HAVE_NO_DATE_TIME -# endif /* HAVE_TIME_H */ -# endif /* HAVE_SYS_TIME_H */ -#endif /* TIME_WITH_SYS_TIME */ +#include "time_1.h" #ifndef abs #define abs(x) ((x)>=0 ? (x) : -(x)) @@ -176,28 +162,12 @@ date_and_time (char *__date, char *__time, char *__zone, struct tm local_time; struct tm UTC_time; -#if HAVE_GETTIMEOFDAY - { - struct timeval tp; - - if (!gettimeofday (&tp, NULL)) - { - lt = tp.tv_sec; - values[7] = tp.tv_usec / 1000; - } - else - { - lt = time (NULL); - values[7] = 0; - } - } -#else - lt = time (NULL); - values[7] = 0; -#endif /* HAVE_GETTIMEOFDAY */ + long nanosecs; - if (lt != (time_t) -1) + if (!gf_gettime(GF_CLOCK_REALTIME, <, &nanosecs)) { + values[7] = nanosecs / 1000000; + localtime_r (<, &local_time); gmtime_r (<, &UTC_time); |