From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20568 invoked by alias); 11 Apr 2013 12:32:12 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 20437 invoked by uid 48); 11 Apr 2013 12:32:08 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/56919] New: [4.6/4.7/4.8/4.9 Regression] Wrong result for SYSTEM_CLOCK on Cygwin Date: Thu, 11 Apr 2013 12:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-SW-Source: 2013-04/txt/msg00973.txt.bz2 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