diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2023-11-14 17:52:48 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2023-11-14 17:54:55 +0100 |
commit | 8d5043b32f8f6a6e569800bf9b872b901512a0c9 (patch) | |
tree | 3c83718426a39bba2c9fb02bf86558f7950c0429 | |
parent | 721b5e05b9c9c588ec5b4417ece1ae5067777513 (diff) | |
download | newlib-8d5043b32f8f6a6e569800bf9b872b901512a0c9.zip newlib-8d5043b32f8f6a6e569800bf9b872b901512a0c9.tar.gz newlib-8d5043b32f8f6a6e569800bf9b872b901512a0c9.tar.bz2 |
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>
-rw-r--r-- | winsup/cygwin/random.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/release/3.4.10 | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/winsup/cygwin/random.cc b/winsup/cygwin/random.cc index 51f5a6e..ddba6fb 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 3bbbca3..758a6e0 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 |