summaryrefslogtreecommitdiffstats
path: root/src/H5Eprivate.h
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2003-07-23 03:13:27 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2003-07-23 03:13:27 (GMT)
commit4b0fa0dbf06a93c7cb7c62a374019543ffa70fe6 (patch)
tree308f7e073432340fa18ab5faa4a8e234170284e7 /src/H5Eprivate.h
parent49e9863714840caa2e60d8caa12c6144b5b182f9 (diff)
downloadhdf5-4b0fa0dbf06a93c7cb7c62a374019543ffa70fe6.zip
hdf5-4b0fa0dbf06a93c7cb7c62a374019543ffa70fe6.tar.gz
hdf5-4b0fa0dbf06a93c7cb7c62a374019543ffa70fe6.tar.bz2
[svn-r7256] Purpose: gradual checkin for error api
Platforms tested: RH 8(simple checkin)
Diffstat (limited to 'src/H5Eprivate.h')
-rw-r--r--src/H5Eprivate.h277
1 files changed, 159 insertions, 118 deletions
diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h
index d4ce7e5..5d58fe1 100644
--- a/src/H5Eprivate.h
+++ b/src/H5Eprivate.h
@@ -44,7 +44,7 @@ typedef struct H5E_msg_t {
/* Printing information */
typedef struct H5E_print_t {
FILE *stream;
- H5E_cls_t *cls;
+ H5E_cls_t cls;
} H5E_print_t;
/*H5_DLLVAR herr_t (*H5E_auto_g_new)(hid_t estack, void *client_data);
@@ -59,165 +59,197 @@ typedef struct H5E_t_new {
void *auto_data;
} H5E_t_new;
-#ifdef TMP
+/* HDF5 error class */
+/*#define H5E_ERR_CLS (H5OPEN H5E_ERR_CLS_g)*/
+H5_DLLVAR hid_t H5E_ERR_CLS_g;
+
/* HDF5 error class */
#define H5E_CLS_NAME "HDF5"
#define H5E_CLS_LIB_NAME "HDF5"
#define H5E_CLS_LIB_VERS "" /* How to find out version number? */
/* HDF5 error class: major errors */
-#define H5E_NONE_MAJOR_MSG "No error"
-#define H5E_MAJ_ARGS_MSG "Function arguments"
-#define H5E_MAJ_RESOURCE_MSG "Resource unavailable"
-#define H5E_MAJ_INTERNAL_MSG "Internal HDF5 error"
-#define H5E_MAJ_FILE_MSG "File interface"
-#define H5E_MAJ_IO_MSG "Low-level I/O layer"
-#define H5E_MAJ_FUNC_MSG "Function entry/exit"
-#define H5E_MAJ_ATOM_MSG "Atom layer"
-#define H5E_MAJ_CACHE_MSG "Meta data cache layer"
-#define H5E_MAJ_BTREE_MSG "B-tree layer"
-#define H5E_MAJ_SYM_MSG "Symbol table layer"
-#define H5E_MAJ_HEAP_MSG "Heap layer"
-#define H5E_MAJ_OHDR_MSG "Object header layer"
-#define H5E_MAJ_DATATYPE_MSG "Datatype interface"
-#define H5E_MAJ_DATASPACE_MSG "Dataspace interface"
-#define H5E_MAJ_DATASET_MSG "Dataset interface"
-#define H5E_MAJ_STORAGE_MSG "Data storage layer"
-#define H5E_MAJ_PLIST_MSG "Property list interface"
-#define H5E_MAJ_ATTR_MSG "Attribute layer"
-#define H5E_MAJ_PLINE_MSG "Data filters layer"
-#define H5E_MAJ_EFL_MSG "External file list"
-#define H5E_MAJ_REFERENCE_MSG "References layer"
-#define H5E_MAJ_VFL_MSG "Virtual File Layer"
-#define H5E_MAJ_TBBT_MSG "Threaded, Balanced, Binary Trees"
-#define H5E_MAJ_FPHDF5_MSG "Flexible Parallel HDF5"
-#define H5E_MAJ_TST_MSG "Ternary Search Trees"
-#define H5E_MAJ_RS_MSG "Reference Counted Strings"
-#define H5E_MAJ_ERROR_MSG "Error API"
+#define H5E_NONE_MAJOR_MSG_new "No error"
+#define H5E_MAJ_ARGS_MSG_new "Function arguments"
+#define H5E_MAJ_RESOURCE_MSG_new "Resource unavailable"
+#define H5E_MAJ_INTERNAL_MSG_new "Internal HDF5 error"
+#define H5E_MAJ_FILE_MSG_new "File interface"
+#define H5E_MAJ_IO_MSG_new "Low-level I/O layer"
+#define H5E_MAJ_FUNC_MSG_new "Function entry/exit"
+#define H5E_MAJ_ATOM_MSG_new "Atom layer"
+#define H5E_MAJ_CACHE_MSG_new "Meta data cache layer"
+#define H5E_MAJ_BTREE_MSG_new "B-tree layer"
+#define H5E_MAJ_SYM_MSG_new "Symbol table layer"
+#define H5E_MAJ_HEAP_MSG_new "Heap layer"
+#define H5E_MAJ_OHDR_MSG_new "Object header layer"
+#define H5E_MAJ_DATATYPE_MSG_new "Datatype interface"
+#define H5E_MAJ_DATASPACE_MSG_new "Dataspace interface"
+#define H5E_MAJ_DATASET_MSG_new "Dataset interface"
+#define H5E_MAJ_STORAGE_MSG_new "Data storage layer"
+#define H5E_MAJ_PLIST_MSG_new "Property list interface"
+#define H5E_MAJ_ATTR_MSG_new "Attribute layer"
+#define H5E_MAJ_PLINE_MSG_new "Data filters layer"
+#define H5E_MAJ_EFL_MSG_new "External file list"
+#define H5E_MAJ_REFERENCE_MSG_new "References layer"
+#define H5E_MAJ_VFL_MSG_new "Virtual File Layer"
+#define H5E_MAJ_TBBT_MSG_new "Threaded, Balanced, Binary Trees"
+#define H5E_MAJ_FPHDF5_MSG_new "Flexible Parallel HDF5"
+#define H5E_MAJ_TST_MSG_new "Ternary Search Trees"
+#define H5E_MAJ_RS_MSG_new "Reference Counted Strings"
+#define H5E_MAJ_ERROR_MSG_new "Error API"
/* HDF5 error class: minor errors */
-#define H5E_NONE_MINOR "No error"
-
/* Argument errors */
-#define H5E_MIN_UNINITIALIZED_MSG "Information is uninitialized"
-#define H5E_MIN_UNSUPPORTED_MSG "Feature is unsupported"
-#define H5E_MIN_BADTYPE_MSG "Inappropriate type"
-#define H5E_MIN_BADRANGE_MSG "Out of range"
-#define H5E_MIN_BADVALUE_MSG "Bad value"
+#define H5E_NONE_MINOR_MSG_new "No error"
+#define H5E_MIN_UNINITIALIZED_MSG_new "Information is uninitialized"
+#define H5E_MIN_UNSUPPORTED_MSG_new "Feature is unsupported"
+#define H5E_MIN_BADTYPE_MSG_new "Inappropriate type"
+#define H5E_MIN_BADRANGE_MSG_new "Out of range"
+#define H5E_MIN_BADVALUE_MSG_new "Bad value"
/* Resource errors */
-#define H5E_MIN_NOSPACE_MSG "No space available for allocation"
-#define H5E_MIN_CANTCOPY_MSG "Unable to copy object"
-#define H5E_MIN_CANTFREE_MSG "Unable to free object"
-#define H5E_MIN_ALREADYEXISTS_MSG "Object already exists"
-#define H5E_MIN_CANTLOCK_MSG "Unable to lock object"
-#define H5E_MIN_CANTUNLOCK_MSG "Unable to unlock object"
-#define H5E_MIN_CANTGC_MSG "Unable to garbage collect"
+#define H5E_MIN_NOSPACE_MSG_new "No space available for allocation"
+#define H5E_MIN_CANTCOPY_MSG_new "Unable to copy object"
+#define H5E_MIN_CANTFREE_MSG_new "Unable to free object"
+#define H5E_MIN_ALREADYEXISTS_MSG_new "Object already exists"
+#define H5E_MIN_CANTLOCK_MSG_new "Unable to lock object"
+#define H5E_MIN_CANTUNLOCK_MSG_new "Unable to unlock object"
+#define H5E_MIN_CANTGC_MSG_new "Unable to garbage collect"
/* File accessability errors */
-#define H5E_MIN_FILEEXISTS_MSG "File already exists"
-#define H5E_MIN_FILEOPEN_MSG "File already open"
-#define H5E_MIN_CANTCREATE_MSG "Unable to create file"
-#define H5E_MIN_CANTOPENFILE_MSG "Unable to open file"
-#define H5E_MIN_CANTCLOSEFILE_MSG "Unable to close file"
-#define H5E_MIN_NOTHDF5_MSG "Not an HDF5 file"
-#define H5E_MIN_BADFILE_MSG "Bad file ID accessed"
-#define H5E_MIN_TRUNCATED_MSG "File has been truncated"
-#define H5E_MIN_MOUNT_MSG "File mount error"
+#define H5E_MIN_FILEEXISTS_MSG_new "File already exists"
+#define H5E_MIN_FILEOPEN_MSG_new "File already open"
+#define H5E_MIN_CANTCREATE_MSG_new "Unable to create file"
+#define H5E_MIN_CANTOPENFILE_MSG_new "Unable to open file"
+#define H5E_MIN_CANTCLOSEFILE_MSG_new "Unable to close file"
+#define H5E_MIN_NOTHDF5_MSG_new "Not an HDF5 file"
+#define H5E_MIN_BADFILE_MSG_new "Bad file ID accessed"
+#define H5E_MIN_TRUNCATED_MSG_new "File has been truncated"
+#define H5E_MIN_MOUNT_MSG_new "File mount error"
/* Generic low-level file I/O errors */
-#define H5E_MIN_SEEKERROR_MSG "Seek failed"
-#define H5E_MIN_READERROR_MSG "Read failed"
-#define H5E_MIN_WRITEERROR_MSG "Write failed"
-#define H5E_MIN_CLOSEERROR_MSG "Close failed"
-#define H5E_MIN_OVERFLOW_MSG "Address overflowed"
-#define H5E_MIN_FCNTL_MSG "File control (fcntl) failed"
+#define H5E_MIN_SEEKERROR_MSG_new "Seek failed"
+#define H5E_MIN_READERROR_MSG_new "Read failed"
+#define H5E_MIN_WRITEERROR_MSG_new "Write failed"
+#define H5E_MIN_CLOSEERROR_MSG_new "Close failed"
+#define H5E_MIN_OVERFLOW_MSG_new "Address overflowed"
+#define H5E_MIN_FCNTL_MSG_new "File control (fcntl) failed"
/* Function entry/exit interface errors */
-#define H5E_MIN_CANTINIT_MSG "Unable to initialize object"
-#define H5E_MIN_ALREADYINIT_MSG "Object already initialized"
-#define H5E_MIN_CANTRELEASE_MSG "Unable to release object"
+#define H5E_MIN_CANTINIT_MSG_new "Unable to initialize object"
+#define H5E_MIN_ALREADYINIT_MSG_new "Object already initialized"
+#define H5E_MIN_CANTRELEASE_MSG_new "Unable to release object"
/* Object atom related errors */
-#define H5E_MIN_BADATOM_MSG "Unable to find atom information (already closed?)"
-#define H5E_MIN_BADGROUP_MSG "Unable to find ID group information"
-#define H5E_MIN_CANTREGISTER_MSG "Unable to register new atom"
-#define H5E_MIN_CANTINC_MSG "Unable to increment reference count"
-#define H5E_MIN_CANTDEC_MSG "Unable to decrement reference count"
-#define H5E_MIN_NOIDS_MSG "Out of IDs for group"
+#define H5E_MIN_BADATOM_MSG_new "Unable to find atom information (already closed?)"
+#define H5E_MIN_BADGROUP_MSG_new "Unable to find ID group information"
+#define H5E_MIN_CANTREGISTER_MSG_new "Unable to register new atom"
+#define H5E_MIN_CANTINC_MSG_new "Unable to increment reference count"
+#define H5E_MIN_CANTDEC_MSG_new "Unable to decrement reference count"
+#define H5E_MIN_NOIDS_MSG_new "Out of IDs for group"
/* Cache related errors */
-#define H5E_MIN_CANTFLUSH_MSG "Unable to flush data from cache"
-#define H5E_MIN_CANTLOAD_MSG "Unable to load meta data into cache"
-#define H5E_MIN_PROTECT_MSG "Protected meta data error"
-#define H5E_MIN_NOTCACHED_MSG "Meta data not currently cached"
+#define H5E_MIN_CANTFLUSH_MSG_new "Unable to flush data from cache"
+#define H5E_MIN_CANTLOAD_MSG_new "Unable to load meta data into cache"
+#define H5E_MIN_PROTECT_MSG_new "Protected meta data error"
+#define H5E_MIN_NOTCACHED_MSG_new "Meta data not currently cached"
/* B-tree related errors */
-#define H5E_MIN_NOTFOUND_MSG "Object not found"
-#define H5E_MIN_EXISTS_MSG "Object already exists"
-#define H5E_MIN_CANTENCODE_MSG "Unable to encode value"
-#define H5E_MIN_CANTDECODE_MSG "Unable to decode value"
-#define H5E_MIN_CANTSPLIT_MSG "Unable to split node"
-#define H5E_MIN_CANTINSERT_MSG "Unable to insert object"
-#define H5E_MIN_CANTLIST_MSG "Unable to list node"
+#define H5E_MIN_NOTFOUND_MSG_new "Object not found"
+#define H5E_MIN_EXISTS_MSG_new "Object already exists"
+#define H5E_MIN_CANTENCODE_MSG_new "Unable to encode value"
+#define H5E_MIN_CANTDECODE_MSG_new "Unable to decode value"
+#define H5E_MIN_CANTSPLIT_MSG_new "Unable to split node"
+#define H5E_MIN_CANTINSERT_MSG_new "Unable to insert object"
+#define H5E_MIN_CANTLIST_MSG_new "Unable to list node"
/* Object header related errors */
-#define H5E_MIN_LINKCOUNT_MSG "Bad object header link count"
-#define H5E_MIN_VERSION_MSG "Wrong version number"
-#define H5E_MIN_ALIGNMENT_MSG "Alignment error"
-#define H5E_MIN_BADMESG_MSG "Unrecognized message"
-#define H5E_MIN_CANTDELETE_MSG "Can't delete message"
+#define H5E_MIN_LINKCOUNT_MSG_new "Bad object header link count"
+#define H5E_MIN_VERSION_MSG_new "Wrong version number"
+#define H5E_MIN_ALIGNMENT_MSG_new "Alignment error"
+#define H5E_MIN_BADMESG_MSG_new "Unrecognized message"
+#define H5E_MIN_CANTDELETE_MSG_new "Can't delete message"
/* Group related errors */
-#define H5E_MIN_CANTOPENOBJ_MSG "Can't open object"
-#define H5E_MIN_COMPLEN_MSG "Name component is too long"
-#define H5E_MIN_CWG_MSG "Problem with current working group"
-#define H5E_MIN_LINK_MSG "Link count failure"
-#define H5E_MIN_SLINK_MSG "Symbolic link error"
+#define H5E_MIN_CANTOPENOBJ_MSG_new "Can't open object"
+#define H5E_MIN_COMPLEN_MSG_new "Name component is too long"
+#define H5E_MIN_CWG_MSG_new "Problem with current working group"
+#define H5E_MIN_LINK_MSG_new "Link count failure"
+#define H5E_MIN_SLINK_MSG_new "Symbolic link error"
/* Datatype conversion errors */
-#define H5E_MIN_CANTCONVERT_MSG "Can't convert datatypes"
-#define H5E_MIN_BADSIZE_MSG "Bad size for object"
+#define H5E_MIN_CANTCONVERT_MSG_new "Can't convert datatypes"
+#define H5E_MIN_BADSIZE_MSG_new "Bad size for object"
/* Dataspace errors */
-#define H5E_MIN_CANTCLIP_MSG "Can't clip hyperslab region"
-#define H5E_MIN_CANTCOUNT_MSG "Can't count elements"
-#define H5E_MIN_CANTSELECT_MSG "Can't select hyperslab"
-#define H5E_MIN_CANTNEXT_MSG "Can't move to next iterator location"
-#define H5E_MIN_BADSELECT_MSG "Invalid selection"
-#define H5E_MIN_CANTCOMPARE_MSG "Can't compare objects"
+#define H5E_MIN_CANTCLIP_MSG_new "Can't clip hyperslab region"
+#define H5E_MIN_CANTCOUNT_MSG_new "Can't count elements"
+#define H5E_MIN_CANTSELECT_MSG_new "Can't select hyperslab"
+#define H5E_MIN_CANTNEXT_MSG_new "Can't move to next iterator location"
+#define H5E_MIN_BADSELECT_MSG_new "Invalid selection"
+#define H5E_MIN_CANTCOMPARE_MSG_new "Can't compare objects"
/* Property list errors */
-#define H5E_MIN_CANTGET_MSG "Can't get value"
-#define H5E_MIN_CANTSET_MSG "Can't set value"
-#define H5E_MIN_DUPCLASS_MSG "Duplicate class name in parent class"
+#define H5E_MIN_CANTGET_MSG_new "Can't get value"
+#define H5E_MIN_CANTSET_MSG_new "Can't set value"
+#define H5E_MIN_DUPCLASS_MSG_new "Duplicate class name in parent class"
/* Parallel MPI errors */
-#define H5E_MIN_MPI_MSG "Some MPI function failed"
-#define H5E_MIN_MPIERRSTR_MSG "MPI Error String"
+#define H5E_MIN_MPI_MSG_new "Some MPI function failed"
+#define H5E_MIN_MPIERRSTR_MSG_new "MPI Error String"
/* FPHDF5 errors */
-#define H5E_MIN_CANTMAKETREE_MSG "Can't create a binary tree node"
-#define H5E_MIN_CANTRECV_MSG "Can't receive messages from processes"
-#define H5E_MIN_CANTSENDMDATA_MSG "Can't send metadata message"
-#define H5E_MIN_CANTCHANGE_MSG "Can't register change with server"
-#define H5E_MIN_CANTALLOC_MSG "Can't allocate from file"
+#define H5E_MIN_CANTMAKETREE_MSG_new "Can't create a binary tree node"
+#define H5E_MIN_CANTRECV_MSG_new "Can't receive messages from processes"
+#define H5E_MIN_CANTSENDMDATA_MSG_new "Can't send metadata message"
+#define H5E_MIN_CANTCHANGE_MSG_new "Can't register change with server"
+#define H5E_MIN_CANTALLOC_MSG_new "Can't allocate from file"
/* I/O pipeline errors */
-#define H5E_MIN_NOFILTER_MSG "Requested filter is not available"
-#define H5E_MIN_CALLBACK_MSG "Callback failed"
-#define H5E_MIN_CANAPPLY_MSG "Error from filter \"can apply\" callback"
-#define H5E_MIN_SETLOCAL_MSG "Error from filter \"set local\" callback"
-#endif /* TMP */
+#define H5E_MIN_NOFILTER_MSG_new "Requested filter is not available"
+#define H5E_MIN_CALLBACK_MSG_new "Callback failed"
+#define H5E_MIN_CANAPPLY_MSG_new "Error from filter \"can apply\" callback"
+#define H5E_MIN_SETLOCAL_MSG_new "Error from filter \"set local\" callback"
#endif /* NEW_ERR */
+#ifndef NEW_ERR
+#ifdef H5_HAVE_THREADSAFE
+/*
+ * The per-thread error stack. pthread_once() initializes a special
+ * key that will be used by all threads to create a stack specific to
+ * each thread individually. The association of stacks to threads will
+ * be handled by the pthread library.
+ *
+ * In order for this macro to work, H5E_get_my_stack() must be preceeded
+ * by "H5E_t *estack =".
+ */
+#define H5E_get_my_stack_new() H5E_get_stack_new()
+#else /* H5_HAVE_THREADSAFE */
+/*
+ * The current error stack. Eventually we'll have some sort of global table
+ * so each thread has it's own stack. The stacks will be created on demand
+ * when the thread first calls H5E_push(). */
+H5E_t_new H5E_stack_g_new[1];
+#define H5E_get_my_stack_new() (H5E_stack_g_new+0)
+#endif /* H5_HAVE_THREADSAFE */
+#endif /* NEW_ERR */
+
+
/*
* HERROR macro, used to facilitate error reporting between a FUNC_ENTER()
* 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.
*/
#ifdef NEW_ERR
-#define HERROR(maj, min, str) H5E_push_new(H5E_DEFAULT, __FILE__, FUNC, __LINE__, maj, min, str)
+#define HERROR(maj_id, min_id, str) { \
+ H5E_msg_t *maj_ptr, *min_ptr; \
+ hid_t cls_id; \
+ maj_ptr = H5I_object_verify(maj_id, H5I_ERROR_MSG); \
+ min_ptr = H5I_object_verify(min_id, H5I_ERROR_MSG); \
+ /*check error: cls of maj and min should be same*/ \
+ cls_id = H5I_register(H5I_ERROR_CLASS, maj_ptr->cls); \
+ H5E_push_new(H5E_DEFAULT, __FILE__, FUNC, __LINE__, cls_id, maj_id, min_id, str); \
+}
#else
#define HERROR(maj, min, str) H5E_push(maj, min, FUNC, __FILE__, __LINE__, str)
#endif /* NEW_ERR */
@@ -226,10 +258,18 @@ typedef struct H5E_t_new {
* HCOMMON_ERROR macro, used by HDONE_ERROR and HGOTO_ERROR
* (Shouldn't need to be used outside this header file)
*/
+#ifdef NEW_ERR
+#define HCOMMON_ERROR(maj, min, str) \
+ H5E_t_new *estack = H5E_get_my_stack_new(); \
+ HERROR (maj, min, str); \
+ if (H5_IS_API(FUNC) && estack->auto_data) \
+ (void)((estack->func)(H5E_DEFAULT, estack->auto_data))
+#else
#define HCOMMON_ERROR(maj, min, str) \
HERROR (maj, min, str); \
if (H5_IS_API(FUNC) && H5E_auto_g) \
(void)((H5E_auto_g)(H5E_auto_data_g))
+#endif /* NEW_ERR */
/*
* HDONE_ERROR macro, used to facilitate error reporting between a
@@ -297,13 +337,14 @@ H5_DLL herr_t H5E_walk (H5E_direction_t dir, H5E_walk_t func,
#ifndef NEW_ERR
/* New error API */
-H5_DLL hid_t H5E_register_class(const char *cls_name, const char *lib_name,
+H5E_t_new * H5E_get_stack_new(void);
+H5_DLL hid_t H5E_register_class(const char *cls_name, const char *lib_name,
const char *version);
H5_DLL herr_t H5E_unregister_class(H5E_cls_t *cls);
-H5_DLL herr_t H5E_close_msg(H5E_msg_t *err);
-H5_DLL hid_t H5E_create_msg(hid_t cls_id, H5E_type_t msg_type, const char *msg);
-H5_DLL hid_t H5E_get_current_stack(void);
-H5_DLL herr_t H5E_close_stack(H5E_t_new *err_stack);
+H5_DLL herr_t H5E_close_msg(H5E_msg_t *err);
+H5_DLL hid_t H5E_create_msg(hid_t cls_id, H5E_type_t msg_type, const char *msg);
+H5_DLL hid_t H5E_get_current_stack(void);
+H5_DLL herr_t H5E_close_stack(H5E_t_new *err_stack);
H5_DLL ssize_t H5E_get_class_name(H5E_cls_t *cls, char *name, size_t size);
H5_DLL ssize_t H5E_get_msg(H5E_msg_t *msg_ptr, H5E_type_t *type, char *msg, size_t size);
H5_DLL int H5E_get_num(H5E_t_new *err_stack);