]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: rand(3): implement in terms of random(3)
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 14 Nov 2023 16:52:48 +0000 (17:52 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 14 Nov 2023 16:54:55 +0000 (17:54 +0100)
This makes rand(3) ISO C compliant and adds locking to avoid
race conditions.

Reported-by: Bruno Haible <bruno@clisp.org>
Fixes: 8a0efa53e4491 ("import newlib-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/random.cc
winsup/cygwin/release/3.4.10

index 51f5a6e963e0f292031fff4de1a197016c499bb9..ddba6fb944ec965e658afde3923759d267cd6c34 100644 (file)
@@ -293,6 +293,8 @@ srandom(unsigned x)
        __random_unlock();
 }
 
+EXPORT_ALIAS (srandom, srand)
+
 /*
  * initstate:
  *
@@ -481,4 +483,10 @@ random()
        return (r);
 }
 
+int
+rand()
+{
+       return ((int) random());
+}
+
 }
index 3bbbca38138bdfa4cb49e13b5cd1bc7d741ca710..758a6e071c59954425a5da4c2db0031a4718a7db 100644 (file)
@@ -15,3 +15,6 @@ Bug Fixes
 
 - Updates to profiler and gmondump: error display mechanics, buffer sizing,
   and output formatting.
+
+- Align behaviour of rand(3) to ISO C.
+  Adresses: https://cygwin.com/pipermail/cygwin/2023-November/254735.html
This page took 0.032763 seconds and 5 git commands to generate.