diff options
-rw-r--r-- | src/H5.c | 86 | ||||
-rw-r--r-- | src/H5A.c | 92 | ||||
-rw-r--r-- | src/H5AC.c | 116 | ||||
-rw-r--r-- | src/H5C.c | 57 | ||||
-rw-r--r-- | src/H5D.c | 26 | ||||
-rw-r--r-- | src/H5E.c | 64 | ||||
-rw-r--r-- | src/H5Eprivate.h | 7 | ||||
-rw-r--r-- | src/H5Eproto.h | 35 | ||||
-rw-r--r-- | src/H5F.c | 132 | ||||
-rw-r--r-- | src/H5M.c | 40 | ||||
-rw-r--r-- | src/H5P.c | 31 | ||||
-rw-r--r-- | src/H5T.c | 61 | ||||
-rw-r--r-- | src/hdf5gen.h | 96 | ||||
-rw-r--r-- | src/hdf5glob.h | 4 |
14 files changed, 434 insertions, 413 deletions
@@ -44,10 +44,12 @@ static char RcsId[] = "@(#)$Revision$"; #include "H5Bprivate.h" /*B-link trees */ #include "H5private.h" /* Generic info */ +#define PABLO_MASK H5_mask + /*--------------------- Locally scoped variables -----------------------------*/ /* Whether we've installed the library termination function yet for this interface */ -static intn interface_initialize = FALSE; +static intn interface_initialize_g = FALSE; /*------------------_-- Local function prototypes ----------------------------*/ static herr_t H5_init_interface(void); @@ -66,27 +68,14 @@ DESCRIPTION --------------------------------------------------------------------------*/ herr_t H5_init_library(void) { - CONSTR(FUNC, "H5_init_library"); /* For HERROR */ - herr_t ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5_mask, ID_H5_init_library); - - /* Don't call this routine again... */ - library_initialize = TRUE; + FUNC_ENTER (H5_init_library, NULL, FAIL); /* Install atexit() library cleanup routine */ if(install_atexit==TRUE) if (HDatexit(&H5_term_library) != 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL); - -done: - if(ret_value == FAIL) - { /* Error condition cleanup */ - - } /* end if */ + HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL); - FUNC_LEAVE(H5_mask, ID_H5_init_library,ret_value); + FUNC_LEAVE (SUCCEED); } /* H5_init_library */ /*-------------------------------------------------------------------------- @@ -97,7 +86,7 @@ done: USAGE void HPend() RETURNS - none + SUCCEED/FAIL DESCRIPTION Walk through the shutdown routines for the various interfaces and terminate them all. @@ -107,12 +96,9 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -void H5_term_library(void) +void +H5_term_library (void) { -#ifdef LATER - CONSTR(FUNC, "H5_term_library"); /* for HERROR */ -#endif /* LATER */ - } /* end H5_term_library() */ /*-------------------------------------------------------------------------- @@ -129,23 +115,13 @@ DESCRIPTION --------------------------------------------------------------------------*/ herr_t H5_init_thread(void) { -#ifdef LATER - CONSTR(FUNC, "H5_init_thread"); /* For HERROR */ -#endif /* LATER */ - herr_t ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5_mask, ID_H5_init_thread); - - /* Don't call this routine again... */ - thread_initialize = TRUE; - + FUNC_ENTER (H5_init_thread, NULL, FAIL); /* Create/initialize this thread's error stack */ if((thrderrid=H5Enew_err_stack(16))==FAIL) - ret_value=FAIL; + HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, FAIL); - FUNC_LEAVE(H5_mask, ID_H5_init_thread, ret_value); + FUNC_LEAVE (SUCCEED); } /* H5_init_thread */ /*-------------------------------------------------------------------------- @@ -162,18 +138,9 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t H5_init_interface(void) { -#ifdef LATER - CONSTR(FUNC, "H5_init_interface"); /* For HERROR */ -#endif /* LATER */ - herr_t ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5_mask, ID_H5_init_interface); - - /* Don't call this routine again... */ - interface_initialize = TRUE; + FUNC_ENTER (H5_init_interface, NULL, FAIL); - FUNC_LEAVE(H5_mask, ID_H5_init_interface, ret_value); + FUNC_LEAVE (SUCCEED); } /* H5_init_interface */ /*-------------------------------------------------------------------------- @@ -204,28 +171,12 @@ static herr_t H5_init_interface(void) --------------------------------------------------------------------------*/ herr_t H5dont_atexit(void) { -#ifdef LATER - CONSTR(FUNC, "H5dont_atexit"); /* for HERROR */ -#endif /* LATER */ - intn ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, we are trying to avoid certain initialization code */ - PABLO_TRACE_ON(H5_mask, ID_H5dont_atexit); + FUNC_ENTER (H5dont_atexit, NULL, FAIL); if(install_atexit == TRUE) install_atexit=FALSE; -#ifdef LATER -done: - if(ret_value == FAIL) - { /* Error condition cleanup */ - - } /* end if */ -#endif /* LATER */ - - /* Normal function cleanup */ - - FUNC_LEAVE(H5_mask, ID_H5dont_atexit,ret_value); + FUNC_LEAVE (SUCCEED); } /* end H5dont_atexit() */ /*-------------------------------------------------------------------------- @@ -246,10 +197,9 @@ DESCRIPTION --------------------------------------------------------------------------*/ herr_t H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum) { - CONSTR(FUNC, "H5version"); /* For HERROR */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5_mask, ID_H5version, H5_init_interface,FAIL); + FUNC_ENTER(H5version, H5_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -270,6 +220,6 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5_mask, ID_H5version, ret_value); + FUNC_LEAVE(ret_value); } /* H5version */ @@ -62,15 +62,20 @@ MODIFICATION HISTORY #define HDF5_ATOM_MASTER #include "hdf5.h" +#include "H5private.h" #include "H5Aprivate.h" +#define PABLO_MASK H5A_mask + + +static int interface_initialize_g = FALSE; /* Private function prototypes */ static atom_info_t *H5A_find_atom(hatom_t atm); static atom_info_t *H5A_get_atom_node(void); -static void H5A_release_atom_node(atom_info_t *atm); +static herr_t H5A_release_atom_node(atom_info_t *atm); /****************************************************************************** NAME @@ -94,13 +99,10 @@ intn H5Ainit_group(group_t grp, /* IN: Group to initialize */ uintn reserved /* IN: Number of hash table entries to reserve */ ) { -#ifdef LATER - CONSTR(FUNC, "H5Ainit_group"); /* for HERROR */ -#endif /* LATER */ atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */ intn ret_value=SUCCEED; - PABLO_TRACE_ON(H5A_mask, ID_H5Ainit_group); + FUNC_ENTER (H5Ainit_group, NULL, FAIL); if((grp<=BADGROUP || grp>=MAXGROUP) && hash_size>0) HGOTO_DONE(FAIL); @@ -158,7 +160,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5A_mask, ID_H5Ainit_group, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Ainit_group() */ /****************************************************************************** @@ -178,13 +180,10 @@ done: intn H5Adestroy_group(group_t grp /* IN: Group to destroy */ ) { -#ifdef LATER - CONSTR(FUNC, "H5Adestroy_group"); /* for HERROR */ -#endif /* LATER */ atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */ intn ret_value=SUCCEED; - PABLO_TRACE_ON(H5A_mask, ID_H5Adestroy_group); + FUNC_ENTER (H5Adestroy_group, NULL, FAIL); if(grp<=BADGROUP || grp>=MAXGROUP) HGOTO_DONE(FAIL); @@ -221,7 +220,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5A_mask, ID_H5Adestroy_group, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Adestroy_group() */ /****************************************************************************** @@ -244,16 +243,13 @@ hatom_t H5Aregister_atom(group_t grp, /* IN: Group to register the object in const VOIDP object /* IN: Object to attach to atom */ ) { -#ifdef LATER - CONSTR(FUNC, "H5Aregister_atom"); /* for HERROR */ -#endif /* LATER */ atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */ atom_info_t *atm_ptr=NULL; /* ptr to the new atom */ hatom_t atm_id; /* new atom ID */ uintn hash_loc; /* new item's hash table location */ hatom_t ret_value=SUCCEED; - PABLO_TRACE_ON(H5A_mask, ID_H5Aregister_atom); + FUNC_ENTER (H5Aregister_atom, NULL, FAIL); if(grp<=BADGROUP || grp>=MAXGROUP) HGOTO_DONE(FAIL); @@ -324,7 +320,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5A_mask, ID_H5Aregister_atom, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Aregister_atom() */ /****************************************************************************** @@ -341,16 +337,13 @@ done: VOIDP H5Aatom_object(hatom_t atm /* IN: Atom to retrieve object for */ ) { -#ifdef LATER - CONSTR(FUNC, "H5Aatom_object"); /* for HERROR */ -#endif /* LATER */ #ifdef ATOMS_ARE_CACHED uintn i; /* local counter */ #endif /* ATOMS_ARE_CACHED */ atom_info_t *atm_ptr=NULL; /* ptr to the new atom */ VOIDP ret_value=NULL; - PABLO_TRACE_ON(H5A_mask, ID_H5Aatom_object); + FUNC_ENTER (H5Aatom_object, NULL, NULL); #ifdef ATOMS_ARE_CACHED /* Look for the atom in the cache first */ @@ -387,7 +380,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5A_mask, ID_H5Aatom_object, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Aatom_object() */ /****************************************************************************** @@ -404,12 +397,9 @@ done: group_t H5Aatom_group(hatom_t atm /* IN: Atom to retrieve group for */ ) { -#ifdef LATER - CONSTR(FUNC, "H5Aatom_group"); /* for HERROR */ -#endif /* LATER */ group_t ret_value=BADGROUP; - PABLO_TRACE_ON(H5A_mask, ID_H5Aatom_group); + FUNC_ENTER (H5Aatom_group, NULL, FAIL); ret_value=ATOM_TO_GROUP(atm); if(ret_value<=BADGROUP || ret_value>=MAXGROUP) @@ -422,7 +412,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5A_mask, ID_H5Aatom_group, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Aatom_group() */ /****************************************************************************** @@ -439,9 +429,6 @@ done: VOIDP H5Aremove_atom(hatom_t atm /* IN: Atom to remove */ ) { -#ifdef LATER - CONSTR(FUNC, "H5Aremove_atom"); /* for HERROR */ -#endif /* LATER */ atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */ atom_info_t *curr_atm, /* ptr to the current atom */ *last_atm; /* ptr to the last atom */ @@ -452,7 +439,7 @@ VOIDP H5Aremove_atom(hatom_t atm /* IN: Atom to remove */ #endif /* ATOMS_ARE_CACHED */ VOIDP ret_value=NULL; - PABLO_TRACE_ON(H5A_mask, ID_H5Aremove_atom); + FUNC_ENTER (H5Aremove_atom, NULL, NULL); grp=ATOM_TO_GROUP(atm); if(grp<=BADGROUP || grp>=MAXGROUP) @@ -510,7 +497,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5A_mask, ID_H5Aremove_atom, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Aremove_atom() */ /****************************************************************************** @@ -532,15 +519,12 @@ VOIDP H5Asearch_atom(group_t grp, /* IN: Group to search for the object i const VOIDP key /* IN: pointer to key to compare against */ ) { -#ifdef LATER - CONSTR(FUNC, "H5Asearch_atom"); /* for HERROR */ -#endif /* LATER */ atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */ atom_info_t *atm_ptr=NULL; /* ptr to the new atom */ intn i; /* local counting variable */ VOIDP ret_value=NULL; - PABLO_TRACE_ON(H5A_mask, ID_H5Asearch_atom); + FUNC_ENTER (H5Asearch_atom, NULL, NULL); if(grp<=BADGROUP || grp>=MAXGROUP) HGOTO_DONE(NULL); @@ -568,7 +552,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5A_mask, ID_H5Asearch_atom, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Asearch_atom() */ /****************************************************************************** @@ -586,14 +570,11 @@ done: intn H5Ais_reserved(hatom_t atm /* IN: Group to search for the object in */ ) { -#ifdef LATER - CONSTR(FUNC, "H5Ais_reserved"); /* for HERROR */ -#endif /* LATER */ atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */ group_t grp; /* atom's atomic group */ hbool_t ret_value=BFAIL; - PABLO_TRACE_ON(H5A_mask, ID_H5Ais_reserved); + FUNC_ENTER (H5Ais_reserved, NULL, FAIL); grp=ATOM_TO_GROUP(atm); if(grp<=BADGROUP || grp>=MAXGROUP) @@ -616,7 +597,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5A_mask, ID_H5Ais_reserved, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Ais_reserved() */ /****************************************************************************** @@ -633,15 +614,13 @@ done: static atom_info_t *H5A_find_atom(hatom_t atm /* IN: Atom to retrieve atom for */ ) { -#ifdef LATER - CONSTR(FUNC, "H5A_find_atom"); /* for HERROR */ -#endif /* LATER */ atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */ atom_info_t *atm_ptr=NULL; /* ptr to the new atom */ group_t grp; /* atom's atomic group */ uintn hash_loc; /* atom's hash table location */ atom_info_t *ret_value=NULL; + FUNC_ENTER (H5A_find_atom, NULL, NULL); grp=ATOM_TO_GROUP(atm); if(grp<=BADGROUP || grp>=MAXGROUP) @@ -678,7 +657,7 @@ done: /* Normal function cleanup */ - return ret_value; + FUNC_LEAVE (ret_value); } /* end H5A_find_atom() */ /****************************************************************************** @@ -695,11 +674,10 @@ done: *******************************************************************************/ static atom_info_t *H5A_get_atom_node(void) { -#ifdef LATER - CONSTR(FUNC, "H5A_get_atom_node"); /* for HERROR */ -#endif /* LATER */ atom_info_t *ret_value=NULL; + FUNC_ENTER (H5A_get_atom_node, NULL, NULL); + if(atom_free_list!=NULL) { ret_value=atom_free_list; @@ -719,7 +697,7 @@ done: /* Normal function cleanup */ - return ret_value; + FUNC_LEAVE (ret_value); } /* end H5A_get_atom_node() */ /****************************************************************************** @@ -730,18 +708,19 @@ done: Puts an atom node into the free list RETURNS - No return value + SUCCEED *******************************************************************************/ -static void H5A_release_atom_node(atom_info_t *atm) +static herr_t +H5A_release_atom_node(atom_info_t *atm) { -#ifdef LATER - CONSTR(FUNC, "H5A_release_atom_node"); /* for HERROR */ -#endif /* LATER */ + FUNC_ENTER (H5A_release_atom_node, NULL, FAIL); /* Insert the atom at the beginning of the free list */ atm->next=atom_free_list; atom_free_list=atm; + + FUNC_LEAVE (SUCCEED); } /* end H5A_release_atom_node() */ /*-------------------------------------------------------------------------- @@ -767,6 +746,8 @@ H5Ashutdown(void) atom_info_t *curr; intn i; + FUNC_ENTER (H5Ashutdown, NULL, FAIL); + /* Release the free-list if it exists */ if(atom_free_list!=NULL) { @@ -784,6 +765,7 @@ H5Ashutdown(void) HDfree(atom_group_list[i]); atom_group_list[i]=NULL; } /* end if */ - return (SUCCEED); + + FUNC_LEAVE (SUCCEED); } /* end H5Ashutdown() */ @@ -13,26 +13,34 @@ * with a particular HDF file share the same cache; each * HDF file has it's own cache. * - * Modifications: + * Modifications: + * + * Robb Matzke, 4 Aug 1997 + * Added calls to H5E. * *------------------------------------------------------------------------- */ #include <assert.h> #include "hdf5.h" +#include "H5private.h" #include "H5ACprivate.h" +#include "H5MMprivate.h" +#define PABLO_MASK H5AC_mask #define HASH(addr) ((unsigned)(addr) % H5AC_NSLOTS) +static int interface_initialize_g = FALSE; /*initialized?*/ + /*------------------------------------------------------------------------- * Function: H5AC_new * * Purpose: Initialize the cache just after a file is opened. * - * Return: Success: 0 + * Return: Success: SUCCEED * - * Failure: -1 + * Failure: FAIL * * Programmer: Robb Matzke * robb@maya.nuance.com @@ -45,8 +53,14 @@ herr_t H5AC_new (hdf5_file_t *f) { - f->cache = HDcalloc (H5AC_NSLOTS, sizeof (H5AC_cache_t)); - return 0; + FUNC_ENTER (H5AC_new, NULL, FAIL); + + assert (f); + assert (NULL==f->cache); + + f->cache = H5MM_xcalloc (H5AC_NSLOTS, sizeof (H5AC_cache_t)); + + FUNC_LEAVE (SUCCEED); } @@ -55,9 +69,9 @@ H5AC_new (hdf5_file_t *f) * * Purpose: Flushes all data to disk and destroys the cache. * - * Return: Success: 0 + * Return: Success: SUCCEED * - * Failure: -1 + * Failure: FAIL * * Programmer: Robb Matzke * robb@maya.nuance.com @@ -70,9 +84,17 @@ H5AC_new (hdf5_file_t *f) herr_t H5AC_dest (hdf5_file_t *f) { - if (H5AC_flush (f, NULL, 0, TRUE)<0) return -1; - HDfree (f->cache); - return 0; + FUNC_ENTER (H5AC_dest, NULL, FAIL); + + assert (f); + assert (f->cache); + + if (H5AC_flush (f, NULL, 0, TRUE)<0) { + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); + } + + f->cache = H5MM_xfree (f->cache); + FUNC_LEAVE (SUCCEED); } @@ -113,6 +135,10 @@ H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, void *thing = NULL; herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; + FUNC_ENTER (H5AC_find, NULL, NULL); + + assert (f); + assert (f->cache); assert (type); assert (type->load); assert (type->flush); @@ -130,7 +156,7 @@ H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, */ if (f->cache[idx].type && f->cache[idx].addr==addr && f->cache[idx].type!=type) { - return NULL; + HRETURN_ERROR (H5E_CACHE, H5E_BADTYPE, NULL); } /* @@ -138,7 +164,7 @@ H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, * without preempting anything. */ if (NULL==(thing=(type->load)(f, addr, udata))) { - return NULL; + HRETURN_ERROR (H5E_CACHE, H5E_CANTLOAD, NULL); } /* @@ -152,9 +178,10 @@ H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, * The old thing could not be removed from the stack. * Release the new thing and fail. */ - status = (type->flush)(f, TRUE, addr, thing); - assert (status>=0); - return NULL; + if ((type->flush)(f, TRUE, addr, thing)<0) { + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, NULL); + } + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, NULL); } } @@ -165,7 +192,7 @@ H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, f->cache[idx].addr = addr; f->cache[idx].thing = thing; - return thing; + FUNC_LEAVE (thing); } @@ -177,9 +204,9 @@ H5AC_find (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, * all types of entries are flushed. If the ADDR is zero then * all entries of the specified type are flushed. * - * Return: Success: 0 + * Return: Success: SUCCEED * - * Failure: -1 + * Failure: FAIL * * Programmer: Robb Matzke * robb@maya.nuance.com @@ -197,6 +224,11 @@ H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, herr_t status; herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; + FUNC_ENTER (H5AC_flush, NULL, FAIL); + + assert (f); + assert (f->cache); + if (!type || 0==addr) { /* * Look at all cache entries. @@ -208,7 +240,9 @@ H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, flush = f->cache[i].type->flush; status = (flush)(f, destroy, f->cache[i].addr, f->cache[i].thing); - if (status<0) return -1; + if (status<0) { + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); + } if (destroy) f->cache[i].type = NULL; } } @@ -219,11 +253,14 @@ H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, */ flush = f->cache[i].type->flush; status = (flush) (f, destroy, f->cache[i].addr, f->cache[i].thing); - if (status<0) return -1; + if (status<0) { + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); + } if (destroy) f->cache[i].type = NULL; } - return 0; + + FUNC_LEAVE (SUCCEED); } @@ -234,9 +271,9 @@ H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, * exist on disk yet, but it must have an address and disk * space reserved. * - * Return: Success: 0 + * Return: Success: SUCCEED * - * Failure: -1 + * Failure: FAIL * * Programmer: Robb Matzke * robb@maya.nuance.com @@ -253,19 +290,28 @@ H5AC_set (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, void *thing) uintn idx = HASH (addr); herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; + FUNC_ENTER (H5AC_set, NULL, FAIL); + + assert (f); + assert (f->cache); assert (type); assert (type->flush); + assert (addr>=0); + assert (thing); if (f->cache[idx].type) { flush = f->cache[idx].type->flush; status = (flush)(f, TRUE, f->cache[idx].addr, f->cache[idx].thing); - if (status<0) return -1; + if (status<0) { + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); + } } f->cache[idx].type = type; f->cache[idx].addr = addr; f->cache[idx].thing = thing; - return 0; + + FUNC_LEAVE (SUCCEED); } @@ -275,9 +321,9 @@ H5AC_set (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, void *thing) * Purpose: Use this function to notify the cache that an object's * file address changed. * - * Return: Success: 0 + * Return: Success: SUCCEED * - * Failure: -1 + * Failure: FAIL * * Programmer: Robb Matzke * robb@maya.nuance.com @@ -296,15 +342,21 @@ H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, herr_t (*flush)(hdf5_file_t*, hbool_t, haddr_t, void*); herr_t status; + FUNC_ENTER (H5AC_rename, NULL, FAIL); + + assert (f); + assert (f->cache); assert (type); + assert (old_addr>=0); + assert (new_addr>=0); if (f->cache[old_idx].type!=type || f->cache[old_idx].addr!=old_addr) { - return 0; /*item not in cache*/ + HRETURN (SUCCEED); } if (old_idx==new_idx) { f->cache[old_idx].addr = new_addr; - return 0; + HRETURN (SUCCEED); } /* @@ -314,7 +366,9 @@ H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, flush = f->cache[new_idx].type->flush; status = (flush)(f, TRUE, f->cache[new_idx].addr, f->cache[new_idx].thing); - if (status<0) return -1; + if (status<0) { + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); + } } /* @@ -325,6 +379,6 @@ H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, f->cache[new_idx].thing = f->cache[old_idx].thing; f->cache[old_idx].type = NULL; - return 0; + FUNC_LEAVE (SUCCEED); } @@ -38,10 +38,12 @@ static char RcsId[] = "@(#)$Revision$"; #include "H5private.h" /* Generic Functions */ #include "H5Cprivate.h" /* Template information */ +#define PABLO_MASK H5C_mask + /*--------------------- Locally scoped variables -----------------------------*/ /* Whether we've installed the library termination function yet for this interface */ -static intn interface_initialize = FALSE; +static intn interface_initialize_g = FALSE; /* Define the library's default file creation template (constants in hdf5lims.h) */ const file_create_temp_t default_file_create={ @@ -74,21 +76,14 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t H5C_init_interface(void) { -#ifdef LATER - CONSTR(FUNC, "H5C_init_interface"); /* For HERROR */ -#endif /* LATER */ herr_t ret_value = SUCCEED; - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5C_mask, ID_H5C_init_interface); - - /* Don't call this routine again... */ - interface_initialize = TRUE; + FUNC_ENTER (H5C_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ ret_value=H5Ainit_group(H5_TEMPLATE,HDF5_TEMPID_HASHSIZE,0); - FUNC_LEAVE(H5C_mask, ID_H5C_init_interface, ret_value); + FUNC_LEAVE(ret_value); } /* H5C_init_interface */ /*-------------------------------------------------------------------------- @@ -104,14 +99,18 @@ static herr_t H5C_init_interface(void) success, FAIL on failure DESCRIPTION This is function retrieves atoms for the default templates for the - different types of HDF5 templates. + different types of HDF5 templates. + + MODIFICATIONS + Robb Matzke, 4 Aug 1997 + The `FUNC' auto variable was changed from `H5C_create' to + `H5C_get_default_atom'. --------------------------------------------------------------------------*/ hatom_t H5C_get_default_atom(hobjtype_t type) { - CONSTR(FUNC, "H5C_create"); /* for HERROR */ hatom_t ret_value = FAIL; - FUNC_ENTER(H5C_mask, ID_H5C_get_default_atom, H5C_init_interface, FAIL); + FUNC_ENTER(H5C_get_default_atom, H5C_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -139,7 +138,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5C_mask, ID_H5C_get_default_atom, ret_value); + FUNC_LEAVE(ret_value); } /* end H5C_get_default_atom() */ /*-------------------------------------------------------------------------- @@ -159,11 +158,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5C_init(hatom_t dst_atm, const file_create_temp_t *src) { - CONSTR(FUNC, "H5C_init"); /* for HERROR */ file_create_temp_t *dst; /* destination template */ herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER(H5C_mask, ID_H5C_init, H5C_init_interface, FAIL); + FUNC_ENTER(H5C_init, H5C_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -185,7 +183,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5C_mask, ID_H5C_init, ret_value); + FUNC_LEAVE(ret_value); } /* end H5C_init() */ /*-------------------------------------------------------------------------- @@ -206,10 +204,9 @@ done: --------------------------------------------------------------------------*/ hatom_t H5C_create(hatom_t owner_id, hobjtype_t type, const char *name) { - CONSTR(FUNC, "H5C_create"); /* for HERROR */ hatom_t ret_value = FAIL; /* atom for template object to return */ - FUNC_ENTER(H5C_mask, ID_H5C_create, H5C_init_interface, FAIL); + FUNC_ENTER(H5C_create, H5C_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -239,7 +236,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5C_mask, ID_H5C_create, ret_value); + FUNC_LEAVE(ret_value); } /* end H5C_create() */ /*-------------------------------------------------------------------------- @@ -257,11 +254,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5C_release(hatom_t oid) { - CONSTR(FUNC, "H5C_release"); /* for HERROR */ file_create_temp_t *template; /* template to destroy */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5C_mask, ID_H5C_release, H5C_init_interface, FAIL); + FUNC_ENTER(H5C_release, H5C_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -279,7 +275,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5C_mask, ID_H5C_release, ret_value); + FUNC_LEAVE(ret_value); } /* end H5C_release() */ /*-------------------------------------------------------------------------- @@ -300,11 +296,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5Cgetparm(hatom_t tid, file_create_param_t parm, VOIDP buf) { - CONSTR(FUNC, "H5Cgetparm"); /* for HERROR */ file_create_temp_t *template; /* template to query */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5C_mask, ID_H5Cgetparm, H5C_init_interface, FAIL); + FUNC_ENTER(H5Cgetparm, H5C_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -365,7 +360,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5C_mask, ID_H5Cgetparm, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Cgetparm() */ /*-------------------------------------------------------------------------- @@ -385,11 +380,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5Csetparm(hatom_t tid, file_create_param_t parm, const VOIDP buf) { - CONSTR(FUNC, "H5Csetparm"); /* for HERROR */ file_create_temp_t *template; /* template to query */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5C_mask, ID_H5Csetparm, H5C_init_interface, FAIL); + FUNC_ENTER(H5Csetparm, H5C_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -450,7 +444,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5C_mask, ID_H5Csetparm, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Csetparm() */ /*-------------------------------------------------------------------------- @@ -469,11 +463,10 @@ done: --------------------------------------------------------------------------*/ hatom_t H5C_copy(hatom_t tid) { - CONSTR(FUNC, "H5C_copy"); /* for HERROR */ file_create_temp_t *template, *new_template; /* template to query */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5C_mask, ID_H5C_copy, H5C_init_interface, FAIL); + FUNC_ENTER(H5C_copy, H5C_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -501,6 +494,6 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5C_mask, ID_H5C_copy, ret_value); + FUNC_LEAVE(ret_value); } /* end H5C_copy() */ @@ -36,10 +36,12 @@ static char RcsId[] = "@(#)$Revision$"; #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Dataset functions */ +#define PABLO_MASK H5D_mask + /*--------------------- Locally scoped variables -----------------------------*/ /* Whether we've installed the library termination function yet for this interface */ -static intn interface_initialize = FALSE; +static intn interface_initialize_g = FALSE; /*-------------------------------------------------------------------------- NAME @@ -55,21 +57,13 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t H5D_init_interface(void) { -#ifdef LATER - CONSTR(FUNC, "H5D_init_interface"); /* For HERROR */ -#endif /* LATER */ herr_t ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5D_mask, ID_H5D_init_interface); - - /* Don't call this routine again... */ - interface_initialize = TRUE; + FUNC_ENTER (H5D_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ ret_value=H5Ainit_group(H5_DATASET,HDF5_DATASETID_HASHSIZE,H5D_RESERVED_ATOMS); - FUNC_LEAVE(H5D_mask, ID_H5D_init_interface, ret_value); + FUNC_LEAVE(ret_value); } /* H5D_init_interface */ /*-------------------------------------------------------------------------- @@ -89,11 +83,10 @@ static herr_t H5D_init_interface(void) --------------------------------------------------------------------------*/ hatom_t H5D_create(hatom_t owner_id, hobjtype_t type, const char *name) { - CONSTR(FUNC, "H5D_create"); /* for HERROR */ H5D_dataset_t *new_dataset; /* new dataset object to create */ hatom_t ret_value = SUCCEED; - FUNC_ENTER(H5D_mask, ID_H5D_create, H5D_init_interface, FAIL); + FUNC_ENTER(H5D_create, H5D_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -116,7 +109,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5D_mask, ID_H5D_create, ret_value); + FUNC_LEAVE(ret_value); } /* end H5D_create() */ /*-------------------------------------------------------------------------- @@ -134,11 +127,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5D_release(hatom_t oid) { - CONSTR(FUNC, "H5D_release"); /* for HERROR */ H5D_dataset_t *dataset; /* dataset object to release */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5D_mask, ID_H5Drelease, H5D_init_interface, FAIL); + FUNC_ENTER(H5Drelease, H5D_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -156,7 +148,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5D_mask, ID_H5D_release, ret_value); + FUNC_LEAVE(ret_value); } /* end H5D_release() */ @@ -39,10 +39,12 @@ static char RcsId[] = "@(#)$Revision$"; #include "H5private.h" /* Generic Functions */ +#define PABLO_MASK H5E_mask + /*--------------------- Locally scoped variables -----------------------------*/ /* Whether we've installed the library termination function yet for this interface */ -static intn interface_initialize = FALSE; +static intn interface_initialize_g = FALSE; /*------------------_-- Local function prototypes ----------------------------*/ static herr_t H5E_init_interface(void); @@ -58,24 +60,20 @@ RETURNS DESCRIPTION Initializes any interface-specific data or routines. +Modifications: + Robb Matzke, 4 Aug 1997 + Changed the pablo mask from H5_mask to H5E_mask + --------------------------------------------------------------------------*/ static herr_t H5E_init_interface(void) { -#ifdef LATER - CONSTR(FUNC, "H5E_init_interface"); /* For HERROR */ -#endif /* LATER */ herr_t ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5_mask, ID_H5Iinit_interface); - - /* Don't call this routine again... */ - interface_initialize = TRUE; + FUNC_ENTER (H5E_init_interface, NULL, FAIL); /* Initialize the atom group for the error stacks */ ret_value=H5Ainit_group(H5_ERR,HDF5_ERRSTACK_HASHSIZE,0); - FUNC_LEAVE(H5_mask, ID_H5E_init_interface, ret_value); + FUNC_LEAVE(ret_value); } /* H5E_init_interface */ /*-------------------------------------------------------------------------- @@ -94,11 +92,10 @@ DESCRIPTION --------------------------------------------------------------------------*/ int32 H5Enew_err_stack(uintn initial_stack_size) { - CONSTR(FUNC, "H5Enew_err_stack"); /* For HERROR */ H5E_errstack_t *new_stack=NULL; /* Pointer to the new error stack */ int32 ret_value = FAIL; - FUNC_ENTER(H5E_mask, ID_H5Enew_err_stack, H5E_init_interface,FAIL); + FUNC_ENTER(H5Enew_err_stack, H5E_init_interface,FAIL); /* Allocate the stack header */ if((new_stack=HDmalloc(sizeof(H5E_errstack_t)))==NULL) @@ -125,7 +122,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5E_mask, ID_H5Enew_err_stack, ret_value); + FUNC_LEAVE(ret_value); } /* H5Enew_err_stack */ /*-------------------------------------------------------------------------- @@ -144,11 +141,10 @@ DESCRIPTION --------------------------------------------------------------------------*/ intn H5Edelete_err_stack(int32 err_stack) { - CONSTR(FUNC, "H5Edelete_err_stack"); /* For HERROR */ H5E_errstack_t *old_stack=NULL; /* Pointer to the new error stack */ intn ret_value = SUCCEED; - FUNC_ENTER(H5E_mask, ID_H5Edelete_err_stack, H5E_init_interface,FAIL); + FUNC_ENTER(H5Edelete_err_stack, H5E_init_interface,FAIL); /* Clear errors and check args and all the boring stuff. */ if (H5Aatom_group(err_stack)!=H5_ERR) @@ -179,7 +175,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5E_mask, ID_H5Edelete_err_stack, ret_value); + FUNC_LEAVE(ret_value); } /* H5Edelete_err_stack */ /*-------------------------------------------------------------------------- @@ -190,18 +186,18 @@ USAGE int32 err_hand; IN: The ID of the error stack to push the error onto. RETURNS - none + SUCCEED/FAIL DESCRIPTION Clear an error stack to allow errors to be pushed onto it. --------------------------------------------------------------------------*/ -void H5Eclear(int32 err_hand) +herr_t +H5Eclear (int32 err_hand) { - CONSTR(FUNC, "H5Eclear"); /* For HERROR */ H5E_errstack_t *err_stack=NULL; /* Pointer to the error stack to put value on */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5E_mask, ID_H5Eclear, H5E_init_interface,FAIL); + FUNC_ENTER (H5Eclear, H5E_init_interface, FAIL); /* Get the error stack for this error handler, initialized earlier in H5Enew_err_stack */ if (H5Aatom_group(err_hand)!=H5_ERR) @@ -229,7 +225,7 @@ done: /* Normal function cleanup */ - PABLO_TRACE_OFF(H5E_mask, ID_H5Eclear); /* ignore ret_value set */ + FUNC_LEAVE (ret_value); } /* H5Eclear */ /*-------------------------------------------------------------------------- @@ -243,19 +239,19 @@ USAGE intn line; IN: Line # in the file the error occurred on. RETURNS - none + SUCCESS/FAIL DESCRIPTION Pushes an error onto an error stack for this thread. (This is the default action when errors occur, but can be overridden by user's code) --------------------------------------------------------------------------*/ -void H5E_store(int32 errid, hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line) +herr_t +H5E_store(int32 errid, hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line) { - CONSTR(FUNC, "H5E_store"); /* For HERROR */ H5E_errstack_t *err_stack=NULL; /* Pointer to the error stack to put value on */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5E_mask, ID_H5E_store, H5E_init_interface,FAIL); + FUNC_ENTER(H5E_store, H5E_init_interface,FAIL); /* Clear errors and check args and all the boring stuff. */ H5Eclear(errid); @@ -296,7 +292,7 @@ done: /* Normal function cleanup */ - PABLO_TRACE_OFF(H5E_mask, ID_H5E_store); /* ignore ret_value set */ + FUNC_LEAVE (ret_value); } /* H5E_store */ /*-------------------------------------------------------------------------- @@ -310,18 +306,18 @@ USAGE intn line; IN: Line # in the file the error occurred on. RETURNS - none + SUCCEED/FAIL DESCRIPTION Pushes an error onto an error stack for this thread. --------------------------------------------------------------------------*/ -void H5Epush(hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line) +herr_t +H5Epush(hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line) { - CONSTR(FUNC, "H5Epush"); /* For HERROR */ H5E_errstack_t *err_stack=NULL; /* Pointer to the error stack to put value on */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5E_mask, ID_H5Epush, H5E_init_interface,FAIL); + FUNC_ENTER(H5Epush, H5E_init_interface,FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -342,7 +338,7 @@ done: /* Normal function cleanup */ - PABLO_TRACE_OFF(H5E_mask, ID_H5Epush); /* ignore ret_value set */ + FUNC_LEAVE (ret_value); } /* H5Epush */ #ifdef H5_ERROR_DEBUG @@ -368,7 +364,7 @@ H5E_push_func_t H5Eset_push(H5E_push_func_t func) H5E_errstack_t *err_stack=NULL; /* Pointer to the error stack to put value on */ H5E_push_func_t ret_value = NULL; - FUNC_ENTER(H5E_mask, ID_H5Eset_push, H5E_init_interface,NULL); + FUNC_ENTER(H5Eset_push, H5E_init_interface,NULL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -390,7 +386,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5E_mask, ID_H5Eset_push, ret_value); + FUNC_LEAVE(ID_H5Eset_push, ret_value); } /* H5Eset_push */ #endif /* H5_ERROR_DEBUG */ diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 6ccefb1..d21adde 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -57,6 +57,7 @@ static const hdf_maj_error_messages_t hdf_maj_error_messages[] = {H5E_IO, "Low-level I/O"}, {H5E_FUNC, "Function Entry/Exit"}, {H5E_ATOM, "Object Atom"}, + {H5E_CACHE, "Object Cache"}, }; typedef struct @@ -86,7 +87,9 @@ static const hdf_min_error_messages_t hdf_min_error_messages[] = {H5E_CANTINIT, "Can't initialize interface"}, {H5E_ALREADYINIT, "Object already initialized"}, {H5E_BADATOM, "Can't find atom information"}, - {H5E_CANTREGISTER, "Can't register new atom"} + {H5E_CANTREGISTER, "Can't register new atom"}, + {H5E_CANTFLUSH, "Can't flush object from cache"}, + {H5E_CANTLOAD, "Can't load object into cache"}, }; /* We use a stack to hold the errors plus we keep track of the function, @@ -121,7 +124,7 @@ extern "C" #endif /* c_plusplus || __cplusplus */ /* Private functions in H5E.c */ -void H5E_store(int32 errid, hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line); +herr_t H5E_store(int32 errid, hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line); #if defined c_plusplus || defined __cplusplus } diff --git a/src/H5Eproto.h b/src/H5Eproto.h index d6e1ccd..c51ceac 100644 --- a/src/H5Eproto.h +++ b/src/H5Eproto.h @@ -30,15 +30,29 @@ same assumptions as HERROR. IN ADDITION, this macro causes a return from the calling routine */ -#define HRETURN_ERROR(pablo_mask, pablo_func_id, maj, min, ret_val) {HERROR(maj, min); PABLO_TRACE_OFF(pablo_mask,pablo_func_id); return(ret_val);} +#define HRETURN_ERROR(maj, min, ret_val) { \ + HERROR (maj, min); \ + 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); \ +} /* 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) { HERROR(maj, min); \ - ret_value = ret_val; goto done; } +#define HGOTO_ERROR(maj, min, ret_val) { \ + HERROR (maj, min); \ + 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' @@ -62,7 +76,8 @@ typedef enum H5E_FILE, /* File Accessability */ H5E_IO, /* Low-level I/O */ H5E_FUNC, /* Function Entry/Exit */ - H5E_ATOM /* Object Atom */ + H5E_ATOM, /* Object Atom */ + H5E_CACHE /* Object Cache */ } hdf_maj_err_code_t; @@ -99,12 +114,16 @@ typedef enum /* Object atom related errors */ H5E_BADATOM, /* Can't find atom information */ - H5E_CANTREGISTER /* Can't register new atom */ + H5E_CANTREGISTER, /* Can't register new atom */ + + /* Cache related errors */ + H5E_CANTFLUSH, /* Can't flush object from cache */ + H5E_CANTLOAD /* Can't load object into cache */ } hdf_min_err_code_t; /* Function pointer to report errors through */ -typedef void (*H5E_push_func_t)(int32 errid, hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line); +typedef herr_t (*H5E_push_func_t)(int32 errid, hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line); #if defined c_plusplus || defined __cplusplus extern "C" @@ -117,8 +136,8 @@ intn H5Edelete_err_stack(int32 err_hand); #ifdef H5_ERROR_DEBUG H5E_push_func_t H5Eset_push(H5E_push_func_t func); #endif /* H5_ERROR_DEBUG */ -void H5Epush(hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line); -void H5Eclear(int32 err_hand); +herr_t H5Epush(hdf_maj_err_code_t maj, hdf_min_err_code_t min, const char *function_name, const char *file_name, intn line); +herr_t H5Eclear(int32 err_hand); #if defined c_plusplus || defined __cplusplus } @@ -42,10 +42,12 @@ static char RcsId[] = "@(#)$Revision$"; #include "H5Gprivate.h" /*symbol tables */ #include "H5MMprivate.h" /*core memory management */ +#define PABLO_MASK H5F_mask + /*--------------------- Locally scoped variables -----------------------------*/ /* Whether we've installed the library termination function yet for this interface */ -static intn interface_initialize = FALSE; +static intn interface_initialize_g = FALSE; /*--------------------- Local function prototypes ----------------------------*/ static herr_t H5F_init_interface(void); @@ -63,24 +65,21 @@ RETURNS DESCRIPTION Initializes any interface-specific data or routines. +Modifications: + Robb Matzke, 4 Aug 1997 + Changed pablo mask from H5_mask to H5F_mask for the FUNC_LEAVE call. + It was already H5F_mask for the PABLO_TRACE_ON call. + --------------------------------------------------------------------------*/ static herr_t H5F_init_interface(void) { -#ifdef LATER - CONSTR(FUNC, "H5F_init_interface"); /* For HERROR */ -#endif /* LATER */ herr_t ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5F_mask, ID_H5F_init_interface); - - /* Don't call this routine again... */ - interface_initialize = TRUE; + FUNC_ENTER (H5F_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ ret_value=H5Ainit_group(H5_FILE,HDF5_FILEID_HASHSIZE,0); - FUNC_LEAVE(H5_mask, ID_H5F_init_interface, ret_value); + FUNC_LEAVE(ret_value); } /* H5F_init_interface */ #ifdef LATER @@ -99,9 +98,6 @@ static herr_t H5F_init_interface(void) --------------------------------------------------------------------------*/ void H5F_encode_length_unusual(const hdf5_file_t *f, uint8 **p, uint8 *l) { -#ifdef LATER - CONSTR(FUNC, "H5F_encode_length_unusual"); -#endif /* LATER */ intn i = H5F_SIZEOF_SIZE (f); /* For non-little-endian platforms, encode each byte in memory backwards */ @@ -140,9 +136,6 @@ done: --------------------------------------------------------------------------*/ void H5F_encode_offset_unusual(const hdf5_file_t *f, uint8 **p, uint8 *o) { -#ifdef LATER - CONSTR(FUNC, "H5F_encode_offset_unusual"); -#endif /* LATER */ intn i = H5F_SIZEOF_OFFSET(f); /* For non-little-endian platforms, encode each byte in memory backwards */ @@ -180,24 +173,18 @@ done: Look inside the file record for the atom API and compare the the filenames. --------------------------------------------------------------------------*/ -intn H5F_compare_filename(const VOIDP obj, const VOIDP key) +intn +H5F_compare_filename (const VOIDP _obj, const VOIDP _key) { -#ifdef LATER - CONSTR(FUNC, "H5F_compare_filename"); -#endif /* LATER */ - - -#ifdef LATER -done: - if(ret_value == FALSE) - { /* Error condition cleanup */ - - } /* end if */ -#endif /* LATER */ + const hdf5_file_t *obj = (const hdf5_file_t *)_obj; + const char *key = (const char *)_key; + int ret_value = FALSE; + + FUNC_ENTER (H5F_compare_filename, NULL, FALSE); - /* Normal function cleanup */ + ret_value = !HDstrcmp (obj->filename, key); - return(!HDstrcmp(((const hdf5_file_t *)obj)->filename,(const char *)key)); + FUNC_LEAVE (ret_value); } /* H5F_compare_filename */ /*-------------------------------------------------------------------------- @@ -216,11 +203,10 @@ done: --------------------------------------------------------------------------*/ hatom_t H5Fget_create_template(hatom_t fid) { - CONSTR(FUNC, "H5Fget_create_template"); /* for HERROR */ hdf5_file_t *file=NULL; /* file struct for file to close */ hatom_t ret_value = FAIL; - FUNC_ENTER(H5F_mask, ID_H5Fget_create_template, H5F_init_interface, FAIL); + FUNC_ENTER(H5Fget_create_template, H5F_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -244,7 +230,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5F_mask, ID_H5Fget_create_template, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Fget_create_template() */ /*-------------------------------------------------------------------------- @@ -262,14 +248,13 @@ done: --------------------------------------------------------------------------*/ hbool_t H5Fis_hdf5(const char *filename) { - CONSTR(FUNC, "H5Fis_hdf5"); /* for HERROR */ hdf_file_t f_handle=H5F_INVALID_FILE; /* file handle */ uint8 temp_buf[HDF5_FILE_SIGNATURE_LEN]; /* temporary buffer for checking file signature */ haddr_t curr_off=0; /* The current offset to check in the file */ size_t file_len=0; /* The length of the file we are checking */ hbool_t ret_value = BFALSE; - FUNC_ENTER(H5F_mask, ID_H5Fis_hdf5, H5F_init_interface, BFAIL); + FUNC_ENTER(H5Fis_hdf5, H5F_init_interface, BFAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -317,7 +302,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5F_mask, ID_H5Fis_hdf5, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Fis_hdf5() */ @@ -419,7 +404,6 @@ H5F_dest (hdf5_file_t *f) --------------------------------------------------------------------------*/ hatom_t H5Fcreate(const char *filename, uintn flags, hatom_t create_temp, hatom_t access_temp) { - CONSTR(FUNC, "H5Fcreate"); /* for HERROR */ hdf5_file_t *new_file=NULL; /* file struct for new file */ hdf_file_t f_handle=H5F_INVALID_FILE; /* file handle */ const file_create_temp_t *f_create_parms; /* pointer to the parameters to use when creating the file */ @@ -427,7 +411,7 @@ hatom_t H5Fcreate(const char *filename, uintn flags, hatom_t create_temp, hatom_ intn file_exists=0; /* flag to indicate that file exists already */ hatom_t ret_value = FAIL; - FUNC_ENTER(H5F_mask, ID_H5Fcreate, H5F_init_interface, FAIL); + FUNC_ENTER(H5Fcreate, H5F_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -542,7 +526,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5F_mask, ID_H5Fcreate, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Fcreate() */ @@ -575,7 +559,6 @@ done: --------------------------------------------------------------------------*/ hatom_t H5Fopen(const char *filename, uintn flags, hatom_t access_temp) { - CONSTR(FUNC, "H5Fopen"); /* for HERROR */ hdf5_file_t *new_file=NULL; /* file struct for new file */ hdf_file_t f_handle=H5F_INVALID_FILE; /* file handle */ hatom_t create_temp; /* file-creation template ID */ @@ -586,7 +569,7 @@ hatom_t H5Fopen(const char *filename, uintn flags, hatom_t access_temp) hatom_t ret_value = FAIL; size_t variable_size; /*size of the variable part of the bb */ - FUNC_ENTER(H5F_mask, ID_H5Fopen, H5F_init_interface, FAIL); + FUNC_ENTER(H5Fopen, H5F_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -723,7 +706,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5F_mask, ID_H5Fopen, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Fopen() */ /*-------------------------------------------------------------------------- @@ -747,11 +730,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5Fclose(hatom_t fid) { - CONSTR(FUNC, "H5Fclose"); /* for HERROR */ hdf5_file_t *file=NULL; /* file struct for file to close */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5F_mask, ID_H5Fclose, H5F_init_interface, FAIL); + FUNC_ENTER(H5Fclose, H5F_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -782,7 +764,7 @@ done: } /* end if */ /* Normal function cleanup */ - FUNC_LEAVE(H5F_mask, ID_H5Fclose, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Fclose() */ @@ -792,9 +774,9 @@ done: * Purpose: Reads some data from a file/server/etc into a buffer. * The data is contiguous. * - * Return: Success: 0 + * Return: Success: SUCCEED * - * Failure: -1 + * Failure: FAIL * * Programmer: Robb Matzke * robb@maya.nuance.com @@ -807,19 +789,19 @@ done: herr_t H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) { - CONSTR(FUNC, "H5F_block_read"); /* for HERROR */ + FUNC_ENTER (H5F_block_read, NULL, FAIL); - PABLO_TRACE_ON(H5F_mask, ID_H5F_block_read); - - if (0==size) return 0; - addr += f->file_create_parms.userblock_size; + if (0==size) return 0; + addr += f->file_create_parms.userblock_size; - if (H5F_SEEK (f->file_handle, addr)<0) - HRETURN_ERROR(H5F_mask, ID_H5F_block_read, H5E_IO, H5E_SEEKERROR, FAIL); - if (H5F_READ (f->file_handle, buf, size)<0) - HRETURN_ERROR(H5F_mask, ID_H5F_block_read, H5E_IO, H5E_READERROR, FAIL); - PABLO_TRACE_OFF(H5F_mask, ID_H5F_block_read); - return SUCCEED; + if (H5F_SEEK (f->file_handle, addr)<0) { + HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL); + } + if (H5F_READ (f->file_handle, buf, size)<0) { + HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL); + } + + FUNC_LEAVE (SUCCEED); } @@ -829,9 +811,9 @@ H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) * Purpose: Writes some data from memory to a file/server/etc. The * data is contiguous. * - * Return: Success: 0 + * Return: Success: SUCCEED * - * Failure: -1 + * Failure: FAIL * * Programmer: Robb Matzke * robb@maya.nuance.com @@ -844,19 +826,19 @@ H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) herr_t H5F_block_write (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) { - CONSTR(FUNC, "H5F_block_write"); /* for HERROR */ - - PABLO_TRACE_ON(H5F_mask, ID_H5F_block_read); - - if (0==size) return 0; - addr += f->file_create_parms.userblock_size; - - if (H5F_SEEK (f->file_handle, addr)<0) - HRETURN_ERROR(H5F_mask, ID_H5F_block_write, H5E_IO, H5E_SEEKERROR, FAIL); - if (H5F_WRITE (f->file_handle, buf, size)<0) - HRETURN_ERROR(H5F_mask, ID_H5F_block_write, H5E_IO, H5E_WRITEERROR, FAIL); - PABLO_TRACE_OFF(H5F_mask, ID_H5F_block_write); - return SUCCEED; + FUNC_ENTER (H5F_block_write, NULL, FAIL); + + if (0==size) return 0; + addr += f->file_create_parms.userblock_size; + + if (H5F_SEEK (f->file_handle, addr)<0) { + HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL); + } + if (H5F_WRITE (f->file_handle, buf, size)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL); + } + + FUNC_LEAVE (SUCCEED); } @@ -40,10 +40,12 @@ static char RcsId[] = "@(#)$Revision$"; #include "H5Mprivate.h" /* Meta-object interface */ #include "H5Cprivate.h" /* Template interface */ +#define PABLO_MASK H5M_mask + /*--------------------- Locally scoped variables -----------------------------*/ /* Whether we've installed the library termination function yet for this interface */ -static intn interface_initialize = FALSE; +static intn interface_initialize_g = FALSE; /*------------------_-- Local function prototypes ----------------------------*/ static herr_t H5M_init_interface(void); @@ -59,21 +61,17 @@ RETURNS DESCRIPTION Initializes any interface-specific data or routines. +MODIFICATIONS + Robb Matzke, 4 Aug 1997 + Changed the FUNC variable value to H5M_init_interface. + --------------------------------------------------------------------------*/ static herr_t H5M_init_interface(void) { -#ifdef LATER - CONSTR(FUNC, "H5CIinit_interface"); /* For HERROR */ -#endif /* LATER */ herr_t ret_value = SUCCEED; + FUNC_ENTER (H5M_init_interface, NULL, FAIL); - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5M_mask, ID_H5M_init_interface); - - /* Don't call this routine again... */ - interface_initialize = TRUE; - - FUNC_LEAVE(H5M_mask, ID_H5M_init_interface, ret_value); + FUNC_LEAVE(ret_value); } /* H5M_init_interface */ /*-------------------------------------------------------------------------- @@ -93,11 +91,10 @@ static herr_t H5M_init_interface(void) --------------------------------------------------------------------------*/ static intn H5M_find_type(hobjtype_t type) { - CONSTR(FUNC, "H5M_find_type"); /* for HERROR */ intn i; /* local counting variable */ intn ret_value = FAIL; - FUNC_ENTER(H5M_mask, ID_H5M_find_type, H5M_init_interface, FAIL); + FUNC_ENTER(H5M_find_type, H5M_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -118,7 +115,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5M_mask, ID_H5M_find_type, ret_value); + FUNC_LEAVE(ret_value); } /* end H5M_find_type() */ /*-------------------------------------------------------------------------- @@ -139,11 +136,10 @@ done: --------------------------------------------------------------------------*/ hatom_t H5Mcreate(hatom_t owner_id, hobjtype_t type, const char *name) { - CONSTR(FUNC, "H5Mcreate"); /* for HERROR */ intn i; /* local counting variable */ hatom_t ret_value = SUCCEED; - FUNC_ENTER(H5M_mask, ID_H5Mcreate, H5M_init_interface, FAIL); + FUNC_ENTER(H5Mcreate, H5M_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -163,7 +159,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5M_mask, ID_H5Mcreate, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Mcreate() */ @@ -183,12 +179,11 @@ done: --------------------------------------------------------------------------*/ hatom_t H5Mcopy(hatom_t oid) { - CONSTR(FUNC, "H5Mcopy"); /* for HERROR */ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */ intn i; /* local counting variable */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5M_mask, ID_H5Mcopy, H5M_init_interface, FAIL); + FUNC_ENTER(H5Mcopy, H5M_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -208,7 +203,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5M_mask, ID_H5Mcopy, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Mcopy() */ /*-------------------------------------------------------------------------- @@ -227,12 +222,11 @@ done: --------------------------------------------------------------------------*/ herr_t H5Mrelease(hatom_t oid) { - CONSTR(FUNC, "H5Mrelease"); /* for HERROR */ group_t group=H5Aatom_group(oid); /* Atom group for incoming object */ intn i; /* local counting variable */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5M_mask, ID_H5Mrelease, H5M_init_interface, FAIL); + FUNC_ENTER(H5Mrelease, H5M_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -252,6 +246,6 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5M_mask, ID_H5Mrelease, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Mrelease() */ @@ -36,10 +36,12 @@ static char RcsId[] = "@(#)$Revision$"; #include "H5private.h" /* Generic Functions */ #include "H5Pprivate.h" /* Data-space functions */ +#define PABLO_MASK H5P_mask + /*--------------------- Locally scoped variables -----------------------------*/ /* Whether we've installed the library termination function yet for this interface */ -static intn interface_initialize = FALSE; +static intn interface_initialize_g = FALSE; /*-------------------------------------------------------------------------- NAME @@ -55,21 +57,13 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t H5P_init_interface(void) { -#ifdef LATER - CONSTR(FUNC, "H5P_init_interface"); /* For HERROR */ -#endif /* LATER */ herr_t ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5P_mask, ID_H5P_init_interface); - - /* Don't call this routine again... */ - interface_initialize = TRUE; + FUNC_ENTER (H5P_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ ret_value=H5Ainit_group(H5_DATASPACE,HDF5_DATASPACEID_HASHSIZE,H5P_RESERVED_ATOMS); - FUNC_LEAVE(H5P_mask, ID_H5P_init_interface, ret_value); + FUNC_LEAVE(ret_value); } /* H5P_init_interface */ /*-------------------------------------------------------------------------- @@ -89,11 +83,10 @@ static herr_t H5P_init_interface(void) --------------------------------------------------------------------------*/ hatom_t H5P_create(hatom_t owner_id, hobjtype_t type, const char *name) { - CONSTR(FUNC, "H5P_create"); /* for HERROR */ H5P_dim_t *new_dim; /* new dimensionality object to create */ hatom_t ret_value = SUCCEED; - FUNC_ENTER(H5P_mask, ID_H5P_create, H5P_init_interface, FAIL); + FUNC_ENTER(H5P_create, H5P_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -118,7 +111,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5P_mask, ID_H5P_create, ret_value); + FUNC_LEAVE(ret_value); } /* end H5P_create() */ /*-------------------------------------------------------------------------- @@ -139,10 +132,9 @@ done: --------------------------------------------------------------------------*/ uintn H5Pnelem(hatom_t sid) { - CONSTR(FUNC, "H5Pnelem"); /* for HERROR */ uintn ret_value = UFAIL; - FUNC_ENTER(H5P_mask, ID_H5Pnelem, H5P_init_interface, UFAIL); + FUNC_ENTER(H5Pnelem, H5P_init_interface, UFAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -161,7 +153,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5P_mask, ID_H5Pnelem, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Pnelem() */ /*-------------------------------------------------------------------------- @@ -179,11 +171,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5P_release(hatom_t oid) { - CONSTR(FUNC, "H5P_release"); /* for HERROR */ H5P_dim_t *dim; /* dimensionality object to release */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5P_mask, ID_H5Prelease, H5P_init_interface, FAIL); + FUNC_ENTER(H5Prelease, H5P_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -203,6 +194,6 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5P_mask, ID_H5P_release, ret_value); + FUNC_LEAVE(ret_value); } /* end H5P_release() */ @@ -42,10 +42,12 @@ static char RcsId[] = "@(#)$Revision$"; #include "H5private.h" /* Generic Functions */ #include "H5Tprivate.h" /* Data-type functions */ +#define PABLO_MASK H5T_mask + /*--------------------- Locally scoped variables -----------------------------*/ /* Whether we've installed the library termination function yet for this interface */ -static intn interface_initialize = FALSE; +static intn interface_initialize_g = FALSE; /*------------------_-- Local function prototypes ----------------------------*/ static herr_t H5T_init_interface(void); @@ -64,21 +66,13 @@ DESCRIPTION --------------------------------------------------------------------------*/ static herr_t H5T_init_interface(void) { -#ifdef LATER - CONSTR(FUNC, "H5T_init_interface"); /* For HERROR */ -#endif /* LATER */ herr_t ret_value = SUCCEED; - - /* Don't use "FUNC_ENTER" macro, to avoid potential infinite recursion */ - PABLO_TRACE_ON(H5T_mask, ID_H5T_init_interface); - - /* Don't call this routine again... */ - interface_initialize = TRUE; + FUNC_ENTER (H5T_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ ret_value=H5Ainit_group(H5_DATATYPE,HDF5_DATATYPEID_HASHSIZE,H5T_RESERVED_ATOMS); - FUNC_LEAVE(H5T_mask, ID_H5T_init_interface, ret_value); + FUNC_LEAVE(ret_value); } /* H5T_init_interface */ /*-------------------------------------------------------------------------- @@ -98,11 +92,10 @@ static herr_t H5T_init_interface(void) --------------------------------------------------------------------------*/ hatom_t H5T_create(hatom_t owner_id, hobjtype_t type, const char *name) { - CONSTR(FUNC, "H5T_create"); /* for HERROR */ h5_datatype_t *new_dt; /* new data-type object to create */ hatom_t ret_value = SUCCEED; - FUNC_ENTER(H5T_mask, ID_H5T_create, H5T_init_interface, FAIL); + FUNC_ENTER(H5T_create, H5T_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -128,7 +121,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5T_create, ret_value); + FUNC_LEAVE(ret_value); } /* end H5T_create() */ /*-------------------------------------------------------------------------- @@ -148,11 +141,10 @@ done: --------------------------------------------------------------------------*/ uint32 H5Tget_num_fields(hatom_t tid) { - CONSTR(FUNC, "H5Tget_num_fields"); /* for HERROR */ h5_datatype_t *dt; /* new data-type object to create */ uint32 ret_value = UFAIL; - FUNC_ENTER(H5T_mask, ID_H5Tget_num_fields, H5T_init_interface, UFAIL); + FUNC_ENTER(H5Tget_num_fields, H5T_init_interface, UFAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -180,7 +172,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5Tget_num_fields, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Tget_num_fields() */ /*-------------------------------------------------------------------------- @@ -201,11 +193,10 @@ done: --------------------------------------------------------------------------*/ hbool_t H5Tis_field_atomic(hatom_t tid, uintn fidx) { - CONSTR(FUNC, "H5Tis_field_atomic"); /* for HERROR */ h5_datatype_t *dt; /* new data-type object to create */ hbool_t ret_value = BTRUE; - FUNC_ENTER(H5T_mask, ID_H5Tis_field_atomic, H5T_init_interface, BFAIL); + FUNC_ENTER(H5Tis_field_atomic, H5T_init_interface, BFAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -238,7 +229,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5Tis_field_atomic, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Tis_field_atomic() */ /*-------------------------------------------------------------------------- @@ -258,11 +249,10 @@ done: --------------------------------------------------------------------------*/ hbool_t H5Tis_atomic(hatom_t tid) { - CONSTR(FUNC, "H5Tis_atomic"); /* for HERROR */ h5_datatype_t *dt; /* new data-type object to create */ hbool_t ret_value = BTRUE; - FUNC_ENTER(H5T_mask, ID_H5Tis_atomic, H5T_init_interface, BFAIL); + FUNC_ENTER(H5Tis_atomic, H5T_init_interface, BFAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -283,7 +273,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5Tis_atomic, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Tis_atomic() */ /*-------------------------------------------------------------------------- @@ -307,11 +297,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5Tset_type(hatom_t tid,hatom_t base,uint8 len,uint8 arch) { - CONSTR(FUNC, "H5Tset_type"); /* for HERROR */ h5_datatype_t *dt; /* new data-type object to create */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5T_mask, ID_H5Tset_type, H5T_init_interface, FAIL); + FUNC_ENTER(H5Tset_type, H5T_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -337,7 +326,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5Tset_type, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Tset_type() */ /*-------------------------------------------------------------------------- @@ -366,12 +355,11 @@ done: --------------------------------------------------------------------------*/ herr_t H5Tadd_field(hatom_t tid, const char *name, hatom_t base, uint8 len, uint8 arch, hatom_t space) { - CONSTR(FUNC, "H5Tadd_field"); /* for HERROR */ h5_field_info_t *new_field; /* pointer to new field to add */ h5_datatype_t *dt; /* data-type object to manipulate */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5T_mask, ID_H5Tadd_field, H5T_init_interface, FAIL); + FUNC_ENTER(H5Tadd_field, H5T_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -426,7 +414,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5Tadd_field, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Tadd_field() */ /*-------------------------------------------------------------------------- @@ -447,10 +435,9 @@ done: --------------------------------------------------------------------------*/ uintn H5Tsize(hatom_t tid, uint8 len, uint8 arch, hbool_t mem_flag) { - CONSTR(FUNC, "H5Tsize"); /* for HERROR */ uintn ret_value = UFAIL; - FUNC_ENTER(H5T_mask, ID_H5Tsize, H5T_init_interface, UFAIL); + FUNC_ENTER(H5Tsize, H5T_init_interface, UFAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -519,7 +506,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5Tsize, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Tsize() */ /*-------------------------------------------------------------------------- @@ -540,10 +527,9 @@ done: --------------------------------------------------------------------------*/ herr_t H5Tget_fields(hatom_t tid, hatom_t *field_list) { - CONSTR(FUNC, "H5Tget_fields"); /* for HERROR */ herr_t ret_value = FAIL; - FUNC_ENTER(H5T_mask, ID_H5Tget_fields, H5T_init_interface, FAIL); + FUNC_ENTER(H5Tget_fields, H5T_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -560,7 +546,7 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5Tget_fields, ret_value); + FUNC_LEAVE(ret_value); } /* end H5Tget_fields() */ /*-------------------------------------------------------------------------- @@ -578,11 +564,10 @@ done: --------------------------------------------------------------------------*/ herr_t H5T_release(hatom_t oid) { - CONSTR(FUNC, "H5T_release"); /* for HERROR */ h5_datatype_t *dt; /* new data-type object to create */ herr_t ret_value = SUCCEED; - FUNC_ENTER(H5T_mask, ID_H5T_release, H5T_init_interface, FAIL); + FUNC_ENTER(H5T_release, H5T_init_interface, FAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -605,6 +590,6 @@ done: /* Normal function cleanup */ - FUNC_LEAVE(H5T_mask, ID_H5T_release, ret_value); + FUNC_LEAVE(ret_value); } /* end H5T_release() */ 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 */ diff --git a/src/hdf5glob.h b/src/hdf5glob.h index 2fc752d..5d45bcb 100644 --- a/src/hdf5glob.h +++ b/src/hdf5glob.h @@ -25,7 +25,7 @@ #ifndef HDF5_MASTER extern #endif /* HDF5_MASTER */ -intn library_initialize /* Whether we've initialized library global information yet */ +intn library_initialize_g /* Whether we've initialized library global information yet */ #ifdef HDF5_MASTER = FALSE #endif /* HDF5_MASTER */ @@ -43,7 +43,7 @@ intn install_atexit /* Whether to install the atexit routine */ #ifndef HDF5_MASTER extern #endif /* HDF5_MASTER */ -intn thread_initialize /* Whether we've initialized thread global information yet */ +intn thread_initialize_g /* Whether we've initialized thread global information yet */ #ifdef HDF5_MASTER = FALSE #endif /* HDF5_MASTER */ |