Skip to content

Commit

Permalink
random --> rand for Windows compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert van Renesse committed Feb 1, 2024
1 parent 207182b commit 170c0b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions harmony_model_checker/charm/charm.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ static void run_direct(struct state *state){
for (int i = 0; i < state->bagsize; i++) {
total += state_multiplicity(state, i);
}
unsigned int select = random() % total;
unsigned int select = rand() % total;
// printf("--> %u %u\n", total, select);
for (int i = 0; i < state->bagsize; i++) {
if (state_multiplicity(state, i) > select) {
Expand All @@ -342,7 +342,7 @@ static void run_direct(struct state *state){
// Check if an interrupt is in order
if (cc->extended && ctx_trap_pc(cc) != 0 && !cc->interruptlevel) {
interrupt_count += 1;
if (random() % interrupt_count == 0) {
if (rand() % interrupt_count == 0) {
interrupt_invoke(&step);
}
}
Expand Down Expand Up @@ -3672,7 +3672,7 @@ int exec_model_checker(int argc, char **argv){
// This is an experimental feature: run code directly (don't model check)
if (dflag) {
global.run_direct = true;
srandom((unsigned) gettime());
srand((unsigned) gettime());
run_direct(state);
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion harmony_model_checker/charm/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ void op_Choose(const void *env, struct state *state, struct step *step){
exit(1);
}
if (line[0] == '\n') {
unsigned int selection = random() % size;
unsigned int selection = rand() % size;
ctx_push(step->ctx, vals[selection]);
step->ctx->pc++;
return;
Expand Down

0 comments on commit 170c0b4

Please sign in to comment.