diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-01-08 22:25:26 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-01-08 22:25:26 (GMT) |
commit | d978a22b36d148a17f331eb51d0e13ede524770a (patch) | |
tree | e27cd9e51275efdbc7e626f94b24942c8c2fd7bf /src/H5SMtest.c | |
parent | a4527a631c6713b491aff80a4604dc21500540c4 (diff) | |
download | hdf5-d978a22b36d148a17f331eb51d0e13ede524770a.zip hdf5-d978a22b36d148a17f331eb51d0e13ede524770a.tar.gz hdf5-d978a22b36d148a17f331eb51d0e13ede524770a.tar.bz2 |
[svn-r13121] Description:
Add support & tests for using shared datatypes with shared & un-shared
attributes. Involves some fairly icky code to make the "copy on write"
paradigm for shared attributes work.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5SMtest.c')
-rw-r--r-- | src/H5SMtest.c | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/src/H5SMtest.c b/src/H5SMtest.c index 20a23e9..36832d3 100644 --- a/src/H5SMtest.c +++ b/src/H5SMtest.c @@ -63,139 +63,6 @@ /*------------------------------------------------------------------------- - * Function: H5SM_get_refcount_bt2_cb - * - * Purpose: v2 B-tree 'find' callback to retrieve the record for a message - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * Tuesday, December 19, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5SM_get_refcount_bt2_cb(const void *_record, void *_op_data) -{ - const H5SM_sohm_t *record = (const H5SM_sohm_t *)_record; /* v2 B-tree record for message */ - H5SM_sohm_t *op_data = (H5SM_sohm_t *)_op_data; /* "op data" from v2 B-tree find */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_get_refcount_bt2_cb) - - /* - * Check arguments. - */ - HDassert(record); - HDassert(op_data); - - /* Make a copy of the record */ - *op_data = *record; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_get_refcount_bt2_cb() */ - - -/*------------------------------------------------------------------------- - * Function: H5SM_get_refcount_test - * - * Purpose: Retrieve the reference count for a message - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, December 19, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5SM_get_refcount_test(H5F_t *f, hid_t dxpl_id, unsigned type_id, - const H5O_shared_t *sh_mesg, hsize_t *ref_count) -{ - H5HF_t *fheap = NULL; /* Fractal heap that contains shared messages */ - H5SM_master_table_t *table = NULL; /* SOHM master table */ - H5SM_list_t *list = NULL; /* SOHM index list for message type (if in list form) */ - H5SM_index_header_t *header=NULL; /* Index header for message type */ - H5SM_mesg_key_t key; /* Key for looking up message */ - H5SM_fh_ud_gh_t udata; /* User data for fractal heap 'op' callback */ - H5SM_sohm_t message; /* Record for shared message */ - ssize_t index_num; /* Table index for message type */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5SM_get_refcount_test) - - /* Sanity check */ - HDassert(f); - HDassert(sh_mesg); - HDassert(ref_count); - - /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") - - /* Find the correct index and try to delete from it */ - if((index_num = H5SM_get_index(table, type_id)) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index") - header = &(table->indexes[index_num]); - - /* Open the heap that this message is in */ - if(NULL == (fheap = H5HF_open(f, dxpl_id, header->heap_addr))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") - - /* Prepare user data for callback */ - udata.type_id = type_id; - - /* Compute the hash value for the B-tree lookup */ - if(H5HF_op(fheap, dxpl_id, &(sh_mesg->u.heap_id), H5SM_get_hash_fh_cb, &udata) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't access message in fractal heap") - - /* Set up key for message to locate */ - key.hash = udata.hash; - key.encoding = NULL; - key.encoding_size = 0; - key.fheap = fheap; - key.mesg_heap_id = sh_mesg->u.heap_id; - - /* Try to find the message in the index */ - if(header->index_type == H5SM_LIST) { - size_t list_pos; /* Position of the message in the list */ - - /* If the index is stored as a list, get it from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, NULL, header, H5AC_READ))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") - - /* Find the message in the list */ - if((list_pos = H5SM_find_in_list(list, &key)) == UFAIL) - HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") - - /* Copy the message */ - message = list->messages[list_pos]; - } /* end if */ - else /* Index is a B-tree */ - { - HDassert(header->index_type == H5SM_BTREE); - - /* Look up the message in the v2 B-tree */ - if(H5B2_find(f, dxpl_id, H5SM_INDEX, header->index_addr, &key, H5SM_get_refcount_bt2_cb, &message) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") - } /* end else */ - - /* Set the refcount for the message */ - *ref_count = message.ref_count; - -done: - /* Release resources */ - if(list && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, list, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") - if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "unable to close SOHM master table") - if(fheap && H5HF_close(fheap, dxpl_id) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CLOSEERROR, FAIL, "can't close fractal heap") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SM_get_refcount_test() */ - - -/*------------------------------------------------------------------------- * Function: H5SM_get_mesg_count_test * * Purpose: Retrieve the number of messages tracked of a certain type |