1 /* panic.h - decls for fatal errors 2 * 3 **************************************************************** 4 * Copyright (C) 1998, 2000 Thomas Lord 5 * 6 * See the file "COPYING" for further information about 7 * the copyright and warranty status of this work. 8 */ 9 10 11 #ifndef INCLUDE__BUGS__PANIC_H 12 #define INCLUDE__BUGS__PANIC_H 13 14 15 #include "hackerlab/machine/types.h" 16 #include "hackerlab/bugs/panic-exit.h" 17 18 19 #define invariant_4(CONDITION, MSG, FILE, LINE) \ 20 do { if (!(CONDITION)) invariant_test (0, (MSG), (FILE), (LINE)); } while (0) 21 22 #define invariant_2(CONDITION, MSG) \ 23 invariant_4 ((CONDITION), (MSG), __FILE__, __LINE__) 24 25 #define invariant__x(CONDITION) \ 26 invariant_4 ((CONDITION), #CONDITION, __FILE__, __LINE__) 27 28 #define invariant(CONDITION) \ 29 invariant__x(CONDITION) 30 31 #define invariant_at_file_linex(CONDITION, FILE, LINE) \ 32 do { if (!(CONDITION)) invariant_test (0, #CONDITION, (FILE), (LINE)); } while (0) 33 34 #define invariant_at_file_line(CONDITION, FILE, LINE) \ 35 invariant_at_file_linex((CONDITION), (FILE), (LINE)) 36 37 38 /* Use invariant_TODO when you want to write an invariant check 39 * because you *think* the code is right but for external reasons 40 * you aren't certain. This allows an invariant failure to be 41 * checked but also allows you to `grep' for code that needs 42 * more careful review. 43 */ 44 45 #define invariant_TODO(X) invariant(X) 46 47 48 49 50 /* automatically generated __STDC__ prototypes */ 51 extern void panic (const char * str); 52 extern void panic_msg (const char * str); 53 extern void invariant_test (int condition, const char * str, char * file, int line); 54 #endif /* INCLUDE__BUGS__PANIC_H */ 55