aboutsummaryrefslogtreecommitdiff
path: root/stdlib/random_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/random_r.c')
-rw-r--r--stdlib/random_r.c11
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)