mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-12 17:31:09 +08:00
[svn-r14230] Description:
Add H5Ecreate_stack() API routine, to fill a minor gap in the error routines. Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.4.10 (amazon) in debug mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
This commit is contained in:
parent
24f2310b12
commit
1f3aede7c7
92
src/H5E.c
92
src/H5E.c
@ -151,6 +151,37 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5E_init() */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Function: H5E_set_default_auto
|
||||
*
|
||||
* Purpose: Initialize "automatic" error stack reporting info to library
|
||||
* default
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Thursday, November 1, 2007
|
||||
*
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5E_set_default_auto(H5E_t *stk)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_set_default_auto)
|
||||
|
||||
#ifdef H5_USE_16_API
|
||||
stk->auto_op.vers = 1;
|
||||
stk->auto_op.u.func1 = (H5E_auto1_t)H5Eprint1;
|
||||
#else /* H5_USE_16_API */
|
||||
stk->auto_op.vers = 2;
|
||||
stk->auto_op.u.func2 = (H5E_auto2_t)H5Eprint2;
|
||||
#endif /* H5_USE_16_API */
|
||||
stk->auto_data = NULL;
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
} /* end H5E_set_default_auto() */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* Function: H5E_init_interface
|
||||
@ -191,14 +222,7 @@ H5E_init_interface(void)
|
||||
|
||||
#ifndef H5_HAVE_THREADSAFE
|
||||
H5E_stack_g[0].nused = 0;
|
||||
#ifdef H5_USE_16_API
|
||||
H5E_stack_g[0].auto_op.vers = 1;
|
||||
H5E_stack_g[0].auto_op.u.func1 = (H5E_auto1_t)H5Eprint1;
|
||||
#else /* H5_USE_16_API */
|
||||
H5E_stack_g[0].auto_op.vers = 2;
|
||||
H5E_stack_g[0].auto_op.u.func2 = (H5E_auto2_t)H5Eprint2;
|
||||
#endif /* H5_USE_16_API */
|
||||
H5E_stack_g[0].auto_data = NULL;
|
||||
H5E_set_default_auto(H5E_stack_g);
|
||||
#endif /* H5_HAVE_THREADSAFE */
|
||||
|
||||
/* Allocate the HDF5 error class */
|
||||
@ -321,14 +345,7 @@ H5E_get_stack(void)
|
||||
|
||||
/* Set the thread-specific info */
|
||||
estack->nused = 0;
|
||||
#ifdef H5_USE_16_API
|
||||
estack->auto_op.vers = 1;
|
||||
estack->auto_op.u.func1 = (H5E_auto1_t)H5Eprint1;
|
||||
#else /* H5_USE_16_API */
|
||||
estack->auto_op.vers = 2;
|
||||
estack->auto_op.u.func2 = (H5E_auto2_t)H5Eprint2;
|
||||
#endif /* H5_USE_16_API */
|
||||
estack->auto_data = NULL;
|
||||
H5E_set_default_auto(estack);
|
||||
|
||||
/* (It's not necessary to release this in this API, it is
|
||||
* released by the "key destructor" set up in the H5TS
|
||||
@ -791,6 +808,43 @@ done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
} /* end H5Eget_msg() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Ecreate_stack
|
||||
*
|
||||
* Purpose: Creates a new, empty, error stack.
|
||||
*
|
||||
* Return: Non-negative value as stack ID on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Thursday, November 1, 2007
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hid_t
|
||||
H5Ecreate_stack(void)
|
||||
{
|
||||
H5E_t *stk; /* Error stack */
|
||||
hid_t ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_API(H5Ecreate_stack, FAIL)
|
||||
H5TRACE0("i","");
|
||||
|
||||
/* Allocate a new error stack */
|
||||
if(NULL == (stk = H5FL_CALLOC(H5E_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
||||
|
||||
/* Set the "automatic" error reporting info to the library default */
|
||||
H5E_set_default_auto(stk);
|
||||
|
||||
/* Register the stack */
|
||||
if((ret_value = H5I_register(H5I_ERROR_STACK, stk)) < 0)
|
||||
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't create error stack")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_API(ret_value)
|
||||
} /* end H5Ecreate_stack() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Eget_current_stack
|
||||
@ -855,7 +909,7 @@ H5E_get_current_stack(void)
|
||||
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get current error stack")
|
||||
|
||||
/* Allocate a new error stack */
|
||||
if(NULL == (estack_copy = H5FL_MALLOC(H5E_t)))
|
||||
if(NULL == (estack_copy = H5FL_CALLOC(H5E_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
|
||||
/* Make a copy of current error stack */
|
||||
@ -886,6 +940,10 @@ H5E_get_current_stack(void)
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
} /* end for */
|
||||
|
||||
/* Copy the "automatic" error reporting information */
|
||||
estack_copy->auto_op = current_stack->auto_op;
|
||||
estack_copy->auto_data = current_stack->auto_data;
|
||||
|
||||
/* Empty current error stack */
|
||||
H5E_clear_stack(current_stack);
|
||||
|
||||
|
@ -159,6 +159,7 @@ H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name,
|
||||
H5_DLL herr_t H5Eunregister_class(hid_t class_id);
|
||||
H5_DLL herr_t H5Eclose_msg(hid_t err_id);
|
||||
H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg);
|
||||
H5_DLL hid_t H5Ecreate_stack(void);
|
||||
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);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* Programmer: Raymond Lu
|
||||
* October 14, 2001
|
||||
*
|
||||
* Purpose: Tests the H5Tget_native_type function.
|
||||
* Purpose: Tests the error API routines.
|
||||
*/
|
||||
#include "h5test.h"
|
||||
|
||||
@ -452,6 +452,58 @@ error:
|
||||
return -1;
|
||||
} /* end custom_print_cb() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_create
|
||||
*
|
||||
* Purpose: Test creating an empty error stack
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* November 1, 2007
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
test_create(void)
|
||||
{
|
||||
const char *err_func = "test_create"; /* Function name for pushing error */
|
||||
const char *err_msg = "Error message"; /* Error message for pushing error */
|
||||
int err_num; /* Number of errors on stack */
|
||||
hid_t estack_id; /* Error stack ID */
|
||||
|
||||
/* Create an empty error stack */
|
||||
if((estack_id = H5Ecreate_stack()) < 0) TEST_ERROR
|
||||
|
||||
/* Check the number of errors on stack */
|
||||
err_num = H5Eget_num(estack_id);
|
||||
if(err_num != 0) TEST_ERROR
|
||||
|
||||
/* Push an error with a long description */
|
||||
if(H5Epush(estack_id, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, err_msg) < 0) TEST_ERROR;
|
||||
|
||||
/* Check the number of errors on stack */
|
||||
err_num = H5Eget_num(estack_id);
|
||||
if(err_num != 1) TEST_ERROR
|
||||
|
||||
/* Clear the error stack */
|
||||
if(H5Eclear2(estack_id) < 0) TEST_ERROR
|
||||
|
||||
/* Check the number of errors on stack */
|
||||
err_num = H5Eget_num(estack_id);
|
||||
if(err_num != 0) TEST_ERROR
|
||||
|
||||
/* Close error stack */
|
||||
if(H5Eclose_stack(estack_id) < 0) TEST_ERROR
|
||||
|
||||
return(0);
|
||||
|
||||
error:
|
||||
return(-1);
|
||||
} /* end test_create() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: close_error
|
||||
@ -551,6 +603,9 @@ main(void)
|
||||
/* Test pushing a very long error description */
|
||||
if(test_long_desc() < 0) TEST_ERROR;
|
||||
|
||||
/* Test creating a new error stack */
|
||||
if(test_create() < 0) TEST_ERROR;
|
||||
|
||||
if(H5Fclose(file) < 0) TEST_ERROR;
|
||||
h5_cleanup(FILENAME, fapl);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user