summaryrefslogtreecommitdiff
path: root/05/setjmp.h
blob: b3ffce19562bf2badbfe0550f7a791cf5c07f149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef _SETJMP_H
#define _SETJMP_H

#include <stdc_common.h>

typedef long jmp_buf[3];

// @NONSTANDARD: we don't actually support setjmp

int setjmp(jmp_buf env) {
	return 0;
}

void __longjmp(jmp_buf env, int val, const char *filename, int line) {
	fprintf(stderr, "Error: Tried to longjmp from %s:%d with value %d\n", filename, line, val);
	_Exit(-1);
}

#define longjmp(env, val) __longjmp(env, val, __FILE__, __LINE__)

#endif