Debian Codegraph @

lang-maps/libbm/src/try_throw_catch.h

raw
1 /* Copyright (C) 2009-2014 Francesco Nidito
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights to
6 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 * of the Software, and to permit persons to whom the Software is furnished to do
8 * so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in all
11 * copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 * SOFTWARE.
20 */
21
22 #ifndef _TRY_THROW_CATCH_H_
23 #define _TRY_THROW_CATCH_H_
24
25 #include <stdio.h>
26 #include <setjmp.h>
27
28 /* For the full documentation and explanation of the code below, please refer to
29 * http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html
30 */
31
32 #define BM_TRY do { /*jmp_buf ex_buf__;*/ switch( setjmp(ex_buf__) ) { case 0: while(1) {
33 #define CATCH(x) break; case x:
34 #define FINALLY break; } default: {
35 #define ETRY break; } } } while(0)
36 #define BM_THROW(x) longjmp(ex_buf__, x)
37
38 #endif /*!_TRY_THROW_CATCH_H_*/