diff options
Diffstat (limited to 'src/H5Eprivate.h')
-rw-r--r-- | src/H5Eprivate.h | 126 |
1 files changed, 71 insertions, 55 deletions
diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 6de4cb5..440f40b 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -30,16 +30,17 @@ typedef struct H5E_t H5E_t; * and a FUNC_LEAVE() within a function body. The arguments are the major * error number, the minor error number, and a description of the error. */ -#define HERROR(maj_id, min_id, ...) H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__) +#define HERROR(maj_id, min_id, ...) \ + H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__) /* * HCOMMON_ERROR macro, used by HDONE_ERROR and HGOTO_ERROR * (Shouldn't need to be used outside this header file) */ -#define HCOMMON_ERROR(maj, min, ...) \ - HERROR(maj, min, __VA_ARGS__); \ - err_occurred = TRUE; \ - err_occurred = err_occurred; /* Shut GCC warnings up! */ +#define HCOMMON_ERROR(maj, min, ...) \ + HERROR(maj, min, __VA_ARGS__); \ + err_occurred = TRUE; \ + err_occurred = err_occurred; /* Shut GCC warnings up! */ /* * HDONE_ERROR macro, used to facilitate error reporting between a @@ -50,10 +51,11 @@ typedef struct H5E_t H5E_t; * (This macro can also be used to push an error and set the return value * without jumping to any labels) */ -#define HDONE_ERROR(maj, min, ret_val, ...) { \ - HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - ret_value = ret_val; \ -} +#define HDONE_ERROR(maj, min, ret_val, ...) \ + { \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + ret_value = ret_val; \ + } /* * HGOTO_ERROR macro, used to facilitate error reporting between a @@ -62,10 +64,11 @@ typedef struct H5E_t H5E_t; * error string. The return value is assigned to a variable `ret_value' and * control branches to the `done' label. */ -#define HGOTO_ERROR(maj, min, ret_val, ...) { \ - HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - HGOTO_DONE(ret_val) \ -} +#define HGOTO_ERROR(maj, min, ret_val, ...) \ + { \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + HGOTO_DONE(ret_val) \ + } /* * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER() @@ -73,14 +76,19 @@ typedef struct H5E_t H5E_t; * value which is assigned to the `ret_value' variable. Control branches to * the `done' label. */ -#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} +#define HGOTO_DONE(ret_val) \ + { \ + ret_value = ret_val; \ + goto done; \ + } /* * H5E_PRINTF macro, used to facilitate error reporting between a BEGIN_FUNC() * and an END_FUNC() within a function body. The arguments are the minor * error number, a description of the error (as a printf-like format string), * and an optional set of arguments for the printf format arguments. */ -#define H5E_PRINTF(...) H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__) +#define H5E_PRINTF(...) \ + H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__) /* * H5_LEAVE macro, used to facilitate control flow between a @@ -89,11 +97,12 @@ typedef struct H5E_t H5E_t; * The return value is assigned to a variable `ret_value' and control branches * to the `catch_except' label, if we're not already past it. */ -#define H5_LEAVE(v) { \ - ret_value = v; \ - if(!past_catch) \ - goto catch_except; \ -} +#define H5_LEAVE(v) \ + { \ + ret_value = v; \ + if (!past_catch) \ + goto catch_except; \ + } /* * H5E_THROW macro, used to facilitate error reporting between a @@ -102,24 +111,25 @@ typedef struct H5E_t H5E_t; * The return value is assigned to a variable `ret_value' and control branches * to the `catch_except' label, if we're not already past it. */ -#define H5E_THROW(...) { \ - H5E_PRINTF(__VA_ARGS__); \ - H5_LEAVE(fail_value) \ -} +#define H5E_THROW(...) \ + { \ + H5E_PRINTF(__VA_ARGS__); \ + H5_LEAVE(fail_value) \ + } /* Macro for "catching" flow of control when an error occurs. Note that the * H5_LEAVE macro won't jump back here once it's past this point. */ -#define CATCH catch_except:; past_catch = TRUE; - - +#define CATCH \ +catch_except:; \ + past_catch = TRUE; /* Library-private functions defined in H5E package */ H5_DLL herr_t H5E_init(void); -H5_DLL herr_t H5E_push_stack(H5E_t *estack, const char *file, const char *func, - unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc); -H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, - unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...); +H5_DLL herr_t H5E_push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, + hid_t maj_id, hid_t min_id, const char *desc); +H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, + hid_t maj_id, hid_t min_id, const char *fmt, ...); H5_DLL herr_t H5E_clear_stack(H5E_t *estack); H5_DLL herr_t H5E_dump_api_stack(int is_api); @@ -131,36 +141,42 @@ H5_DLL herr_t H5E_dump_api_stack(int is_api); /* Retrieve the error code description string and push it onto the error * stack. */ -#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) { \ - int myerrno = errno; \ - HDONE_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, HDstrerror(myerrno)); \ -} -#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) { \ - int myerrno = errno; \ - HGOTO_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, HDstrerror(myerrno)); \ -} +#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) \ + { \ + int myerrno = errno; \ + HDONE_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, \ + HDstrerror(myerrno)); \ + } +#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) \ + { \ + int myerrno = errno; \ + HGOTO_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, \ + HDstrerror(myerrno)); \ + } #ifdef H5_HAVE_PARALLEL /* * MPI error handling macros. */ -extern char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; -extern int H5E_mpi_error_str_len; - -#define HMPI_ERROR(mpierr){ \ - MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ - HERROR(H5E_INTERNAL, H5E_MPIERRSTR, "%s", H5E_mpi_error_str); \ -} -#define HMPI_DONE_ERROR(retcode, str, mpierr){ \ - HMPI_ERROR(mpierr); \ - HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ -} -#define HMPI_GOTO_ERROR(retcode, str, mpierr){ \ - HMPI_ERROR(mpierr); \ - HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ -} +extern char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; +extern int H5E_mpi_error_str_len; + +#define HMPI_ERROR(mpierr) \ + { \ + MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ + HERROR(H5E_INTERNAL, H5E_MPIERRSTR, "%s", H5E_mpi_error_str); \ + } +#define HMPI_DONE_ERROR(retcode, str, mpierr) \ + { \ + HMPI_ERROR(mpierr); \ + HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ + } +#define HMPI_GOTO_ERROR(retcode, str, mpierr) \ + { \ + HMPI_ERROR(mpierr); \ + HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ + } #endif /* H5_HAVE_PARALLEL */ #endif /* _H5Eprivate_H */ - |