This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: drand48() (and erand48) returns only zeros and pthread application problems - in cygwin 1.7.8 returns always same values
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Tue, 11 Jan 2011 17:54:39 -0500
- Subject: Re: drand48() (and erand48) returns only zeros and pthread application problems - in cygwin 1.7.8 returns always same values
- References: <AANLkTim2Wz20AdnhMJ9kgjW7x+hsm0PMLY6dJj+sBQzs@mail.gmail.com>
- Reply-to: cygwin at cygwin dot com
On Tue, Jan 11, 2011 at 11:50:14AM +0100, jdzstz - gmail dot com wrote:
>About all the problems with drand48, explained in:
> * http://www.cygwin.com/ml/cygwin/2010-12/msg00460.html
>
>Christopher Faylor fixed it in 20101229 snapshot:
>http://www.cygwin.com/snapshots/winsup-changelog-20101226-20101229
>
>I have realized that the fix does not work as expected, it is used
>thread memory address to initialize srand48 with srand48 ((long int)
>&x);
>
>--- winsup-src-20101226/cygwin-snapshot-20101226-1/winsup/cygwin/cygtls.cc 2010-02-28
>15:55:33.000000000 +0000
>+++ winsup-src-20101229/cygwin-snapshot-20101229-1/winsup/cygwin/cygtls.cc 2010-12-29
>06:34:24.000000000 +0000
>@@ -94,4 +95,5 @@ _cygtls::init_thread (void *x, DWORD (*f
> local_clib._current_locale = "C";
> locals.process_logmask = LOG_UPTO (LOG_DEBUG);
>+ srand48 ((long int) &x);
> }
>
>Now, drand48 doesnot returns zero in thread, but the problem is that
>in every execution the adress should be the same, because it returns
>always the same values.
Right. That was exactly the point. If you want more randomness then
seed this yourself. Linux always provides a fixed series of numbers when
srand48 has not been called too.
cgf
--
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