diff options
author | Robb Matzke <matzke@llnl.gov> | 1997-08-05 02:07:08 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1997-08-05 02:07:08 (GMT) |
commit | e251f45b8741c7e7bf2dbd4d76a76d67dbfc6da1 (patch) | |
tree | 99ce978bac2ceec3646a60753b437d874a92de29 /src/H5AC.c | |
parent | 6a3cb617d3aa57f439065118fbc68afcb1465a54 (diff) | |
download | hdf5-e251f45b8741c7e7bf2dbd4d76a76d67dbfc6da1.zip hdf5-e251f45b8741c7e7bf2dbd4d76a76d67dbfc6da1.tar.gz hdf5-e251f45b8741c7e7bf2dbd4d76a76d67dbfc6da1.tar.bz2 |
[svn-r13] ./src/H5.c
Added an `_g' to the end of library_initialize,
thread_initialize, and interface_initialize to abide by the
naming convention. Removed setting of these variables from
the various initialization functions since it happens in the
FUNC_ENTER() macro now.
Defined PABLO_MASK.
Removed `CONSTR(FUNC,"function_name")' everywhere since it's
handled by the various FUNC_ENTER macros.
Fixed calls to FUNC_ENTER(), FUNC_LEAVE(), and HRETURN_ERROR()
so they don't need so many arguments.
Changed PABLO_TRACE_ON() to FUNC_ENTER() since there is no
longer any danger of infinite recursion.
H5_term_library() now returns SUCCEED/FAIL and uses
FUNC_ENTER/FUNC_EXIT macros.
./src/H5A.c
Changes similar to H5.c.
Most (all?) of the functions called PABLO_TRACE_ON() and the
package doesn't have an interface initializer that I can see,
so the second argument to FUNC_ENTER() is always NULL.
H5A_release_atom_node() returns SUCCEED/FAIL.
./src/H5AC.c
Added error handling.
Arguments for internal functions are checked with assert().
./src/H5C.c
Changes similar to H5.c
Fixed the FUNC variable in H5C_get_default_atom() since it was
initialized to the wrong name.
./src/H5D.c
Changes similar to H5.c
./src/H5E.c
Changes similar to H5.c
Changed the pablo mask from H5_mask to H5E_mask in
H5E_init_interface().
H5Eclear(), H5E_store(), and H5Epush() return SUCCEED/FAIL.
Changed PABLO_TRACE_OFF() calls to FUNC_LEAVE() calls in the
same functions.
./src/H5Eprivate.h
./src/H5Eproto.h
Added additional error symbols for the H5AC package.
Changed prototypes for H5Eclear() and H5Epush().
Changes to HRETURN_ERROR() and HGOTO_ERROR() to reduce the
number of arguments.
./src/H5F.c
Changes similr to H5.c
Changed the pablo mask from H5_mask to H5F_mask for the
FUNC_LEAVE() call of H5F_init_interface().
Added FUNC_ENTER() and FUNC_LEAVE() calls to some functions
that didn't have them.
./src/H5M.c
Changes similar to H5.c
Fixed the FUNC variable in H5M_init_interface() since it was
initialized to the wrong name.
./src/H5P.c
Changes similar to H5.c
./src/H5T.c
Changes similar to H5.c
./src/hdf5gen.c
Changes to FUNC_ENTER() and FUNC_EXIT() to reduce the number
of arguments. FUNC_ENTER() is now safe from infinite
recursion since it updates the library_initialize_g,
thread_initialize_g, or interface_initialize_g variables
before calling the appropriate initialize function.
Diffstat (limited to 'src/H5AC.c')
-rw-r--r-- | src/H5AC.c | 116 |
1 files changed, 85 insertions, 31 deletions
@@ -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); } |