diff options
| author | Damien <damien.p.george@gmail.com> | 2013-10-15 22:25:17 +0100 |
|---|---|---|
| committer | Damien <damien.p.george@gmail.com> | 2013-10-15 22:25:17 +0100 |
| commit | ce89a21ea49e51274d016d9601c462312664271e (patch) | |
| tree | d9ad69657b6ad313c988ce201a42e97d5cd38a39 /py/nlr.h | |
| parent | 5dd455d06dd3cdda7daf496822776b0c8319f02b (diff) | |
Implement basic exception framework, and simple for loop.
Diffstat (limited to 'py/nlr.h')
| -rw-r--r-- | py/nlr.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/py/nlr.h b/py/nlr.h new file mode 100644 index 000000000..b824e4a63 --- /dev/null +++ b/py/nlr.h @@ -0,0 +1,26 @@ +// non-local return +// exception handling, basically a stack of setjmp/longjmp buffers + +#include <limits.h> + +#ifndef __WORDSIZE +#error __WORDSIZE needs to be defined +#endif + +typedef struct _nlr_buf_t nlr_buf_t; +struct _nlr_buf_t { + // the entries here must all be machine word size + nlr_buf_t *prev; + void *ret_val; +#if __WORDSIZE == 32 + void *regs[6]; +#elif __WORDSIZE == 64 + void *regs[8]; +#else +#error Unsupported __WORDSIZE +#endif +}; + +unsigned int nlr_push(nlr_buf_t *); +void nlr_pop(); +void nlr_jump(void *val) __attribute__((noreturn)); |
