This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cygwin with clock_gettime and CLOCK_MONOTONIC - gives always 0


Please CC your reply to fortran@gcc.gnu.org

Dear all,

using clock_gettime with CLOCK_MONOTONIC fails on Cygwin; it always gives 0. That breaks code compiled with GCC's gfortran which uses system_clock in libgfortran.

libgfortran uses CLOCK_MONOTONIC if defined and otherwise it falls back to CLOCK_REALTIME (which works); however, Cygwin defines both. Maybe a better check would be _POSIX_MONOTONIC_CLOCK [2], however, that is also defined with Cygwin [1].


First, is a known problem that clock_gettime gives the wrong result?

Secondly, do you have an idea how to test for it? One could use an exec test in configure, but that does not nicely work with cross compilations, which are commonly done for GCC.


See http://gcc.gnu.org/ml/fortran/2013-04/msg00085.html for the thread at GCC, where the issue showed up.

(The issue is new since GCC 4.6 (2011-01-31) as that's the first GCC version where libgfortran uses clock_gettime (when available); before gettimeofday was used. See also GCC bugreport 56919. And CLOCK_MONOTONIC appeared in Cygwin around the same time [Aug 2010], cf. [1])


Tobias


[1] Cf. Cygwin-1.7.6 announcement at http://cygwin.com/ml/cygwin-announce/2010-08/msg00019.html and the "#define _POSIX_MONOTONIC_CLOCK 200112L" patch at http://sourceware.org/ml/newlib/2010/msg00454.html Note that Linux's glibc has in /usr/include/bits/posix_opt.h a more careful value: "/* The monotonic clock might be available. */", "#define _POSIX_MONOTONIC_CLOCK 0"
[2] http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap02.html

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]