polylib 5.22.8
arithmetic_errors.h
Go to the documentation of this file.
1/*
2 * $Id: arithmetic_errors.h,v 1.4 2006/03/15 19:59:37 verdoolaege Exp $
3 *
4 * managing arithmetic errors...
5 * detecting and managing arithmetic errors on Values should be
6 * systematic. These macros gives a C++ look and feel to this
7 * management.
8 *
9 * (c) CA et FC, Sept 1997
10 *
11 * $Log: arithmetic_errors.h,v $
12 * Revision 1.4 2006/03/15 19:59:37 verdoolaege
13 * arith: add some missing consts
14 *
15 * Revision 1.3 2004/02/08 21:53:27 kienhuis
16 * Update from Fabien Coelho, via Bart Kienhuis
17 *
18 * I've updated here in the C3/Linear library the arithmetic_error
19 * package that I developped (with others) to handle exceptions in C.
20 * It adds a simple callback feature which is needed for pips here.
21 * If you do not use it, it should not harm;-)
22 *
23 * Revision 1.34 2003/09/03 13:59:46 coelho
24 * ++
25 *
26 * Revision 1.33 2003/09/03 13:35:34 coelho
27 * no more callback.
28 *
29 * Revision 1.32 2003/08/18 14:55:38 coelho
30 * callback fix.
31 *
32 * Revision 1.31 2003/08/18 14:16:45 coelho
33 * NULL callback added.
34 *
35 * Revision 1.30 2003/06/13 13:59:55 coelho
36 * hop.
37 *
38 * Revision 1.29 2000/07/27 15:01:55 coelho
39 * hop.
40 *
41 * Revision 1.28 2000/07/26 09:11:58 coelho
42 * hop.
43 *
44 * Revision 1.27 2000/07/26 09:07:32 coelho
45 * *** empty log message ***
46 *
47 * Revision 1.26 2000/07/26 09:06:32 coelho
48 * the_last_just_thrown_exception declared.
49 *
50 * Revision 1.25 2000/07/26 08:41:40 coelho
51 * RETHROW added.
52 *
53 * Revision 1.24 1998/10/26 14:37:48 coelho
54 * constants moved out.
55 *
56 * Revision 1.23 1998/10/26 14:36:13 coelho
57 * constants explicitely defined in .h.
58 *
59 * Revision 1.22 1998/10/24 15:18:26 coelho
60 * THROW macro updated to tell its source.
61 *
62 * Revision 1.21 1998/10/24 14:33:08 coelho
63 * parser exception added.
64 *
65 * Revision 1.20 1998/10/24 14:32:45 coelho
66 * simpler macros.
67 *
68 * Revision 1.19 1998/10/24 09:22:47 coelho
69 * size update.
70 *
71 * Revision 1.18 1998/10/24 09:21:45 coelho
72 * const added to constants.
73 *
74 */
75
76#if !defined(linear_arithmetic_error_included)
77#define linear_arithmetic_error_included
78
79#include <setjmp.h>
80
81typedef void (*exception_callback_t)(const char *, const char *, int);
82
83/*
84const unsigned int overflow_error = 1;
85const unsigned int simplex_arithmetic_error = 2;
86const unsigned int user_exception_error = 4;
87const unsigned int parser_exception_error = 8;
88const unsigned int any_exception_error = ~0;
89*/
90
91/* use gnu cpp '__FUNCTION__' extension if possible.
92 */
93#if defined(__GNUC__)
94#define __CURRENT_FUNCTION_NAME__ __FUNCTION__
95#else
96#define __CURRENT_FUNCTION_NAME__ "<unknown>"
97#endif
98
99/* 'const' out because of cproto 4.6. FC 13/06/2003 */
100#define EXCEPTION extern unsigned int
101
102#define THROW(what) \
103 (throw_exception(what, __CURRENT_FUNCTION_NAME__, __FILE__, __LINE__))
104
105#define CATCH(what) \
106 if (setjmp(*push_exception_on_stack(what, __CURRENT_FUNCTION_NAME__, \
107 __FILE__, __LINE__)))
108
109#define UNCATCH(what) \
110 (pop_exception_from_stack(what, __CURRENT_FUNCTION_NAME__, __FILE__, \
111 __LINE__))
112
113#define TRY else
114
115extern unsigned int the_last_just_thrown_exception;
116#define RETHROW() THROW(the_last_just_thrown_exception)
117
118#endif /* linear_arithmetic_error_included */
119
120/* end of it.
121 */
void(* exception_callback_t)(const char *, const char *, int)
unsigned int the_last_just_thrown_exception
Definition: errors.c:141