cb22561995-10-11Fredrik Hübinette (Hubbe) /*\ ||| This file a part of uLPC, and is copyright by Fredrik Hubinette ||| uLPC is distributed as GPL (General Public License) ||| See the files COPYING and DISCLAIMER for more information. \*/
5267b71995-08-09Fredrik Hübinette (Hubbe) #ifndef ERROR_H #define ERROR_H
2d31fb1996-08-12Fredrik Hübinette (Hubbe) #include "machine.h" #ifdef HAVE_SETJMP_H
5267b71995-08-09Fredrik Hübinette (Hubbe) #include <setjmp.h>
2d31fb1996-08-12Fredrik Hübinette (Hubbe) #undef HAVE_SETJMP_H #endif
5267b71995-08-09Fredrik Hübinette (Hubbe) #include <stdarg.h>
2d31fb1996-08-12Fredrik Hübinette (Hubbe) 
5267b71995-08-09Fredrik Hübinette (Hubbe) #include "svalue.h"
cb22561995-10-11Fredrik Hübinette (Hubbe) typedef void (*error_call)(void *);
5267b71995-08-09Fredrik Hübinette (Hubbe)  struct frame;
cb22561995-10-11Fredrik Hübinette (Hubbe) typedef struct ONERROR { struct ONERROR *previous; error_call func; void *arg; } ONERROR;
f170fa1996-03-04Fredrik Hübinette (Hubbe) typedef jmp_buf my_jmp_buf; /* Maybe I'll get less warnings like this */
5267b71995-08-09Fredrik Hübinette (Hubbe) typedef struct JMP_BUF { struct JMP_BUF *previous;
f170fa1996-03-04Fredrik Hübinette (Hubbe)  my_jmp_buf recovery;
5267b71995-08-09Fredrik Hübinette (Hubbe)  struct frame *fp;
f0cd981996-06-21Fredrik Hübinette (Hubbe)  INT32 sp; INT32 mark_sp;
cb22561995-10-11Fredrik Hübinette (Hubbe)  ONERROR *onerror;
5267b71995-08-09Fredrik Hübinette (Hubbe) } JMP_BUF;
cb22561995-10-11Fredrik Hübinette (Hubbe) extern ONERROR *onerror_stack;
5267b71995-08-09Fredrik Hübinette (Hubbe) extern JMP_BUF *recoveries; extern struct svalue throw_value; extern char *automatic_fatal; #define SETJMP(X) setjmp((init_recovery(&X)[0])) #define UNSETJMP(X) recoveries=X.previous;
cb22561995-10-11Fredrik Hübinette (Hubbe) #define SET_ONERROR(X,Y,Z) \ do{ \ X.func=(error_call)(Y); \ X.arg=(void *)(Z); \ X.previous=onerror_stack; \ onerror_stack=&X; \ }while(0) #define UNSET_ONERROR(X) onerror_stack=X.previous
f170fa1996-03-04Fredrik Hübinette (Hubbe) my_jmp_buf *init_recovery(JMP_BUF *r);
5267b71995-08-09Fredrik Hübinette (Hubbe) int fix_recovery(int i, JMP_BUF *r); void throw() ATTRIBUTE((noreturn)); void va_error(char *fmt, va_list args) ATTRIBUTE((noreturn)); void error(char *fmt,...) ATTRIBUTE((noreturn,format (printf, 1, 2))); void fatal(char *fmt, ...) ATTRIBUTE((noreturn,format (printf, 1, 2))); #endif