summaryrefslogtreecommitdiffstats
path: root/src/H5AC.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5AC.c')
-rw-r--r--src/H5AC.c138
1 files changed, 67 insertions, 71 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 862eb8c..22851d8 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -114,7 +114,7 @@ H5AC_dest(H5F_t *f)
assert(f->shared->cache);
cache = f->shared->cache;
- if (H5AC_flush(f, NULL, NULL, TRUE) < 0) {
+ if (H5AC_flush(f, NULL, H5F_ADDR_UNDEF, TRUE) < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush cache");
}
@@ -175,17 +175,19 @@ H5AC_dest(H5F_t *f)
* Keeps track of hits, misses, and flushes per object type so we have
* some cache performance diagnostics.
*
+ * Robb Matzke, 1999-07-27
+ * The ADDR argument is passed by value.
+ *
*-------------------------------------------------------------------------
*/
void *
-H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- const void *udata1, void *udata2)
+H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
+ const void *udata1, void *udata2)
{
unsigned idx;
herr_t status;
void *thing = NULL;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
- void *) = NULL;
+ herr_t (*flush) (H5F_t *, hbool_t, haddr_t, void*) = NULL;
H5AC_slot_t *slot = NULL;
H5AC_t *cache = NULL;
@@ -196,7 +198,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
assert(type);
assert(type->load);
assert(type->flush);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
slot = cache->slot + idx;
@@ -204,7 +206,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
/*
* Return right away if the item is in the cache.
*/
- if (slot->type == type && H5F_addr_eq(&(slot->addr), addr)) {
+ if (slot->type == type && H5F_addr_eq(slot->addr, addr)) {
cache->diagnostics[type->id].nhits++;
HRETURN(slot->thing);
}
@@ -214,7 +216,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* Fail if the item in the cache is at the correct address but is
* of the wrong type.
*/
- if (slot->type && slot->type != type && H5F_addr_eq(&(slot->addr), addr)) {
+ if (slot->type && slot->type != type && H5F_addr_eq(slot->addr, addr)) {
HRETURN_ERROR(H5E_CACHE, H5E_BADTYPE, NULL,
"internal error (correct address, wrong type)");
}
@@ -227,7 +229,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
{
intn i;
for (i = 0; i < slot->nprots; i++) {
- assert(H5F_addr_ne(addr, &(slot->prot[i].addr)));
+ assert(H5F_addr_ne(addr, slot->prot[i].addr));
}
}
#endif
@@ -236,7 +238,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* Load a new thing. If it can't be loaded, then return an error
* without preempting anything.
*/
- if (NULL == (thing = (type->load) (f, addr, udata1, udata2))) {
+ if (NULL == (thing = (type->load)(f, addr, udata1, udata2))) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load object");
}
/*
@@ -244,13 +246,13 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
*/
if (slot->type) {
flush = slot->type->flush;
- status = (flush) (f, TRUE, &(slot->addr), slot->thing);
+ status = (flush)(f, TRUE, slot->addr, slot->thing);
if (status < 0) {
/*
* The old thing could not be removed from the stack.
* Release the new thing and fail.
*/
- if ((type->flush) (f, TRUE, addr, thing) < 0) {
+ if ((type->flush)(f, TRUE, addr, thing) < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL,
"unable to flush just-loaded object");
}
@@ -263,7 +265,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* Make the cache point to the new thing.
*/
slot->type = type;
- slot->addr = *addr;
+ slot->addr = addr;
slot->thing = thing;
FUNC_LEAVE(thing);
@@ -318,8 +320,8 @@ H5AC_compare(const void *_a, const void *_b)
*
* Purpose: Flushes (and destroys if DESTROY is non-zero) the specified
* entry from the cache. If the entry TYPE is CACHE_FREE and
- * ADDR is the null pointer then all types of entries are
- * flushed. If TYPE is CACHE_FREE and ADDR is non-null, then
+ * ADDR is H5F_ADDR_UNDEF then all types of entries are
+ * flushed. If TYPE is CACHE_FREE and ADDR is defined then
* whatever is cached at ADDR is flushed. Otherwise the thing
* at ADDR is flushed if it is the correct type.
*
@@ -335,17 +337,16 @@ H5AC_compare(const void *_a, const void *_b)
* Jul 9 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-27
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- hbool_t destroy)
+H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
{
uintn i;
herr_t status;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
- void *) = NULL;
+ herr_t (*flush)(H5F_t *, hbool_t, haddr_t, void*) = NULL;
H5AC_slot_t *slot;
intn *map = NULL;
uintn nslots;
@@ -357,7 +358,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
assert(f->shared->cache);
cache = f->shared->cache;
- if (!addr) {
+ if (!H5F_addr_defined(addr)) {
#ifdef H5AC_SORT_BY_ADDR
/*
@@ -378,8 +379,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
current_cache_g = NULL;
#ifdef NDEBUG
for (i = 1; i < nslots; i++) {
- assert(H5F_addr_lt(&(cache->slot[i - 1].addr),
- &(cache->slot[i].addr)));
+ assert(H5F_addr_lt(cache->slot[i - 1].addr, cache->slot[i].addr));
}
#endif
#else
@@ -399,7 +399,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
#endif
if (!type || type == slot->type) {
flush = slot->type->flush;
- status = (flush) (f, destroy, &(slot->addr), slot->thing);
+ status = (flush)(f, destroy, slot->addr, slot->thing);
if (status < 0) {
map = H5MM_xfree(map);
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
@@ -423,13 +423,13 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
} else {
i = H5AC_HASH(f, addr);
if ((!type || cache->slot[i].type == type) &&
- H5F_addr_eq(&(cache->slot[i].addr), addr)) {
+ H5F_addr_eq(cache->slot[i].addr, addr)) {
/*
* Flush just this entry.
*/
flush = cache->slot[i].type->flush;
- status = (flush) (f, destroy, &(cache->slot[i].addr),
- cache->slot[i].thing);
+ status = (flush)(f, destroy, cache->slot[i].addr,
+ cache->slot[i].thing);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush object");
@@ -460,16 +460,16 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* Jul 9 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-27
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
+H5AC_set(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
{
herr_t status;
uintn idx;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
- void *) = NULL;
+ herr_t (*flush)(H5F_t *, hbool_t, haddr_t, void*) = NULL;
H5AC_slot_t *slot = NULL;
H5AC_t *cache = NULL;
@@ -479,7 +479,7 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
assert(f->shared->cache);
assert(type);
assert(type->flush);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(thing);
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
@@ -489,14 +489,14 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
{
intn i;
for (i = 0; i < slot->nprots; i++) {
- assert(H5F_addr_ne(addr, &(slot->prot[i].addr)));
+ assert(H5F_addr_ne(addr, slot->prot[i].addr));
}
}
#endif
if (slot->type) {
flush = slot->type->flush;
- status = (flush) (f, TRUE, &(slot->addr), slot->thing);
+ status = (flush)(f, TRUE, slot->addr, slot->thing);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush object");
@@ -504,7 +504,7 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
cache->diagnostics[slot->type->id].nflushes++;
}
slot->type = type;
- slot->addr = *addr;
+ slot->addr = addr;
slot->thing = thing;
cache->diagnostics[type->id].ninits++;
@@ -528,16 +528,16 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
* Jul 9 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-27
+ * The OLD_ADDR and NEW_ADDR arguments are passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_rename(H5F_t *f, const H5AC_class_t *type,
- const haddr_t *old_addr, const haddr_t *new_addr)
+H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
+ haddr_t new_addr)
{
uintn old_idx, new_idx;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
- void *);
+ herr_t (*flush)(H5F_t *, hbool_t, haddr_t, void*);
herr_t status;
H5AC_t *cache = NULL;
@@ -546,8 +546,6 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
assert(f);
assert(f->shared->cache);
assert(type);
- assert(old_addr);
- assert(new_addr);
old_idx = H5AC_HASH(f, old_addr);
new_idx = H5AC_HASH(f, new_addr);
cache = f->shared->cache;
@@ -557,12 +555,10 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
int i;
for (i = 0; i < cache->slot[old_idx].nprots; i++) {
- assert(H5F_addr_ne(old_addr,
- &(cache->slot[old_idx].prot[i].addr)));
+ assert(H5F_addr_ne(old_addr, cache->slot[old_idx].prot[i].addr));
}
for (i = 0; i < cache->slot[new_idx].nprots; i++) {
- assert(H5F_addr_ne(new_addr,
- &(cache->slot[new_idx].prot[i].addr)));
+ assert(H5F_addr_ne(new_addr, cache->slot[new_idx].prot[i].addr));
}
}
#endif
@@ -572,11 +568,11 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
* new hash value is the same as the old one.
*/
if (cache->slot[old_idx].type != type ||
- H5F_addr_ne(&(cache->slot[old_idx].addr), old_addr)) {
+ H5F_addr_ne(cache->slot[old_idx].addr, old_addr)) {
HRETURN(SUCCEED);
}
if (old_idx == new_idx) {
- cache->slot[old_idx].addr = *new_addr;
+ cache->slot[old_idx].addr = new_addr;
HRETURN(SUCCEED);
}
/*
@@ -584,8 +580,8 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
*/
if (cache->slot[new_idx].type) {
flush = cache->slot[new_idx].type->flush;
- status = (flush) (f, TRUE, &(cache->slot[new_idx].addr),
- cache->slot[new_idx].thing);
+ status = (flush)(f, TRUE, cache->slot[new_idx].addr,
+ cache->slot[new_idx].thing);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush object");
@@ -596,7 +592,7 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
* Move the source to the destination (it might not be cached)
*/
cache->slot[new_idx].type = cache->slot[old_idx].type;
- cache->slot[new_idx].addr = *new_addr;
+ cache->slot[new_idx].addr = new_addr;
cache->slot[new_idx].thing = cache->slot[old_idx].thing;
cache->slot[old_idx].type = NULL;
@@ -626,12 +622,13 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type,
* Sep 2 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-27
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
void *
-H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- const void *udata1, void *udata2)
+H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
+ const void *udata1, void *udata2)
{
int idx;
void *thing = NULL;
@@ -657,22 +654,22 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
assert(type);
assert(type->load);
assert(type->flush);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
slot = cache->slot + idx;
- if (slot->type == type && H5F_addr_eq(&(slot->addr), addr)) {
+ if (slot->type == type && H5F_addr_eq(slot->addr, addr)) {
/*
* The object is already cached; simply remove it from the cache.
*/
cache->diagnostics[slot->type->id].nhits++;
thing = slot->thing;
slot->type = NULL;
- H5F_addr_undef(&(slot->addr));
+ slot->addr = H5F_ADDR_UNDEF;
slot->thing = NULL;
- } else if (slot->type && H5F_addr_eq(&(slot->addr), addr)) {
+ } else if (slot->type && H5F_addr_eq(slot->addr, addr)) {
/*
* Right address but wrong object type.
*/
@@ -688,7 +685,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
*/
intn i;
for (i = 0; i < slot->nprots; i++) {
- assert(H5F_addr_ne(addr, &(slot->prot[i].addr)));
+ assert(H5F_addr_ne(addr, slot->prot[i].addr));
}
#endif
@@ -697,7 +694,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* without preempting anything.
*/
cache->diagnostics[type->id].nmisses++;
- if (NULL == (thing = (type->load) (f, addr, udata1, udata2))) {
+ if (NULL == (thing = (type->load)(f, addr, udata1, udata2))) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL,
"unable to load object");
}
@@ -720,7 +717,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
slot->prot = x;
}
slot->prot[slot->nprots].type = type;
- slot->prot[slot->nprots].addr = *addr;
+ slot->prot[slot->nprots].addr = addr;
slot->prot[slot->nprots].thing = thing;
slot->nprots += 1;
#endif
@@ -748,17 +745,16 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* Sep 2 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-27
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- void *thing)
+H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
{
herr_t status;
uintn idx;
- herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *,
- void *) = NULL;
+ herr_t (*flush)(H5F_t*, hbool_t, haddr_t, void*) = NULL;
H5AC_t *cache = NULL;
H5AC_slot_t *slot = NULL;
@@ -769,7 +765,7 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
assert(f->shared->cache);
assert(type);
assert(type->flush);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(thing);
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
@@ -780,9 +776,9 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* better not be another copy of the protected object.
*/
if (slot->type) {
- assert(H5F_addr_ne(&(slot->addr), addr));
+ assert(H5F_addr_ne(slot->addr, addr));
flush = slot->type->flush;
- status = (flush) (f, TRUE, &(slot->addr), slot->thing);
+ status = (flush)(f, TRUE, slot->addr, slot->thing);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush object");
@@ -797,7 +793,7 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
{
int found, i;
for (i = 0, found = FALSE; i < slot->nprots && !found; i++) {
- if (H5F_addr_eq(addr, &(slot->prot[i].addr))) {
+ if (H5F_addr_eq(addr, slot->prot[i].addr)) {
assert(slot->prot[i].type == type);
HDmemmove(slot->prot + i, slot->prot + i + 1,
((slot->nprots - i) - 1) * sizeof(H5AC_prot_t));
@@ -813,7 +809,7 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
* Insert the object back into the cache; it is no longer protected.
*/
slot->type = type;
- slot->addr = *addr;
+ slot->addr = addr;
slot->thing = thing;
cache->nprots -= 1;