blob: 8ca8a9dc62451452f5809bcc29ad4a059d162a62 [file] [log] [blame]
Damience89a212013-10-15 22:25:17 +01001// non-local return
2// exception handling, basically a stack of setjmp/longjmp buffers
3
4#include <limits.h>
5
Damien152568b2013-10-16 00:46:39 +01006//#ifndef __WORDSIZE
7//#error __WORDSIZE needs to be defined
8//#endif
Damience89a212013-10-15 22:25:17 +01009
10typedef struct _nlr_buf_t nlr_buf_t;
11struct _nlr_buf_t {
12 // the entries here must all be machine word size
13 nlr_buf_t *prev;
14 void *ret_val;
15#if __WORDSIZE == 32
16 void *regs[6];
17#elif __WORDSIZE == 64
18 void *regs[8];
19#else
Damien152568b2013-10-16 00:46:39 +010020 // hack for thumb
21 void *regs[10];
22//#error Unsupported __WORDSIZE
Damience89a212013-10-15 22:25:17 +010023#endif
24};
25
26unsigned int nlr_push(nlr_buf_t *);
Damien8b3a7c22013-10-23 20:20:17 +010027void nlr_pop(void);
Damience89a212013-10-15 22:25:17 +010028void nlr_jump(void *val) __attribute__((noreturn));