Cygwin with clock_gettime and CLOCK_MONOTONIC - gives always 0

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Apr 11 19:09:00 GMT 2013


On Apr 11 15:37, Tobias Burnus wrote:
> Please CC your reply to fortran@gcc.gnu.org

Please don't CC me or cgf.  We're subscribed to the Cygwin list anyway.

> 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.

Works fine for me with the current Cygwin 1.7.17, and the upcoming
Cygwin 1.7.18:

  $ cat > ct.c <<EOF
  #include <stdio.h>
  #include <time.h>

  int
  main ()
  {
    struct timespec tp;

    sleep (1);
    if (!clock_gettime (CLOCK_MONOTONIC, &tp))
      printf ("tv_sec = %ld, tv_nsec = %ld\n", tp.tv_sec, tp.tv_nsec);
    sleep (1);
    if (!clock_gettime (CLOCK_MONOTONIC, &tp))
      printf ("tv_sec = %ld, tv_nsec = %ld\n", tp.tv_sec, tp.tv_nsec);
    sleep (1);
    if (!clock_gettime (CLOCK_MONOTONIC, &tp))
      printf ("tv_sec = %ld, tv_nsec = %ld\n", tp.tv_sec, tp.tv_nsec);
    sleep (1);
    if (!clock_gettime (CLOCK_MONOTONIC, &tp))
      printf ("tv_sec = %ld, tv_nsec = %ld\n", tp.tv_sec, tp.tv_nsec);
  }
  EOF
  $ gcc -o ct ct.c
  $ ./ct
  tv_sec = 0, tv_nsec = 29920
  tv_sec = 1, tv_nsec = 15866090
  tv_sec = 2, tv_nsec = 28048880
  tv_sec = 3, tv_nsec = 42100530
  $


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

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



More information about the Cygwin mailing list