public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56919] New: [4.6/4.7/4.8/4.9 Regression] Wrong result for SYSTEM_CLOCK on Cygwin
@ 2013-04-11 12:32 burnus at gcc dot gnu.org
  2013-04-11 13:53 ` [Bug fortran/56919] " burnus at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-11 12:32 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56919

             Bug #: 56919
           Summary: [4.6/4.7/4.8/4.9 Regression] Wrong result for
                    SYSTEM_CLOCK on Cygwin
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org, jb@gcc.gnu.org


The regression has been caused by Janne's patch, Rev.
http://gcc.gnu.org/r169449 - which was checked in 2011-01-31  (= GCC 4.6)


See Angelo Graziosi's bug report at
http://gcc.gnu.org/ml/fortran/2013-04/msg00085.html


The problem is that Cygwin does not support CLOCK_MONOTONIC; using it will
return always return 0.

Note that Cygwin not only defines CLOCK_MONOTONIC but since Cygwin-1.7.6 also 
"_POSIX_MONOTONIC_CLOCK 200112L" [1]. Thus, _POSIX_MONOTONIC_CLOCK [2] can also
not be used.


Currently, libgfortran uses (cf.libgfortran/intrinsics/system_clock.c):


/* POSIX states that CLOCK_REALTIME must be present if clock_gettime
   is available, others are optional.  */
#ifdef CLOCK_MONOTONIC
#define GF_CLOCK_MONOTONIC CLOCK_MONOTONIC
#else
#define GF_CLOCK_MONOTONIC CLOCK_REALTIME
#endif

#ifdef HAVE_CLOCK_GETTIME
  err = clock_gettime (GF_CLOCK_MONOTONIC, &ts);
#else
#if defined(HAVE_CLOCK_GETTIME_LIBRT) && SUPPORTS_WEAK && GTHREAD_USE_WEAK
  if (weak_gettime)
    err = clock_gettime (GF_CLOCK_MONOTONIC, &ts);
#endif
  err = gf_gettime (secs, nanosecs);
#endif


And gf_gettime (time_1.h) uses: gettimeofday - or if not available:
"clock_gettime (CLOCK_REALTIME" - or a simple "time(NULL)".


Nick suggests to simply call gf_gettime unconditionally. [3]


[1] Cf. http://cygwin.com/ml/cygwin-announce/2010-08/msg00019.html ,
http://sourceware.org/ml/newlib/2010/msg00454.html
[2] http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap02.html
[3] http://gcc.gnu.org/ml/fortran/2013-04/msg00086.html


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-05-03 21:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 12:32 [Bug fortran/56919] New: [4.6/4.7/4.8/4.9 Regression] Wrong result for SYSTEM_CLOCK on Cygwin burnus at gcc dot gnu.org
2013-04-11 13:53 ` [Bug fortran/56919] " burnus at gcc dot gnu.org
2013-04-11 18:32 ` jb at gcc dot gnu.org
2013-04-11 20:14 ` burnus at gcc dot gnu.org
2013-04-11 21:18 ` burnus at gcc dot gnu.org
2013-04-12 18:49 ` [Bug fortran/56919] [4.7/4.8/4.9 " jb at gcc dot gnu.org
2013-04-15 12:57 ` burnus at gcc dot gnu.org
2013-05-15 13:27 ` rguenth at gcc dot gnu.org
2013-05-15 15:28 ` [Bug fortran/56919] [4.7/4.8 " jb at gcc dot gnu.org
2014-05-03 20:57 ` jb at gcc dot gnu.org
2014-05-03 21:03 ` jb at gcc dot gnu.org
2014-05-03 21:05 ` jb at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).