aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2007-01-21 17:16:10 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2007-01-21 17:16:10 +0100
commita63a09594132dfe461a87dfd71cf607b987fc770 (patch)
treea99bf5364c681de7075f0f28f1287cd4ae87d259 /libgfortran
parent1eb7b0490470ad3690fb31ed4799008ebdf1e21f (diff)
downloadgcc-a63a09594132dfe461a87dfd71cf607b987fc770.zip
gcc-a63a09594132dfe461a87dfd71cf607b987fc770.tar.gz
gcc-a63a09594132dfe461a87dfd71cf607b987fc770.tar.bz2
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
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog11
-rw-r--r--libgfortran/acinclude.m475
-rw-r--r--libgfortran/config.h.in6
-rwxr-xr-xlibgfortran/configure447
-rw-r--r--libgfortran/configure.ac8
-rw-r--r--libgfortran/intrinsics/date_and_time.c45
6 files changed, 98 insertions, 494 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index a138750..d81546f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,14 @@
+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.
diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
index 3c849fa..1660b6e7 100644
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -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
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index c67365f..ab7a892 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -1,8 +1,5 @@
/* 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
diff --git a/libgfortran/configure b/libgfortran/configure
index 3b3ed6a..5939bb3 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -6043,6 +6043,71 @@ _ACEOF
fi
+echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
+echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
+if test "${ac_cv_header_time+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_time=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_time=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
+echo "${ECHO_T}$ac_cv_header_time" >&6
+if test $ac_cv_header_time = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TIME_WITH_SYS_TIME 1
+_ACEOF
+
+fi
+
@@ -10332,7 +10397,8 @@ done
-for ac_func in wait setmode getrlimit
+
+for ac_func in wait setmode getrlimit gettimeofday
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -23376,385 +23442,6 @@ echo "$as_me: FPU dependent file will be ${fpu_host}.h" >&6;}
FPU_HOST_HEADER=config/${fpu_host}.h
-# 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.
-echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
-echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
-if test "${ac_cv_header_time+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-
-int
-main ()
-{
-if ((struct tm *) 0)
-return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_time=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_header_time=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
-echo "${ECHO_T}$ac_cv_header_time" >&6
-if test $ac_cv_header_time = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define TIME_WITH_SYS_TIME 1
-_ACEOF
-
-fi
-
-
-
-for ac_func in gettimeofday
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test x$gcc_no_link = xyes; then
- { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
-echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
- { (exit 1); exit 1; }; }
-fi
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $ac_func;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_var=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_var=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
- if test "$ac_cv_func_gettimeofday" = yes; then
- echo "$as_me:$LINENO: checking for struct timezone" >&5
-echo $ECHO_N "checking for struct timezone... $ECHO_C" >&6
-if test "${gfor_cv_struct_timezone+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/time.h>
-int
-main ()
-{
-struct timezone tz;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- gfor_cv_struct_timezone=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-gfor_cv_struct_timezone=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $gfor_cv_struct_timezone" >&5
-echo "${ECHO_T}$gfor_cv_struct_timezone" >&6
- if test $gfor_cv_struct_timezone = yes; then
- if test "$cross_compiling" = yes; then
- gfor_have_struct_timezone=yes
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-#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);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- gfor_have_struct_timezone=yes
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-gfor_have_struct_timezone=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
- if test $gfor_have_struct_timezone = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_TIMEZONE 1
-_ACEOF
-
- fi
- fi
-
- echo "$as_me:$LINENO: checking whether gettimeofday can accept two arguments" >&5
-echo $ECHO_N "checking whether gettimeofday can accept two arguments... $ECHO_C" >&6
-if test "${emacs_cv_gettimeofday_two_arguments+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test x$gcc_no_link = xyes; then
- { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
-echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
- { (exit 1); exit 1; }; }
-fi
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-#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
-
-int
-main ()
-{
-
- struct timeval time;
-#ifdef HAVE_TIMEZONE
- struct timezone dummy;
-#define DUMMY &dummy
-#else
-#define DUMMY NULL
-#endif
- gettimeofday (&time, DUMMY);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- emacs_cv_gettimeofday_two_arguments=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-emacs_cv_gettimeofday_two_arguments=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $emacs_cv_gettimeofday_two_arguments" >&5
-echo "${ECHO_T}$emacs_cv_gettimeofday_two_arguments" >&6
- if test $emacs_cv_gettimeofday_two_arguments = no; then
-
-cat >>confdefs.h <<\_ACEOF
-#define GETTIMEOFDAY_ONE_ARGUMENT 1
-_ACEOF
-
- fi
- fi
-
# Attempt to assert that the target is of common type in case we don't
# have C99 integer types at all.
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 802d5ad..8711134 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -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
diff --git a/libgfortran/intrinsics/date_and_time.c b/libgfortran/intrinsics/date_and_time.c
index 9255176..18b3c8b 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)