diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 7 | ||||
-rw-r--r-- | src/H5HFhdr.c | 6 | ||||
-rw-r--r-- | src/H5Opline.c | 69 | ||||
-rw-r--r-- | src/H5Oprivate.h | 1 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 5 | ||||
-rw-r--r-- | src/H5Z.c | 35 | ||||
-rw-r--r-- | src/H5Zpkg.h | 15 | ||||
-rw-r--r-- | src/H5Zprivate.h | 1 |
8 files changed, 91 insertions, 48 deletions
@@ -1499,6 +1499,13 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Get the dataset's external file list information */ if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, &new_dset->shared->dcpl_cache.efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve external file list") + + /* Set the latest version of the pline & fill messages, if requested */ + if(H5F_USE_LATEST_FORMAT(file)) { + /* Set the latest version for the I/O pipeline message */ + if(H5Z_set_latest_version(pline) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of I/O filter pipeline") + } /* end if */ } /* end if */ /* Check if this dataset is going into a parallel file and set space allocation time */ diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 053adbb..c1b856b 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -424,6 +424,12 @@ H5HF_hdr_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) if(NULL == H5O_msg_copy(H5O_PLINE_ID, &(cparam->pline), &(hdr->pline))) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOPY, HADDR_UNDEF, "can't copy I/O filter pipeline") + /* Pay attention to the latest version flag for the file */ + if(H5F_USE_LATEST_FORMAT(hdr->f)) + /* Set the latest version for the I/O pipeline message */ + if(H5Z_set_latest_version(&(hdr->pline)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, HADDR_UNDEF, "can't set latest version of I/O filter pipeline") + /* Compute the I/O filters' encoded size */ if(0 == (hdr->filter_len = H5O_msg_raw_size(hdr->f, H5O_PLINE_ID, FALSE, &(hdr->pline)))) HGOTO_ERROR(H5E_HEAP, H5E_CANTGETSIZE, HADDR_UNDEF, "can't get I/O filter pipeline size") diff --git a/src/H5Opline.c b/src/H5Opline.c index 407c1fc..9a926c1 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -21,12 +21,14 @@ */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ +#include "H5Zpkg.h" /* Data filters */ /* PRIVATE PROTOTYPES */ @@ -86,19 +88,6 @@ const H5O_msg_class_t H5O_MSG_PLINE[1] = {{ }}; -/* The initial version of the format */ -#define H5O_PLINE_VERSION_1 1 - -/* This version encodes the message fields more efficiently */ -/* (Drops the reserved bytes, doesn't align the name and doesn't encode the - * filter name at all if it's a filter provided by the library) - */ -#define H5O_PLINE_VERSION_2 2 - -/* The latest version of the format. Look through the 'encode' and 'size' - * callbacks for places to change when updating this. */ -#define H5O_PLINE_VERSION_LATEST H5O_PLINE_VERSION_2 - /* Declare a free list to manage the H5O_pline_t struct */ H5FL_DEFINE(H5O_pline_t); @@ -122,7 +111,6 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_fla { H5O_pline_t *pline = NULL; /* Pipeline message */ H5Z_filter_info_t *filter; /* Filter to decode */ - unsigned version; /* Message version # */ size_t name_length; /* Length of filter name */ size_t i; /* Local index variable */ void *ret_value; /* Return value */ @@ -137,8 +125,8 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_fla HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Version */ - version = *p++; - if(version < H5O_PLINE_VERSION_1 || version > H5O_PLINE_VERSION_LATEST) + pline->version = *p++; + if(pline->version < H5O_PLINE_VERSION_1 || pline->version > H5O_PLINE_VERSION_LATEST) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "bad version number for filter pipeline message") /* Number of filters */ @@ -147,7 +135,7 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_fla HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter pipeline message has too many filters") /* Reserved */ - if(version == H5O_PLINE_VERSION_1) + if(pline->version == H5O_PLINE_VERSION_1) p += 6; /* Allocate array for filters */ @@ -161,11 +149,11 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_fla UINT16DECODE(p, filter->id); /* Length of filter name */ - if(version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) + if(pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) name_length = 0; else { UINT16DECODE(p, name_length); - if(version == H5O_PLINE_VERSION_1 && name_length % 8) + if(pline->version == H5O_PLINE_VERSION_1 && name_length % 8) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter name length is not a multiple of eight") } /* end if */ @@ -214,7 +202,7 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_fla */ for(j = 0; j < filter->cd_nelmts; j++) UINT32DECODE(p, filter->cd_values[j]); - if(version == H5O_PLINE_VERSION_1) + if(pline->version == H5O_PLINE_VERSION_1) if(filter->cd_nelmts % 2) p += 4; /*padding*/ } /* end if */ @@ -250,7 +238,6 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) { const H5O_pline_t *pline = (const H5O_pline_t*)mesg; /* Pipeline message to encode */ const H5Z_filter_info_t *filter; /* Filter to encode */ - unsigned version; /* Message version # */ size_t i, j; /* Local index variables */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_encode) @@ -259,16 +246,10 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) HDassert(p); HDassert(mesg); - /* Set the version of the message to encode */ - if(H5F_USE_LATEST_FORMAT(f)) - version = H5O_PLINE_VERSION_LATEST; - else - version = H5O_PLINE_VERSION_1; - /* Message header */ - *p++ = version; + *p++ = pline->version; *p++ = (uint8_t)(pline->nused); - if(version == H5O_PLINE_VERSION_1) { + if(pline->version == H5O_PLINE_VERSION_1) { *p++ = 0; /*reserved 1*/ *p++ = 0; /*reserved 2*/ *p++ = 0; /*reserved 3*/ @@ -286,7 +267,7 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) UINT16ENCODE(p, filter->id); /* Skip writing the name length & name if the filter is an internal filter */ - if(version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) { + if(pline->version > H5O_PLINE_VERSION_1 && filter->id < H5Z_FILTER_RESERVED) { name_length = 0; name = NULL; } /* end if */ @@ -303,7 +284,7 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) name_length = name ? HDstrlen(name) + 1 : 0; /* Filter name length */ - UINT16ENCODE(p, version == H5O_PLINE_VERSION_1 ? H5O_ALIGN_OLD(name_length) : name_length); + UINT16ENCODE(p, pline->version == H5O_PLINE_VERSION_1 ? H5O_ALIGN_OLD(name_length) : name_length); } /* end else */ /* Filter flags */ @@ -319,7 +300,7 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) p += name_length; /* Pad out name to alignment, in older versions */ - if(version == H5O_PLINE_VERSION_1) + if(pline->version == H5O_PLINE_VERSION_1) while(name_length++ % 8) *p++ = 0; } /* end if */ @@ -329,7 +310,7 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) UINT32ENCODE(p, filter->cd_values[j]); /* Align the parameters for older versions of the format */ - if(version == H5O_PLINE_VERSION_1) + if(pline->version == H5O_PLINE_VERSION_1) if(filter->cd_nelmts % 2) UINT32ENCODE(p, 0); } /* end for */ @@ -449,25 +430,18 @@ done: *------------------------------------------------------------------------- */ static size_t -H5O_pline_size(const H5F_t *f, const void *mesg) +H5O_pline_size(const H5F_t UNUSED *f, const void *mesg) { const H5O_pline_t *pline = (const H5O_pline_t*)mesg; /* Pipeline message */ - unsigned version; /* Message version # */ size_t i; /* Local index variable */ size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_size) - /* Set the version of the message to encode */ - if(H5F_USE_LATEST_FORMAT(f)) - version = H5O_PLINE_VERSION_LATEST; - else - version = H5O_PLINE_VERSION_1; - /* Message header */ ret_value = 1 + /*version */ 1 + /*number of filters */ - (version == H5O_PLINE_VERSION_1 ? 6 : 0); /*reserved */ + (pline->version == H5O_PLINE_VERSION_1 ? 6 : 0); /*reserved */ /* Calculate size of each filter in pipeline */ for(i = 0; i < pline->nused; i++) { @@ -475,7 +449,7 @@ H5O_pline_size(const H5F_t *f, const void *mesg) const char *name; /* Filter name */ /* Don't write the name length & name if the filter is an internal filter */ - if(version > H5O_PLINE_VERSION_1 && pline->filter[i].id < H5Z_FILTER_RESERVED) + if(pline->version > H5O_PLINE_VERSION_1 && pline->filter[i].id < H5Z_FILTER_RESERVED) name_len = 0; else { H5Z_class_t *cls; /* Filter class */ @@ -487,13 +461,13 @@ H5O_pline_size(const H5F_t *f, const void *mesg) } /* end else */ ret_value += 2 + /*filter identification number */ - ((version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */ + ((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */ 2 + /*flags */ 2 + /*number of client data values */ - (version == H5O_PLINE_VERSION_1 ? H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ + (pline->version == H5O_PLINE_VERSION_1 ? H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ ret_value += pline->filter[i].cd_nelmts * 4; - if(version == H5O_PLINE_VERSION_1) + if(pline->version == H5O_PLINE_VERSION_1) if(pline->filter[i].cd_nelmts % 2) ret_value += 4; } /* end for */ @@ -544,6 +518,9 @@ H5O_pline_reset(void *mesg) /* Reset # of filters */ pline->nused = pline->nalloc = 0; + /* Reset version # of pipeline message */ + pline->version = H5O_PLINE_VERSION_1; + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_pline_reset() */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 120568e..737237b 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -383,6 +383,7 @@ typedef struct H5O_ginfo_t { typedef struct H5O_pline_t { H5O_shared_t sh_loc; /* Shared message info (must be first) */ + unsigned version; /* Encoding version number */ size_t nalloc; /*num elements in `filter' array */ size_t nused; /*num filters defined */ H5Z_filter_info_t *filter; /*array of filters */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index be1c3e0..17c019a 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -28,6 +28,7 @@ /* Module Setup */ /****************/ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ +#define H5Z_PACKAGE /*suppress error about including H5Zpkg */ /***********/ @@ -39,7 +40,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppkg.h" /* Property lists */ -#include "H5Zprivate.h" /* Data filters */ +#include "H5Zpkg.h" /* Data filters */ /****************/ @@ -71,7 +72,7 @@ #define H5D_CRT_EXT_FILE_LIST_CMP H5P_dcrt_ext_file_list_cmp /* Definitions for data filter pipeline */ #define H5D_CRT_DATA_PIPELINE_SIZE sizeof(H5O_pline_t) -#define H5D_CRT_DATA_PIPELINE_DEF {{0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, 0, 0, NULL} +#define H5D_CRT_DATA_PIPELINE_DEF {{0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_PLINE_VERSION_1, 0, 0, NULL} #define H5D_CRT_DATA_PIPELINE_CMP H5P_dcrt_data_pipeline_cmp @@ -785,6 +785,10 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, if(pline->nused >= H5Z_MAX_NFILTERS) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") + /* Check for freshly allocated filter pipeline */ + if(pline->version == 0) + pline->version = H5O_PLINE_VERSION_1; + /* Allocate additional space in the pipeline if it's full */ if(pline->nused >= pline->nalloc) { H5O_pline_t x; @@ -1236,6 +1240,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_delete() */ + /*------------------------------------------------------------------------- * Function: H5Zget_filter_info * @@ -1284,3 +1289,33 @@ done: FUNC_LEAVE_API(ret_value) } + +/*------------------------------------------------------------------------- + * Function: H5Z_set_latest_version + * + * Purpose: Set the encoding for a I/O filter pipeline to the latest version. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Tuesday, July 24, 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Z_set_latest_version(H5O_pline_t *pline) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5Z_set_latest_version, FAIL) + + /* Sanity check */ + HDassert(pline); + + /* Set encoding of I/O pipeline to latest version */ + pline->version = H5O_PLINE_VERSION_LATEST; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5Z_set_latest_version() */ + diff --git a/src/H5Zpkg.h b/src/H5Zpkg.h index cd899fb..9cd126e 100644 --- a/src/H5Zpkg.h +++ b/src/H5Zpkg.h @@ -23,6 +23,21 @@ /* Include private header file */ #include "H5Zprivate.h" /* Filter functions */ + +/* The initial version of the format */ +#define H5O_PLINE_VERSION_1 1 + +/* This version encodes the message fields more efficiently */ +/* (Drops the reserved bytes, doesn't align the name and doesn't encode the + * filter name at all if it's a filter provided by the library) + */ +#define H5O_PLINE_VERSION_2 2 + +/* The latest version of the format. Look through the 'encode' and 'size' + * callbacks for places to change when updating this. */ +#define H5O_PLINE_VERSION_LATEST H5O_PLINE_VERSION_2 + + #ifdef H5_HAVE_FILTER_DEFLATE /* * Deflate filter diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 9868412..cd67e96 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -90,6 +90,7 @@ H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, H5Z_filter_t filter); H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline); H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); +H5_DLL herr_t H5Z_set_latest_version(struct H5O_pline_t *pline); /* Data Transform Functions */ typedef struct H5Z_data_xform_t H5Z_data_xform_t; /* Defined in H5Ztrans.c */ |