summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Ffake.c8
-rw-r--r--src/H5P.c15
-rw-r--r--src/H5Pdcpl.c28
-rw-r--r--src/H5Shyper.c52
-rw-r--r--src/H5Spkg.h3
5 files changed, 68 insertions, 38 deletions
diff --git a/src/H5Ffake.c b/src/H5Ffake.c
index 6720dd2..d199cf0 100644
--- a/src/H5Ffake.c
+++ b/src/H5Ffake.c
@@ -18,6 +18,8 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Pprivate.h" /* Property lists */
/* PRIVATE PROTOTYPES */
@@ -65,8 +67,10 @@ H5F_fake_alloc(uint8_t sizeof_size, hid_t fapl_id)
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list")
- f->shared->low_bound = H5F_LOW_BOUND(f);
- f->shared->high_bound = H5F_HIGH_BOUND(f);
+ if(H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &(f->shared->low_bound)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'low' bound for library format versions")
+ if(H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &(f->shared->high_bound)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'high' bound for library format versions")
/* Set return value */
ret_value = f;
diff --git a/src/H5P.c b/src/H5P.c
index 4dcd305..fe9a70a 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -853,21 +853,8 @@ H5Pencode(hid_t plist_id, void *buf, size_t *nalloc)
if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
- /* Make a copy of the default file access property list */
- if(NULL == (fapl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
- if((new_fapl_id = H5P_copy_plist(fapl_plist, FALSE)) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list")
-
- /* Set latest format in fapl_plist */
- /* This will eventually be used by VDS to encode datasets via H5P__dcrt_layout_enc() */
- if(H5P_set(fapl_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low_bound) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'low' bound for library format versions")
- if(H5P_set(fapl_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high_bound) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'high' bound for library format versions")
-
/* Call the internal encode routine */
- if((ret_value = H5P__encode(plist, TRUE, buf, nalloc, new_fapl_id)) < 0)
+ if((ret_value = H5P__encode(plist, TRUE, buf, nalloc, H5P_FILE_ACCESS_DEFAULT)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list");
done:
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index 19ec00f..76a2658 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -374,14 +374,33 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size, void *_udata)
uint8_t *tmp_p;
size_t tmp_size;
size_t u; /* Local index variable */
+ H5P_genplist_t *fapl_plist; /* The file access property list */
+ hid_t new_fapl_id; /* The file access property list ID */
+ H5F_libver_t low_bound = H5F_LIBVER_V110; /* Set the low bound in fapl to latest */
+ H5F_libver_t high_bound = H5F_LIBVER_V110; /* Set the high bound in fapl to latest */
herr_t ret_value = SUCCEED; /* Return value */
+
FUNC_ENTER_STATIC
/* Sanity check */
HDassert(layout);
HDassert(size);
+ /* Make a copy of the default file access property list */
+ if(NULL == (fapl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+
+ /* Set latest format in fapl_plist */
+ /* This will eventually be used by VDS to encode datasets via H5S_encode() */
+ if(H5P_set(fapl_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low_bound) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'low' bound for library format versions")
+ if(H5P_set(fapl_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high_bound) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'high' bound for library format versions")
+
+ if((new_fapl_id = H5P_copy_plist(fapl_plist, FALSE)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list")
+
if(NULL != *pp) {
/* Encode layout type */
*(*pp)++ = (uint8_t)layout->type;
@@ -427,14 +446,15 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size, void *_udata)
* list before we get here. */
tmp_size = (size_t)-1;
tmp_p = *pp;
- if(H5S_encode(layout->storage.u.virt.list[u].source_select, pp, &tmp_size, udata->fapl_id) < 0)
+
+ if(H5S_encode(layout->storage.u.virt.list[u].source_select, pp, &tmp_size, new_fapl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize source selection")
*size += (size_t)(*pp - tmp_p);
/* Virtual dataset selection. Same notes as above apply. */
tmp_size = (size_t)-1;
tmp_p = *pp;
- if(H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, pp, &tmp_size, udata->fapl_id) < 0)
+ if(H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, pp, &tmp_size, new_fapl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize virtual selection")
*size += (size_t)(*pp - tmp_p);
} /* end for */
@@ -467,14 +487,14 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size, void *_udata)
/* Source selection */
tmp_size = (size_t)0;
tmp_p = NULL;
- if(H5S_encode(layout->storage.u.virt.list[u].source_select, &tmp_p, &tmp_size, udata->fapl_id) < 0)
+ if(H5S_encode(layout->storage.u.virt.list[u].source_select, &tmp_p, &tmp_size, new_fapl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize source selection")
*size += tmp_size;
/* Virtual dataset selection */
tmp_size = (size_t)0;
tmp_p = NULL;
- if(H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, &tmp_p, &tmp_size, udata->fapl_id) < 0)
+ if(H5S_encode(layout->storage.u.virt.list[u].source_dset.virtual_select, &tmp_p, &tmp_size, new_fapl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to serialize virtual selection")
*size += tmp_size;
} /* end for */
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 6f778fe..94b600d 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -28,6 +28,13 @@
#include "H5Spkg.h" /* Dataspace functions */
#include "H5VMprivate.h" /* Vector functions */
+/* Format version bounds for dataspace hyperslab selection */
+const unsigned H5O_sds_hyper_ver_bounds[] = {
+ H5S_HYPER_VERSION_1, /* H5F_LIBVER_EARLIEST */
+ H5S_HYPER_VERSION_1, /* H5F_LIBVER_V18 */
+ H5S_HYPER_VERSION_2 /* H5F_LIBVER_LATEST */
+};
+
/* Local datatypes */
/* Static function prototypes */
@@ -1993,6 +2000,7 @@ done:
H5S_hyper_set_version
PURPOSE
Determine the version to use for encoding hyperslab selection info
+ See tables 2 & 3 in the RFC: H5Sencode/H5Sdecode Format Change
USAGE
hssize_t H5S_hyper_set_version(space, block_count, bounds_end, f, version)
const H5S_t *space: IN: The dataspace
@@ -2014,21 +2022,14 @@ done:
static herr_t
H5S_hyper_set_version(const H5S_t *space, hsize_t block_count, hsize_t bounds_end[], H5F_t *f, uint32_t *version)
{
- hbool_t count_up_version = FALSE;
- hbool_t bound_up_version = FALSE;
- unsigned u;
- herr_t ret_value = SUCCEED; /* return value */
+ hbool_t count_up_version = FALSE; /* Whether number of blocks exceed (2^32 - 1) */
+ hbool_t bound_up_version = FALSE; /* Whether high bounds exceed (2^32 - 1) */
+ unsigned u; /* Local index veriable */
+ uint32_t tmp_version; /* Temporay version */
+ herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Use version 2 for unlimited selection */
- if(space->select.sel_info.hslab->unlim_dim >= 0) {
- *version = H5S_HYPER_VERSION_2;
- HGOTO_DONE(SUCCEED)
- }
-
- *version = H5S_HYPER_VERSION_1;
-
/* Determine whether the number of blocks or the high bounds in the selection exceed (2^32 - 1) */
if(block_count > H5S_UINT32_MAX)
count_up_version = TRUE;
@@ -2038,17 +2039,34 @@ H5S_hyper_set_version(const H5S_t *space, hsize_t block_count, hsize_t bounds_en
bound_up_version = TRUE;
}
- if(H5S_hyper_is_regular(space)) {
- if(((H5F_LOW_BOUND(f) >= H5F_LIBVER_V110) && block_count > 4) ||
- count_up_version || bound_up_version)
- *version = H5S_HYPER_VERSION_2;
- } else { /* Fail for irregular hyperslab if exceeds 32 bits */
+ /* Use version 2 for unlimited selection */
+ if(space->select.sel_info.hslab->unlim_dim >= 0)
+ tmp_version = H5S_HYPER_VERSION_2;
+ else if(H5S_hyper_is_regular(space)) {
+
+ /* If exceed (2^32 -1) */
+ if(count_up_version || bound_up_version)
+ tmp_version = H5S_HYPER_VERSION_2;
+ else
+ /* block_count < 4: version 1 */
+ /* block_count >= 4: determined by low bound */
+ tmp_version = (block_count < 4) ? H5S_HYPER_VERSION_1 : H5O_sds_hyper_ver_bounds[H5F_LOW_BOUND(f)];
+
+ } else {
+ /* Fail for irregular hyperslab if exceeds 32 bits */
if(count_up_version)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The number of blocks in hyperslab selection exceeds 2^32")
else if(bound_up_version)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in hyperslab selection exceeds 2^32")
+ tmp_version = H5S_HYPER_VERSION_1;
}
+ /* Version bounds check */
+ if(tmp_version > H5O_sds_hyper_ver_bounds[H5F_HIGH_BOUND(f)])
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "Dataspace hyperslab selection version out of bounds")
+
+ *version = tmp_version;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S_hyper_set_version() */
diff --git a/src/H5Spkg.h b/src/H5Spkg.h
index 984f56f..75c5e77 100644
--- a/src/H5Spkg.h
+++ b/src/H5Spkg.h
@@ -282,8 +282,9 @@ H5_DLLVAR const H5S_select_class_t H5S_sel_none[1];
*/
H5_DLLVAR const H5S_select_class_t H5S_sel_point[1];
-/* Array of versions for Dataspace */
+/* Array of versions for Dataspace and hyperslab selections */
H5_DLLVAR const unsigned H5O_sdspace_ver_bounds[H5F_LIBVER_NBOUNDS];
+H5_DLLVAR const unsigned H5O_sds_hyper_ver_bounds[H5F_LIBVER_NBOUNDS];
/* Extent functions */
H5_DLL herr_t H5S_extent_release(H5S_extent_t *extent);