1 /* 2 exception.h -- Exception handling. 3 4 Copyright (C) 1994-97 K. Scott Hunziker. 5 Copyright (C) 1990-94 The Boeing Company. 6 7 See the file COPYING for license, warranty, and permission details. 8 */ 9 10 /* $Id: exception.h,v 1.3 1997/02/21 09:53:55 ksh Exp $ */ 11 12 #ifndef EXCEPTION_H 13 #define EXCEPTION_H 1 14 15 #include <setjmp.h> 16 #include <signal.h> 17 #include "algae.h" 18 #include "sigint.h" 19 20 typedef struct except 21 { 22 struct except *link; 23 jmp_buf jb; 24 struct except *check; 25 } 26 EXCEPTION; 27 28 extern EXCEPTION *exception_head; 29 30 31 32 #define WITH_HANDLING { EXCEPTION my ;\ 33 if ( setjmp(my.jb) == 0 ) { exception_push(&my) ; 34 35 36 #define ON_EXCEPTION (void) exception_pop() ; } else { 37 #define EXCEPTION_BASE ON_EXCEPTION 38 39 #define END_EXCEPTION raise_exception(); } } 40 41 #define END_EXCEPTION_BASE ; }} 42 43 44 void PROTO (exception_push, (EXCEPTION *)); 45 jmp_buf *PROTO (exception_pop, (void)); 46 void PROTO (raise_exception, (void)); 47 ENTITY *PROTO (bi_exception, (void)); 48 49 50 /* handling of SIGINT */ 51 52 53 #define POLL_SIGINT() if( sigint_flag ) raise_exception() ; else 54 55 #define SIGINT_RAISE_ON() do {\ 56 (void) signal(SIGINT, SIG_IGN) ;\ 57 POLL_SIGINT() ;\ 58 sigint_raise_exception_flag = 1 ;\ 59 (void) signal(SIGINT, catch_sigint) ; } while(0) 60 61 #define SIGINT_RAISE_OFF() (sigint_raise_exception_flag = 0) 62 #endif /* EXCEPTION_H */ 63