From eb3e9ccd8ac3e1a69d0f9bc2c9e9f1c2b5108f21 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 8 Sep 2004 21:37:02 -0500 Subject: [PATCH] [svn-r9234] Purpose: Code cleanup Description: Tweak recent "forward compatibility" changes to the H5E* API (which allowed for the old H5E API functions to remain unchanged) by allowing for the error stack callback function (H5E_auto_t) to also remain unchanged from the 1.6 branch. This required changing the H5E{get|set}_auto routines to have the old style H5E_auto_t type (which didn't have a stack ID parameter) and the new H5E{get|set}_auto_stack routines to have a newer "H5E_auto_stack_t" type (which has a stack ID parameter). This should make the H5E API changes as forwardly compatible as possible. One side-affect of this change was that it was impossible to determine if the current auto error callback was the old style (H5E_auto_t) or the new style (H5E_auto_stack_t) of callback, so a new API function (H5Eauto_is_stack) was adde to query this. Platforms tested: FreeBSD 4.10 (sleipnir) IRIX64 6.5 (modi4) h5committest --- c++/src/H5Exception.cpp | 4 +- c++/src/H5Exception.h | 4 +- src/H5.c | 2 +- src/H5E.c | 94 +++++++++++++++++++++------ src/H5Eprivate.h | 6 +- src/H5Epublic.h | 37 ++++++++--- src/H5MPprivate.h | 1 + src/H5Tnative.c | 137 ++++++++++++++++++++-------------------- test/error_test.c | 4 +- test/ttsafe_error.c | 38 +---------- testpar/testphdf5.c | 2 +- testpar/testphdf5.h | 2 +- tools/h5dump/h5dump.c | 2 +- tools/h5jam/h5jam.c | 2 +- tools/h5jam/h5unjam.c | 2 +- tools/h5jam/tellub.c | 2 +- 16 files changed, 192 insertions(+), 147 deletions(-) diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 2ea07c3ea6..d89f4867b0 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -109,7 +109,7 @@ string Exception::getMinorString( hid_t err_minor ) const /// handlers // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::setAutoPrint( H5E_auto_t& func, void* client_data ) +void Exception::setAutoPrint( H5E_auto_stack_t& func, void* client_data ) { // calls the C API routine H5Eset_auto to set the auto printing to // the specified function. @@ -142,7 +142,7 @@ void Exception::dontPrint() /// the error function // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::getAutoPrint( H5E_auto_t& func, void** client_data ) +void Exception::getAutoPrint( H5E_auto_stack_t& func, void** client_data ) { // calls the C API routine H5Eget_auto to get the current setting of // the automatic error printing diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index c67ca3fbca..4a5bf3771d 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -46,14 +46,14 @@ class H5_DLLCPP Exception { const char* getCFuncName() const; // function name as a char string // Turns on the automatic error printing. - static void setAutoPrint( H5E_auto_t& func, void* client_data); + static void setAutoPrint( H5E_auto_stack_t& func, void* client_data); // Turns off the automatic error printing. static void dontPrint(); // Retrieves the current settings for the automatic error stack // traversal function and its data. - static void getAutoPrint( H5E_auto_t& func, void** client_data); + static void getAutoPrint( H5E_auto_stack_t& func, void** client_data); // Clears the error stack for the current thread. static void clearErrorStack(); diff --git a/src/H5.c b/src/H5.c index 4078883b81..2e01b58d76 100644 --- a/src/H5.c +++ b/src/H5.c @@ -181,7 +181,7 @@ H5_term_library(void) int pending, ntries=0, n; unsigned at=0; char loop[1024]; - H5E_auto_t func; + H5E_auto_stack_t func; #ifdef H5_HAVE_THREADSAFE /* explicit locking of the API */ diff --git a/src/H5E.c b/src/H5E.c index 36d105f377..db718f36c7 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -113,8 +113,8 @@ static herr_t H5E_print_stack(const H5E_t *estack, FILE *stream); static herr_t H5E_walk_stack(const H5E_t *estack, H5E_direction_t direction, H5E_walk_t func, void *client_data); static herr_t H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, void *client_data); -static herr_t H5E_get_auto_stack(const H5E_t *estack, H5E_auto_t *func, void **client_data); -static herr_t H5E_set_auto_stack(H5E_t *estack, H5E_auto_t func, void *client_data); +static herr_t H5E_get_auto_stack(const H5E_t *estack, hbool_t new_api, void **func, void **client_data); +static herr_t H5E_set_auto_stack(H5E_t *estack, hbool_t new_api, void *func, void *client_data); /*------------------------------------------------------------------------- @@ -183,9 +183,11 @@ H5E_init_interface(void) #ifndef H5_HAVE_THREADSAFE H5E_stack_g[0].nused = 0; #ifdef H5_WANT_H5_V1_6_COMPAT - H5E_stack_g[0].func = (H5E_auto_t)H5Eprint; + H5E_stack_g[0].new_api = FALSE; + H5E_stack_g[0].u.func = (H5E_auto_t)H5Eprint; #else /*H5_WANT_H5_V1_6_COMPAT*/ - H5E_stack_g[0].func = (H5E_auto_t)H5Eprint_stack; + H5E_stack_g[0].new_api = TRUE; + H5E_stack_g[0].u.func_stack = (H5E_auto_stack_t)H5Eprint_stack; #endif /*H5_WANT_H5_V1_6_COMPAT*/ H5E_stack_g[0].auto_data = NULL; #endif /* H5_HAVE_THREADSAFE */ @@ -310,7 +312,8 @@ H5E_get_stack(void) /* no associated value with current thread - create one */ estack = (H5E_t *)H5MM_malloc(sizeof(H5E_t)); estack->nused = 0; - estack->func = (H5E_auto_t)H5Eprint_stack; + estack->new_api = TRUE; + estack->u.func_stack = (H5E_auto_stack_t)H5Eprint_stack; estack->auto_data = NULL; pthread_setspecific(H5TS_errstk_key_g, (void *)estack); } @@ -2240,12 +2243,12 @@ H5Eget_auto(H5E_auto_t *func, void **client_data) FUNC_ENTER_API(H5Eget_auto, FAIL) H5TRACE2("e","*xx",func,client_data); - /* Retieve default error stack */ + /* Retrieve 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_stack(estack, func, client_data)<0) + if(H5E_get_auto_stack(estack, FALSE, (void **)func, client_data)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") done: @@ -2275,7 +2278,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Eget_auto_stack(hid_t estack_id, H5E_auto_t *func, void **client_data) +H5Eget_auto_stack(hid_t estack_id, H5E_auto_stack_t *func, void **client_data) { H5E_t *estack; /* Error stack to operate on */ herr_t ret_value=SUCCEED; /* Return value */ @@ -2292,7 +2295,7 @@ H5Eget_auto_stack(hid_t estack_id, H5E_auto_t *func, void **client_data) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Get the automatic error reporting information */ - if(H5E_get_auto_stack(estack, func, client_data)<0) + if(H5E_get_auto_stack(estack, TRUE, (void **)func, client_data)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") done: @@ -2318,7 +2321,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5E_get_auto_stack(const H5E_t *estack, H5E_auto_t *func, void **client_data) +H5E_get_auto_stack(const H5E_t *estack, hbool_t new_api, void * *func, void **client_data) { herr_t ret_value=SUCCEED; /* Return value */ @@ -2327,7 +2330,8 @@ H5E_get_auto_stack(const H5E_t *estack, H5E_auto_t *func, void **client_data) assert (estack); /* Retrieve the requested information */ - if(func) *func = estack->func; + if(func) + *func = new_api ? (void *)estack->u.func_stack : (void *)estack->u.func; if(client_data) *client_data = estack->auto_data; done: @@ -2375,7 +2379,7 @@ H5Eset_auto(H5E_auto_t func, void *client_data) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Set the automatic error reporting information */ - if(H5E_set_auto_stack(estack, func, client_data)<0) + if(H5E_set_auto_stack(estack, FALSE, (void *)func, client_data)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") done: @@ -2410,7 +2414,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Eset_auto_stack(hid_t estack_id, H5E_auto_t func, void *client_data) +H5Eset_auto_stack(hid_t estack_id, H5E_auto_stack_t func, void *client_data) { H5E_t *estack; /* Error stack to operate on */ herr_t ret_value=SUCCEED; /* Return value */ @@ -2427,7 +2431,7 @@ H5Eset_auto_stack(hid_t estack_id, H5E_auto_t func, void *client_data) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Set the automatic error reporting information */ - if(H5E_set_auto_stack(estack, func, client_data)<0) + if(H5E_set_auto_stack(estack, TRUE, (void *)func, client_data)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") done: @@ -2463,7 +2467,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5E_set_auto_stack(H5E_t *estack, H5E_auto_t func, void *client_data) +H5E_set_auto_stack(H5E_t *estack, hbool_t new_api, void *func, void *client_data) { herr_t ret_value=SUCCEED; /* Return value */ @@ -2472,7 +2476,11 @@ H5E_set_auto_stack(H5E_t *estack, H5E_auto_t func, void *client_data) assert(estack); /* Set the automatic error reporting info */ - estack->func = func; + estack->new_api = new_api; + if(new_api) + estack->u.func_stack = (H5E_auto_stack_t)func; + else + estack->u.func = (H5E_auto_t)func; estack->auto_data = client_data; done: @@ -2508,10 +2516,60 @@ H5E_dump_api_stack(int is_api) H5E_t *estack = H5E_get_my_stack(); assert(estack); - if (estack->func) - (void)((estack->func)(H5E_DEFAULT, estack->auto_data)); + if(estack->new_api) { + if (estack->u.func_stack) + (void)((estack->u.func_stack)(H5E_DEFAULT, estack->auto_data)); + } /* end if */ + else { + if (estack->u.func) + (void)((estack->u.func)(estack->auto_data)); + } /* end else */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } + + +/*------------------------------------------------------------------------- + * Function: H5Eauto_is_stack + * + * Purpose: Determines if the error auto reporting function for an + * error stack conforms to the H5E_auto_stack_t typedef + * or the H5E_auto_t typedef. The IS_STACK parameter is set + * to 1 for the first case and 0 for the latter case. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, September 8, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eauto_is_stack(hid_t estack_id, unsigned *is_stack) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Eauto_is_stack, FAIL) + H5TRACE2("e","ix",estack_id,is_stack); + + if(estack_id == H5E_DEFAULT) { + 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") + } /* end if */ + else + if((estack = H5I_object_verify(estack_id, H5I_ERROR_STACK))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + + /* Check if the error stack reporting function is the "newer" stack type */ + if(is_stack) + *is_stack=estack->new_api; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eauto_is_stack() */ + diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 4dbb670386..9c5744f11a 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -44,7 +44,11 @@ typedef struct H5E_msg_t { typedef struct H5E_t { size_t nused; /* Num slots currently used in stack */ H5E_error_t slot[H5E_NSLOTS]; /* Array of error records */ - H5E_auto_t func; /* Function for 'automatic' error reporting */ + hbool_t new_api; /* Indicate that the function pointer is for the new (stack) API or the old */ + union { + H5E_auto_t func; /* Function for 'automatic' error reporting */ + H5E_auto_stack_t func_stack; /* Function for 'automatic' error reporting */ + } u; void *auto_data; /* Callback data for 'automatic error reporting */ } H5E_t; diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 247767c80a..d5581dd1b2 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -85,13 +85,28 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; * purpose. */ #define H5E_BEGIN_TRY { \ - H5E_auto_t H5E_saved_efunc; \ + unsigned H5E_saved_is_stack; \ + union { \ + H5E_auto_stack_t stack_efunc; \ + H5E_auto_t efunc; \ + } H5E_saved; \ void *H5E_saved_edata; \ - (void)H5Eget_auto_stack(H5E_DEFAULT, &H5E_saved_efunc, &H5E_saved_edata); \ - (void)H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + \ + (void)H5Eauto_is_stack(H5E_DEFAULT, &H5E_saved_is_stack); \ + if(H5E_saved_is_stack) { \ + (void)H5Eget_auto_stack(H5E_DEFAULT, &H5E_saved.stack_efunc, &H5E_saved_edata); \ + (void)H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); \ + } else { \ + (void)H5Eget_auto(&H5E_saved.efunc, &H5E_saved_edata); \ + (void)H5Eset_auto(NULL, NULL); \ + } #define H5E_END_TRY \ - (void)H5Eset_auto_stack(H5E_DEFAULT, H5E_saved_efunc, H5E_saved_edata); \ + if(H5E_saved_is_stack) { \ + (void)H5Eset_auto_stack(H5E_DEFAULT, H5E_saved.stack_efunc, H5E_saved_edata); \ + } else { \ + (void)H5Eset_auto(H5E_saved.efunc, H5E_saved_edata); \ + } \ } /* @@ -131,7 +146,8 @@ extern "C" { /* Error stack traversal callback function pointers */ typedef herr_t (*H5E_walk_t)(unsigned n, const H5E_error_t *err_desc, void *client_data); -typedef herr_t (*H5E_auto_t)(hid_t estack, void *client_data); +typedef herr_t (*H5E_auto_t)(void *client_data); +typedef herr_t (*H5E_auto_stack_t)(hid_t estack, void *client_data); /* Public API functions */ H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version); @@ -142,9 +158,10 @@ 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 H5Epop(hid_t err_stack, size_t count); +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 H5Epop(hid_t err_stack, size_t count); +H5_DLL herr_t H5Eauto_is_stack(hid_t err_stack, unsigned *is_stack); /* These old APIs are kept for backward compatibility. They don't have * the error stack in the parameters. */ @@ -166,8 +183,8 @@ H5_DLL herr_t H5Epush_stack(hid_t err_stack, const char *file, const char *func H5_DLL herr_t H5Eprint_stack(hid_t err_stack, FILE *stream); H5_DLL herr_t H5Ewalk_stack(hid_t err_stack, H5E_direction_t direction, H5E_walk_t func, void *client_data); -H5_DLL herr_t H5Eget_auto_stack(hid_t estack_id, H5E_auto_t *func, void **client_data); -H5_DLL herr_t H5Eset_auto_stack(hid_t estack_id, H5E_auto_t func, void *client_data); +H5_DLL herr_t H5Eget_auto_stack(hid_t estack_id, H5E_auto_stack_t *func, void **client_data); +H5_DLL herr_t H5Eset_auto_stack(hid_t estack_id, H5E_auto_stack_t func, void *client_data); H5_DLL herr_t H5Eclear_stack(hid_t err_stack); #ifdef __cplusplus } diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h index 401d40718d..24e7c45889 100644 --- a/src/H5MPprivate.h +++ b/src/H5MPprivate.h @@ -121,6 +121,7 @@ #define color_H5Eunregister_class "red" #define color_H5Ewalk "red" #define color_H5Ewalk_stack "red" +#define color_H5Eauto_is_stack "red" #define color_H5Fis_hdf5 "red" #define color_H5Fcreate "red" diff --git a/src/H5Tnative.c b/src/H5Tnative.c index aeba729c40..9ae0be73e6 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -535,71 +535,70 @@ H5T_get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, FUNC_ENTER_NOAPI(H5T_get_native_integer, NULL); - if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) - { - if(prec<=H5Tget_precision(H5T_NATIVE_SCHAR)) { - match=H5T_NATIVE_INT_MATCH_CHAR; - native_size = sizeof(char); - } else if(prec<=H5Tget_precision(H5T_NATIVE_SHORT)) { - match=H5T_NATIVE_INT_MATCH_SHORT; - native_size = sizeof(short); - } else if(prec<=H5Tget_precision(H5T_NATIVE_INT)) { - match=H5T_NATIVE_INT_MATCH_INT; - native_size = sizeof(int); - } else if(prec<=H5Tget_precision(H5T_NATIVE_LONG)) { - match=H5T_NATIVE_INT_MATCH_LONG; - native_size = sizeof(long); - } else if(prec<=H5Tget_precision(H5T_NATIVE_LLONG)) { - match=H5T_NATIVE_INT_MATCH_LLONG; - native_size = sizeof(long_long); - } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ - match=H5T_NATIVE_INT_MATCH_LLONG; - native_size = sizeof(long_long); - } - } else if(direction == H5T_DIR_DESCEND) { - if(prec>=H5Tget_precision(H5T_NATIVE_LLONG)) { - match=H5T_NATIVE_INT_MATCH_LLONG; - native_size = sizeof(long_long); - } else if(prec>=H5Tget_precision(H5T_NATIVE_LONG)) { - if(prec==H5Tget_precision(H5T_NATIVE_LONG)) { - match=H5T_NATIVE_INT_MATCH_LONG; - native_size = sizeof(long); - } else { - match=H5T_NATIVE_INT_MATCH_LLONG; - native_size = sizeof(long_long); - } - } - else if(prec>=H5Tget_precision(H5T_NATIVE_INT)) { - if(prec==H5Tget_precision(H5T_NATIVE_INT)) { - match=H5T_NATIVE_INT_MATCH_INT; - native_size = sizeof(int); - } else { - match=H5T_NATIVE_INT_MATCH_LONG; - native_size = sizeof(long); - } - } - else if(prec>=H5Tget_precision(H5T_NATIVE_SHORT)) { - if(prec==H5Tget_precision(H5T_NATIVE_SHORT)) { - match=H5T_NATIVE_INT_MATCH_SHORT; - native_size = sizeof(short); - } else { - match=H5T_NATIVE_INT_MATCH_INT; - native_size = sizeof(int); - } - } - else if(prec>=H5Tget_precision(H5T_NATIVE_SCHAR)) { - if(prec==H5Tget_precision(H5T_NATIVE_SCHAR)) { - match=H5T_NATIVE_INT_MATCH_CHAR; - native_size = sizeof(char); - } else { - match=H5T_NATIVE_INT_MATCH_SHORT; - native_size = sizeof(short); - } - } - else { /* If no native type matches the querried datatype, simple choose the type of smallest size. */ - match=H5T_NATIVE_INT_MATCH_CHAR; - native_size = sizeof(char); - } + if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { + if(prec<=H5Tget_precision(H5T_NATIVE_SCHAR)) { + match=H5T_NATIVE_INT_MATCH_CHAR; + native_size = sizeof(char); + } else if(prec<=H5Tget_precision(H5T_NATIVE_SHORT)) { + match=H5T_NATIVE_INT_MATCH_SHORT; + native_size = sizeof(short); + } else if(prec<=H5Tget_precision(H5T_NATIVE_INT)) { + match=H5T_NATIVE_INT_MATCH_INT; + native_size = sizeof(int); + } else if(prec<=H5Tget_precision(H5T_NATIVE_LONG)) { + match=H5T_NATIVE_INT_MATCH_LONG; + native_size = sizeof(long); + } else if(prec<=H5Tget_precision(H5T_NATIVE_LLONG)) { + match=H5T_NATIVE_INT_MATCH_LLONG; + native_size = sizeof(long_long); + } else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */ + match=H5T_NATIVE_INT_MATCH_LLONG; + native_size = sizeof(long_long); + } + } else if(direction == H5T_DIR_DESCEND) { + if(prec>=H5Tget_precision(H5T_NATIVE_LLONG)) { + match=H5T_NATIVE_INT_MATCH_LLONG; + native_size = sizeof(long_long); + } else if(prec>=H5Tget_precision(H5T_NATIVE_LONG)) { + if(prec==H5Tget_precision(H5T_NATIVE_LONG)) { + match=H5T_NATIVE_INT_MATCH_LONG; + native_size = sizeof(long); + } else { + match=H5T_NATIVE_INT_MATCH_LLONG; + native_size = sizeof(long_long); + } + } + else if(prec>=H5Tget_precision(H5T_NATIVE_INT)) { + if(prec==H5Tget_precision(H5T_NATIVE_INT)) { + match=H5T_NATIVE_INT_MATCH_INT; + native_size = sizeof(int); + } else { + match=H5T_NATIVE_INT_MATCH_LONG; + native_size = sizeof(long); + } + } + else if(prec>=H5Tget_precision(H5T_NATIVE_SHORT)) { + if(prec==H5Tget_precision(H5T_NATIVE_SHORT)) { + match=H5T_NATIVE_INT_MATCH_SHORT; + native_size = sizeof(short); + } else { + match=H5T_NATIVE_INT_MATCH_INT; + native_size = sizeof(int); + } + } + else if(prec>=H5Tget_precision(H5T_NATIVE_SCHAR)) { + if(prec==H5Tget_precision(H5T_NATIVE_SCHAR)) { + match=H5T_NATIVE_INT_MATCH_CHAR; + native_size = sizeof(char); + } else { + match=H5T_NATIVE_INT_MATCH_SHORT; + native_size = sizeof(short); + } + } + else { /* If no native type matches the queried datatype, simply choose the type of smallest size. */ + match=H5T_NATIVE_INT_MATCH_CHAR; + native_size = sizeof(char); + } } /* Set the appropriate native datatype information */ @@ -656,17 +655,17 @@ H5T_get_native_integer(size_t prec, H5T_sign_t sign, H5T_direction_t direction, /* Create new native type */ assert(tid>=0); if(NULL==(dt=H5I_object(tid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") if((ret_value=H5T_copy(dt, H5T_COPY_TRANSIENT))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot copy type") /* compute size and offset of compound type member. */ if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } diff --git a/test/error_test.c b/test/error_test.c index bd5ee2c93d..d99f05a2bc 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -101,7 +101,7 @@ test_error(hid_t file) hid_t estack_id; hsize_t dims[2]; const char *FUNC_test_error="test_error"; - H5E_auto_t old_func; + H5E_auto_stack_t old_func; void *old_data; TESTING("error API based on data I/O"); @@ -129,7 +129,7 @@ test_error(hid_t file) TEST_ERROR; if (old_data != NULL) TEST_ERROR; - if (old_func != (H5E_auto_t)H5Eprint_stack) + if (old_func != (H5E_auto_stack_t)H5Eprint_stack) TEST_ERROR; if(H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL)<0) diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index 7e5eb6440e..62d7277fae 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -54,13 +54,8 @@ #define EXPECTED_ERROR_DEPTH 8 #define WRITE_NUMBER 37 -#ifdef H5_WANT_H5_V1_6_COMPAT static herr_t error_callback(void *); -static herr_t walk_error_callback(int, H5E_error_t *, void *); -#else /*H5_WANT_H5_V1_6_COMPAT*/ -static herr_t error_callback(hid_t, void *); static herr_t walk_error_callback(unsigned, const H5E_error_t *, void *); -#endif /* H5_WANT_H5_V1_6_COMPAT */ static void *tts_error_thread(void *); /* Global variables */ @@ -154,23 +149,15 @@ void *tts_error_thread(void UNUSED *arg) { hid_t dataspace, datatype, dataset; hsize_t dimsf[1]; /* dataset dimensions */ - H5E_auto_t old_error_cb; + H5E_auto_stack_t old_error_cb; void *old_error_client_data; int value; -#ifdef H5_WANT_H5_V1_6_COMPAT - /* preserve previous error stack handler */ - H5Eget_auto(&old_error_cb, &old_error_client_data); - - /* set each thread's error stack handler */ - H5Eset_auto(error_callback, NULL); -#else /*H5_WANT_H5_V1_6_COMPAT*/ /* preserve previous error stack handler */ H5Eget_auto_stack(H5E_DEFAULT, &old_error_cb, &old_error_client_data); /* set each thread's error stack handler */ - H5Eset_auto_stack(H5E_DEFAULT, error_callback, NULL); -#endif /* H5_WANT_H5_V1_6_COMPAT */ + H5Eset_auto(error_callback, NULL); /* define dataspace for dataset */ dimsf[0] = 1; @@ -192,16 +179,11 @@ void *tts_error_thread(void UNUSED *arg) H5Sclose(dataspace); /* turn our error stack handler off */ -#ifdef H5_WANT_H5_V1_6_COMPAT - H5Eset_auto(old_error_cb, old_error_client_data); -#else /*H5_WANT_H5_V1_6_COMPAT*/ H5Eset_auto_stack(H5E_DEFAULT, old_error_cb, old_error_client_data); -#endif /* H5_WANT_H5_V1_6_COMPAT */ return NULL; } -#ifdef H5_WANT_H5_V1_6_COMPAT static herr_t error_callback(void *client_data) { @@ -210,25 +192,9 @@ herr_t error_callback(void *client_data) pthread_mutex_unlock(&error_mutex); return H5Ewalk(H5E_WALK_DOWNWARD, walk_error_callback, client_data); } -#else /*H5_WANT_H5_V1_6_COMPAT*/ -static -herr_t error_callback(hid_t estack, void *client_data) -{ - pthread_mutex_lock(&error_mutex); - error_count++; - pthread_mutex_unlock(&error_mutex); - return H5Ewalk_stack(estack, H5E_WALK_DOWNWARD, walk_error_callback, client_data); -} -#endif /* H5_WANT_H5_V1_6_COMPAT */ - -#ifdef H5_WANT_H5_V1_6_COMPAT -static -herr_t walk_error_callback(int n, H5E_error_t *err_desc, void UNUSED *client_data) -#else /* H5_WANT_H5_V1_6_COMPAT */ static herr_t walk_error_callback(unsigned n, const H5E_error_t *err_desc, void UNUSED *client_data) -#endif /* H5_WANT_H5_V1_6_COMPAT */ { hid_t maj_num, min_num; diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index 62562126c2..793a9b8d5b 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -33,7 +33,7 @@ int ngroups = 512; /* number of groups to create in root * group. */ int facc_type = FACC_MPIO; /*Test file access type */ -H5E_auto_t old_func; /* previous error handler */ +H5E_auto_stack_t old_func; /* previous error handler */ void *old_client_data; /* previous error handler arg.*/ /* other option flags */ diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h index 6bc1d5a153..deb236bc35 100644 --- a/testpar/testphdf5.h +++ b/testpar/testphdf5.h @@ -142,7 +142,7 @@ typedef int DATATYPE; extern int dim0, dim1; /*Dataset dimensions */ extern int chunkdim0, chunkdim1; /*Chunk dimensions */ extern int nerrors; /*errors count */ -extern H5E_auto_t old_func; /* previous error handler */ +extern H5E_auto_stack_t old_func; /* previous error handler */ extern void *old_client_data; /*previous error handler arg.*/ extern int facc_type; /*Test file access type */ diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 5d12db3850..e370478fb3 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -3369,7 +3369,7 @@ main(int argc, const char *argv[]) hid_t fid, gid; const char *fname = NULL; void *edata; - H5E_auto_t func; + H5E_auto_stack_t func; find_objs_t info; struct handler_t *hand; int i; diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index cc64bd3bf3..d78e28c2b4 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -159,7 +159,7 @@ main (int argc, const char *argv[]) int h5fid; int ofid; void *edata; - H5E_auto_t func; + H5E_auto_stack_t func; hid_t ifile; hid_t plist; herr_t status; diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c index 36a8d80d97..20378e5b15 100644 --- a/tools/h5jam/h5unjam.c +++ b/tools/h5jam/h5unjam.c @@ -161,7 +161,7 @@ main(int argc, const char *argv[]) int ufid; int h5fid; void *edata; - H5E_auto_t func; + H5E_auto_stack_t func; hid_t ifile; off_t fsize; hsize_t usize; diff --git a/tools/h5jam/tellub.c b/tools/h5jam/tellub.c index 2bb457d135..ab88f4d957 100644 --- a/tools/h5jam/tellub.c +++ b/tools/h5jam/tellub.c @@ -127,7 +127,7 @@ main (int argc, const char *argv[]) { char *ifname; void *edata; - H5E_auto_t func; + H5E_auto_stack_t func; hid_t ifile; hsize_t usize; htri_t testval;