[patch,fortran] Fix corner case where consecutive calls to date_and_time can return times out of sequence (PR30015)

Tobias Burnus burnus@net-b.de
Sun Dec 10 19:13:00 GMT 2006


Hi Andreas, hi all,


+#if HAVE_GETTIMEOFDAY  [...]
+#if GETTIMEOFDAY_ONE_ARGUMENT
+    if (!gettimeofday (&tp))
+#else [...]
+#if HAVE_STRUCT_TIMEZONE
+    if (!gettimeofday (&tp, &tzp))
+#else
+    if (!gettimeofday (&tp, (void *) 0))
+#endif /* HAVE_STRUCT_TIMEZONE  */

Andreas Schwab wrote:
> The timezone information is never used, why not always passing NULL for
> it?  This is the only use of gettimeofday in libgfortran, it would also
> make it possible to eliminate a runtime configure check.
>   
I don't know what you mean by runtime configure check. One would speed
up the ./configure when building libgfortran, but I wouldn't call this
runtime.

I agree that one can get rid of HAVE_STRUCT_TIMEZONE and simply pass
NULL as second argument.

Does anyone know whether there is any implementation, which does not
have two arguments for gettimeofday? (Or, for completeness, have
problems with a NULL pointer as second argument?)

POSIX 2001 defines only
       int gettimeofday(struct timeval *restrict tp, void *restrict tzp);
and notes that "If tzp is not a null pointer, the behavior is unspecified."

If no such platform exists, I would like to use a simple:

#if HAVE_GETTIMEOFDAY
    if (!gettimeofday (&tp, NULL))
this is actually also used that way in:
  ./libiberty/mkstemps.c
  ./libgomp/config/posix/time.c
  ./libmudflap/mf-runtime.c


Would something like the attached patch work?

(Note: I know only very little about using the auto* tools. Especially,
I do not how to *properly* regenerate configure; e.g. I have autoconf
2.60, it was generated by autoconf 2.59 -- is 2.60 also ok?)

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: time2.diff
Type: text/x-patch
Size: 5630 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20061210/2f30627f/attachment.bin>


More information about the Fortran mailing list