delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/11/11/15:19:14

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B6803856973
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1699733953;
bh=I5AYlhsgXltQqzJy+LiV80UKnMhnPlsi8pxCd3zx4yk=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=DpqFg/Vbn2I5QJLPCL6u3r4wItTaxQNlZs8EIyuNsBq/AoBlUYwnnVlkyEoFkVQGZ
xG3j8FW6CweJmG2UwO2xwzbz1z3qpFQ3lHIkDX5kPUrZ/ATpElpBt5Ca7k6Umutrrc
KrFxvJ7bJnxqFiivebrtI3ikqAUXvM8PO/N5bKjA=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 208A93858D37
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 208A93858D37
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699733918; cv=none;
b=nu9EsFwr1nk6IfXW3ADlGkKhGgiwDIKLhApKGj1wvrKCbseC/GzP91F702RyAXNIMkTncsqEa8lMjx+nwAHwXLWeV0KWpmjrTJ7aPN37AxInnrc+8AD6mFu7nBLlXTN0rrQgc5bVDqT4odfQSVfUuRjQiMarxqyPfjZxzCINcTM=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1699733918; c=relaxed/simple;
bh=rG1nfuOV1zLSut8Oa0RIVpotuzeLgpNWN2vwMx41yC0=;
h=Message-ID:Date:MIME-Version:Subject:To:From;
b=pRtPJ96NUPw6ao4KYvFxBN48UYCKjPBMEjGiOVmuOoaWvMUNzv7y4l1UnIVYQ/s8C+rh9cVO/SEuxDe3tsOl34s2GYsssLNmYe/s+CeEfm5PX/XgN3FS5dKT/1mnqQkenEzfTXKvIdLbGlazDQcqUMUQrtvx4CvEF+NuuRNyUiQ=
ARC-Authentication-Results: i=1; server2.sourceware.org
Message-ID: <f05ddafa-2af1-4693-abd2-a862a771d963@huarp.harvard.edu>
Date: Sat, 11 Nov 2023 15:18:37 -0500
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: rand is not ISO C compliant in Cygwin
To: =?UTF-8?Q?Ren=C3=A9_Berber?= <rene DOT berber AT gmail DOT com>, cygwin AT cygwin DOT com
References: <9938355 DOT c9vzh5UkMf AT nimes>
<e099714b-9820-4647-ba40-9db5e471e9aa AT huarp DOT harvard DOT edu>
<5748524 DOT yeFs27NDWt AT nimes>
<cec7bb32-1a34-4c3c-8b8b-175d998003ef AT huarp DOT harvard DOT edu>
<f8c95c12-a43e-442e-ad95-129d6340bdf4 AT gmail DOT com>
In-Reply-To: <f8c95c12-a43e-442e-ad95-129d6340bdf4@gmail.com>
X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
SPF_HELO_NONE, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: "Allen, Norton T. via Cygwin" <cygwin AT cygwin DOT com>
Reply-To: "Allen, Norton T." <allen AT huarp DOT harvard DOT edu>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 3ABKJEqG010531

On 11/11/2023 1:25 PM, René Berber via Cygwin wrote:
> On 11/11/2023 10:50 AM, Allen, Norton T. via Cygwin wrote:
>
> [snip]
>>> The srand function is not required to avoid data races with other
>>>     calls to pseudo-random sequence generation functions. ..." 
>> That is not the same as "... required never to avoid data races ...". 
>> "not required" means the sentence is not specifying--not 
>> requiring--any behavior, so you should not depend on the described 
>> behaviors.
> [snip]
>
> The elided part on Bruno's message is:
>
> "The implementation shall behave as if no library function calls the
> rand function."
>
> Which is the point Bruno is making with the sample code.

I would still assert that if the implementation is doing what I 
suggested (maintaining independent state for each thread) it would still 
meet that criteria, although I admit it is debatable. That said, the man 
page says:

"rand and srand are unsafe for multi-threaded applications. rand_r is 
thread-safe and should be used instead."

I read that as "all bets are off" if you are using them in a 
multi-threaded application.



-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019