This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: Random seed initialization


On Apr 11 2013, Tobias Burnus wrote:

It seems as if Cygwin's clock_gettime correctly works for CLOCK_REALTIME but not for CLOCK_MONOTONIC.

Surprise, surprise.  And I am not making rude remarks about Cygwin.

And if I do a grep on my Linux system, I only find in /usr/include/bits/posix_opt.h:
  /* The monotonic clock might be available.  */
  #define _POSIX_MONOTONIC_CLOCK    0

That's better than the "-1" for not available but is not the, e.g., 200809L which states that the support is indeed available.

Does anyone have a good suggestion how to detect the availability?

Don't even try.  POSIX clocks are broken by design, in a fashion that
is so fundamental as to be completely unfixable.  They were told this
at the relevant time, and how to fix the problem, but chose what the
marketdroids and execusuits told them was wanted.

When implementors are faced with a mathematically nonsensical and
unimplementable specification, and are under pressure from Marketing
via Management, they will deliver something that placates the customers
and gets their management off their backs but will not do anything
consistent (or possibly not even sane).  There will be other breakages
on other systems, but usually with different properties.

I recommend using gettimeofday() and ignoring POSIX clocks altogether.


Regards,
Nick Maclaren.



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