diff options
author | Roland McGrath <roland@gnu.org> | 2005-02-10 09:40:23 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2005-02-10 09:40:23 +0000 |
commit | f17c2202e4238b7408b8ee8ab742e5d2198cff6e (patch) | |
tree | bb7302826f1e982e4e3010e8cceacd0dbf7d3fc1 /stdlib/random_r.c | |
parent | 1a53c052c34ec4e934ba177b4f5bcf0b51be2ceb (diff) | |
download | glibc-f17c2202e4238b7408b8ee8ab742e5d2198cff6e.zip glibc-f17c2202e4238b7408b8ee8ab742e5d2198cff6e.tar.gz glibc-f17c2202e4238b7408b8ee8ab742e5d2198cff6e.tar.bz2 |
[BZ #710]
2005-02-09 Jakub Jelinek <jakub@redhat.com>
[BZ #710]
* stdlib/random_r.c (__initstate_r): Save old state.
* stdlib/Makefile (tests): Add tst-random2.
* stdlib/tst-random2.c: New test.
Reported by Peter Bergner <bergner@vnet.ibm.com>.
(s390-.*-.*, powerpc.*-.*-.*, sparc.*-.*-.*): Add WORDSIZE64 entries
for these mapping back to the above.
Diffstat (limited to 'stdlib/random_r.c')
-rw-r--r-- | stdlib/random_r.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/stdlib/random_r.c b/stdlib/random_r.c index 09677e6..c85fd5e 100644 --- a/stdlib/random_r.c +++ b/stdlib/random_r.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation + Copyright (C) 1995, 2005 Free Software Foundation The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -240,10 +240,19 @@ __initstate_r (seed, arg_state, n, buf) int degree; int separation; int32_t *state; + int old_type; + int32_t *old_state; if (buf == NULL) goto fail; + old_type = buf->rand_type; + old_state = buf->state; + if (old_type == TYPE_0) + old_state[-1] = TYPE_0; + else + old_state[-1] = (MAX_TYPES * (buf->rptr - old_state)) + old_type; + if (n >= BREAK_3) type = n < BREAK_4 ? TYPE_3 : TYPE_4; else if (n < BREAK_1) |