summaryrefslogtreecommitdiffstats
path: root/src/H5private.h
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-05-29 15:07:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-05-29 15:07:55 (GMT)
commite69e970a1c71621c39a5f5fa656a185948ed1df8 (patch)
tree6d62761aa80d47e1713786bdeadabed02cc3c8f0 /src/H5private.h
parent0ba943194ec2c8b74bbfd6531ee7a9b110803974 (diff)
downloadhdf5-e69e970a1c71621c39a5f5fa656a185948ed1df8.zip
hdf5-e69e970a1c71621c39a5f5fa656a185948ed1df8.tar.gz
hdf5-e69e970a1c71621c39a5f5fa656a185948ed1df8.tar.bz2
[svn-r5471] Purpose:
Code cleanup Description: Broke the FUNC_ENTER macro into several macros, with more specialized uses (which followup mail will describe). This was designed to move most/all of the checks which could be done at compile time to that point, instead of needlessly performing them (over & over :-) at run-time. This reduces the library's size (and thus staticly linked binaries) and has a minor speedup effect also. Platforms tested: IRIX64 6.5 (modi4) with parallel & FORTRAN enabled, and additional testing on FreeBSD and Solaris immediately after the checkin.
Diffstat (limited to 'src/H5private.h')
-rw-r--r--src/H5private.h69
1 files changed, 51 insertions, 18 deletions
diff --git a/src/H5private.h b/src/H5private.h
index a849fe0..a7ad701 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -958,6 +958,10 @@ __DLL__ void H5_trace(hbool_t returning, const char *func, const char *type,
*
* Robb Matzke, 17 Jun 1998
* Added auto variable RTYPE which is initialized by the tracing macros.
+ *
+ * Quincey Koziol, 28 May 2002
+ * Split FUNC_ENTER macro into FUNC_ENTER_API, FUNC_ENTER_NOAPI and
+ * FUNC_ENTER_NOINIT.
*-------------------------------------------------------------------------
*/
@@ -1033,11 +1037,14 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */
#endif /* H5_HAVE_THREADSAFE */
-#define FUNC_ENTER_COMMON(func_name) \
+#define FUNC_ENTER_COMMON(func_name,asrt) \
CONSTR (FUNC, #func_name); \
PABLO_SAVE (ID_ ## func_name) \
H5TRACE_DECL; \
\
+ /* Check API status */ \
+ assert(asrt); \
+ \
/* Start tracing */ \
PABLO_TRACE_ON (PABLO_MASK, pablo_func_id); \
\
@@ -1048,21 +1055,54 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */
H5_API_UNSET_CANCEL \
H5_API_LOCK
-#define FUNC_ENTER(func_name,err) { \
- FUNC_ENTER_COMMON(func_name); \
- FUNC_ENTER_API_INIT(func_name,INTERFACE_INIT,err)
+/* Use this macro for all "normal" API functions */
+#define FUNC_ENTER_API(func_name,err) { \
+ FUNC_ENTER_COMMON(func_name,H5_IS_API(FUNC)); \
+ FUNC_ENTER_API_COMMON(func_name,INTERFACE_INIT,err) \
+ \
+ /* Clear thread error stack entering public functions */ \
+ H5E_clear(); \
+ {
+
+/*
+ * Use this macro for API functions that shouldn't clear the error stack
+ * like H5Eprint and H5Ewalk.
+ */
+#define FUNC_ENTER_API_NOCLEAR(func_name,err) { \
+ FUNC_ENTER_COMMON(func_name,H5_IS_API(FUNC)); \
+ FUNC_ENTER_API_COMMON(func_name,INTERFACE_INIT,err) \
+ {
+/*
+ * Use this macro for API functions that shouldn't perform _any_ initialization
+ * of the library or an interface, just perform tracing, etc. Examples
+ * are: H5close, H5check_version, H5Eget_major, H5Eget_minor.
+ */
+#define FUNC_ENTER_API_NOINIT(func_name) { \
+ FUNC_ENTER_COMMON(func_name,H5_IS_API(FUNC)); \
+ {
+
+/* Use this macro for all "normal" non-API functions */
#define FUNC_ENTER_NOAPI(func_name,err) { \
- FUNC_ENTER_COMMON(func_name); \
- FUNC_ENTER_NOAPI_INIT(func_name,INTERFACE_INIT,err)
+ FUNC_ENTER_COMMON(func_name,!H5_IS_API(FUNC)); \
+ FUNC_ENTER_NOAPI_INIT(func_name,INTERFACE_INIT,err) \
+ {
+/*
+ * Use this macro for non-API functions which fall into two categories:
+ * - static functions, since they must be called from a function in the
+ * interface, the library and interface must already be
+ * initialized.
+ * - functions which are called during library shutdown, since we don't
+ * want to re-initialize the library.
+ */
#define FUNC_ENTER_NOINIT(func_name) { \
- FUNC_ENTER_COMMON(func_name); \
+ FUNC_ENTER_COMMON(func_name,!H5_IS_API(FUNC)); \
{
-#define FUNC_ENTER_API_INIT(func_name,interface_init_func,err) \
+#define FUNC_ENTER_API_COMMON(func_name,interface_init_func,err) \
/* Initialize the library */ \
- if (H5_IS_API(FUNC) && !(H5_INIT_GLOBAL)) { \
+ if (!(H5_INIT_GLOBAL)) { \
H5_INIT_GLOBAL = TRUE; \
if (H5_init_library()<0) { \
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
@@ -1079,13 +1119,7 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"interface initialization failed"); \
} \
- } \
- \
- /* Clear thread error stack entering public functions */ \
- if (H5_IS_API(FUNC) && H5E_clearable_g) { \
- H5E_clear (); \
- } \
- {
+ }
#define FUNC_ENTER_NOAPI_INIT(func_name,interface_init_func,err) \
/* Initialize this interface or bust */ \
@@ -1097,8 +1131,7 @@ extern hbool_t H5_libinit_g; /* Has the library been initialized? */
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"interface initialization failed"); \
} \
- } \
- {
+ }
/*-------------------------------------------------------------------------
* Purpose: Register function exit for code profiling. This should be