delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Spam-Check-By: | sourceware.org |
Date: | Tue, 11 Jan 2011 17:54:39 -0500 |
From: | Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: drand48() (and erand48) returns only zeros and pthread application problems - in cygwin 1.7.8 returns always same values |
Message-ID: | <20110111225439.GA24015@ednor.casa.cgf.cx> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <AANLkTim2Wz20AdnhMJ9kgjW7x+hsm0PMLY6dJj+sBQzs AT mail DOT gmail DOT com> |
MIME-Version: | 1.0 |
In-Reply-To: | <AANLkTim2Wz20AdnhMJ9kgjW7x+hsm0PMLY6dJj+sBQzs@mail.gmail.com> |
User-Agent: | Mutt/1.5.20 (2009-06-14) |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |