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

Generated on Mon Sep 12 14:48:28 2005 for polylib by doxygen 1.3.5