From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17162 invoked by alias); 10 Aug 2016 15:03:25 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39014 Received: (qmail 15054 invoked from network); 10 Aug 2016 15:03:25 -0000 X-Qmail-Scanner-Diagnostics: from mail-qt0-f196.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.216.196):SA:0(0.0/5.0):. Processed in 0.177703 secs); 10 Aug 2016 15:03:25 -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.216.196 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=+u4evLDU3xwp8OS1YzAHoxM0qLGVdF/FI1xRhQQ1wxY=; b=qrL3619dWcaZ2os5+rXfWwZShnltrxnEWWxFRVsFqGCp3KH1u5KmVSdxCzWD23VCS/ KJhY27suOhpgupGZn9kxQI8ahkKnNylVsdMLk3rzmyI6J6JcmMEcuoSMLZ6pDEBAtdBi GITRw7MFrO9113qrQBmkjpjIlTcVPJTgOpLlQTkLD+HVvCWMABulp7WgtCrtzdFWxVjY YgB+rduUgBuBK+OFa5QIreUp4QGiuIRUsnwv4qrrbsf8DYVZo58X40QkI8s9e+i8nZuy CYhTgFu+ps3udQG/gsD4oX3loj2aPahWWkLLNKy+jd8CE4M8IDFym/14XNpnEOj7yKK0 Z3Yg== 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=+u4evLDU3xwp8OS1YzAHoxM0qLGVdF/FI1xRhQQ1wxY=; b=dqqjbMrAjOTjz9O+rcmdtFSHX8ICyM8cwOtnA3K4Itf8Uk3UqfuMu9gpmjpzAIJImM B5r0qw4EbtgSgqcrUPGKBSzts2Bo53Ypk33mBMNw7n7ESFBu0Or8CAxs+9pI8QkXEn8F SfhBilbx0aj6oTEKXshJTa0Ab7E4cj7UGPAdkILQsEtdwzBG3yv8FgGICQNjVKYBjSPR td61pYIMD3OD4HDZE5GLf1yRT5n2fPZnENGzkYft7NwYkJ4eIRs9/ci+JahPxfPiFtct uKIz+kpgv+fdGEHY6cLKRIES4tHwpiu8h1tgBgOk9THMCIZYgUybhhpFvAdNan5YvbOs eTlg== X-Gm-Message-State: AEkooutrKgi3lgK7AsRLfIUCywglr0RZ6uRmX+QhLtOEZ0vMMdwZYagDM+nJkcj5C/Lf0ETAoa/AWRiRwZJjEA== X-Received: by 10.237.40.66 with SMTP id r60mr4990939qtd.112.1470841397325; Wed, 10 Aug 2016 08:03:17 -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 Date: Wed, 10 Aug 2016 17:03:16 +0200 Message-ID: Subject: Fwd: PATCH: OpenBSD requires special hoops to get correct random numbers To: zsh workers Content-Type: text/plain; charset=UTF-8 Apparently gmail decided to eat the original message? ---------- Forwarded message ---------- From: Mikael Magnusson Date: Tue, Aug 9, 2016 at 10:15 PM Subject: PATCH: OpenBSD requires special hoops to get correct random numbers To: zsh-workers@zsh.org 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 --- Src/zsh_system.h | 4 ++++ configure.ac | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Src/zsh_system.h b/Src/zsh_system.h index 17c4c64..a9cbf02 100644 --- a/Src/zsh_system.h +++ b/Src/zsh_system.h @@ -882,6 +882,10 @@ extern short ospeed; # endif #endif +#ifdef HAVE_SRAND_DETERMINISTIC +# define srand srand_deterministic +#endif + #ifdef ZSH_VALGRIND # include "valgrind/valgrind.h" # include "valgrind/memcheck.h" diff --git a/configure.ac b/configure.ac index 3e9e467..6ee5c5d 100644 --- a/configure.ac +++ b/configure.ac @@ -1322,7 +1322,8 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \ realpath canonicalize_file_name \ symlink getcwd \ cygwin_conv_path \ - nanosleep) + nanosleep \ + srand_deterministic) AC_FUNC_STRCOLL AH_TEMPLATE([REALPATH_ACCEPTS_NULL], -- 2.8.2 -- Mikael Magnusson