GNU bug report logs - #32605
[w64] (random) never returns negative

Previous Next

Package: emacs;

Reported by: f.j.wright <at> live.co.uk

Date: Sat, 1 Sep 2018 17:21:01 UTC

Severity: normal

Tags: confirmed

Found in version 26.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #48 received at 32605 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: 32605 <at> debbugs.gnu.org
Subject: Re: bug#32605: [w64] (random) never returns negative
Date: Sat, 14 Aug 2021 14:33:00 +0300
> From: Andy Moreton <andrewjmoreton <at> gmail.com>
> Date: Sat, 14 Aug 2021 12:06:00 +0100
> 
> >> I'm not an expert on random numbers either, and your efforts are not an
> >> annoyance, but I am puzzled why you so strongly prize performance over
> >> correctness in this instance.
> >
> > Because I have no idea how important the "correctness" part is, or
> > why.  OTOH, this stuff, when used, tends to be in the inner loops, so
> > performance matters.
> 
> I doubt anyone expects cryptographic quality randomness or any given
> statistical distribution from such a general purpose routine, but they
> have a reasonable expectation that the results from 'get_random' do not
> have stuck bits that are always non-random.
> 
> In which case perhaps the solution is to change the RAND_BITS logic
> in sysdep.c on Windows to override the RAND_BITS definition:
> 
> +   #ifdef WINDOWSNT
> +   /* Use w32.c replacement for random().  */
> +   # define RAND_BITS 15
> +   #endif
> 
>     #ifndef RAND_BITS
>     # ifdef HAVE_RANDOM
>     #  define RAND_BITS 31
>     # else /* !HAVE_RANDOM */
>     ...
>     #endif
> 
> ..and then in w32.c make 'random' return the 15bit value from
> 'rand_as183':

Why not keep the 30 bits we produce today on 32-bit builds?




This bug report was last modified 4 years ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.