diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2001-12-05 20:26:39 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2001-12-05 20:26:39 (GMT) |
commit | 6ecbcc1717aa79dbaa00926b7a5f095a921f8991 (patch) | |
tree | 6a5a949e3ef0419d9eb9ad05c90f083a8f49d066 | |
parent | 253123994aaecc1f1fc917383b663104d6630d0f (diff) | |
download | hdf5-6ecbcc1717aa79dbaa00926b7a5f095a921f8991.zip hdf5-6ecbcc1717aa79dbaa00926b7a5f095a921f8991.tar.gz hdf5-6ecbcc1717aa79dbaa00926b7a5f095a921f8991.tar.bz2 |
[svn-r4676] Purpose:
Backward Compatibility Fix
Description:
One of H5P[gs]et_buffer's parameters changed between v1.4 and the
development branch.
Solution:
Added v1.4 compat stuff around H5P[gs]et_buffer implementation and testing
to allow v1.4.x users to continue to use their source code without
modification.
These changes are for everything except the FORTRAN wrappers - I spoke with
Elena and she will make the FORTRAN wrapper changes.
Platforms tested:
FreeBSD 4.4 (hawkwind)
-rw-r--r-- | c++/src/H5DxferProp.cpp | 25 | ||||
-rw-r--r-- | c++/src/H5DxferProp.h | 8 | ||||
-rw-r--r-- | src/H5P.c | 114 | ||||
-rw-r--r-- | src/H5Ppublic.h | 7 | ||||
-rw-r--r-- | tools/h4toh5/h4toh5image.c | 4 | ||||
-rw-r--r-- | tools/h4toh5/h4toh5sds.c | 8 |
6 files changed, 166 insertions, 0 deletions
diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index da67d4c..36d2405 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -19,6 +19,30 @@ DSetMemXferPropList::DSetMemXferPropList() : PropList( H5P_DATASET_XFER) {} // Copy constructor: makes a copy of the original DSetMemXferPropList object; DSetMemXferPropList::DSetMemXferPropList( const DSetMemXferPropList& orig ) : PropList( orig ) {} +#ifdef H5_WANT_H5_V1_4_COMPAT +// Sets type conversion and background buffers +void DSetMemXferPropList::setBuffer( hsize_t size, void* tconv, void* bkg ) const +{ + herr_t ret_value = H5Pset_buffer( id, size, tconv, bkg ); + if( ret_value < 0 ) + { + throw PropListIException("DSetMemXferPropList::setBuffer", + "H5Pset_buffer failed"); + } +} + +// Reads buffer settings +hsize_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const +{ + hsize_t buffer_size = H5Pget_buffer( id, tconv, bkg ); + if( buffer_size == 0 ) + { + throw PropListIException("DSetMemXferPropList::getBuffer", + "H5Pget_buffer returned 0 for buffer size - failure"); + } + return( buffer_size ); +} +#else /* H5_WANT_H5_V1_4_COMPAT */ // Sets type conversion and background buffers void DSetMemXferPropList::setBuffer( size_t size, void* tconv, void* bkg ) const { @@ -41,6 +65,7 @@ size_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const } return( buffer_size ); } +#endif /* H5_WANT_H5_V1_4_COMPAT */ // Sets the dataset transfer property list status to TRUE or FALSE void DSetMemXferPropList::setPreserve( bool status ) const diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index d868ed8..a612805 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -16,11 +16,19 @@ class DSetMemXferPropList : public PropList { // Copy constructor: creates a copy of a DSetMemXferPropList object DSetMemXferPropList( const DSetMemXferPropList& orig ); +#ifdef H5_WANT_H5_V1_4_COMPAT + // Sets type conversion and background buffers + void setBuffer( hsize_t size, void* tconv, void* bkg ) const; + + // Reads buffer settings + hsize_t getBuffer( void** tconv, void** bkg ) const; +#else /* H5_WANT_H5_V1_4_COMPAT */ // Sets type conversion and background buffers void setBuffer( size_t size, void* tconv, void* bkg ) const; // Reads buffer settings size_t getBuffer( void** tconv, void** bkg ) const; +#endif /* H5_WANT_H5_V1_4_COMPAT */ // Sets the dataset transfer property list status to TRUE or FALSE void setPreserve( bool status ) const; @@ -2370,6 +2370,118 @@ done: } #endif /* H5_WANT_H5_V1_4_COMPAT */ +#ifdef H5_WANT_H5_V1_4_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Pset_buffer + * + * Purpose: Given a dataset transfer property list, set the maximum size + * for the type conversion buffer and background buffer and + * optionally supply pointers to application-allocated buffers. + * If the buffer size is smaller than the entire amount of data + * being transfered between application and file, and a type + * conversion buffer or background buffer is required then + * strip mining will be used. + * + * If TCONV and/or BKG are null pointers then buffers will be + * allocated and freed during the data transfer. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Monday, March 16, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_buffer(hid_t plist_id, hsize_t _size, void *tconv, void *bkg) +{ + H5P_genplist_t *plist; /* Property list pointer */ + size_t size=(size_t)_size; /* Work around size difference */ + herr_t ret_value=SUCCEED; /* return value */ + + FUNC_ENTER (H5Pset_buffer, FAIL); + H5TRACE4("e","izxx",plist_id,_size,tconv,bkg); + + /* Check arguments */ + if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); + if (size<=0) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size must not be zero"); + + /* Get the plist structure */ + if(NULL == (plist = H5I_object(plist_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Update property list */ + if(H5P_set(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size)<0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer buffer size"); + if(H5P_set(plist, H5D_XFER_TCONV_BUF_NAME, &tconv)<0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer type conversion buffer"); + if(H5P_set(plist, H5D_XFER_BKGR_BUF_NAME, &bkg)<0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, FAIL, "Can't set background type conversion buffer"); + +done: + FUNC_LEAVE(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pget_buffer + * + * Purpose: Reads values previously set with H5Pset_buffer(). + * + * Return: Success: Buffer size. + * + * Failure: 0 + * + * Programmer: Robb Matzke + * Monday, March 16, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hsize_t +H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) +{ + H5P_genplist_t *plist; /* Property list pointer */ + size_t size; /* Type conversion buffer size */ + hsize_t ret_value=0; /* Type conversion buffer size */ + + FUNC_ENTER (H5Pget_buffer, 0); + H5TRACE3("z","ixx",plist_id,tconv,bkg); + + /* Check arguments */ + if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, 0, "not a dataset transfer property list"); + + /* Get the plist structure */ + if(NULL == (plist = H5I_object(plist_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, 0, "can't find object for ID"); + + /* Return values */ + if (tconv) + if(H5P_get(plist, H5D_XFER_TCONV_BUF_NAME, tconv)<0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, 0, "Can't get transfer type conversion buffer"); + if (bkg) + if(H5P_get(plist, H5D_XFER_BKGR_BUF_NAME, bkg)<0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, 0, "Can't get background type conversion buffer"); + + /* Get the size */ + if(H5P_get(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size)<0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTSET, 0, "Can't set transfer buffer size"); + + /* Set the return value */ + ret_value=(hsize_t)size; + +done: + FUNC_LEAVE(ret_value); +} + +#else /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- * Function: H5Pset_buffer @@ -2479,6 +2591,8 @@ done: FUNC_LEAVE(ret_value); } +#endif /* H5_WANT_H5_V1_4_COMPAT */ + /*------------------------------------------------------------------------- * Function: H5Pset_hyper_cache diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index bbfba2c..fc5f551 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -179,10 +179,17 @@ __DLL__ herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_info); __DLL__ hid_t H5Pget_driver(hid_t plist_id); __DLL__ void *H5Pget_driver_info(hid_t plist_id); +#ifdef H5_WANT_H5_V1_4_COMPAT +__DLL__ herr_t H5Pset_buffer(hid_t plist_id, hsize_t size, void *tconv, + void *bkg); +__DLL__ hsize_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, + void **bkg/*out*/); +#else /* H5_WANT_H5_V1_4_COMPAT */ __DLL__ herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg); __DLL__ size_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/); +#endif /* H5_WANT_H5_V1_4_COMPAT */ __DLL__ herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); __DLL__ int H5Pget_preserve(hid_t plist_id); __DLL__ herr_t H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, diff --git a/tools/h4toh5/h4toh5image.c b/tools/h4toh5/h4toh5image.c index c4c945f..7523974 100644 --- a/tools/h4toh5/h4toh5image.c +++ b/tools/h4toh5/h4toh5image.c @@ -95,7 +95,11 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup,in hsize_t fielddim[1]; hsize_t h5dims[2]; hsize_t h5dims24[3]; +#ifdef H5_WANT_H5_V1_4_COMPAT hsize_t bufsize; +#else /* H5_WANT_H5_V1_4_COMPAT */ + size_t bufsize; +#endif /* H5_WANT_H5_V1_4_COMPAT */ herr_t ret; hid_t create_plist; hid_t write_plist; diff --git a/tools/h4toh5/h4toh5sds.c b/tools/h4toh5/h4toh5sds.c index d464fdf..6945bdb 100644 --- a/tools/h4toh5/h4toh5sds.c +++ b/tools/h4toh5/h4toh5sds.c @@ -95,7 +95,11 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup,int hid_t write_plist; hsize_t h5dims[MAX_VAR_DIMS]; hsize_t max_h5dims[MAX_VAR_DIMS]; +#ifdef H5_WANT_H5_V1_4_COMPAT hsize_t bufsize; +#else /* H5_WANT_H5_V1_4_COMPAT */ + size_t bufsize; +#endif /* H5_WANT_H5_V1_4_COMPAT */ char* h5csds_name; herr_t ret; @@ -1480,7 +1484,11 @@ int convert_sdsfillvalue(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimg hid_t write_plist; hsize_t h5dims[MAX_VAR_DIMS]; hsize_t max_h5dims[MAX_VAR_DIMS]; +#ifdef H5_WANT_H5_V1_4_COMPAT hsize_t bufsize; +#else /* H5_WANT_H5_V1_4_COMPAT */ + size_t bufsize; +#endif /* H5_WANT_H5_V1_4_COMPAT */ char* h5csds_name; if (SDgetinfo(sds_id,sdsname,&sds_rank,sds_dimsizes,&sds_dtype, |