Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: OpenBSD requires special hoops to get correct random numbers
- X-seq: zsh-workers 39012
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: PATCH: OpenBSD requires special hoops to get correct random numbers
- Date: Tue, 9 Aug 2016 22:28:17 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Stt/Y4Of7xQ9YrQvUwnK9tqpnjiho/pRe3q+CrwJsPA=; b=dcYQAsfMUzdch2ysqX/shR7eN7bYCOm3rlRO7t6PAb5gFuJMbWoyT6GZHLtescgKuc Rp7APXuGYbL3STKikHhe6KDCPePLojhwoFeKfr9SiSo+PN4ClAeBaQmrBy3dqAjx6HZS jLG4P2hMV/goioBtFdzvUZiyXSQu3XlejFCqDLNBapRs+VQQBVn9g43KcOIXtmCVP0uv 0ZRJy3lmENhqZss+clIfm3K4S3lF8gBpTDIqsQcCKkBzVeHnlKPKfdCRR+ewJvfji76t rYBAIScC0oREmTTdwrrHBO55v+CZG0LioV1dt7vSf/gM1MZNIuAfhxlukQ10LbRVQ3AN Ak3g==
- In-reply-to: <20160809201539.25399-1-mikachu@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160809201539.25399-1-mikachu@gmail.com>
On Tue, Aug 9, 2016 at 10:15 PM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> Apparently there was a change in OpenBSD fairly recently[1] that
> causes random numbers generated by rand() to ignore the value passed to
> srand(). Since zsh guarantees repeatable sequences we have to use their
> non-standard interface to continue providing this guarantee.
>
> If someone has an opinion on where to stick the #define or if the two
> call-sites should be explicitly #ifdef'd, let me know.
>
> At home,
> % zsh -c 'repeat 3 { RANDOM=5; echo $RANDOM }'
> 23835
> 23835
> 23835
> On OpenBSD system,
> % zsh -c 'repeat 3 { RANDOM=5; echo $RANDOM }'
> 24254
> 32257
> 4161
> On OpenBSD system with patch applied,
> % Src/zsh -c 'repeat 3 { RANDOM=5; echo $RANDOM }'
> 14426
> 14426
> 14426
>
> [1] http://marc.info/?l=openbsd-cvs&m=141807513728073&w=2
(The rand48 zsh math function uses erand48() internally, and that is
unaffected by the change.)
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author