summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-11-01 19:27:15 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-11-01 19:27:15 (GMT)
commit1f3aede7c7adb1a12efb839a15c8cf3a1bce8f1c (patch)
tree1f652a1f70bf984c56553e7fea01535136fd9ce2 /src
parent24f2310b1284c569ea277be00f57248bfd306378 (diff)
downloadhdf5-1f3aede7c7adb1a12efb839a15c8cf3a1bce8f1c.zip
hdf5-1f3aede7c7adb1a12efb839a15c8cf3a1bce8f1c.tar.gz
hdf5-1f3aede7c7adb1a12efb839a15c8cf3a1bce8f1c.tar.bz2
[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
Diffstat (limited to 'src')
-rw-r--r--src/H5E.c92
-rw-r--r--src/H5Epublic.h1
2 files changed, 76 insertions, 17 deletions
diff --git a/src/H5E.c b/src/H5E.c
index 6e553c6..72f0619 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -153,6 +153,37 @@ done:
/*--------------------------------------------------------------------------
+ * 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
*
* Purpose: Initialize interface-specific information
@@ -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
@@ -793,6 +810,43 @@ done:
/*-------------------------------------------------------------------------
+ * 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
*
* Purpose: Registers current error stack, returns object handle for it,
@@ -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);
diff --git a/src/H5Epublic.h b/src/H5Epublic.h
index 7b716ef..b0e93bb 100644
--- a/src/H5Epublic.h
+++ b/src/H5Epublic.h
@@ -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);