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]

Re: Cygwin with clock_gettime and CLOCK_MONOTONIC - gives always 0


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


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