1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00
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.
This commit is contained in:
Roland McGrath
2005-02-10 09:40:23 +00:00
parent 1a53c052c3
commit f17c2202e4
5 changed files with 86 additions and 5 deletions

View File

@ -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)