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: unassig...@gcc.gnu.org

        ReportedBy: bur...@gcc.gnu.org

                CC: ja...@gcc.gnu.org, j...@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

Reply via email to