summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdlib/rand.c
diff options
context:
space:
mode:
authorMatthew Green <mrg@redhat.com>2002-02-03 09:24:18 +0000
committerMatthew Green <mrg@redhat.com>2002-02-03 09:24:18 +0000
commit8195aff714f2ea5d680a5129a1d54af388e90355 (patch)
tree683ff47f4802385e669491dda42bf8050772dbdf /newlib/libc/stdlib/rand.c
parentad67ada2fc7cdb361643d506701e274a67d796f9 (diff)
downloadcygnal-8195aff714f2ea5d680a5129a1d54af388e90355.tar.gz
cygnal-8195aff714f2ea5d680a5129a1d54af388e90355.tar.bz2
cygnal-8195aff714f2ea5d680a5129a1d54af388e90355.zip
* implement a new `struct _reent' that is significantly smaller. use this
if _REENT_SMALL is defined in config.h. define this for xstormy16.
Diffstat (limited to 'newlib/libc/stdlib/rand.c')
-rw-r--r--newlib/libc/stdlib/rand.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/newlib/libc/stdlib/rand.c b/newlib/libc/stdlib/rand.c
index a085ef37c..4f5a60796 100644
--- a/newlib/libc/stdlib/rand.c
+++ b/newlib/libc/stdlib/rand.c
@@ -72,7 +72,7 @@ on two different systems.
void
_DEFUN (srand, (seed), unsigned int seed)
{
- _REENT->_new._reent._rand_next = seed;
+ _REENT_RAND_NEXT(_REENT) = seed;
}
int
@@ -81,9 +81,10 @@ _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->_new._reent._rand_next =
- _REENT->_new._reent._rand_next * __extension__ 6364136223846793005LL + 1;
- return (int)((_REENT->_new._reent._rand_next >> 32) & RAND_MAX);
+ _REENT_CHECK_RAND48(_REENT);
+ _REENT_RAND_NEXT(_REENT) =
+ _REENT_RAND_NEXT(_REENT) * __extension__ 6364136223846793005LL + 1;
+ return (int)((_REENT_RAND_NEXT(_REENT) >> 32) & RAND_MAX);
}
#endif /* _REENT_ONLY */