Skip to content

Commit

Permalink
Fixed wrong setjmp usage in theory main and cleaned up function
Browse files Browse the repository at this point in the history
  • Loading branch information
Snaipe committed Sep 21, 2015
1 parent 87cfa36 commit 7efbac9
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/core/theories.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ void cr_theory_abort(void) {
longjmp(theory_jmp, 1);
}

int cr_theory_mark(void) {
return setjmp(theory_jmp);
}

void cr_theory_reset(struct criterion_theory_context *ctx) {
dcReset(ctx->vm);
}
Expand Down Expand Up @@ -185,14 +181,11 @@ static void concat_arg(char (*msg)[4096], struct criterion_datapoints *dps, size
}

int try_call_theory(struct criterion_theory_context *ctx, void (*fnptr)(void)) {
jmp_buf backup;
memcpy(backup, g_pre_test, sizeof (jmp_buf));
int res = setjmp(g_pre_test);
if (!res) {
if (!setjmp(g_pre_test)) {
cr_theory_call(ctx, fnptr);
return 1;
}
memcpy(g_pre_test, backup, sizeof (jmp_buf));
return !res;
return 0;
}

void cr_theory_main(struct criterion_datapoints *dps, size_t datapoints, void (*fnptr)(void)) {
Expand All @@ -201,9 +194,9 @@ void cr_theory_main(struct criterion_datapoints *dps, size_t datapoints, void (*
size_t *indices = malloc(sizeof (size_t) * datapoints);
memset(indices, 0, datapoints * sizeof (size_t));

bool has_next = true;
volatile bool has_next = true;
while (has_next) {
if (!cr_theory_mark()) {
if (!setjmp(theory_jmp)) {
cr_theory_reset(ctx);
for (size_t i = 0; i < datapoints; ++i) {

Expand Down

0 comments on commit 7efbac9

Please sign in to comment.