summaryrefslogtreecommitdiff
path: root/src/cmd/tests/libc/setjmp.c
blob: 0dded9d6c5956b26cf25b9d0ccde7323b656923f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "../tests.h"
#include <stdbool.h>
#include <setjmp.h>

static void test_setjmp(void) {
	jmp_buf env;
	volatile bool inner;
	int val;
	inner = false;
	if (!(val = setjmp(env))) {
		inner = true;
		longjmp(env, 1234);
		test(0);
	} else {
		test(val == 1234);
		test(inner);
	}
	inner = false;
	if (!(val = setjmp(env))) {
		inner = true;
		longjmp(env, 0);
		test(0);
	} else {
		test(val == 1);
		test(inner);
	}
}

void r_libc_setjmp(void) {
	run_test(test_setjmp);
}