67
67
 
   HGOTO_DONE(ret_val)                                    \
68
68
 
}
69
69
 
70
70
 
/*
71
71
 
 * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER()
72
72
 
 * and a FUNC_LEAVE() within a function body. The argument is the return
73
73
 
 * value which is assigned to the `ret_value' variable.  Control branches to
74
74
 
 * the `done' label.
75
75
 
 */
76
76
 
#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;}
 
77
+
/*
 
78
+
 * H5E_PRINTF macro, used to facilitate error reporting between a BEGIN_FUNC()
 
79
+
 * and an END_FUNC() within a function body.  The arguments are the minor
 
80
+
 * error number, a description of the error (as a printf-like format string),
 
81
+
 * and an optional set of arguments for the printf format arguments.
 
82
+
 */
 
83
+
#define H5E_PRINTF(...) H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR,  __VA_ARGS__)
 
84
+
 
85
+
/*
 
86
+
 * H5_LEAVE macro, used to facilitate control flow between a
 
87
+
 * BEGIN_FUNC() and an END_FUNC() within a function body.  The argument is
 
88
+
 * the return value.
 
89
+
 * The return value is assigned to a variable `ret_value' and control branches
 
90
+
 * to the `catch_except' label, if we're not already past it.
 
91
+
 */
 
92
+
#define H5_LEAVE(v) {                                 \
 
93
+
    ret_value = v;                                \
 
94
+
    if(!past_catch)                               \
 
95
+
        goto catch_except;                            \
 
96
+
}
 
97
+
 
98
+
/*
 
99
+
 * H5E_THROW macro, used to facilitate error reporting between a
 
100
+
 * FUNC_ENTER() and a FUNC_LEAVE() within a function body.  The arguments are
 
101
+
 * the minor error number, and an error string.
 
102
+
 * The return value is assigned to a variable `ret_value' and control branches
 
103
+
 * to the `catch_except' label, if we're not already past it.
 
104
+
 */
 
105
+
#define H5E_THROW(...) {                              \
 
106
+
    H5E_PRINTF(__VA_ARGS__);                              \
 
107
+
    H5_LEAVE(fail_value)                              \
 
108
+
}
 
109
+
 
110
+
/* Macro for "catching" flow of control when an error occurs.  Note that the
 
111
+
 *      H5_LEAVE macro won't jump back here once it's past this point.
 
112
+
 */
 
113
+
#define CATCH catch_except:; past_catch = TRUE;
 
114
+
 
115
+
77
116
 
78
117
 
/* Library-private functions defined in H5E package */
79
118
 
H5_DLL herr_t H5E_init(void);
80
119
 
H5_DLL herr_t H5E_push_stack(H5E_t *estack, const char *file, const char *func,
81
120
 
    unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc);
82
121
 
H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func,
83
122
 
    unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...);
84
123
 
H5_DLL herr_t H5E_clear_stack(H5E_t *estack);
85
124
 
H5_DLL herr_t H5E_dump_api_stack(int is_api);
86
125