zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: OpenBSD requires special hoops to get correct random numbers
Date: Tue, 9 Aug 2016 22:28:17 +0200	[thread overview]
Message-ID: <CAHYJk3Tbv4RPoatJ_CLpSkd2gFO69OM72K54efmaccaABEo8CA@mail.gmail.com> (raw)
In-Reply-To: <20160809201539.25399-1-mikachu@gmail.com>

On Tue, Aug 9, 2016 at 10:15 PM, Mikael Magnusson <mikachu@gmail.com> 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


       reply	other threads:[~2016-08-09 20:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20160809201539.25399-1-mikachu@gmail.com>
2016-08-09 20:28 ` Mikael Magnusson [this message]
2016-08-10 15:03 ` Fwd: " Mikael Magnusson
2016-08-10 15:13   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHYJk3Tbv4RPoatJ_CLpSkd2gFO69OM72K54efmaccaABEo8CA@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).