Main Page | Class List | File List | Class Members | File Members

arithmetic_errors.h

Go to the documentation of this file.
00001 /* 
00002  * $Id: arithmetic_errors.h,v 1.4 2006/03/15 19:59:37 verdoolaege Exp $
00003  *
00004  * managing arithmetic errors...
00005  * detecting and managing arithmetic errors on Values should be
00006  * systematic. These macros gives a C++ look and feel to this
00007  * management. 
00008  *
00009  * (c) CA et FC, Sept 1997
00010  *
00011  * $Log: arithmetic_errors.h,v $
00012  * Revision 1.4  2006/03/15 19:59:37  verdoolaege
00013  * arith: add some missing consts
00014  *
00015  * Revision 1.3  2004/02/08 21:53:27  kienhuis
00016  * Update from Fabien Coelho, via Bart Kienhuis
00017  *
00018  * I've updated here in the C3/Linear library the arithmetic_error
00019  * package that I developped (with others) to handle exceptions in C.
00020  * It adds a simple callback feature which is needed for pips here.
00021  * If you do not use it, it should not harm;-)
00022  *
00023  * Revision 1.34  2003/09/03 13:59:46  coelho
00024  * ++
00025  *
00026  * Revision 1.33  2003/09/03 13:35:34  coelho
00027  * no more callback.
00028  *
00029  * Revision 1.32  2003/08/18 14:55:38  coelho
00030  * callback fix.
00031  *
00032  * Revision 1.31  2003/08/18 14:16:45  coelho
00033  * NULL callback added.
00034  *
00035  * Revision 1.30  2003/06/13 13:59:55  coelho
00036  * hop.
00037  *
00038  * Revision 1.29  2000/07/27 15:01:55  coelho
00039  * hop.
00040  *
00041  * Revision 1.28  2000/07/26 09:11:58  coelho
00042  * hop.
00043  *
00044  * Revision 1.27  2000/07/26 09:07:32  coelho
00045  * *** empty log message ***
00046  *
00047  * Revision 1.26  2000/07/26 09:06:32  coelho
00048  * the_last_just_thrown_exception declared.
00049  *
00050  * Revision 1.25  2000/07/26 08:41:40  coelho
00051  * RETHROW added.
00052  *
00053  * Revision 1.24  1998/10/26 14:37:48  coelho
00054  * constants moved out.
00055  *
00056  * Revision 1.23  1998/10/26 14:36:13  coelho
00057  * constants explicitely defined in .h.
00058  *
00059  * Revision 1.22  1998/10/24 15:18:26  coelho
00060  * THROW macro updated to tell its source.
00061  *
00062  * Revision 1.21  1998/10/24 14:33:08  coelho
00063  * parser exception added.
00064  *
00065  * Revision 1.20  1998/10/24 14:32:45  coelho
00066  * simpler macros.
00067  *
00068  * Revision 1.19  1998/10/24 09:22:47  coelho
00069  * size update.
00070  *
00071  * Revision 1.18  1998/10/24 09:21:45  coelho
00072  * const added to constants.
00073  *
00074  */
00075 
00076 #if !defined(linear_arithmetic_error_included)
00077 #define linear_arithmetic_error_included
00078 
00079 #include <setjmp.h>
00080 
00081 typedef void (*exception_callback_t)(const char *, const char *, int);
00082 
00083 /*
00084 const unsigned int overflow_error = 1;
00085 const unsigned int simplex_arithmetic_error = 2;
00086 const unsigned int user_exception_error = 4;
00087 const unsigned int parser_exception_error = 8;
00088 const unsigned int any_exception_error = ~0;
00089 */
00090 
00091 /* use gnu cpp '__FUNCTION__' extension if possible.
00092  */
00093 #if defined(__GNUC__)
00094 #define __CURRENT_FUNCTION_NAME__ __FUNCTION__
00095 #else
00096 #define __CURRENT_FUNCTION_NAME__ "<unknown>"
00097 #endif
00098 
00099 /* 'const' out because of cproto 4.6. FC 13/06/2003 */
00100 #define EXCEPTION extern unsigned int
00101 
00102 #define THROW(what) \
00103    (throw_exception(what, __CURRENT_FUNCTION_NAME__, __FILE__, __LINE__))
00104 
00105 #define CATCH(what)                                                     \
00106    if (setjmp(*push_exception_on_stack(what, __CURRENT_FUNCTION_NAME__, \
00107                                      __FILE__, __LINE__)))
00108 
00109 #define UNCATCH(what)                                           \
00110      (pop_exception_from_stack(what, __CURRENT_FUNCTION_NAME__, \
00111                                __FILE__, __LINE__))
00112 
00113 #define TRY else
00114 
00115 extern unsigned int the_last_just_thrown_exception;
00116 #define RETHROW() THROW(the_last_just_thrown_exception)
00117 
00118 #endif /* linear_arithmetic_error_included */
00119 
00120 /* end of it.
00121  */

Generated on Thu Sep 4 15:28:57 2008 for polylib by doxygen 1.3.5