summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5.c1
-rw-r--r--src/H5AC.c271
-rw-r--r--src/H5ACprivate.h40
-rw-r--r--src/H5Bprivate.h3
-rw-r--r--src/H5D.c1
-rw-r--r--src/H5Gnode.c3
-rw-r--r--src/H5Gpkg.h2
-rw-r--r--src/H5Gstab.c1
-rw-r--r--src/H5HG.c2
-rw-r--r--src/H5HL.c2
-rw-r--r--src/H5Oprivate.h2
11 files changed, 183 insertions, 145 deletions
diff --git a/src/H5.c b/src/H5.c
index 40d1573..c7fab81 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -18,7 +18,6 @@ static char RcsId[] = "@(#)$Revision$";
/* private headers */
#include <H5private.h> /*library */
-#include <H5ACprivate.h> /*cache */
#include <H5Bprivate.h> /*B-link trees */
#include <H5Eprivate.h> /*error handling */
#include <H5FDprivate.h> /*file driver */
diff --git a/src/H5AC.c b/src/H5AC.c
index dbe8ab1..722b709 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -80,12 +80,18 @@ H5AC_create(H5F_t *f, intn size_hint)
"memory allocation failed");
}
cache->nslots = size_hint;
- cache->slot = H5MM_calloc(cache->nslots*sizeof(H5AC_slot_t));
+ cache->slot = H5MM_calloc(cache->nslots*sizeof(H5AC_info_t *));
if (NULL==cache->slot) {
- f->shared->cache = H5MM_xfree (f->shared->cache);
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
+ f->shared->cache = H5MM_xfree (f->shared->cache);
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
}
+#ifdef H5AC_DEBUG
+ if ((cache->prot = H5MM_calloc(cache->nslots*sizeof(H5AC_prot_t)))==NULL) {
+ cache->slot = H5MM_xfree (cache->slot);
+ f->shared->cache = H5MM_xfree (f->shared->cache);
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ }
+#endif /* H5AC_DEBUG */
FUNC_LEAVE(size_hint);
}
@@ -125,10 +131,11 @@ H5AC_dest(H5F_t *f)
{
uintn i;
for (i=0; i<cache->nslots; i++) {
- cache->slot[i].prot = H5MM_xfree(cache->slot[i].prot);
- cache->slot[i].aprots = 0;
- cache->slot[i].nprots = 0;
+ cache->prot[i].slot = H5MM_xfree(cache->prot[i].slot);
+ cache->prot[i].aprots = 0;
+ cache->prot[i].nprots = 0;
}
+ cache->prot = H5MM_xfree(cache->prot);
}
#endif
@@ -190,8 +197,8 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
unsigned idx;
herr_t status;
void *thing = NULL;
- herr_t (*flush) (H5F_t *, hbool_t, haddr_t, void*) = NULL;
- H5AC_slot_t *slot = NULL;
+ H5AC_flush_func_t flush;
+ H5AC_info_t **info = NULL;
H5AC_t *cache = NULL;
FUNC_ENTER(H5AC_find, NULL);
@@ -204,14 +211,14 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
assert(H5F_addr_defined(addr));
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
- slot = cache->slot + idx;
+ info = cache->slot + idx;
/*
* Return right away if the item is in the cache.
*/
- if (slot->type == type && H5F_addr_eq(slot->addr, addr)) {
+ if ((*info) && (*info)->type == type && H5F_addr_eq((*info)->addr, addr)) {
cache->diagnostics[type->id].nhits++;
- HRETURN(slot->thing);
+ HRETURN(*info);
}
cache->diagnostics[type->id].nmisses++;
@@ -219,7 +226,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, 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 ((*info) && (*info)->type && (*info)->type != type && H5F_addr_eq((*info)->addr, addr)) {
HRETURN_ERROR(H5E_CACHE, H5E_BADTYPE, NULL,
"internal error (correct address, wrong type)");
}
@@ -230,12 +237,15 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
* H5AC_protect() function.
*/
{
+ H5AC_prot_t *prot = NULL;
intn i;
- for (i = 0; i < slot->nprots; i++) {
- assert(H5F_addr_ne(addr, slot->prot[i].addr));
+
+ prot = cache->prot + idx;
+ for (i = 0; i < prot->nprots; i++) {
+ assert(H5F_addr_ne(addr, prot->slot[i]->addr));
}
}
-#endif
+#endif /* H5AC_DEBUG */
/*
* Load a new thing. If it can't be loaded, then return an error
@@ -247,9 +257,9 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
/*
* Free the previous cache entry if there is one.
*/
- if (slot->type) {
- flush = slot->type->flush;
- status = (flush)(f, TRUE, slot->addr, slot->thing);
+ if (*info) {
+ flush = (*info)->type->flush;
+ status = (flush)(f, TRUE, (*info)->addr, (*info));
if (status < 0) {
/*
* The old thing could not be removed from the stack.
@@ -262,14 +272,14 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL,
"unable to flush existing cached object");
}
- cache->diagnostics[slot->type->id].nflushes++;
+ cache->diagnostics[(*info)->type->id].nflushes++;
}
/*
* Make the cache point to the new thing.
*/
- slot->type = type;
- slot->addr = addr;
- slot->thing = thing;
+ (*info)=thing;
+ (*info)->type = type;
+ (*info)->addr = addr;
FUNC_LEAVE(thing);
}
@@ -301,17 +311,17 @@ H5AC_compare(const void *_a, const void *_b)
assert(current_cache_g);
- if (NULL == current_cache_g->slot[a].type) {
- if (NULL == current_cache_g->slot[b].type) {
+ if (NULL == current_cache_g->slot[a]->type) {
+ if (NULL == current_cache_g->slot[b]->type) {
return 0;
} else {
return -1;
}
- } else if (NULL == current_cache_g->slot[b].type) {
+ } else if (NULL == current_cache_g->slot[b]->type) {
return 1;
- } else if (current_cache_g->slot[a].addr < current_cache_g->slot[b].addr) {
+ } else if (current_cache_g->slot[a]->addr < current_cache_g->slot[b]->addr) {
return -1;
- } else if (current_cache_g->slot[a].addr > current_cache_g->slot[b].addr) {
+ } else if (current_cache_g->slot[a]->addr > current_cache_g->slot[b]->addr) {
return 1;
}
return 0;
@@ -349,8 +359,8 @@ 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, haddr_t, void*) = NULL;
- H5AC_slot_t *slot;
+ H5AC_flush_func_t flush=NULL;
+ H5AC_info_t **info;
intn *map = NULL;
uintn nslots;
H5AC_t *cache = NULL;
@@ -373,7 +383,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
"memory allocation failed");
}
for (i = nslots = 0; i < cache->nslots; i++) {
- if (cache->slot[i].type)
+ if (cache->slot[i]!=NULL)
map[nslots++] = i;
}
assert(NULL == current_cache_g);
@@ -382,7 +392,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
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
@@ -394,23 +404,25 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
*/
for (i = 0; i < nslots; i++) {
#ifdef H5AC_SORT_BY_ADDR
- slot = cache->slot + map[i];
- if (NULL == slot->type) break; /*the rest are empty */
+ info = cache->slot + map[i];
+ if (NULL == (*info))
+ break; /*the rest are empty */
#else
- slot = cache->slot + i;
- if (NULL == slot->type) continue;
+ info = cache->slot + i;
+ if (NULL == (*info))
+ continue;
#endif
- if (!type || type == slot->type) {
- flush = slot->type->flush;
- status = (flush)(f, destroy, slot->addr, slot->thing);
+ if ((*info) || type == (*info)->type) {
+ flush = (*info)->type->flush;
+ status = (flush)(f, destroy, (*info)->addr, (*info));
if (status < 0) {
map = H5MM_xfree(map);
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush cache");
}
- cache->diagnostics[slot->type->id].nflushes++;
+ cache->diagnostics[(*info)->type->id].nflushes++;
if (destroy)
- slot->type = NULL;
+ (*info)= NULL;
}
}
map = H5MM_xfree(map);
@@ -425,21 +437,21 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
}
} else {
i = H5AC_HASH(f, addr);
- if ((!type || cache->slot[i].type == type) &&
- H5F_addr_eq(cache->slot[i].addr, addr)) {
+ if (cache->slot[i] && (!type || cache->slot[i]->type == type) &&
+ 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);
+ flush = cache->slot[i]->type->flush;
+ status = (flush)(f, destroy, cache->slot[i]->addr,
+ cache->slot[i]);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush object");
}
- cache->diagnostics[cache->slot[i].type->id].nflushes++;
+ cache->diagnostics[cache->slot[i]->type->id].nflushes++;
if (destroy)
- cache->slot[i].type = NULL;
+ cache->slot[i]= NULL;
}
}
@@ -472,8 +484,8 @@ 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, haddr_t, void*) = NULL;
- H5AC_slot_t *slot = NULL;
+ H5AC_flush_func_t flush=NULL;
+ H5AC_info_t **info = NULL;
H5AC_t *cache = NULL;
FUNC_ENTER(H5AC_set, FAIL);
@@ -486,30 +498,33 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
assert(thing);
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
- slot = cache->slot + idx;
+ info = cache->slot + idx;
#ifdef H5AC_DEBUG
{
+ H5AC_prot_t *prot = NULL;
intn i;
- for (i = 0; i < slot->nprots; i++) {
- assert(H5F_addr_ne(addr, slot->prot[i].addr));
+
+ prot = cache->prot + idx;
+ for (i = 0; i < prot->nprots; i++) {
+ assert(H5F_addr_ne(addr, prot->slot[i]->addr));
}
}
#endif
- if (slot->type) {
- flush = slot->type->flush;
- status = (flush)(f, TRUE, slot->addr, slot->thing);
+ if ((*info)) {
+ flush = (*info)->type->flush;
+ status = (flush)(f, TRUE, (*info)->addr, (*info));
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush object");
}
- cache->diagnostics[slot->type->id].nflushes++;
+ cache->diagnostics[(*info)->type->id].nflushes++;
}
- slot->type = type;
- slot->addr = addr;
- slot->thing = thing;
+ (*info)=thing;
+ (*info)->type = type;
+ (*info)->addr = addr;
cache->diagnostics[type->id].ninits++;
FUNC_LEAVE(SUCCEED);
@@ -541,7 +556,7 @@ 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, haddr_t, void*);
+ H5AC_flush_func_t flush=NULL;
herr_t status;
H5AC_t *cache = NULL;
@@ -556,13 +571,16 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
#ifdef H5AC_DEBUG
{
+ H5AC_prot_t *prot = NULL;
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));
+ prot = cache->prot + old_idx;
+ for (i = 0; i < prot->nprots; i++) {
+ assert(H5F_addr_ne(old_addr, prot->slot[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));
+ prot = cache->prot + new_idx;
+ for (i = 0; i < prot->nprots; i++) {
+ assert(H5F_addr_ne(new_addr, prot->slot[i]->addr));
}
}
#endif
@@ -571,34 +589,34 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
* We don't need to do anything if the object isn't cached or if the
* 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)) {
+ if (cache->slot[old_idx]->type != type ||
+ 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);
}
/*
* Free the item from the destination cache line.
*/
- 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);
+ if (cache->slot[new_idx]) {
+ flush = cache->slot[new_idx]->type->flush;
+ status = (flush)(f, TRUE, cache->slot[new_idx]->addr,
+ cache->slot[new_idx]);
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush object");
}
- cache->diagnostics[cache->slot[new_idx].type->id].nflushes++;
+ cache->diagnostics[cache->slot[new_idx]->type->id].nflushes++;
}
/*
* 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].thing = cache->slot[old_idx].thing;
- cache->slot[old_idx].type = NULL;
+ cache->slot[new_idx]= cache->slot[old_idx];
+ cache->slot[new_idx]->type = cache->slot[old_idx]->type;
+ cache->slot[new_idx]->addr = new_addr;
+ cache->slot[old_idx]= NULL;
FUNC_LEAVE(SUCCEED);
}
@@ -637,9 +655,11 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
int idx;
void *thing = NULL;
H5AC_t *cache = NULL;
- H5AC_slot_t *slot = NULL;
+ H5AC_info_t **info = NULL;
#ifdef H5AC_DEBUG
+ H5AC_prot_t *prot = NULL;
+
static int ncalls = 0;
if (0 == ncalls++) {
if (H5DEBUG(AC)) {
@@ -661,19 +681,22 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
assert(H5F_addr_defined(addr));
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
- slot = cache->slot + idx;
+ info = cache->slot + idx;
+#ifdef H5AC_DEBUG
+ prot = cache->prot + idx;
+#endif /* H5AC_DEBUG */
- if (slot->type == type && H5F_addr_eq(slot->addr, addr)) {
+ if ((*info) && (*info)->type == type && H5F_addr_eq((*info)->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;
- slot->addr = HADDR_UNDEF;
- slot->thing = NULL;
+ cache->diagnostics[(*info)->type->id].nhits++;
+ thing = (*info);
+ (*info)->type = NULL;
+ (*info)->addr = HADDR_UNDEF;
+ (*info)= NULL;
- } else if (slot->type && H5F_addr_eq(slot->addr, addr)) {
+ } else if ((*info) && (*info)->type && H5F_addr_eq((*info)->addr, addr)) {
/*
* Right address but wrong object type.
*/
@@ -688,10 +711,11 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
* H5AC_protect() function.
*/
intn i;
- for (i = 0; i < slot->nprots; i++) {
- assert(H5F_addr_ne(addr, slot->prot[i].addr));
+
+ for (i = 0; i < prot->nprots; i++) {
+ assert(H5F_addr_ne(addr, prot->slot[i]->addr));
}
-#endif
+#endif /* H5AC_DEBUG */
/*
* Load a new thing. If it can't be loaded, then return an error
@@ -709,22 +733,22 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
* Add the protected object to the protect debugging fields of the
* cache.
*/
- if (slot->nprots >= slot->aprots) {
- size_t na = slot->aprots + 10;
- H5AC_prot_t *x = H5MM_realloc(slot->prot,
- na * sizeof(H5AC_prot_t));
- if (NULL==x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- slot->aprots = (intn)na;
- slot->prot = x;
+ if (prot->nprots >= prot->aprots) {
+ size_t na = prot->aprots + 10;
+ H5AC_info_t **x = H5MM_realloc(prot->slot,
+ na * sizeof(H5AC_info_t *));
+ if (NULL==x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ prot->aprots = (intn)na;
+ prot->slot = x;
}
- slot->prot[slot->nprots].type = type;
- slot->prot[slot->nprots].addr = addr;
- slot->prot[slot->nprots].thing = thing;
- slot->nprots += 1;
-#endif
+ prot->slot[prot->nprots]= thing;
+ prot->slot[prot->nprots]->type = type;
+ prot->slot[prot->nprots]->addr = addr;
+ prot->nprots += 1;
+#endif /* H5AC_DEBUG */
cache->nprots += 1;
FUNC_LEAVE(thing);
@@ -758,9 +782,9 @@ 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, haddr_t, void*) = NULL;
+ H5AC_flush_func_t flush=NULL;
H5AC_t *cache = NULL;
- H5AC_slot_t *slot = NULL;
+ H5AC_info_t **info = NULL;
FUNC_ENTER(H5AC_unprotect, FAIL);
@@ -773,21 +797,21 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
assert(thing);
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
- slot = cache->slot + idx;
+ info = cache->slot + idx;
/*
* Flush any object already in the cache at that location. It had
* better not be another copy of the protected object.
*/
- if (slot->type) {
- assert(H5F_addr_ne(slot->addr, addr));
- flush = slot->type->flush;
- status = (flush)(f, TRUE, slot->addr, slot->thing);
+ if ((*info)) {
+ assert(H5F_addr_ne((*info)->addr, addr));
+ flush = (*info)->type->flush;
+ status = (flush)(f, TRUE, (*info)->addr, (*info));
if (status < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
"unable to flush object");
}
- cache->diagnostics[slot->type->id].nflushes++;
+ cache->diagnostics[(*info)->type->id].nflushes++;
}
#ifdef H5AC_DEBUG
/*
@@ -795,26 +819,29 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
* protected.
*/
{
+ H5AC_prot_t *prot = NULL;
int found, i;
- for (i = 0, found = FALSE; i < slot->nprots && !found; i++) {
- 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));
- slot->nprots -= 1;
+
+ prot = cache->prot + idx;
+ for (i = 0, found = FALSE; i < prot->nprots && !found; i++) {
+ if (H5F_addr_eq(addr, prot->slot[i]->addr)) {
+ assert(prot->slot[i]->type == type);
+ HDmemmove(prot->slot + i, prot->slot + i + 1,
+ ((prot->nprots - i) - 1) * sizeof(H5AC_info_t *));
+ prot->nprots -= 1;
found = TRUE;
}
}
assert(found);
}
-#endif
+#endif /* H5AC_DEBUG */
/*
* Insert the object back into the cache; it is no longer protected.
*/
- slot->type = type;
- slot->addr = addr;
- slot->thing = thing;
+ (*info)=thing;
+ (*info)->type = type;
+ (*info)->addr = addr;
cache->nprots -= 1;
FUNC_LEAVE(SUCCEED);
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index 34f8121..7335c0d 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -58,12 +58,13 @@ typedef enum H5AC_subid_t {
H5AC_NTYPES = 5 /*THIS MUST BE LAST! */
} H5AC_subid_t;
+typedef void *(*H5AC_load_func_t)(H5F_t*, haddr_t addr, const void *udata1, void *udata2);
+typedef herr_t (*H5AC_flush_func_t)(H5F_t*, hbool_t dest, haddr_t addr, void *thing);
+
typedef struct H5AC_class_t {
H5AC_subid_t id;
- void *(*load)(H5F_t*, haddr_t addr, const void *udata1,
- void *udata2);
- herr_t (*flush)(H5F_t*, hbool_t dest, haddr_t addr,
- void *thing);
+ H5AC_load_func_t load;
+ H5AC_flush_func_t flush;
} H5AC_class_t;
/*
@@ -77,26 +78,25 @@ typedef struct H5AC_class_t {
/* of the smallest file format object written to the file. */
#define H5AC_HASH(F,ADDR) H5F_addr_hash((ADDR/H5AC_HASH_DIVISOR),(F)->shared->cache->nslots)
-typedef struct H5AC_prot_t {
- const H5AC_class_t *type; /*type of protected thing */
- haddr_t addr; /*address of protected thing */
- void *thing; /*(possible) protected thing */
-} H5AC_prot_t;
-
-typedef struct H5AC_slot_t {
+typedef struct H5AC_info_t {
const H5AC_class_t *type; /*type of object stored here */
haddr_t addr; /*file address for object */
- void *thing; /*the thing which is cached */
+} H5AC_info_t;
+
#ifdef H5AC_DEBUG
+typedef struct H5AC_prot_t {
intn nprots; /*number of things protected */
intn aprots; /*nelmts of `prot' array */
- H5AC_prot_t *prot; /*array of protected things */
-#endif
-} H5AC_slot_t;
+ H5AC_info_t **slot; /*array of pointers to protected things */
+} H5AC_prot_t;
+#endif /* H5AC_DEBUG */
typedef struct H5AC_t {
uintn nslots; /*number of cache slots */
- H5AC_slot_t *slot; /*the cache slots */
+ H5AC_info_t **slot; /*the cache slots, an array of pointers to the cached objects */
+#ifdef H5AC_DEBUG
+ H5AC_prot_t *prot; /*the protected slots */
+#endif /* H5AC_DEBUG */
intn nprots; /*number of protected objects */
struct {
uintn nhits; /*number of cache hits */
@@ -126,10 +126,12 @@ __DLL__ herr_t H5AC_set(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
__DLL__ herr_t H5AC_debug(H5F_t *f);
#define H5AC_find(F,TYPE,ADDR,UDATA1,UDATA2) \
- (((F)->shared->cache->slot[H5AC_HASH(F,ADDR)].type==(TYPE) && \
- (F)->shared->cache->slot[H5AC_HASH(F,ADDR)].addr==ADDR) ? \
+ ((F)->shared->cache->slot[H5AC_HASH(F,ADDR)]!=NULL && \
+ ((F)->shared->cache->slot[H5AC_HASH(F,ADDR)]->type==(TYPE) && \
+ (F)->shared->cache->slot[H5AC_HASH(F,ADDR)]->addr==ADDR) ? \
((F)->shared->cache->diagnostics[(TYPE)->id].nhits++, \
- (F)->shared->cache->slot[H5AC_HASH(F,ADDR)].thing) : \
+ (F)->shared->cache->slot[H5AC_HASH(F,ADDR)]) : \
H5AC_find_f(F, TYPE, ADDR, UDATA1, UDATA2))
#endif /* !_H5ACprivate_H */
+
diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h
index cb60768..7effb7f 100644
--- a/src/H5Bprivate.h
+++ b/src/H5Bprivate.h
@@ -22,6 +22,7 @@
/* Private headers needed by this file */
#include <H5private.h>
#include <H5Fprivate.h>
+#include <H5ACprivate.h> /*cache */
/*
* Feature: Define this constant if you want to check B-tree consistency
@@ -106,6 +107,8 @@ typedef struct H5B_key_t {
} H5B_key_t;
typedef struct H5B_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
const H5B_class_t *type; /*type of tree */
size_t sizeof_rkey; /*size of raw (disk) key */
hbool_t dirty; /*something in the tree is dirty */
diff --git a/src/H5D.c b/src/H5D.c
index 8574bb4..285fddd 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -18,7 +18,6 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5private.h> /* Generic Functions */
#include <H5Iprivate.h> /* IDs */
-#include <H5ACprivate.h> /* Cache */
#include <H5Dprivate.h> /* Dataset functions */
#include <H5Eprivate.h> /* Error handling */
#include <H5FLprivate.h> /*Free Lists */
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index b99653f..d1d8828 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -71,7 +71,7 @@ static size_t H5G_node_sizeof_rkey(H5F_t *f, const void *_udata);
/* H5G inherits cache-like properties from H5AC */
const H5AC_class_t H5AC_SNODE[1] = {{
H5AC_SNODE_ID,
- (void *(*)(H5F_t*, haddr_t, const void*, void*))H5G_node_load,
+ (H5AC_load_func_t)H5G_node_load,
(herr_t (*)(H5F_t*, hbool_t, haddr_t, void*))H5G_node_flush,
}};
@@ -1209,3 +1209,4 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, intn indent,
H5AC_unprotect(f, H5AC_SNODE, addr, sn);
FUNC_LEAVE(SUCCEED);
}
+
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 17ec6d8..aa0b981 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -33,6 +33,8 @@
* table or group.
*/
typedef struct H5G_node_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
hbool_t dirty; /*has cache been modified? */
int nsyms; /*number of symbols */
H5G_entry_t *entry; /*array of symbol table entries */
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 2b48712..3dd58a8 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -9,7 +9,6 @@
#define H5G_PACKAGE
#include <H5private.h>
-#include <H5ACprivate.h>
#include <H5Eprivate.h>
#include <H5Gpkg.h>
#include <H5HLprivate.h>
diff --git a/src/H5HG.c b/src/H5HG.c
index 5d6ebe3..a76dbe7 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -42,6 +42,8 @@ typedef struct H5HG_obj_t {
} H5HG_obj_t;
struct H5HG_heap_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
haddr_t addr; /*collection address */
hbool_t dirty; /*does heap need to be saved? */
size_t size; /*total size of collection */
diff --git a/src/H5HL.c b/src/H5HL.c
index 340387f..b90a9db 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -40,6 +40,8 @@ typedef struct H5HL_free_t {
} H5HL_free_t;
typedef struct H5HL_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
intn dirty;
haddr_t addr; /*address of data */
size_t disk_alloc; /*data bytes allocated on disk */
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 826d0bb..10a1f13 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -100,6 +100,8 @@ typedef struct H5O_chunk_t {
} H5O_chunk_t;
typedef struct H5O_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
hbool_t dirty; /*out of data wrt disk */
intn version; /*version number */
intn nlink; /*link count */