github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/jit-setjmp.h (about) 1 /* 2 * jit-setjmp.h - Support definitions that use "setjmp" for exceptions. 3 * 4 * Copyright (C) 2004 Southern Storm Software, Pty Ltd. 5 * 6 * This file is part of the libjit library. 7 * 8 * The libjit library is free software: you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public License 10 * as published by the Free Software Foundation, either version 2.1 of 11 * the License, or (at your option) any later version. 12 * 13 * The libjit library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with the libjit library. If not, see 20 * <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef _JIT_SETJMP_H 24 #define _JIT_SETJMP_H 25 26 #include <setjmp.h> 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /* 33 * Jump buffer structure, with link. 34 */ 35 typedef struct jit_jmp_buf 36 { 37 jmp_buf buf; 38 jit_backtrace_t trace; 39 void *catch_pc; 40 struct jit_jmp_buf *parent; 41 42 } jit_jmp_buf; 43 #define jit_jmp_catch_pc_offset \ 44 ((jit_nint)&(((jit_jmp_buf *)0)->catch_pc)) 45 46 /* 47 * Push a "setjmp" buffer onto the current thread's unwind stck. 48 */ 49 void _jit_unwind_push_setjmp(jit_jmp_buf *jbuf); 50 51 /* 52 * Pop the top-most "setjmp" buffer from the current thread's unwind stack. 53 */ 54 void _jit_unwind_pop_setjmp(void); 55 56 /* 57 * Pop the top-most "setjmp" buffer and rethrow the current exception. 58 */ 59 void _jit_unwind_pop_and_rethrow(void); 60 61 #ifdef __cplusplus 62 }; 63 #endif 64 65 #endif /* _JIT_SETJMP_H */