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

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 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])


[1] Cf. Cygwin-1.7.6 announcement at and the "#define _POSIX_MONOTONIC_CLOCK 200112L" patch at 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"

Problem reports:
Unsubscribe info:

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