Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
/ veriwell Public archive

Commit

Permalink
only change global seed when random call does not have and argument
Browse files Browse the repository at this point in the history
  • Loading branch information
markhummel committed May 25, 2008
1 parent fe5b1d3 commit 5db6c99
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/systask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ struct sysfunction_info sysfunction_info[] = {
};

tree current_tf_instance; /* node of systask being executed or compiled */
int seed = 0; /* seed for random number generator */
int globalSeed = 0; /* seed for random number generator */

extern s_tfcell veriusertfs[]; /* Hooks into user tfs */
extern s_tfcell verisystfs[]; /* Hooks into internal tfs */
Expand Down Expand Up @@ -1437,16 +1437,18 @@ void exec_sysfunc(tree node, nbits_t nbits)
}
case F_RANDOM:
{
int result;
if (FUNC_REF_INASSIGN(node)) { /* seed present? */
int seed;
eval_1(FUNC_REF_INASSIGN(node));
seed = AVAL(*--R);
g = *R;
}
int result = rtl_dist_uniform (&seed, INT_MIN, INT_MAX);
if (FUNC_REF_INASSIGN(node)) { /* seed present? */
result = rtl_dist_uniform (&seed, INT_MIN, INT_MAX);
AVAL(g) = (unsigned)seed;
*++R = g + 1;
store(FUNC_REF_INASSIGN(node), node);
} else {
result = rtl_dist_uniform (&globalSeed, INT_MIN, INT_MAX);
}
AVAL(DECL_STORAGE(sysrand_return)) = result;
BVAL(DECL_STORAGE(sysrand_return)) = 0;
Expand Down

0 comments on commit 5db6c99

Please sign in to comment.