except.h
Go to the documentation of this file.00001
00039 #ifndef MWARE_EXCEPT_H
00040 #define MWARE_EXCEPT_H
00041
00042 #include <cfg/debug.h>
00043
00044 #include <setjmp.h>
00045
00046 #define EXCEPT_CONTEXTS 8
00047
00057 extern jmp_buf except_stack[EXCEPT_CONTEXTS];
00058 extern int except_top;
00059
00060 #define PUSH_EXCEPT (ASSERT(except_top < EXCEPT_CONTEXTS), setjmp(except_stack[except_top++]))
00061 #define POP_EXCEPT (ASSERT(except_top > 0), --except_top)
00062 #define DO_EXCEPT (ASSERT(except_top > 0), longjmp(except_stack[--except_top], true))
00063
00114 #define TRY if (PUSH_EXCEPT) { {
00115 #define TRY_END } POP_EXCEPT; }
00116 #define CATCH } POP_EXCEPT; } else {
00117 #define CATCH_END }
00118 #define THROW DO_EXCEPT
00119
00120
00121 #define EXCEPT_DEFINE \
00122 jmp_buf except_stack[EXCEPT_CONTEXTS]; \
00123 int except_top;
00124
00125 #endif