diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-21 16:16:10 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-21 16:16:10 +0000 |
commit | e93cd3187c29f422d142eaa6de64175ae89efbee (patch) | |
tree | a99bf5364c681de7075f0f28f1287cd4ae87d259 /libgfortran/intrinsics | |
parent | 533a9fbc2542e52b8366dda8158b1d7ec7ee49bd (diff) | |
download | gcc-e93cd3187c29f422d142eaa6de64175ae89efbee.tar.gz |
2006-12-09 Tobias Burnus <burnus@net-b.de>
PR libfortran/30015
* intrinsics/date_and_time.c (date_and_time): Fix case where time
can go backwards.
* configure.ac: Remove AC_TRY_RUN test for timezone in
gettimeofday.
* acinclude.m4: Ditto.
* configure: Regenerate.
* config.h.in: Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121033 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r-- | libgfortran/intrinsics/date_and_time.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/libgfortran/intrinsics/date_and_time.c b/libgfortran/intrinsics/date_and_time.c index 9255176adcb..18b3c8b141b 100644 --- a/libgfortran/intrinsics/date_and_time.c +++ b/libgfortran/intrinsics/date_and_time.c @@ -126,8 +126,6 @@ Boston, MA 02110-1301, USA. */ TODO : - Check year boundaries. - - There is no STDC/POSIX way to get VALUES(8). A GNUish way may - be to use ftime. */ #define DATE_LEN 8 #define TIME_LEN 10 @@ -154,7 +152,25 @@ 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 */ if (lt != (time_t) -1) { @@ -171,31 +187,6 @@ date_and_time (char *__date, char *__time, char *__zone, values[4] = local_time.tm_hour; values[5] = local_time.tm_min; values[6] = local_time.tm_sec; - values[7] = 0; - -#if HAVE_GETTIMEOFDAY - { - struct timeval tp; -# if GETTIMEOFDAY_ONE_ARGUMENT - if (!gettimeofday (&tp)) -# else -# if HAVE_STRUCT_TIMEZONE - struct timezone tzp; - - /* Some systems such as HP-UX, do have struct timezone, but - gettimeofday takes void* as the 2nd arg. However, the - effect of passing anything other than a null pointer is - unspecified on HP-UX. Configure checks if gettimeofday - actually fails with a non-NULL arg and pretends that - struct timezone is missing if it does fail. */ - if (!gettimeofday (&tp, &tzp)) -# else - if (!gettimeofday (&tp, (void *) 0)) -# endif /* HAVE_STRUCT_TIMEZONE */ -# endif /* GETTIMEOFDAY_ONE_ARGUMENT */ - values[7] = tp.tv_usec / 1000; - } -#endif /* HAVE_GETTIMEOFDAY */ #if HAVE_SNPRINTF if (__date) |