X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d45e78ba048ff7e081f940006a77bc122b5315be..2539fff313cbd67c45b8490f7961e45e358d9ba2:/include/xbt/error.h diff --git a/include/xbt/error.h b/include/xbt/error.h index 4dabcc80aa..c88d536d22 100644 --- a/include/xbt/error.h +++ b/include/xbt/error.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* gras/error.h - Error tracking support */ +/* xbt/error.h - Error tracking support */ /* Authors: Martin Quinson */ /* Copyright (C) 2003,2004 da GRAS posse. */ @@ -9,8 +9,8 @@ under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef GRAS_ERROR_H -#define GRAS_ERROR_H +#ifndef XBT_ERROR_H +#define XBT_ERROR_H #include /* FIXME: Get rid of it */ @@ -40,15 +40,15 @@ typedef enum { remote_timeout_error, remote_thread_error, remote_unknown_error -} gras_error_t; +} xbt_error_t; -/*@observer@*/ const char *gras_error_name(gras_error_t errcode); +/*@observer@*/ const char *xbt_error_name(xbt_error_t errcode); #define TRY(a) do { \ if ((errcode=a) != no_error) { \ fprintf (stderr, "%s:%d: '%s' error raising...\n", \ __FILE__,__LINE__, \ - gras_error_name(errcode)); \ + xbt_error_name(errcode)); \ return errcode; \ } } while (0) @@ -57,18 +57,18 @@ typedef enum { if ((errcode=a) != no_error) { \ fprintf(stderr,"%s:%d: Got '%s' error !\n", \ __FILE__,__LINE__, \ - gras_error_name(errcode)); \ + xbt_error_name(errcode)); \ fflush(stdout); \ - gras_abort(); \ + xbt_abort(); \ } } while(0) #define TRYEXPECT(action,expected_error) do { \ errcode=action; \ if (errcode != expected_error) { \ fprintf(stderr,"Got error %s (instead of %s expected)\n", \ - gras_error_name(errcode), \ - gras_error_name(expected_error)); \ - gras_abort(); \ + xbt_error_name(errcode), \ + xbt_error_name(expected_error)); \ + xbt_abort(); \ } \ } while(0) @@ -81,13 +81,13 @@ typedef enum { } while(0) #if 0 /* FIXME: We don't use backtrace. Drop it? */ -#define _GRAS_ERR_PRE do { \ +#define _XBT_ERR_PRE do { \ void *_gs_array[30]; \ size_t _gs_size= backtrace (_gs_array, 30); \ char **_gs_strings= backtrace_symbols (_gs_array, _gs_size); \ size_t _gs_i; -#define _GRAS_ERR_POST(code) \ +#define _XBT_ERR_POST(code) \ fprintf(stderr,"Backtrace follows\n"); \ for (_gs_i = 0; _gs_i < _gs_size; _gs_i++) \ fprintf (stderr," %s\n", _gs_strings[_gs_i]); \ @@ -95,71 +95,71 @@ typedef enum { } while (0) #else /* if 0 */ -#define _GRAS_ERR_PRE do { -#define _GRAS_ERR_POST(code) \ +#define _XBT_ERR_PRE do { +#define _XBT_ERR_POST(code) \ return code; \ } while (0) #endif -#define RAISE0(code,fmt) _GRAS_ERR_PRE \ +#define RAISE0(code,fmt) _XBT_ERR_PRE \ fprintf(stderr,"%s:%d:%s: " fmt "\n", \ __FILE__,__LINE__,__FUNCTION__); \ - _GRAS_ERR_POST(code) -#define RAISE1(code,fmt,a1) _GRAS_ERR_PRE \ + _XBT_ERR_POST(code) +#define RAISE1(code,fmt,a1) _XBT_ERR_PRE \ fprintf(stderr,"%s:%d:%s: " fmt "\n", \ __FILE__,__LINE__,__FUNCTION__,a1); \ - _GRAS_ERR_POST(code) -#define RAISE2(code,fmt,a1,a2) _GRAS_ERR_PRE \ + _XBT_ERR_POST(code) +#define RAISE2(code,fmt,a1,a2) _XBT_ERR_PRE \ fprintf(stderr,"%s:%d:%s: " fmt "\n", \ __FILE__,__LINE__,__FUNCTION__,a1,a2); \ - _GRAS_ERR_POST(code) -#define RAISE3(code,fmt,a1,a2,a3) _GRAS_ERR_PRE \ + _XBT_ERR_POST(code) +#define RAISE3(code,fmt,a1,a2,a3) _XBT_ERR_PRE \ fprintf(stderr,"%s:%d:%s: " fmt "\n", \ __FILE__,__LINE__,__FUNCTION__,a1,a2,a3); \ - _GRAS_ERR_POST(code) -#define RAISE4(code,fmt,a1,a2,a3,a4) _GRAS_ERR_PRE \ + _XBT_ERR_POST(code) +#define RAISE4(code,fmt,a1,a2,a3,a4) _XBT_ERR_PRE \ fprintf(stderr,"%s:%d:%s: " fmt "\n", \ __FILE__,__LINE__,__FUNCTION__,a1,a2,a3,a4); \ - _GRAS_ERR_POST(code) -#define RAISE5(code,fmt,a1,a2,a3,a4,a5) _GRAS_ERR_PRE \ + _XBT_ERR_POST(code) +#define RAISE5(code,fmt,a1,a2,a3,a4,a5) _XBT_ERR_PRE \ fprintf(stderr,"%s:%d:%s: " fmt "\n", \ __FILE__,__LINE__,__FUNCTION__,a1,a2,a3,a4,a5); \ - _GRAS_ERR_POST(code) -#define RAISE6(code,fmt,a1,a2,a3,a4,a5,a6) _GRAS_ERR_PRE \ + _XBT_ERR_POST(code) +#define RAISE6(code,fmt,a1,a2,a3,a4,a5,a6) _XBT_ERR_PRE \ fprintf(stderr,"%s:%d:%s: " fmt "\n", \ __FILE__,__LINE__,__FUNCTION__,a1,a2,a3,a4,a5,a6); \ - _GRAS_ERR_POST(code) + _XBT_ERR_POST(code) //#define RAISE_MALLOC RAISE0(malloc_error,"Malloc error") #define RAISE_IMPOSSIBLE RAISE0(unknown_error,"The Impossible did happen") #define RAISE_UNIMPLEMENTED RAISE1(unknown_error,"Function %s unimplemented",__FUNCTION__) #ifdef NDEBUG -#define gras_assert(cond) -#define gras_assert0(cond,msg) -#define gras_assert1(cond,msg,a) -#define gras_assert2(cond,msg,a,b) -#define gras_assert3(cond,msg,a,b,c) -#define gras_assert4(cond,msg,a,b,c,d) -#define gras_assert5(cond,msg,a,b,c,d,e) -#define gras_assert6(cond,msg,a,b,c,d,e,f) +#define xbt_assert(cond) +#define xbt_assert0(cond,msg) +#define xbt_assert1(cond,msg,a) +#define xbt_assert2(cond,msg,a,b) +#define xbt_assert3(cond,msg,a,b,c) +#define xbt_assert4(cond,msg,a,b,c,d) +#define xbt_assert5(cond,msg,a,b,c,d,e) +#define xbt_assert6(cond,msg,a,b,c,d,e,f) #else -#define gras_assert(cond) if (!(cond)) { CRITICAL1("Assertion %s failed", #cond); gras_abort(); } -#define gras_assert0(cond,msg) if (!(cond)) { CRITICAL0(msg); gras_abort(); } -#define gras_assert1(cond,msg,a) if (!(cond)) { CRITICAL1(msg,a); gras_abort(); } -#define gras_assert2(cond,msg,a,b) if (!(cond)) { CRITICAL2(msg,a,b); gras_abort(); } -#define gras_assert3(cond,msg,a,b,c) if (!(cond)) { CRITICAL3(msg,a,b,c); gras_abort(); } -#define gras_assert4(cond,msg,a,b,c,d) if (!(cond)) { CRITICAL4(msg,a,b,c,d); gras_abort(); } -#define gras_assert5(cond,msg,a,b,c,d,e) if (!(cond)) { CRITICAL5(msg,a,b,c,d,e); gras_abort(); } -#define gras_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) { CRITICAL6(msg,a,b,c,d,e,f); gras_abort(); } +#define xbt_assert(cond) if (!(cond)) { CRITICAL1("Assertion %s failed", #cond); xbt_abort(); } +#define xbt_assert0(cond,msg) if (!(cond)) { CRITICAL0(msg); xbt_abort(); } +#define xbt_assert1(cond,msg,a) if (!(cond)) { CRITICAL1(msg,a); xbt_abort(); } +#define xbt_assert2(cond,msg,a,b) if (!(cond)) { CRITICAL2(msg,a,b); xbt_abort(); } +#define xbt_assert3(cond,msg,a,b,c) if (!(cond)) { CRITICAL3(msg,a,b,c); xbt_abort(); } +#define xbt_assert4(cond,msg,a,b,c,d) if (!(cond)) { CRITICAL4(msg,a,b,c,d); xbt_abort(); } +#define xbt_assert5(cond,msg,a,b,c,d,e) if (!(cond)) { CRITICAL5(msg,a,b,c,d,e); xbt_abort(); } +#define xbt_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) { CRITICAL6(msg,a,b,c,d,e,f); xbt_abort(); } #endif -void gras_die(const char *msg); +void xbt_die(const char *msg); -#define DIE_IMPOSSIBLE gras_assert0(0,"The Impossible did happen (yet again)") -#define gras_assert_error(a) gras_assert1(errcode == (a), "Error %s unexpected",gras_error_name(errcode)) +#define DIE_IMPOSSIBLE xbt_assert0(0,"The Impossible did happen (yet again)") +#define xbt_assert_error(a) xbt_assert1(errcode == (a), "Error %s unexpected",xbt_error_name(errcode)) END_DECL -#endif /* GRAS_ERROR_H */ +#endif /* XBT_ERROR_H */