summaryrefslogtreecommitdiffstats
path: root/src/H5HG.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
commit4a17aff4085ad6ee265b95730aca3f493056dec8 (patch)
tree8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5HG.c
parent853ae26333592faf69cd8c454ef92ffea8549df5 (diff)
downloadhdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5HG.c')
-rw-r--r--src/H5HG.c106
1 files changed, 44 insertions, 62 deletions
diff --git a/src/H5HG.c b/src/H5HG.c
index 893be80..53f1b2a 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -82,7 +82,7 @@
/* Local Prototypes */
/********************/
-static haddr_t H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size);
+static haddr_t H5HG__create(H5F_t *f, size_t size);
/*********************/
@@ -114,7 +114,7 @@ H5FL_BLK_DEFINE(gheap_chunk);
/*-------------------------------------------------------------------------
- * Function: H5HG_create
+ * Function: H5HG__create
*
* Purpose: Creates a global heap collection of the specified size. If
* SIZE is less than some minimum it will be readjusted. The
@@ -133,7 +133,7 @@ H5FL_BLK_DEFINE(gheap_chunk);
*-------------------------------------------------------------------------
*/
static haddr_t
-H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
+H5HG__create(H5F_t *f, size_t size)
{
H5HG_heap_t *heap = NULL;
uint8_t *p = NULL;
@@ -141,7 +141,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
size_t n;
haddr_t ret_value = HADDR_UNDEF; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, HADDR_UNDEF)
+ FUNC_ENTER_STATIC_TAG(H5AC__GLOBALHEAP_TAG)
/* Check args */
HDassert(f);
@@ -151,7 +151,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
/* Create it */
H5_CHECK_OVERFLOW(size, size_t, hsize_t);
- if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, dxpl_id, (hsize_t)size)))
+ if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, (hsize_t)size)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file space for global heap")
if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed")
@@ -207,7 +207,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to add global heap collection to file's CWFS")
/* Add the heap to the cache */
- if(H5AC_insert_entry(f, dxpl_id, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_insert_entry(f, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to cache global heap collection")
ret_value = addr;
@@ -217,7 +217,7 @@ done:
if(!H5F_addr_defined(ret_value)) {
if(H5F_addr_defined(addr)) {
/* Release the space on disk */
- if(H5MF_xfree(f, H5FD_MEM_GHEAP, dxpl_id, addr, (hsize_t)size) < 0)
+ if(H5MF_xfree(f, H5FD_MEM_GHEAP, addr, (hsize_t)size) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free global heap")
/* Check if the heap object was allocated */
@@ -228,12 +228,12 @@ done:
} /* end if */
} /* end if */
- FUNC_LEAVE_NOAPI_TAG(ret_value, HADDR_UNDEF);
-} /* H5HG_create() */
+ FUNC_LEAVE_NOAPI_TAG(ret_value);
+} /* H5HG__create() */
/*-------------------------------------------------------------------------
- * Function: H5HG_protect
+ * Function: H5HG__protect
*
* Purpose: Convenience wrapper around H5AC_protect on an indirect block
*
@@ -245,12 +245,12 @@ done:
*-------------------------------------------------------------------------
*/
H5HG_heap_t *
-H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
+H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags)
{
H5HG_heap_t *heap; /* Global heap */
H5HG_heap_t *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Check arguments */
HDassert(f);
@@ -260,7 +260,7 @@ H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0);
/* Lock the heap into memory */
- if(NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, f, flags)))
+ if(NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, H5AC_GHEAP, addr, f, flags)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect global heap")
/* Set the heap's address */
@@ -271,7 +271,7 @@ H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HG_protect() */
+} /* H5HG__protect() */
/*-------------------------------------------------------------------------
@@ -412,20 +412,10 @@ done:
* Programmer: Quincey Koziol
* Saturday, June 12, 2004
*
- * Modifications:
- *
- * John Mainzer, 6/8/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
- * In this case, that required adding the new heap_dirtied_ptr
- * parameter to the function's argument list.
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_extend(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t need)
+H5HG_extend(H5F_t *f, haddr_t addr, size_t need)
{
H5HG_heap_t *heap = NULL; /* Pointer to heap to extend */
unsigned heap_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting heap */
@@ -442,7 +432,7 @@ H5HG_extend(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t need)
HDassert(H5F_addr_defined(addr));
/* Protect the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, addr, H5AC__NO_FLAGS_SET)))
+ if(NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
/* Re-allocate the heap information in memory */
@@ -485,7 +475,7 @@ H5HG_extend(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t need)
heap_flags |= H5AC__DIRTIED_FLAG;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap")
FUNC_LEAVE_NOAPI(ret_value)
@@ -515,7 +505,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/)
+H5HG_insert(H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
{
size_t need; /*total space needed for object */
size_t idx;
@@ -524,7 +514,7 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
unsigned heap_flags = H5AC__NO_FLAGS_SET;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL)
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL)
/* Check args */
HDassert(f);
@@ -539,7 +529,7 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
/* Look for a heap in the file's CWFS that has enough space for the object */
addr = HADDR_UNDEF;
- if(H5F_cwfs_find_free_heap(f, dxpl_id, need, &addr) < 0)
+ if(H5F_cwfs_find_free_heap(f, need, &addr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "error trying to locate heap")
/*
@@ -547,14 +537,14 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
* new collection large enough for the message plus the collection header.
*/
if(!H5F_addr_defined(addr)) {
- addr = H5HG_create(f, dxpl_id, need + H5HG_SIZEOF_HDR(f));
+ addr = H5HG__create(f, need + H5HG_SIZEOF_HDR(f));
if(!H5F_addr_defined(addr))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection")
} /* end if */
HDassert(H5F_addr_defined(addr));
- if(NULL == (heap = H5HG_protect(f, dxpl_id, addr, H5AC__NO_FLAGS_SET)))
+ if(NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
/* Split the free space to make room for the new object */
@@ -577,10 +567,10 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
hobj->idx = idx;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap.")
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* H5HG_insert() */
@@ -602,8 +592,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
- size_t *buf_size)
+H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size)
{
H5HG_heap_t *heap = NULL; /* Pointer to global heap object */
size_t size; /* Size of the heap object */
@@ -611,14 +600,14 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
void *orig_object = object; /* Keep a copy of the original object pointer */
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, NULL)
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, NULL)
/* Check args */
HDassert(f);
HDassert(hobj);
/* Load the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC__READ_ONLY_FLAG)))
+ if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect global heap")
HDassert(hobj->idx < heap->nused);
@@ -648,13 +637,13 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
ret_value = object;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release object header")
if(NULL == ret_value && NULL == orig_object && object)
H5MM_free(object);
- FUNC_LEAVE_NOAPI_TAG(ret_value, NULL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5HG_read() */
@@ -677,13 +666,13 @@ done:
*-------------------------------------------------------------------------
*/
int
-H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust)
+H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust)
{
H5HG_heap_t *heap = NULL;
unsigned heap_flags = H5AC__NO_FLAGS_SET;
int ret_value = -1; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL)
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL)
/* Check args */
HDassert(f);
@@ -692,7 +681,7 @@ H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust)
HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file")
/* Load the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC__NO_FLAGS_SET)))
+ if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
if(adjust != 0) {
@@ -710,10 +699,10 @@ H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust)
ret_value = heap->obj[hobj->idx].nrefs;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5HG_link() */
@@ -731,12 +720,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_get_obj_size(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, size_t *obj_size)
+H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size)
{
H5HG_heap_t *heap = NULL; /* Pointer to global heap object */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL)
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL)
/* Check args */
HDassert(f);
@@ -744,7 +733,7 @@ H5HG_get_obj_size(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, size_t *obj_size)
HDassert(obj_size);
/* Load the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC__READ_ONLY_FLAG)))
+ if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
HDassert(hobj->idx < heap->nused);
@@ -754,10 +743,10 @@ H5HG_get_obj_size(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, size_t *obj_size)
*obj_size = heap->obj[hobj->idx].size;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5HG_get_obj_size() */
@@ -771,17 +760,10 @@ done:
* Programmer: Robb Matzke
* Monday, March 30, 1998
*
- * Modifications:
- *
- * John Mainzer - 6/8/05
- * Modified function to use the dirtied parameter of
- * H5AC_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
+H5HG_remove (H5F_t *f, H5HG_t *hobj)
{
H5HG_heap_t *heap = NULL;
uint8_t *p = NULL, *obj_start = NULL;
@@ -790,7 +772,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
unsigned flags = H5AC__NO_FLAGS_SET;/* Whether the heap gets deleted */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL);
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL)
/* Check args */
HDassert(f);
@@ -799,7 +781,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file")
/* Load the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC__NO_FLAGS_SET)))
+ if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
HDassert(hobj->idx < heap->nused);
@@ -849,10 +831,10 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
} /* end else */
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, flags) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL);
+ FUNC_LEAVE_NOAPI_TAG(ret_value);
} /* end H5HG_remove() */