Commit a63a0959 by Tobias Burnus Committed by Tobias Burnus

re PR libfortran/30015 ([4.1 only] Intrinsic date_and_time can go back in time)

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.

From-SVN: r121033
parent 1eb7b049
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.
2007-01-20 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* m4/misc_specifics.m4: Add _gfortran prefix to specific names.
......
......@@ -17,81 +17,6 @@ AC_LANG_POP([Fortran])
])
dnl Check:
dnl * If we have gettimeofday;
dnl * If we have struct timezone for use in calling it;
dnl * If calling it with a timezone pointer actually works -- this is deemed
dnl obsolete or undefined on some systems which say you should use a null
dnl pointer -- and undefine HAVE_TIMEZONE if so;
dnl * Whether it only takes one arg.
AC_DEFUN([LIBGFOR_GETTIMEOFDAY], [
AC_CHECK_FUNCS(gettimeofday)
if test "$ac_cv_func_gettimeofday" = yes; then
AC_CACHE_CHECK([for struct timezone], gfor_cv_struct_timezone,
[AC_TRY_COMPILE([#include <sys/time.h>],
[struct timezone tz;],
gfor_cv_struct_timezone=yes, gfor_cv_struct_timezone=no)])
if test $gfor_cv_struct_timezone = yes; then
dnl It may be that we can't call gettimeofday with a non-null pointer.
dnl In that case we'll lie about struct timezone.
AC_TRY_RUN([
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
main ()
{
struct timeval time;
struct timezone dummy;
if (gettimeofday (&time, &dummy))
exit (1);
else
exit (0);
}],
[gfor_have_struct_timezone=yes], [gfor_have_struct_timezone=no],
[gfor_have_struct_timezone=yes])
if test $gfor_have_struct_timezone = yes; then
AC_DEFINE(HAVE_TIMEZONE, 1, [Do we have struct timezone])
fi
fi
AC_REQUIRE([AC_HEADER_TIME])
AC_CACHE_CHECK([whether gettimeofday can accept two arguments],
emacs_cv_gettimeofday_two_arguments,
[AC_TRY_LINK([
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
],
[
struct timeval time;
#ifdef HAVE_TIMEZONE
struct timezone dummy;
#define DUMMY &dummy
#else
#define DUMMY NULL
#endif
gettimeofday (&time, DUMMY);],
emacs_cv_gettimeofday_two_arguments=yes,
emacs_cv_gettimeofday_two_arguments=no)])
if test $emacs_cv_gettimeofday_two_arguments = no; then
AC_DEFINE(GETTIMEOFDAY_ONE_ARGUMENT, 1,
[Does gettimeofday take a single argument])
fi
fi])
sinclude(../libtool.m4)
dnl The lines below arrange for aclocal not to bring an installed
dnl libtool.m4 into aclocal.m4, while still arranging for automake to
......
/* config.h.in. Generated from configure.ac by autoheader. */
/* Does gettimeofday take a single argument */
#undef GETTIMEOFDAY_ONE_ARGUMENT
/* Define to 0 if the target shouldn't use #pragma weak */
#undef GTHREAD_USE_WEAK
......@@ -645,9 +642,6 @@
/* Define to 1 if you have the `times' function. */
#undef HAVE_TIMES
/* Do we have struct timezone */
#undef HAVE_TIMEZONE
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
......
......@@ -160,6 +160,7 @@ AC_TYPE_OFF_T
# check header files
AC_STDC_HEADERS
AC_HEADER_TIME
AC_HAVE_HEADERS(stdlib.h stdio.h string.h stddef.h math.h unistd.h signal.h)
AC_CHECK_HEADERS(time.h sys/params.h sys/time.h sys/times.h sys/resource.h)
AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/wait.h floatingpoint.h ieeefp.h)
......@@ -175,7 +176,7 @@ AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_CHECK_FUNCS(getrusage times mkstemp strtof strtold snprintf ftruncate chsize)
AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime clock access fork execl)
AC_CHECK_FUNCS(wait setmode getrlimit)
AC_CHECK_FUNCS(wait setmode getrlimit gettimeofday)
# Check for types
AC_CHECK_TYPES([intptr_t])
......@@ -377,11 +378,6 @@ AC_MSG_NOTICE([FPU dependent file will be ${fpu_host}.h])
FPU_HOST_HEADER=config/${fpu_host}.h
AC_SUBST(FPU_HOST_HEADER)
# The standard autoconf HAVE_STRUCT_TIMEZONE doesn't actually check
# for struct timezone, as you might think. We also need to check how
# to call gettimeofday if we have it.
LIBGFOR_GETTIMEOFDAY
# Attempt to assert that the target is of common type in case we don't
# have C99 integer types at all.
LIBGFOR_TARGET_ILP32
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment