This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Random seed initialization
- From: "N.M. Maclaren" <nmm1 at cam dot ac dot uk>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: Angelo Graziosi <angelo dot graziosi at alice dot it>, Janus Weil <janus at gcc dot gnu dot org>, fortran <fortran at gcc dot gnu dot org>, dave dot korn dot cygwin at gmail dot com
- Date: 11 Apr 2013 12:57:13 +0100
- Subject: Re: Random seed initialization
- References: <51603400 dot 3030705 at alice dot it> <CAKwh3qgG=pPbKyE6YT8H9++E_74uKmFC0UKG+Q3cW8bxYHVHRw at mail dot gmail dot com> <51603FEF dot 9020300 at alice dot it> <516042C9 dot 9010002 at alice dot it> <CAKwh3qgKztRYUGh-OjsRatsEqK=TmAF2+62S3jQfd8DkhUYi-Q at mail dot gmail dot com> <51604788 dot 3020603 at alice dot it> <CAKwh3qg0x2=b+QpKvzGSU36sKc_C6BcUs13mT0=-jxG-HnaU4g at mail dot gmail dot com> <51667E13 dot 7040300 at alice dot it> <5166894C dot 4050804 at net-b dot de> <51669BFD dot 3090407 at alice dot it> <5166A0B3 dot 70801 at net-b dot de>
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.