Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Qmail-Scanner-Diagnostics: from mail-qk0-f170.google.com by f.primenet.com.au (envelope-from <mikachu@gmail.com>, uid 7791) with qmail-scanner-2.11 
 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1.  
 Clear:RC:0(209.85.220.170):SA:0(0.0/5.0):. 
 Processed in 0.137701 secs); 09 Aug 2016 20:36:15 -0000
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS,
	T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1
X-Envelope-From: mikachu@gmail.com
X-Qmail-Scanner-Mime-Attachments: |
X-Qmail-Scanner-Zip-Files: |
Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.220.170 as permitted sender)
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==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to;
        bh=Stt/Y4Of7xQ9YrQvUwnK9tqpnjiho/pRe3q+CrwJsPA=;
        b=krTKlqXs2sTEgvpM7BHAPL1QcyDgVkOcEVHHqshvcGy53vWqTQtHX6F43LetAmnpuM
         F2+RKHJ34XsQWtLkyQ6IsgO9qjXwu4z+CxZgw3/jQF2pP9+wCznpPZnTkdDrh+BYtwd/
         TYxrzBUDbRWYfP0E/WebkGHvZZLaZDPMZpL7FwHodAXJ1WVET8fJqCMm1I2fi1RmdeTj
         NtG58vV3pWQYxfl7mI6wCk5l+nrdIwWg85+dIm/tNd0K7ezikTQ5qWl7pLh5Szs3pAvk
         8QPDBCDOPwhxyd7SSJ9QoDjQZ4FliIxZ6qIEYmo9EXrWdg0sGS4lKNs3oNFuk9Xgp3EB
         sirg==
X-Gm-Message-State: AEkooutjUmL1RvfDDZrfmM8SK8i0gBi+/JxfHedp0zRnwwJoD7aJ2V4Dkv5j+mlbNXoJE2y48+gx/czjeNHEQA==
X-Received: by 10.55.19.23 with SMTP id d23mr363962qkh.230.1470774498117; Tue,
 09 Aug 2016 13:28:18 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <20160809201539.25399-1-mikachu@gmail.com>
References: <20160809201539.25399-1-mikachu@gmail.com>
From: Mikael Magnusson <mikachu@gmail.com>
Date: Tue, 9 Aug 2016 22:28:17 +0200
Message-ID: <CAHYJk3Tbv4RPoatJ_CLpSkd2gFO69OM72K54efmaccaABEo8CA@mail.gmail.com>
Subject: Re: PATCH: OpenBSD requires special hoops to get correct random numbers
To: zsh workers <zsh-workers@zsh.org>
Content-Type: text/plain; charset=UTF-8
X-Seq: zsh-workers 39012

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

