A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update versionning info, and add a cheat sheet to the makefile in order to do so...
[simgrid.git]
/
include
/
error.h
diff --git
a/include/error.h
b/include/error.h
index
4a45d91
..
8505083
100644
(file)
--- a/
include/error.h
+++ b/
include/error.h
@@
-15,8
+15,9
@@
#include <stddef.h> /* offsetof() */
#include <sys/types.h> /* size_t */
#include <stdarg.h>
#include <stddef.h> /* offsetof() */
#include <sys/types.h> /* size_t */
#include <stdarg.h>
+#ifdef HAVE_EXECINFO_H
#include <execinfo.h> /* to print the backtrace */
#include <execinfo.h> /* to print the backtrace */
-
+#endif
/* C++ users need love */
#ifndef BEGIN_DECL
/* C++ users need love */
#ifndef BEGIN_DECL
@@
-52,11
+53,19
@@
typedef enum {
/*@observer@*/ const char *gras_error_name(gras_error_t errcode);
/*@observer@*/ const char *gras_error_name(gras_error_t errcode);
-#define TRY(a) if ((errcode=a) != no_error) return errcode
+#define TRY(a) do { \
+ if ((errcode=a) != no_error) { \
+ fprintf (stderr, "%s:%d: '%s' error raising...\n", \
+ __FILE__,__LINE__, \
+ gras_error_name(errcode)); \
+ return errcode; \
+ } } while (0)
+
#define TRYCATCH(a,b) if ((errcode=a) != no_error && errcode !=b) return errcode
#define TRYFAIL(a) do { \
if ((errcode=a) != no_error) { \
#define TRYCATCH(a,b) if ((errcode=a) != no_error && errcode !=b) return errcode
#define TRYFAIL(a) do { \
if ((errcode=a) != no_error) { \
- fprintf(stderr,"Got '%s' error !\n", \
+ fprintf(stderr,"%s:%d: Got '%s' error !\n", \
+ __FILE__,__LINE__, \
gras_error_name(errcode)); \
fflush(stdout); \
abort(); \
gras_error_name(errcode)); \
fflush(stdout); \
abort(); \
@@
-80,6
+89,7
@@
typedef enum {
} \
} while(0)
} \
} while(0)
+#if 0 /* FIXME: We don't use backtrace. Drop it? */
#define _GRAS_ERR_PRE do { \
void *_gs_array[30]; \
size_t _gs_size= backtrace (_gs_array, 30); \
#define _GRAS_ERR_PRE do { \
void *_gs_array[30]; \
size_t _gs_size= backtrace (_gs_array, 30); \
@@
-93,6
+103,12
@@
typedef enum {
return code; \
} while (0)
return code; \
} while (0)
+#else
+#define _GRAS_ERR_PRE do {
+#define _GRAS_ERR_POST(code) \
+ return code; \
+} while (0)
+#endif
#define RAISE0(code,fmt) _GRAS_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
#define RAISE0(code,fmt) _GRAS_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
@@
-125,6
+141,7
@@
typedef enum {
#define RAISE_MALLOC RAISE0(malloc_error,"Malloc error")
#define RAISE_IMPOSSIBLE RAISE0(unknown_error,"The Impossible did happen")
#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__)
#define gras_abort abort
#define gras_abort abort