summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Pfcpl.c66
-rw-r--r--test/tattr.c53
2 files changed, 78 insertions, 41 deletions
diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c
index d487f29..51daa38 100644
--- a/src/H5Pfcpl.c
+++ b/src/H5Pfcpl.c
@@ -660,10 +660,10 @@ herr_t
H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ )
{
unsigned btree_k[H5B_NUM_BTREE_ID];
- H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=SUCCEED; /* return value */
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Pget_istore_k, FAIL);
+ FUNC_ENTER_API(H5Pget_istore_k, FAIL)
H5TRACE2("e","ix",plist_id,ik);
/* Get the plist structure */
@@ -671,15 +671,15 @@ H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ )
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
/* Get value */
- if (ik) {
+ if(ik) {
if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes");
*ik = btree_k[H5B_ISTORE_ID];
- }
+ } /* end if */
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_istore_k() */
/*-------------------------------------------------------------------------
@@ -716,15 +716,15 @@ H5Pset_shared_mesgs(hid_t plist_id, unsigned nindexes, const unsigned mesg_type_
unsigned flags_used; /* type flags already specified.
* Used to make sure a flag isn't used twice.
*/
- herr_t ret_value=SUCCEED; /* return value */
+ herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_API(H5Pset_shared_mesgs, FAIL);
+ FUNC_ENTER_API(H5Pset_shared_mesgs, FAIL)
H5TRACE3("e","iIu*Iu",plist_id,nindexes,mesg_type_flags);
/* Check arguments */
- if (nindexes > H5SM_MAX_NUM_INDEXES)
+ if(nindexes > H5SM_MAX_NUM_INDEXES)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of indexes is too large");
- if (nindexes > 0 && !mesg_type_flags)
+ if(nindexes > 0 && !mesg_type_flags)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no type flags specified");
/* Get the plist structure */
@@ -732,26 +732,26 @@ H5Pset_shared_mesgs(hid_t plist_id, unsigned nindexes, const unsigned mesg_type_
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
flags_used = H5O_MESG_NONE_FLAG;
-
- for (i=0; i<nindexes; i++) {
- if (mesg_type_flags[i] == H5O_MESG_NONE_FLAG)
+ for(i = 0; i < nindexes; i++) {
+ if(mesg_type_flags[i] == H5O_MESG_NONE_FLAG)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "at least one flag must be set");
- if (mesg_type_flags[i] != (mesg_type_flags[i] & H5O_MESG_ALL_FLAG))
+ if(mesg_type_flags[i] != (mesg_type_flags[i] & H5O_MESG_ALL_FLAG))
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid mesg type flag set");
- if (mesg_type_flags[i] & flags_used)
+ if(mesg_type_flags[i] & flags_used)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "flag set for two different indexes");
- type_flags[i]=mesg_type_flags[i]; /* Store message types dimensions */
+ type_flags[i] = mesg_type_flags[i]; /* Store message types dimensions */
flags_used |= mesg_type_flags[i]; /* Make sure the user doesn't re-use a flag */
} /* end for */
+ /* Set properties in property list */
if(H5P_set(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set number of SOHM indexes");
if(H5P_set(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type flags for indexes");
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_shared_mesgs() */
/*-------------------------------------------------------------------------
@@ -775,7 +775,7 @@ herr_t
H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes)
{
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pset_shared_mesg_nindexes, FAIL);
H5TRACE2("e","iIu",plist_id,nindexes);
@@ -785,7 +785,7 @@ H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of indexes is greater than H5SM_MAX_NUM_INDEXES");
/* Get the plist structure */
- if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE)))
+ if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
if(H5P_set(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0)
@@ -793,9 +793,9 @@ H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes)
done:
FUNC_LEAVE_API(ret_value);
-}
-
+} /* end H5Pset_shared_mesg_nindexes() */
+
/*-------------------------------------------------------------------------
* Function: H5Pget_shared_mesg_nindexes
*
@@ -812,10 +812,10 @@ done:
herr_t
H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes)
{
- H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=SUCCEED; /* Return value */
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Pget_shared_mesg_nindexes, FAIL);
+ FUNC_ENTER_API(H5Pget_shared_mesg_nindexes, FAIL)
H5TRACE2("e","i*Iu",plist_id,nindexes);
/* Get the plist structure */
@@ -826,9 +826,9 @@ H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes");
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_shared_mesg_nindexes() */
-}
/*-------------------------------------------------------------------------
* Function: H5Pset_shared_mesg_index
@@ -851,9 +851,9 @@ H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_
unsigned nindexes; /* Number of SOHM indexes */
unsigned type_flags[H5SM_MAX_NUM_INDEXES]; /* Array of mesg_type_flags*/
unsigned minsizes[H5SM_MAX_NUM_INDEXES]; /* Array of min_mesg_sizes*/
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Pset_shared_mesg_index, FAIL);
+ FUNC_ENTER_API(H5Pset_shared_mesg_index, FAIL)
H5TRACE4("e","iIuIuIu",plist_id,index_num,mesg_type_flags,min_mesg_size);
/* Check arguments */
@@ -870,6 +870,7 @@ H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_
if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes");
+ /* Range check */
if(index_num > nindexes)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index_num is greater than number of indexes in property list");
@@ -890,11 +891,10 @@ H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set min mesg sizes");
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_shared_mesg_index() */
-
/*-------------------------------------------------------------------------
* Function: H5Pget_shared_mesg_index
*
diff --git a/test/tattr.c b/test/tattr.c
index 12eebec..04350a8 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -1688,7 +1688,7 @@ test_attr_dtype_shared(hid_t fapl)
**
****************************************************************/
static void
-test_attr_dense_create(hid_t fapl)
+test_attr_dense_create(hid_t fcpl, hid_t fapl)
{
hid_t fid; /* HDF5 File ID */
hid_t dataset; /* Dataset ID */
@@ -1794,7 +1794,7 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
**
****************************************************************/
static void
-test_attr_dense_open(hid_t fapl)
+test_attr_dense_open(hid_t fcpl, hid_t fapl)
{
hid_t fid; /* HDF5 File ID */
hid_t dataset; /* Dataset ID */
@@ -1915,7 +1915,7 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
**
****************************************************************/
static void
-test_attr_dense_delete(hid_t fapl)
+test_attr_dense_delete(hid_t fcpl, hid_t fapl)
{
hid_t fid; /* HDF5 File ID */
hid_t dataset; /* Dataset ID */
@@ -2018,7 +2018,9 @@ void
test_attr(void)
{
hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */
- hbool_t new_format; /* Whether to use the new format or not */
+ hid_t fcpl = (-1), fcpl2 = (-1); /* File creation property lists */
+ hbool_t new_format; /* Whether to use the new format or not */
+ hbool_t use_shared; /* Whether to use shared attributes or not */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2043,7 +2045,7 @@ test_attr(void)
/* Set the FAPL for the type of format */
if(new_format) {
- MESSAGE(7, ("testing with new file format\n"));
+ MESSAGE(7, ("testing with new file format\n"));
my_fapl = fapl2;
} /* end if */
else {
@@ -2077,14 +2079,49 @@ test_attr(void)
test_attr_dtype_shared(my_fapl); /* Test using shared dataypes in attributes */
} /* end for */
+ /* Create a default file creation property list */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+
+ /* Copy the file creation property list */
+ fcpl2 = H5Pcopy(fcpl);
+ CHECK(fcpl2, FAIL, "H5Pcopy");
+
+ /* Make attributes > 1 byte shared (i.e. all of them :-) */
+ ret = H5Pset_shared_mesg_nindexes(fcpl2, (unsigned)1);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl2, (unsigned)1, H5O_MESG_ATTR_FLAG, (unsigned)1);
+ CHECK_I(ret, "H5Pset_shared_mesg_index");
+
/* Tests on "new format" attribute storage */
- test_attr_dense_create(fapl2); /* Test dense attribute storage creation */
- test_attr_dense_open(fapl2); /* Test opening attributes in dense storage */
- test_attr_dense_delete(fapl2); /* Test deleting attributes in dense storage */
+ /* Loop over using shared attributes */
+ for(use_shared = FALSE; use_shared <= TRUE; use_shared++) {
+ hid_t my_fcpl;
+
+ /* Set the FCPL for shared or not */
+ if(new_format) {
+ MESSAGE(7, ("testing with shared attributes\n"));
+ my_fcpl = fcpl2;
+ } /* end if */
+ else {
+ MESSAGE(7, ("testing with shared attributes\n"));
+ my_fcpl = fcpl;
+ } /* end else */
+
+ test_attr_dense_create(my_fcpl, fapl2); /* Test dense attribute storage creation */
+ test_attr_dense_open(my_fcpl, fapl2); /* Test opening attributes in dense storage */
+ test_attr_dense_delete(my_fcpl, fapl2); /* Test deleting attributes in dense storage */
+ } /* end for */
#else /* QAK */
HDfprintf(stderr, "Uncomment tests!\n");
#endif /* QAK */
+ /* Close FCPLs */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fcpl2);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Close FAPLs */
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");