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


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Andy Moreton <andrewjmoreton <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 32605 <at> debbugs.gnu.org
Subject: bug#32605: [w64] (random) never returns negative
Date: Thu, 12 Aug 2021 15:17:46 +0200
Andy Moreton <andrewjmoreton <at> gmail.com> writes:

>> This bug seems specific to 64 bit Windows builds.
>
> ON 64bit Windows, sysdep.c sets RAND_BITS to 31, but random (in w32.c)
> only provides 30 bits. It looks like the mixing in get_random does not
> result in the top fixnum bit being set.

So it's this:

int
random (void)
{
  /* rand_as183 () gives us 15 random bits...hack together 30 bits.  */
  return ((rand_as183 () << 15) | rand_as183 ());
}

So running rand_as183 and taking another bit from that might do the
trick?  Eli, do you have any comments here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




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.