diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2003-09-24 19:26:50 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2003-09-24 19:26:50 (GMT) |
commit | 7e79a8d71e6a579710e0fc2c677dfc32336d058f (patch) | |
tree | d9b4f93046b8c2930fd35b3ec75953eccf1c1a47 /src | |
parent | 52f3545bde417a7eaeb996bfc97b58ab32075c73 (diff) | |
download | hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.zip hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.tar.gz hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.tar.bz2 |
[svn-r7507] *** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 4 | ||||
-rw-r--r-- | src/H5E.c | 392 | ||||
-rw-r--r-- | src/H5Epublic.h | 65 | ||||
-rw-r--r-- | src/H5FDmulti.c | 104 | ||||
-rw-r--r-- | src/H5FDstdio.c | 50 |
5 files changed, 590 insertions, 25 deletions
@@ -196,7 +196,11 @@ H5_term_library(void) goto done; /* Check if we should display error output */ +#ifdef H5_WANT_H5_V1_6_COMPAT + (void)H5Eget_auto(&func,NULL); +#else (void)H5Eget_auto(H5E_DEFAULT,&func,NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* * Terminate each interface. The termination functions return a positive @@ -735,6 +735,108 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Eget_major + * + * Purpose: Retrieves a major error message. + * + * Return: Returns message if succeeds. + * otherwise returns NULL. + * + * Programmer: Raymond Lu + * Friday, July 14, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +const char * +H5Eget_major(H5E_major_t maj) +{ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size = 0; /* Return value */ + H5E_type_t type; + char *msg_str; + char *ret_value = NULL; + + FUNC_ENTER_API_NOINIT(H5Eget_major) + + /* Get the message object */ + if((msg = H5I_object_verify(maj, H5I_ERROR_MSG))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") + + /* Get the message's text */ + if((size = H5E_get_msg(msg, &type, NULL, 0))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text"); + + if(type != H5E_MAJOR) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a major one"); + + /* Don't know who is going to free it */ + msg_str = (char*)HDmalloc((++size)*sizeof(char)); + + if(H5E_get_msg(msg, NULL, msg_str, size)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") + + ret_value = msg_str; + +done: + FUNC_LEAVE_API(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5Eget_minor + * + * Purpose: Retrieves a minor error message. + * + * Return: Returns message if succeeds. + * otherwise returns NULL. + * + * Programmer: Raymond Lu + * Friday, July 14, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +const char * +H5Eget_minor(H5E_minor_t min) +{ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size = 0; /* Return value */ + H5E_type_t type; + char *msg_str; + char *ret_value = NULL; + + FUNC_ENTER_API_NOINIT(H5Eget_minor) + + /* Get the message object */ + if((msg = H5I_object_verify(min, H5I_ERROR_MSG))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") + + /* Get the message's text */ + if((size = H5E_get_msg(msg, &type, NULL, 0))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text"); + + if(type != H5E_MINOR) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a minor one"); + + /* Don't know who is going to free it */ + msg_str = (char*)HDmalloc((++size)*sizeof(char)); + + if(H5E_get_msg(msg, NULL, msg_str, size)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") + + ret_value = msg_str; + +done: + FUNC_LEAVE_API(ret_value) +} + +#else /*------------------------------------------------------------------------- * Function: H5Eget_msg @@ -770,6 +872,7 @@ H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg_str, size_t size) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -903,12 +1006,12 @@ H5E_get_current_stack(void) if(H5I_inc_ref(current_error->cls_id)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error class") new_error->cls_id = current_error->cls_id; - if(H5I_inc_ref(current_error->maj_id)<0) + if(H5I_inc_ref(current_error->maj_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") - new_error->maj_id = current_error->maj_id; - if(H5I_inc_ref(current_error->min_id)<0) + new_error->maj_num = current_error->maj_num; + if(H5I_inc_ref(current_error->min_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") - new_error->min_id = current_error->min_id; + new_error->min_num = current_error->min_num; if((new_error->func_name = HDstrdup(current_error->func_name))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if((new_error->file_name = HDstrdup(current_error->file_name))==NULL) @@ -1017,12 +1120,12 @@ H5E_set_current_stack(H5E_t *estack) if(H5I_inc_ref(new_error->cls_id)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") current_error->cls_id = new_error->cls_id; - if(H5I_inc_ref(new_error->maj_id)<0) + if(H5I_inc_ref(new_error->maj_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") - current_error->maj_id = new_error->maj_id; - if(H5I_inc_ref(new_error->min_id)<0) + current_error->maj_num = new_error->maj_num; + if(H5I_inc_ref(new_error->min_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") - current_error->min_id = new_error->min_id; + current_error->min_num = new_error->min_num; if((current_error->func_name = HDstrdup(new_error->func_name))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") if((current_error->file_name = HDstrdup(new_error->file_name))==NULL) @@ -1270,6 +1373,47 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Epush + * + * Purpose: This function definition is for backward compatibility only. + * It doesn't have error stack and error class as parameters. + * The old definition of major and minor is casted as HID_T + * in H5Epublic.h + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Tuesday, Sep 16, 2003 + * + * Notes: Basically a public API wrapper around the H5E_push function. + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Epush(const char *file, const char *func, unsigned line, + H5E_major_t maj, H5E_minor_t min, const char *str) +{ + H5E_t *estack = NULL; /* Default error stack */ + herr_t ret_value=SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Epush, FAIL) + H5TRACE6("e","ssIuiis",file,func,line,maj,min,str); + + /* Push the error on the stack */ + if(H5E_push(estack, file, func, line, H5E_ERR_CLS_g, maj, min, str)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") + +done: + FUNC_LEAVE_API(ret_value) +} +#else /* H5_WANT_H5_V1_6_COMPAT */ + /*------------------------------------------------------------------------- * Function: H5Epush @@ -1313,7 +1457,6 @@ H5Epush(hid_t err_stack, const char *file, const char *func, unsigned line, FUNC_ENTER_API_NOCLEAR(H5Epush, FAIL) H5TRACE7("e","issIuiis",err_stack,file,func,line,maj_id,min_id,fmt); - /* Need to check for errors */ if(err_stack == H5E_DEFAULT) estack = NULL; else { @@ -1345,6 +1488,7 @@ H5Epush(hid_t err_stack, const char *file, const char *func, unsigned line, done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -1420,10 +1564,10 @@ H5E_push(H5E_t *estack, const char *file, const char *func, unsigned line, estack->slot[estack->nused].cls_id = cls_id; if(H5I_inc_ref(maj_id)<0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].maj_id = maj_id; + estack->slot[estack->nused].maj_num = maj_id; if(H5I_inc_ref(min_id)<0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].min_id = min_id; + estack->slot[estack->nused].min_num = min_id; if((estack->slot[estack->nused].func_name = HDstrdup(func))==NULL) HGOTO_DONE(FAIL) if((estack->slot[estack->nused].file_name = HDstrdup(file))==NULL) @@ -1438,6 +1582,42 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Eclear + * + * Purpose: This function is for backward compatbility. + * Clears the error stack for the specified error stack. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Wednesday, July 16, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eclear(void) +{ + H5E_t *estack = NULL; /* Default error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Eclear, FAIL) + H5TRACE0("e",""); + + /* Clear the error stack */ + if(H5E_clear(estack)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") + +done: + FUNC_LEAVE_API(ret_value) +} +#else + /*------------------------------------------------------------------------- * Function: H5Eclear @@ -1481,6 +1661,7 @@ H5Eclear(hid_t err_stack) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -1517,9 +1698,9 @@ H5E_clear_entries(H5E_t *estack, unsigned nentries) /* Decrement the IDs to indicate that they are no longer used by this stack */ /* (In reverse order that they were incremented, so that reference counts work well) */ - if(H5I_dec_ref(error->min_id)<0) + if(H5I_dec_ref(error->min_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->maj_id)<0) + if(H5I_dec_ref(error->maj_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") if(H5I_dec_ref(error->cls_id)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") @@ -1578,6 +1759,51 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT +/*------------------------------------------------------------------------- + * Function: H5Eprint + * + * Purpose: This function is for backward compatbility. + * Prints the error stack in some default way. This is just a + * convenience function for H5Ewalk() with a function that + * prints error messages. Users are encouraged to write there + * own more specific error handlers. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + * Modifications: + * Albert Cheng, 2000/12/02 + * Show MPI process rank id if applicable. + * Albert Cheng, 2001/07/14 + * Show HDF5 library version information string too. + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eprint(FILE *stream) +{ + H5E_t *estack = NULL; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Eprint, FAIL) + /*NO TRACE*/ + + if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Print error stack */ + if(H5E_print(estack, stream)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") + +done: + FUNC_LEAVE_API(ret_value) +} +#else + /*------------------------------------------------------------------------- * Function: H5Eprint @@ -1635,6 +1861,7 @@ H5Eprint(hid_t err_stack, FILE *stream) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -1692,6 +1919,46 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Ewalk + * + * Purpose: This function is for backward compatbility. + * Walks the error stack for the current thread and calls some + * function for each error along the way. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void *client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Ewalk, FAIL) + /*NO TRACE*/ + + if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Walk the error stack */ + if(H5E_walk (estack, direction, func, client_data)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") + +done: + FUNC_LEAVE_API(ret_value) +} +#else + /*------------------------------------------------------------------------- * Function: H5Ewalk @@ -1742,6 +2009,7 @@ H5Ewalk(hid_t err_stack, H5E_direction_t direction, H5E_walk_t func, void *clien done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -1866,8 +2134,8 @@ H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, void *client_data) else stream = eprint->stream; /* Get descriptions for the major and minor error numbers */ - maj_ptr = H5I_object_verify(err_desc->maj_id, H5I_ERROR_MSG); - min_ptr = H5I_object_verify(err_desc->min_id, H5I_ERROR_MSG); + maj_ptr = H5I_object_verify(err_desc->maj_num, H5I_ERROR_MSG); + min_ptr = H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); assert(maj_ptr && min_ptr); if(maj_ptr->msg) maj_str = maj_ptr->msg; @@ -1919,6 +2187,48 @@ H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, void *client_data) FUNC_LEAVE_NOAPI(SUCCEED) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Eget_auto + * + * Purpose: This function is for backward compatbility. + * Returns the current settings for the automatic error stack + * traversal function and its data for specific error stack. + * Either (or both) arguments may be null in which case the + * value is not returned. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eget_auto(H5E_auto_t *func, void **client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Eget_auto, FAIL) + H5TRACE2("e","*x*x",func,client_data); + + /* Retieve default error stack */ + if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Get the automatic error reporting information */ + if(H5E_get_auto(estack, func, client_data)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") + +done: + FUNC_LEAVE_API(ret_value) +} + +#else /*------------------------------------------------------------------------- * Function: H5Eget_auto @@ -1965,6 +2275,7 @@ H5Eget_auto(hid_t estack_id, H5E_auto_t *func, void **client_data) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -2001,6 +2312,56 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Eset_auto + * + * Purpose: This function is for backward compatbility. + * Turns on or off automatic printing of errors for certain + * error stack. When turned on (non-null FUNC pointer) any + * API function which returns an error indication will first + * call FUNC passing it CLIENT_DATA as an argument. + * + * The default values before this function is called are + * H5Eprint() with client data being the standard error stream, + * stderr. + * + * Automatic stack traversal is always in the H5E_WALK_DOWNWARD + * direction. + * + * See Also: H5Ewalk() + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eset_auto(H5E_auto_t func, void *client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Eset_auto, FAIL) + H5TRACE2("e","xx",func,client_data); + + if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Set the automatic error reporting information */ + if(H5E_set_auto(estack, func, client_data)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") + +done: + FUNC_LEAVE_API(ret_value) +} + +#else /*------------------------------------------------------------------------- * Function: H5Eset_auto @@ -2052,6 +2413,7 @@ H5Eset_auto(hid_t estack_id, H5E_auto_t func, void *client_data) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 5afd5a7..99fccd8 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -36,11 +36,16 @@ typedef enum H5E_type_t { H5E_MINOR } H5E_type_t; +#ifdef H5_WANT_H5_V1_6_COMPAT +typedef hid_t H5E_major_t; +typedef hid_t H5E_minor_t; +#endif /* H5_WANT_H5_V1_6_COMPAT */ + /* Information about an error; element of error stack */ typedef struct H5E_error_t { hid_t cls_id; /*class ID */ - hid_t maj_id; /*major error ID */ - hid_t min_id; /*minor error number */ + hid_t maj_num; /*major error ID */ + hid_t min_num; /*minor error number */ const char *func_name; /*function in which error occurred */ const char *file_name; /*file in which error occurred */ unsigned line; /*line in file where error occurs */ @@ -77,38 +82,68 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; * Warning: don't break, return, or longjmp() from the body of the loop or * the error reporting won't be properly restored! */ +#ifdef H5_WANT_H5_V1_6_COMPAT #define H5E_BEGIN_TRY { \ H5E_auto_t H5E_saved_efunc; \ void *H5E_saved_edata; \ - (void)H5Eget_auto(H5E_DEFAULT, &H5E_saved_efunc, &H5E_saved_edata); \ + (void)H5Eget_auto(&H5E_saved_efunc, &H5E_saved_edata); \ + (void)H5Eset_auto(NULL, NULL); + +#define H5E_END_TRY \ + (void)H5Eset_auto (H5E_saved_efunc, H5E_saved_edata); \ +} +#else /* H5_WANT_H5_V1_6_COMPAT */ +#define H5E_BEGIN_TRY { \ + H5E_auto_t H5E_saved_efunc; \ + void *H5E_saved_edata; \ + (void)H5Eget_auto(H5E_DEFAULT, &H5E_saved_efunc, &H5E_saved_edata); \ (void)H5Eset_auto(H5E_DEFAULT, NULL, NULL); #define H5E_END_TRY \ - (void)H5Eset_auto (H5E_DEFAULT, H5E_saved_efunc, H5E_saved_edata); \ + (void)H5Eset_auto (H5E_DEFAULT, H5E_saved_efunc, H5E_saved_edata); \ } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* * Public API Convenience Macros for Error reporting - Documented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ +#ifdef H5_WANT_H5_V1_6_COMPAT +#define H5Epush_sim(func,cls,maj,min,str) H5Epush(__FILE__,func,__LINE__,maj,min,str) +#else #define H5Epush_sim(func,cls,maj,min,str) H5Epush(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str) +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* * Public API Convenience Macros for Error reporting - Undocumented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And return after pushing error onto stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT +#define H5Epush_ret(func,cls,maj,min,str,ret) { \ + H5Epush(__FILE__,func,__LINE__,maj,min,str); \ + return(ret); \ +} +#else #define H5Epush_ret(func,cls,maj,min,str,ret) { \ H5Epush(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str); \ return(ret); \ } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And goto a label after pushing error onto stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT +#define H5Epush_goto(func,cls,maj,min,str,label) { \ + H5Epush(__FILE__,func,__LINE__,maj,min,str); \ + goto label; \ +} +#else #define H5Epush_goto(func,cls,maj,min,str,label) { \ H5Epush(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str); \ goto label; \ } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Error stack traversal direction */ typedef enum H5E_direction_t { @@ -133,19 +168,31 @@ H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg); H5_DLL hid_t H5Eget_current_stack(void); H5_DLL herr_t H5Eclose_stack(hid_t stack_id); H5_DLL ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size); -H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size); H5_DLL int H5Eget_num(hid_t error_stack_id); H5_DLL herr_t H5Eset_current_stack(hid_t err_stack_id); -H5_DLL herr_t H5Epush(hid_t err_stack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...); H5_DLL herr_t H5Epop(hid_t err_stack, size_t count); -H5_DLL herr_t H5Eclear(hid_t err_stack); +#ifdef H5_WANT_H5_V1_6_COMPAT +H5_DLL herr_t H5Epush(const char *file, const char *func, unsigned line, + H5E_major_t maj, H5E_minor_t min, const char *str); +H5_DLL herr_t H5Eprint(FILE *stream); +H5_DLL herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, + void *client_data); +H5_DLL herr_t H5Eget_auto(H5E_auto_t *func, void **client_data); +H5_DLL herr_t H5Eset_auto(H5E_auto_t func, void *client_data); +H5_DLL herr_t H5Eclear(void); +H5_DLL const char * H5Eget_major(H5E_major_t maj); +H5_DLL const char * H5Eget_minor(H5E_minor_t min); +#else +H5_DLL herr_t H5Epush(hid_t err_stack, const char *file, const char *func, unsigned line, + hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...); H5_DLL herr_t H5Eprint(hid_t err_stack, FILE *stream); H5_DLL herr_t H5Ewalk(hid_t err_stack, H5E_direction_t direction, H5E_walk_t func, void *client_data); H5_DLL herr_t H5Eget_auto(hid_t estack_id, H5E_auto_t *func, void **client_data); H5_DLL herr_t H5Eset_auto(hid_t estack_id, H5E_auto_t func, void *client_data); - +H5_DLL herr_t H5Eclear(hid_t err_stack); +H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size); +#endif /* H5_WANT_H5_V1_6_COMPAT */ #ifdef __cplusplus } #endif diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index d4ada22..d16421e 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -231,7 +231,11 @@ hid_t H5FD_multi_init(void) { /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (H5I_VFL!=H5Iget_type(H5FD_MULTI_g)) { H5FD_MULTI_g = H5FDregister(&H5FD_multi_g); @@ -277,7 +281,11 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Initialize */ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -421,7 +429,11 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check arguments and supply default values */ if(H5I_GENPROP_LST != H5Iget_type(fapl_id) || @@ -522,7 +534,11 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if(H5I_GENPROP_LST != H5Iget_type(fapl_id) || TRUE != H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) @@ -589,7 +605,11 @@ H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl) /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check arguments */ if (TRUE!=H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) @@ -641,7 +661,11 @@ H5Pget_dxpl_multi(hid_t dxpl_id, hid_t *memb_dxpl/*out*/) /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (TRUE!=H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) @@ -688,7 +712,11 @@ H5FD_multi_sb_size(H5FD_t *_file) hsize_t nbytes = 8; /*size of header*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* How many unique files? */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { @@ -746,7 +774,11 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, static const char *func="H5FD_multi_sb_encode"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Name and version number */ strcpy(name, "NCSAmulti"); @@ -830,7 +862,11 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) static const char *func="H5FD_multi_sb_decode"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Make sure the name/version number is correct */ if (strcmp(name, "NCSAmult")) @@ -973,7 +1009,11 @@ H5FD_multi_fapl_get(H5FD_t *_file) H5FD_multi_t *file = (H5FD_multi_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return H5FD_multi_fapl_copy(&(file->fa)); } @@ -1007,7 +1047,11 @@ H5FD_multi_fapl_copy(const void *_old_fa) assert(new_fa); /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t)); for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1058,7 +1102,11 @@ H5FD_multi_fapl_free(void *_fa) static const char *func="H5FD_multi_fapl_free"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { if (fa->memb_fapl[mt]>=0) @@ -1101,7 +1149,11 @@ H5FD_multi_dxpl_copy(const void *_old_dx) assert(new_dx); /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ memcpy(new_dx, old_dx, sizeof(H5FD_multi_dxpl_t)); for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1145,7 +1197,11 @@ H5FD_multi_dxpl_free(void *_dx) static const char *func="H5FD_multi_dxpl_free"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) if (dx->memb_dxpl[mt]>=0) @@ -1185,7 +1241,11 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, static const char *func="H5FD_multi_open"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check arguments */ if (!name || !*name) @@ -1280,7 +1340,11 @@ H5FD_multi_close(H5FD_t *_file) static const char *func="H5FD_multi_close"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Close as many members as possible */ ALL_MEMBERS(mt) { @@ -1346,7 +1410,11 @@ H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2) int cmp=0; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { if (f1->memb[mt] && f2->memb[mt]) break; @@ -1420,7 +1488,11 @@ H5FD_multi_get_eoa(H5FD_t *_file) H5FD_multi_t *file = (H5FD_multi_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return file->eoa; } @@ -1454,7 +1526,11 @@ H5FD_multi_set_eoa(H5FD_t *_file, haddr_t eoa) static const char *func="H5FD_multi_set_eoa"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Find the subfile in which the new EOA value falls */ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1510,7 +1586,11 @@ H5FD_multi_get_eof(H5FD_t *_file) static const char *func="H5FD_multi_eof"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) { @@ -1632,7 +1712,11 @@ H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi H5FD_mem_t mmt; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ mmt = file->fa.memb_map[type]; if (H5FD_MEM_DEFAULT==mmt) mmt = type; @@ -1672,7 +1756,11 @@ H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz haddr_t start_addr=0; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Get the data transfer properties */ if (H5P_FILE_ACCESS_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { @@ -1727,7 +1815,11 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si haddr_t start_addr=0; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Get the data transfer properties */ if (H5P_FILE_ACCESS_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { @@ -1811,7 +1903,11 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) #endif /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Flush each file */ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1849,7 +1945,11 @@ static int compute_next(H5FD_multi_t *file) { /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ ALL_MEMBERS(mt) { file->memb_next[mt] = HADDR_UNDEF; @@ -1896,7 +1996,11 @@ open_members(H5FD_multi_t *file) static const char *func="(H5FD_multi)open_members"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) continue; /*already open*/ diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 20350f1..ea53da9 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -216,7 +216,11 @@ hid_t H5FD_stdio_init(void) { /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (H5I_VFL!=H5Iget_type(H5FD_STDIO_g)) H5FD_STDIO_g = H5FDregister(&H5FD_stdio_g); @@ -249,7 +253,11 @@ H5Pset_fapl_stdio(hid_t fapl_id) /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if(0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) @@ -309,7 +317,11 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, fapl_id=fapl_id; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check arguments */ if (!name || !*name) @@ -397,7 +409,11 @@ H5FD_stdio_close(H5FD_t *_file) static const char *func="H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (fclose(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1) @@ -434,7 +450,11 @@ H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ #ifdef WIN32 if (f1->fileindexhi < f2->fileindexhi) return -1; @@ -524,7 +544,11 @@ H5FD_stdio_get_eoa(H5FD_t *_file) H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return(file->eoa); } @@ -555,7 +579,11 @@ H5FD_stdio_set_eoa(H5FD_t *_file, haddr_t addr) H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ file->eoa = addr; @@ -590,7 +618,11 @@ H5FD_stdio_get_eof(H5FD_t *_file) H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return(MAX(file->eof, file->eoa)); } @@ -620,8 +652,12 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) fapl=fapl; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); - +#endif /* H5_WANT_H5_V1_6_COMPAT */ + *file_handle = &(file->fp); if(*file_handle==NULL) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "get handle failed", -1) @@ -666,7 +702,11 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz dxpl_id=dxpl_id; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check for overflow */ if (HADDR_UNDEF==addr) @@ -764,7 +804,11 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, type=type; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check for overflow conditions */ if (HADDR_UNDEF==addr) @@ -841,7 +885,11 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) dxpl_id=dxpl_id; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Only try to flush the file if we have write access */ if(file->write_access) { |