summaryrefslogtreecommitdiffstats
path: root/src/H5Eprivate.h
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-02-28 18:19:05 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-02-28 18:19:05 (GMT)
commit808a5e6be1b7f1025c6b1182e160cefbce0f8e68 (patch)
tree59eabaf3e7991d5791b83dbaa0d5797fc5e44ae9 /src/H5Eprivate.h
parent0b4d32bb4a12fe0e34026c0f069aa99bf34cd834 (diff)
downloadhdf5-808a5e6be1b7f1025c6b1182e160cefbce0f8e68.zip
hdf5-808a5e6be1b7f1025c6b1182e160cefbce0f8e68.tar.gz
hdf5-808a5e6be1b7f1025c6b1182e160cefbce0f8e68.tar.bz2
[svn-r302] Changes since 19980227
---------------------- ./html/Errors.html [NEW] ./html/H5.user.html ./MANIFEST Documents the new error handling interface and gives examples. ./src/H5.c ./src/H5private.h ./src/H5Apublic.h ./src/H5E.c ./src/H5Eprivate.h ./src/H5Epublic.h Rewrote error handling. Got rid of `push' overloading and added a few API functions. The error stack is statically allocated and not entered into H5A, simplifying error handling within the error handler. Rudimentary support for threads. Changed the names of some errors. ./src/H5G.c ./src/H5Gnode.c ./src/H5H.c ./src/H5O.c ./src/H5T.c Changed H5ECLEAR to H5E_clear(). ./src/Makefile.in Alphabetized source list. ./test/dsets.c Turned off error reporting around functions that are expected to fail. Error messages are sent to stdout. ./test/testhdf5.c ./test/testhdf5.h Turned off automatic error reporting since this file mostly calls internal functions and does its own error reporting.
Diffstat (limited to 'src/H5Eprivate.h')
-rw-r--r--src/H5Eprivate.h169
1 files changed, 75 insertions, 94 deletions
diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h
index 8b59828..885ad44 100644
--- a/src/H5Eprivate.h
+++ b/src/H5Eprivate.h
@@ -1,13 +1,13 @@
/****************************************************************************
- * NCSA HDF *
- * Software Development Group *
- * National Center for Supercomputing Applications *
- * University of Illinois at Urbana-Champaign *
- * 605 E. Springfield, Champaign IL 61820 *
- * *
- * For conditions of distribution and use, see the accompanying *
- * hdf/COPYING file. *
- * *
+ * NCSA HDF *
+ * Software Development Group *
+ * National Center for Supercomputing Applications *
+ * University of Illinois at Urbana-Champaign *
+ * 605 E. Springfield, Champaign IL 61820 *
+ * *
+ * For conditions of distribution and use, see the accompanying *
+ * hdf/COPYING file. *
+ * *
****************************************************************************/
/*
@@ -21,113 +21,94 @@
/* Private headers needed by this file */
#include <H5private.h>
-/*
- ======================================================================
- Error codes
+#define H5E_NSLOTS 32 /*number of slots in an error stack */
- NOTE: Remember to update the error_messages[] structure later in this file
- whenever errors are added/deleted from this list.
- ======================================================================
+/*
+ * 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.
*/
+#define HERROR(maj, min, str) H5E_push(maj, min, FUNC, __FILE__, __LINE__, str)
-/* HERROR macro, used to facilitate error reporting. Assumes that
- there's a variable called FUNC which holds the function name.
- Assume that func and file are both stored in static space, or at
- least be not corrupted in the meanwhile. */
-#define HERROR(maj, min, str) H5Epush (H5E_thrdid_g, maj, min, \
- FUNC, __FILE__, __LINE__, str)
-
-/* HRETURN_ERROR macro, used to facilitate error reporting. Makes
- same assumptions as HERROR. IN ADDITION, this macro causes
- a return from the calling routine */
-#define HRETURN_ERROR(maj, min, ret_val, str) { \
- HERROR (maj, min, str); \
- PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \
- return (ret_val); \
+/*
+ * HRETURN_ERROR 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, a return value, and a
+ * description of the error.
+ */
+#define HRETURN_ERROR(maj, min, ret_val, str) { \
+ HERROR (maj, min, str); \
+ if (H5_IS_API(FUNC) && H5E_auto_g) { \
+ (H5E_auto_g)(H5E_auto_data_g); \
+ } \
+ PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \
+ return (ret_val); \
}
-/* HRETURN macro, similar to HRETURN_ERROR() except for success */
-#define HRETURN(ret_val) { \
- PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \
- return (ret_val); \
+/*
+ * HRETURN macro, used to facilitate returning from a function between a
+ * FUNC_ENTER() and a FUNC_LEAVE() within a function body. The argument is
+ * the return value.
+ */
+#define HRETURN(ret_val) { \
+ PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \
+ return (ret_val); \
}
-/* HGOTO_ERROR macro, used to facilitate error reporting. Makes
- same assumptions as HERROR. IN ADDITION, this macro causes
- a jump to the label 'done' which should be in every fucntion
- Also there is an assumption of a variable 'ret_value' */
-#define HGOTO_ERROR(maj, min, ret_val, str) { \
- HERROR (maj, min, str); \
- ret_value = ret_val; \
- goto done; \
+/*
+ * HGOTO_ERROR 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, the return value, and an
+ * error string. The return value is assigned to a variable `ret_value' and
+ * control branches to the `done' label.
+ */
+#define HGOTO_ERROR(maj, min, ret_val, str) { \
+ HERROR (maj, min, str); \
+ if (H5_IS_API(FUNC) && H5E_auto_g) { \
+ (H5E_auto_g)(H5E_auto_data_g); \
+ } \
+ ret_value = ret_val; \
+ goto done; \
}
-/* HGOTO_DONE macro, used to facilitate the new error reporting model.
- This macro is just a wrapper to set the return value and jump to the 'done'
- label. Also assumption of a variable 'ret_value' */
+/*
+ * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER()
+ * and a FUNC_LEAVE() within a function body. The argument is the return
+ * value which is assigned to the `ret_value' variable. Control branches to
+ * the `done' label.
+ */
#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;}
-/* H5ECLEAR macro, used to facilitate the new error reporting model.
- This macro is just a wrapper to clear the error stack with the thread
- error ID */
-#define H5ECLEAR H5Eclear(H5E_thrdid_g)
-
-/* Maximum length of function name to push onto error stack */
-#define MAX_FUNC_NAME 32
-
/*
- * error_messages is the list of error messages in the system, kept as
- * error_code-message pairs.
+ * The list of error messages in the system is kept as an array of
+ * error_code/message pairs, one for major error numbers and another for
+ * minor error numbers.
*/
typedef struct H5E_major_mesg_t {
H5E_major_t error_code;
- const char *str;
+ const char *str;
} H5E_major_mesg_t;
typedef struct H5E_minor_mesg_t {
H5E_minor_t error_code;
- const char *str;
+ const char *str;
} H5E_minor_mesg_t;
-/* Function pointer to report errors through */
-struct H5E_t; /*forward decl */
-typedef herr_t (*H5E_push_t)(struct H5E_t *estack, H5E_major_t maj_num,
- H5E_minor_t min_num, const char *function_name,
- const char *file_name, intn line,
- const char *desc);
-
-/*
- * We use a stack to hold the errors plus we keep track of the function, file
- * and line where the error occurs.
- */
-
-/* the structure of the error stack element */
-typedef struct H5E_error_t {
- H5E_major_t maj_num; /*major error number */
- H5E_minor_t min_num; /*minor error number */
- char func_name[MAX_FUNC_NAME]; /*function where error occur */
- const char *file_name; /*file where error occur */
- intn line; /*line in file where error occurs */
- char *desc; /*optional supplied description */
-} H5E_error_t;
-
-/* Structure to store error information for a thread */
+/* An error stack */
typedef struct H5E_t {
- uintn nelmts; /*num elements allocated in the stack */
- uintn top; /*index of the next open stack element */
- H5E_error_t *stack; /*pointer to the error stack */
- H5E_push_t push; /*func that pushes new error on stack */
+ uintn nused; /*num slots currently used in stack */
+ H5E_error_t slot[H5E_NSLOTS]; /*array of error records */
} H5E_t;
-/* Private global variables in H5E.c */
-extern hid_t H5E_thrdid_g; /* Thread-specific "global" error-handler ID */
-extern hbool_t install_atexit; /* Whether to install the atexit routine */
-extern const hbool_t H5E_clearable_g; /* Safe to call H5Eclear() on enter?*/
-
-herr_t H5E_close (H5E_t *estack);
-herr_t H5E_clear (H5E_t *estack);
-herr_t H5E_print (H5E_t *estack, FILE * file);
-herr_t H5E_push (H5E_t *estack, H5E_major_t maj_num, H5E_minor_t min_num,
- const char *function_name, const char *file_name, intn line,
- const char *desc);
+extern const hbool_t H5E_clearable_g; /*safe to call H5E_clear() on enter? */
+extern herr_t (*H5E_auto_g)(void *client_data);
+extern void *H5E_auto_data_g;
+
+herr_t H5E_push (H5E_major_t maj_num, H5E_minor_t min_num,
+ const char *func_name, const char *file_name, unsigned line,
+ const char *desc);
+herr_t H5E_clear (void);
+herr_t H5E_walk (H5E_direction_t dir, H5E_walk_t func, void *client_data);
+
+
#endif