https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=324ace778f70e3e89d16c5460d2f9b4454acddb2
commit 324ace778f70e3e89d16c5460d2f9b4454acddb2 Author: Corinna Vinschen <[email protected]> AuthorDate: Tue Nov 14 17:52:48 2023 +0100 Commit: Corinna Vinschen <[email protected]> CommitDate: Tue Nov 14 17:52:48 2023 +0100 Cygwin: rand(3): implement in terms of random(3) This makes rand(3) ISO C compliant and adds locking to avoid race conditions. Reported-by: Bruno Haible <[email protected]> Fixes: 8a0efa53e4491 ("import newlib-2000-02-17 snapshot") Signed-off-by: Corinna Vinschen <[email protected]> Diff: --- winsup/cygwin/random.cc | 8 ++++++++ winsup/cygwin/release/3.4.10 | 3 +++ 2 files changed, 11 insertions(+) diff --git a/winsup/cygwin/random.cc b/winsup/cygwin/random.cc index 51f5a6e963e0..ddba6fb944ec 100644 --- a/winsup/cygwin/random.cc +++ b/winsup/cygwin/random.cc @@ -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()); +} + } diff --git a/winsup/cygwin/release/3.4.10 b/winsup/cygwin/release/3.4.10 index 3bbbca38138b..758a6e071c59 100644 --- a/winsup/cygwin/release/3.4.10 +++ b/winsup/cygwin/release/3.4.10 @@ -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
