public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-3_4-branch] Cygwin: rand(3): implement in terms of random(3)
@ 2023-11-14 16:56 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-11-14 16:56 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8d5043b32f8f6a6e569800bf9b872b901512a0c9

commit 8d5043b32f8f6a6e569800bf9b872b901512a0c9
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Nov 14 17:52:48 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Nov 14 17:54:55 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 <bruno@clisp.org>
    Fixes: 8a0efa53e4491 ("import newlib-2000-02-17 snapshot")
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-14 16:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14 16:56 [newlib-cygwin/cygwin-3_4-branch] Cygwin: rand(3): implement in terms of random(3) Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).