summaryrefslogtreecommitdiffstats
path: root/src/H5Pfapl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r--src/H5Pfapl.c178
1 files changed, 145 insertions, 33 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 1b0a4b9..a1d53cc 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -142,11 +142,19 @@
#define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT
#define H5F_ACS_MULTI_TYPE_ENC H5P__facc_multi_type_enc
#define H5F_ACS_MULTI_TYPE_DEC H5P__facc_multi_type_dec
-/* Definition for 'use latest format version' flag */
-#define H5F_ACS_LATEST_FORMAT_SIZE sizeof(hbool_t)
-#define H5F_ACS_LATEST_FORMAT_DEF FALSE
-#define H5F_ACS_LATEST_FORMAT_ENC H5P__encode_hbool_t
-#define H5F_ACS_LATEST_FORMAT_DEC H5P__decode_hbool_t
+
+/* Definition for "low" bound of library format versions */
+#define H5F_ACS_FORMAT_LOW_BOUND_SIZE sizeof(H5F_libver_t)
+#define H5F_ACS_FORMAT_LOW_BOUND_DEF H5F_LIBVER_EARLIEST
+#define H5F_ACS_FORMAT_LOW_BOUND_ENC H5P__facc_libver_type_enc
+#define H5F_ACS_FORMAT_LOW_BOUND_DEC H5P__facc_libver_type_dec
+
+/* Definition for "high" bound of library format versions */
+#define H5F_ACS_FORMAT_HIGH_BOUND_SIZE sizeof(H5F_libver_t)
+#define H5F_ACS_FORMAT_HIGH_BOUND_DEF H5F_LIBVER_LATEST
+#define H5F_ACS_FORMAT_HIGH_BOUND_ENC H5P__facc_libver_type_enc
+#define H5F_ACS_FORMAT_HIGH_BOUND_DEC H5P__facc_libver_type_dec
+
/* Definition for whether to query the file descriptor from the core VFD
* instead of the memory address. (Private to library)
*/
@@ -290,6 +298,8 @@ static herr_t H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t
static herr_t H5P__facc_fclose_degree_dec(const void **pp, void *value);
static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size);
static herr_t H5P__facc_multi_type_dec(const void **_pp, void *value);
+static herr_t H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size);
+static herr_t H5P__facc_libver_type_dec(const void **_pp, void *value);
/* Metadata cache log location property callbacks */
static herr_t H5P_facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size);
@@ -354,7 +364,10 @@ static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF;
static const hsize_t H5F_def_family_newsize_g = H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */
static const hbool_t H5F_def_family_to_sec2_g = H5F_ACS_FAMILY_TO_SEC2_DEF; /* Default ?? for family VFD */
static const H5FD_mem_t H5F_def_mem_type_g = H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */
-static const hbool_t H5F_def_latest_format_g = H5F_ACS_LATEST_FORMAT_DEF; /* Default setting for "use the latest version of the format" flag */
+
+static const H5F_libver_t H5F_def_format_low_bound_g = H5F_ACS_FORMAT_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */
+static const H5F_libver_t H5F_def_format_high_bound_g = H5F_ACS_FORMAT_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */
+
static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */
static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */
static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */
@@ -493,9 +506,15 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
- /* Register the 'use the latest version of the format' flag */
- if(H5P_register_real(pclass, H5F_ACS_LATEST_FORMAT_NAME, H5F_ACS_LATEST_FORMAT_SIZE, &H5F_def_latest_format_g,
- NULL, NULL, NULL, H5F_ACS_LATEST_FORMAT_ENC, H5F_ACS_LATEST_FORMAT_DEC,
+ /* Register the 'low' bound of library format versions */
+ if(H5P_register_real(pclass, H5F_ACS_FORMAT_LOW_BOUND_NAME, H5F_ACS_FORMAT_LOW_BOUND_SIZE, &H5F_def_format_low_bound_g,
+ NULL, NULL, NULL, H5F_ACS_FORMAT_LOW_BOUND_ENC, H5F_ACS_FORMAT_LOW_BOUND_DEC,
+ NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
+ /* Register the 'high' bound of library format versions */
+ if(H5P_register_real(pclass, H5F_ACS_FORMAT_HIGH_BOUND_NAME, H5F_ACS_FORMAT_HIGH_BOUND_SIZE, &H5F_def_format_high_bound_g,
+ NULL, NULL, NULL, H5F_ACS_FORMAT_HIGH_BOUND_ENC, H5F_ACS_FORMAT_HIGH_BOUND_DEC,
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
@@ -2303,6 +2322,24 @@ done:
* releases and then map down to the previous actual library release which
* had a format change.
*
+ * Note #3: The enumerated define for H5F_libver_t in 1.10 is:
+ * typedef enum H5F_libver_t {
+ * H5F_LIBVER_ERROR = -1,
+ * H5F_LIBVER_EARLIEST = 0,
+ * H5F_LIBVER_V18 = 1,
+ * H5F_LIBVER_V110 = 2,
+ * H5F_LIBVER_NBOUNDS
+ * } H5F_libver_t;
+ * #define H5F_LIBVER_LATEST H5F_LIBVER_V110
+ *
+ * The library supports five pairs of (low, high) combinations via H5Pset_libver_bounds():
+ * 1) H5F_LIBVER_EARLIEST, H5F_LIBVER_V18
+ * 2) H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST
+ * 4) H5F_LIBVER_V18, H5F_LIBVER_V18
+ * 4) H5F_LIBVER_V18, H5F_LIBVER_LATEST
+ * 5) H5F_LIBVER_LATEST, H5F_LIBVER_LATEST
+ * See detailed description in the RFC: Setting Bounds for Object Creation in HDF5 1.10.0.
+ *
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
@@ -2311,32 +2348,38 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low,
- H5F_libver_t high)
+H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high)
{
H5P_genplist_t *plist; /* Property list pointer */
- hbool_t latest; /* Whether to use the latest version or not */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "iFvFv", plist_id, low, high);
/* Check args */
- /* (Note that this is _really_ restricted right now, we'll want to loosen
- * this up more as we add features - QAK)
- */
- if(high != H5F_LIBVER_LATEST)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid high library version bound")
+ if(low < 0 || low > H5F_LIBVER_LATEST)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "low bound is not valid")
+
+ if(high < 0 || high > H5F_LIBVER_LATEST)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "high bound is not valid")
+
+ /* (earliest, earliest), (latest, earliest), (v18, earliest) are not valid combinations */
+ if(high == H5F_LIBVER_EARLIEST)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound")
+
+ /* (latest, v18) is not valid combination */
+ if(high < low)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound")
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* Set values */
- latest = (hbool_t)((low == H5F_LIBVER_LATEST) ? TRUE : FALSE);
- if(H5P_set(plist, H5F_ACS_LATEST_FORMAT_NAME, &latest) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set library version bounds")
-
+ if(H5P_set(plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, &low) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set low bound for library format versions")
+ if(H5P_set(plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, &high) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set high bound for library format versions")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pset_libver_bounds() */
@@ -2346,7 +2389,7 @@ done:
* Function: H5Pget_libver_bounds
*
* Purpose: Returns the current settings for the library version format bounds
- * from a file access property list.
+ * from a file access property list.
*
* Return: Non-negative on success/Negative on failure
*
@@ -2360,7 +2403,6 @@ H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low/*out*/,
H5F_libver_t *high/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
- hbool_t latest; /* Whether to use the latest version or not */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
@@ -2369,17 +2411,17 @@ H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low/*out*/,
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Get values */
+ if(low) {
+ if(H5P_get(plist, H5F_ACS_FORMAT_LOW_BOUND_NAME, low) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get low bound for library format versions")
+ }
- /* Get value */
- if(H5P_get(plist, H5F_ACS_LATEST_FORMAT_NAME, &latest) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get library version bounds")
-
- /* Check for setting values to return */
- /* (Again, this is restricted now, we'll need to open it up later -QAK) */
- if(low)
- *low = latest ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST;
- if(high)
- *high = H5F_LIBVER_LATEST;
+ if(high) {
+ if(H5P_get(plist, H5F_ACS_FORMAT_HIGH_BOUND_NAME, high) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get high bound for library format versions")
+ }
done:
FUNC_LEAVE_API(ret_value)
@@ -3795,6 +3837,76 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value)
/*-------------------------------------------------------------------------
+ * Function: H5P__facc_libver_type_enc
+ *
+ * Purpose: Callback routine which is called whenever the 'low' or
+ * 'high' bound of library format versions property in the
+ * file access property list is encoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size)
+{
+ const H5F_libver_t *type = (const H5F_libver_t *)value; /* Create local alias for values */
+ uint8_t **pp = (uint8_t **)_pp;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity check */
+ HDassert(type);
+ HDassert(size);
+
+ /* Encode */
+ if(NULL != *pp)
+ *(*pp)++ = (uint8_t)*type;
+
+ /* Size */
+ (*size)++;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5P__facc_libver_type_enc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P__facc_libver_type_dec
+ *
+ * Purpose: Callback routine which is called whenever the 'low' or
+ * 'high' bound of library format versions property in the
+ * file access property list is decoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__facc_libver_type_dec(const void **_pp, void *_value)
+{
+ H5F_libver_t *type = (H5F_libver_t *)_value;
+ const uint8_t **pp = (const uint8_t **)_pp;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity checks */
+ HDassert(pp);
+ HDassert(*pp);
+ HDassert(type);
+
+ /* Decode */
+ *type = (H5F_libver_t)*(*pp)++;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5P__facc_libver_type_dec() */
+
+/*-------------------------------------------------------------------------
* Function: H5Pset_core_write_tracking
*
* Purpose: Enables/disables core VFD write tracking and page