Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdlib/rand.c')
-rw-r--r--newlib/libc/stdlib/rand.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/newlib/libc/stdlib/rand.c b/newlib/libc/stdlib/rand.c
index 6a46aa807..a085ef37c 100644
--- a/newlib/libc/stdlib/rand.c
+++ b/newlib/libc/stdlib/rand.c
@@ -51,8 +51,8 @@ number between <<0>> and <<RAND_MAX>> (inclusive).
<<srand>> does not return a result.
NOTES
-<<rand>> and <<srand>> are unsafe for multi-threaded applications.
-<<rand_r>> is thread-safe and should be used instead.
+<<rand>> and <<srand>> are unsafe for multi-thread applications.
+<<rand_r>> is MT-Safe and should be used instead.
PORTABILITY
@@ -72,7 +72,7 @@ on two different systems.
void
_DEFUN (srand, (seed), unsigned int seed)
{
- _REENT_RAND_NEXT(_REENT) = seed;
+ _REENT->_new._reent._rand_next = seed;
}
int
@@ -81,10 +81,9 @@ _DEFUN_VOID (rand)
/* This multiplier was obtained from Knuth, D.E., "The Art of
Computer Programming," Vol 2, Seminumerical Algorithms, Third
Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */
- _REENT_CHECK_RAND48(_REENT);
- _REENT_RAND_NEXT(_REENT) =
- _REENT_RAND_NEXT(_REENT) * __extension__ 6364136223846793005LL + 1;
- return (int)((_REENT_RAND_NEXT(_REENT) >> 32) & RAND_MAX);
+ _REENT->_new._reent._rand_next =
+ _REENT->_new._reent._rand_next * __extension__ 6364136223846793005LL + 1;
+ return (int)((_REENT->_new._reent._rand_next >> 32) & RAND_MAX);
}
#endif /* _REENT_ONLY */