diff options
Diffstat (limited to 'src/hdf5gen.h')
-rw-r--r-- | src/hdf5gen.h | 96 |
1 files changed, 88 insertions, 8 deletions
diff --git a/src/hdf5gen.h b/src/hdf5gen.h index 4d01685..39e3d05 100644 --- a/src/hdf5gen.h +++ b/src/hdf5gen.h @@ -36,14 +36,94 @@ # define TRUE (!FALSE) #endif -/* Function entry & exit macros */ -#define FUNC_ENTER(pablo_mask,pablo_func_id,interface_init_func,err) \ - { PABLO_TRACE_ON(pablo_mask,pablo_func_id); \ - if(library_initialize==FALSE) if(H5_init_library()==FAIL) HGOTO_ERROR(H5E_FUNC,H5E_CANTINIT,err); \ - if(thread_initialize==FALSE) if(H5_init_thread()==FAIL) HGOTO_ERROR(H5E_FUNC,H5E_CANTINIT,err); \ - if(interface_initialize==FALSE) if(interface_init_func()==FAIL) HGOTO_ERROR(H5E_FUNC,H5E_CANTINIT,err); } -#define FUNC_LEAVE(pablo_mask,pablo_func_id,return_value) \ - { PABLO_TRACE_OFF(pablo_mask,pablo_func_id); return(return_value); } +/*------------------------------------------------------------------------- + * Purpose: Register function entry for library initialization and code + * profiling. + * + * Notes: Every file must have a file-scope variable called + * `initialize_interface'. + * + * Don't use local variable initializers which contain + * calls to other library functions since the initializer + * would happen before the FUNC_ENTER() gets called. Don't + * use initializers that require special cleanup code to + * execute if FUNC_ENTER() fails since a failing FUNC_ENTER() + * returns immediately without branching to the `done' label. + * + * Programmer: Quincey Koziol + * + * Modifications: + * + * Robb Matzke, 4 Aug 1997 + * The `interface_init_func' can be the null pointer. Changed + * HGOTO_ERROR() to HRETURN_ERROR() since no clean-up needs to occur + * when an error is detected at this point since this must be the + * first executable statement in a function. This allows functions + * to omit the `done:' label when convenient to do so. + * + * Robb Matzke, 4 Aug 1997 + * The pablo mask comes from the constant PABLO_MASK defined on + * a per-file basis. The `pablo_func_id' is generated from the + * `func_name' argument by prepending an `ID_' to the name. The + * pablo function identifier should be saved in a local variable + * so FUNC_LEAVE() can access it. + * + * Robb Matzke, 4 Aug 1997 + * It is safe to call this function even inside various library + * initializing functions. Infinite recursion is no longer a + * danger. + * + *------------------------------------------------------------------------- + */ +#define FUNC_ENTER(func_name,interface_init_func,err) \ + CONSTR (FUNC, #func_name); \ + /* int pablo_func_id = ID_ ## func_name; */ \ + \ + PABLO_TRACE_ON (PABLO_MASK, ID_ ## func_name); \ + \ + if (!library_initialize_g) { \ + library_initialize_g = TRUE; \ + if (H5_init_library()<0) { \ + HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err); \ + } \ + } \ + \ + if (!thread_initialize_g) { \ + thread_initialize_g = TRUE; \ + if (H5_init_thread()<0) { \ + HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err); \ + } \ + } \ + \ + if (!interface_initialize_g) { \ + interface_initialize_g = TRUE; \ + if (interface_init_func && \ + ((herr_t(*)(void))interface_init_func)()<0) { \ + HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err); \ + } \ + } + + + +/*------------------------------------------------------------------------- + * Purpose: Register function exit for code profiling. This should be + * the last statement executed by a function. + * + * Programmer: Quincey Koziol + * + * Modifications: + * + * Robb Matzke, 4 Aug 1997 + * The pablo mask comes from the constant PABLO_MASK defined on a + * per-file basis. The pablo_func_id comes from an auto variable + * defined by FUNC_ENTER. + * + *------------------------------------------------------------------------- + */ +#define FUNC_LEAVE(return_value) { \ + PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \ + return (return_value); \ +} #endif /* HDF5GEN_H */ |