diff options
author | Eli Zaretskii <eliz@gnu.org> | 2021-08-14 17:39:38 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2021-08-14 17:39:38 +0300 |
commit | 482049e54277f0a429efdcd660286e9e7b465033 (patch) | |
tree | fe721559a2b67711a2aef9d78074a6efbc4fbcdd /src/w32.c | |
parent | e5cb6d3fd1875e425be31fd885519326ba2304b8 (diff) | |
download | emacs-482049e54277f0a429efdcd660286e9e7b465033.tar.gz emacs-482049e54277f0a429efdcd660286e9e7b465033.tar.bz2 emacs-482049e54277f0a429efdcd660286e9e7b465033.zip |
Fix 'random' on MS-Windows when integers are wider than 30 bits
* src/w32.c (random): Provide more random bits for MS-Windows
builds with EMACS_INT that is wider than 32 bits. (Bug#32605)
Diffstat (limited to 'src/w32.c')
-rw-r--r-- | src/w32.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/w32.c b/src/w32.c index 968b4bbe489..180c73aa0f0 100644 --- a/src/w32.c +++ b/src/w32.c @@ -2389,8 +2389,13 @@ rand_as183 (void) int random (void) { - /* rand_as183 () gives us 15 random bits...hack together 30 bits. */ + /* rand_as183 () gives us 15 random bits...hack together 30 bits for + Emacs with 32-bit EMACS_INT, and at least 31 bit for wider EMACS_INT. */ +#if EMACS_INT_MAX > INT_MAX + return ((rand_as183 () << 30) | (rand_as183 () << 15) | rand_as183 ()); +#else return ((rand_as183 () << 15) | rand_as183 ()); +#endif } void |