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: 8a0efa53e4 ("import newlib-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-11-14 17:52:48 +01:00
parent c4008b8bc0
commit 324ace778f
2 changed files with 11 additions and 0 deletions

View 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());
}
}

View 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