From 5c0011a71384223791d18028968382db43f08a6f Mon Sep 17 00:00:00 2001 From: James Laird Date: Tue, 28 Sep 2004 14:04:19 -0500 Subject: [svn-r9329] Purpose: Feature Description: Datatypes and groups now use H5FO "file object" code that was previously only used by datasets. These objects will hold a file open if the file is closed but they have not yet been closed. If these objects are unlinked then relinked, they will not be destroyed. If they are opened twice (even by two different names), both IDs will "see" changes made to the object using the other ID. When an object is opened using two different names (e.g., if a dataset was opened under one name, then mounted and opened under its new name), calling H5Iget_name() on a given hid_t will return the name used to open that hid_t, not the current name of the object (this is a feature, and a change from the previous behavior of datasets). Solution: Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's, and H5G_t's into a "shared" struct and a private struct. The shared structs (H5D_shared_t, etc.) hold the object's information and are used by all IDs that point to a given object in the file. The private structs are pointed to by the hid_t and contain the object's group entry information (including its name) and a pointer to the shared struct for that object. This changed the naming of structs throughout the library (e.g., datatype->size is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip. Platforms tested: Visual Studio 7, sleipnir, arabica, verbena Misc. update: --- src/H5D.c | 577 +++++++++++++------------ src/H5Dcompact.c | 6 +- src/H5Dcontig.c | 168 ++++---- src/H5Dio.c | 148 +++---- src/H5Distore.c | 227 +++++----- src/H5Dmpio.c | 6 +- src/H5Dpkg.h | 14 +- src/H5Dprivate.h | 3 +- src/H5Dseq.c | 8 +- src/H5Dtest.c | 6 +- src/H5Edefin.h | 3 - src/H5Einit.h | 13 +- src/H5Epubgen.h | 5 - src/H5Eterm.h | 4 +- src/H5F.c | 58 +-- src/H5FO.c | 26 +- src/H5FOprivate.h | 5 +- src/H5G.c | 190 ++++++--- src/H5Gpkg.h | 11 +- src/H5Gprivate.h | 5 +- src/H5O.c | 2 +- src/H5Odtype.c | 536 +++++++++++++----------- src/H5R.c | 27 +- src/H5T.c | 925 ++++++++++++++++++++++------------------- src/H5Tarray.c | 46 +- src/H5Tcommit.c | 16 +- src/H5Tcompound.c | 130 +++--- src/H5Tconv.c | 918 ++++++++++++++++++++-------------------- src/H5Tcset.c | 26 +- src/H5Tenum.c | 83 ++-- src/H5Tfields.c | 138 +++--- src/H5Tfixed.c | 20 +- src/H5Tfloat.c | 94 ++--- src/H5Tnative.c | 4 +- src/H5Toffset.c | 44 +- src/H5Topaque.c | 20 +- src/H5Torder.c | 20 +- src/H5Tpad.c | 24 +- src/H5Tpkg.h | 10 +- src/H5Tprecis.c | 56 +-- src/H5Tprivate.h | 2 +- src/H5Tstrpad.c | 26 +- src/H5Tvlen.c | 99 ++--- src/H5detect.c | 42 +- test/getname.c | 100 ++++- test/unlink.c | 149 ++++++- tools/h5repack/h5repack_refs.c | 10 +- windows/all.zip | Bin 344782 -> 344886 bytes 48 files changed, 2784 insertions(+), 2266 deletions(-) diff --git a/src/H5D.c b/src/H5D.c index 71c8a07..168e07c 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -36,7 +36,7 @@ /* Local functions */ static herr_t H5D_init_storage(H5D_t *dataset, hbool_t full_overwrite, hid_t dxpl_id); -static H5D_t * H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type); +static H5D_shared_t * H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type); static H5D_t * H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dxpl_id); static H5D_t * H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id); @@ -45,7 +45,6 @@ static hsize_t H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id); static haddr_t H5D_get_offset(const H5D_t *dset); static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); static herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); -static herr_t H5D_close(H5D_t *dataset); static herr_t H5D_init_type(H5F_t *file, H5D_t *dset, hid_t type_id, const H5T_t *type); static int H5D_crt_fill_value_cmp(const void *value1, const void *value2, size_t size); static int H5D_crt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); @@ -65,8 +64,9 @@ typedef struct { hsize_t size; /* Accumulated number of bytes for the selection */ } H5D_vlen_bufsize_t; -/* Declare a free list to manage the H5D_t struct */ +/* Declare a free list to manage the H5D_t and H5D_shared_t structs */ H5FL_DEFINE_STATIC(H5D_t); +H5FL_DEFINE_STATIC(H5D_shared_t); /* Declare a free list to manage blocks of VL data */ H5FL_BLK_DEFINE_STATIC(vlen_vl_buf); @@ -78,7 +78,7 @@ H5FL_BLK_DEFINE_STATIC(vlen_fl_buf); H5FL_BLK_EXTERN(sieve_buf); /* Define a static "default" dataset structure to use to initialize new datasets */ -static H5D_t H5D_def_dset; +static H5D_shared_t H5D_def_dset; /* Define a "default" dataset transfer property list cache structure to use for default DXPLs */ H5D_dxpl_cache_t H5D_def_dxpl_cache; @@ -350,7 +350,7 @@ H5D_init_interface(void) } /* end if */ /* Reset the "default dataset" information */ - HDmemset(&H5D_def_dset,0,sizeof(H5D_t)); + HDmemset(&H5D_def_dset,0,sizeof(H5D_shared_t)); /* Get the default dataset cretion property list values and initialize the * default dataset with them. @@ -1201,10 +1201,6 @@ H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if ((ret_value = H5I_register(H5I_DATASET, new_dset)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") - /* Add the dataset to the list of opened objects in the file */ - if(H5FO_insert(new_dset->ent.file,new_dset->ent.header,ret_value)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert dataset into list of open objects") - done: if(ret_value<0) { if(new_dset!=NULL) { @@ -1240,26 +1236,32 @@ done: hid_t H5Dopen(hid_t loc_id, const char *name) { + H5D_t *dset; H5G_entry_t *loc = NULL; /*location holding the dataset */ - H5G_entry_t ent; /*dataset symbol table entry */ - hid_t ret_value; + H5G_entry_t ent; /*dataset symbol table entry */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ + hid_t ret_value; FUNC_ENTER_API(H5Dopen, FAIL) H5TRACE2("i","is",loc_id,name); /* Check args */ if (NULL == (loc = H5G_loc(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Find the dataset object */ - if (H5G_find(loc, name, NULL, &ent, H5AC_dxpl_id) < 0) + if (H5G_find(loc, name, NULL, &ent, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") /* Open the dataset */ - if ((ret_value = H5D_open(&ent, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset") + if ((dset = H5D_open(&ent, dxpl_id))==NULL) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") + + /* Register an atom for the dataset */ + if((ret_value=H5I_register(H5I_DATASET, dset)) <0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") done: FUNC_LEAVE_API(ret_value) @@ -1314,7 +1316,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5Dget_space + * Function: H5Dget_space * * Purpose: Returns a copy of the file data space for a dataset. * @@ -1348,7 +1350,7 @@ H5Dget_space(hid_t dset_id) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Read the data space message and return a data space object */ - if (NULL==(space=H5S_copy (dset->space, FALSE))) + if (NULL==(space=H5S_copy (dset->shared->space, FALSE))) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space") /* Create an atom */ @@ -1436,7 +1438,7 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) assert(dset); /* Get the dataset's dataspace */ - space=dset->space; + space=dset->shared->space; assert(space); /* Get the total number of elements in dataset's dataspace */ @@ -1444,7 +1446,7 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get # of dataspace elements") /* Get the size of the dataset's datatype */ - if((type_size=H5T_get_size(dset->type))==0) + if((type_size=H5T_get_size(dset->shared->type))==0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get size of datatype") /* Compute the maximum size of the dataset in bytes */ @@ -1461,7 +1463,7 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) *allocation = H5D_SPACE_STATUS_ALLOCATED; else { /* Should only happen for chunked datasets currently */ - assert(dset->layout.type==H5D_CHUNKED); + assert(dset->shared->layout.type==H5D_CHUNKED); *allocation = H5D_SPACE_STATUS_PART_ALLOCATED; } /* end else */ @@ -1510,7 +1512,7 @@ H5Dget_type(hid_t dset_id) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Copy the data type and mark it read-only */ - if (NULL==(copied_type=H5T_copy (dset->type, H5T_COPY_REOPEN))) + if (NULL==(copied_type=H5T_copy (dset->shared->type, H5T_COPY_REOPEN))) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the data type") /* Mark any datatypes as being in memory now */ @@ -1576,7 +1578,7 @@ H5Dget_create_plist(hid_t dset_id) /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if (NULL == (dcpl_plist = H5I_object(dset->dcpl_id))) + if (NULL == (dcpl_plist = H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Copy the creation property list */ @@ -1591,7 +1593,7 @@ H5Dget_create_plist(hid_t dset_id) /* Copy the dataset type into the fill value message */ if(copied_fill.type==NULL) - if(NULL==(copied_fill.type=H5T_copy(dset->type, H5T_COPY_TRANSIENT))) + if(NULL==(copied_fill.type=H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset data type for fill value") /* Set back the fill value property to property list */ @@ -1674,16 +1676,16 @@ done: * *------------------------------------------------------------------------- */ -static H5D_t * +static H5D_shared_t * H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) { - H5P_genplist_t *plist; /* Property list created */ - H5D_t *new_dset = NULL; /* New dataset object */ - H5D_t *ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list created */ + H5D_shared_t *new_dset = NULL; /* New dataset object */ + H5D_shared_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_new, NULL) - if (NULL==(new_dset = H5FL_MALLOC(H5D_t))) + if (NULL==(new_dset = H5FL_MALLOC(H5D_shared_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* If we are using the default dataset creation property list, during creation @@ -1691,7 +1693,7 @@ H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) */ if(!vl_type && creating && dcpl_id == H5P_DATASET_CREATE_DEFAULT) { /* Copy the default dataset information */ - HDmemcpy(new_dset,&H5D_def_dset,sizeof(H5D_t)); + HDmemcpy(new_dset,&H5D_def_dset,sizeof(H5D_shared_t)); if(H5I_inc_ref(dcpl_id)<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, NULL, "Can't increment default DCPL ID") @@ -1699,7 +1701,7 @@ H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) } /* end if */ else { /* Reset the dataset information */ - HDmemset(new_dset,0,sizeof(H5D_t)); + HDmemset(new_dset,0,sizeof(H5D_shared_t)); /* Get the property list */ if (NULL == (plist = H5I_object(dcpl_id))) @@ -1708,8 +1710,6 @@ H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) new_dset->dcpl_id = H5P_copy_plist(plist); } /* end else */ - new_dset->ent.header = HADDR_UNDEF; - /* Set return value */ ret_value=new_dset; @@ -1718,7 +1718,7 @@ done: if(new_dset!=NULL) { if(new_dset->dcpl_id!=0) (void)H5I_dec_ref(new_dset->dcpl_id); - H5FL_FREE(H5D_t,new_dset); + H5FL_FREE(H5D_shared_t,new_dset); } /* end if */ } /* end if */ @@ -1769,15 +1769,15 @@ H5D_init_type(H5F_t *file, H5D_t *dset, hid_t type_id, const H5T_t *type) /* Copy the datatype if it's a custom datatype or if it'll change when it's location is changed */ if(!immutable || relocatable) { /* Copy datatype for dataset */ - if((dset->type = H5T_copy(type, H5T_COPY_ALL))==NULL) + if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL))==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy datatype") /* Mark any datatypes as being on disk now */ - if(H5T_set_loc(dset->type, file, H5T_LOC_DISK)<0) + if(H5T_set_loc(dset->shared->type, file, H5T_LOC_DISK)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") /* Get a datatype ID for the dataset's datatype */ - if((dset->type_id = H5I_register(H5I_DATATYPE, dset->type))<0) + if((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") } /* end if */ /* Not a custom datatype, just use it directly */ @@ -1786,8 +1786,8 @@ H5D_init_type(H5F_t *file, H5D_t *dset, hid_t type_id, const H5T_t *type) HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, FAIL, "Can't increment datatype ID") /* Use existing datatype */ - dset->type_id = type_id; - dset->type = (H5T_t *)type; /* (Cast away const OK - QAK) */ + dset->shared->type_id = type_id; + dset->shared->type = (H5T_t *)type; /* (Cast away const OK - QAK) */ } /* end else */ done: @@ -1846,11 +1846,11 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p /* Pick up former parameters */ ent=&dset->ent; - layout=&dset->layout; - type=dset->type; - space=dset->space; - alloc_time=dset->alloc_time; - efl=&dset->efl; + layout=&dset->shared->layout; + type=dset->shared->type; + space=dset->shared->space; + alloc_time=dset->shared->alloc_time; + efl=&dset->shared->efl; /* Add the dataset's raw data size to the size of the header, if the raw data will be stored as compact */ if (layout->type == H5D_COMPACT) @@ -1865,18 +1865,18 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to protect dataset object header") /* Point at dataset's copy, to cache it for later */ - fill_prop=&dset->fill; - fill_time=dset->fill_time; + fill_prop=&dset->shared->fill; + fill_time=dset->shared->fill_time; /* Check if dataset has non-default creation property list */ - if(dset->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) { + if(dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) { /* * Retrieve properties of fill value and others. Copy them into new fill * value struct. */ if (H5P_get(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time") - dset->fill_time=fill_time; /* Cache this for later */ + dset->shared->fill_time=fill_time; /* Cache this for later */ /* Get the fill value information from the property list */ if (H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) @@ -1890,10 +1890,10 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p if(H5T_detect_class(type, H5T_VLEN)) { /* If the default fill value is chosen for variable-length types, always write it */ if(fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_DEFAULT) { - dset->fill_time=fill_time=H5D_FILL_TIME_ALLOC; + dset->shared->fill_time=fill_time=H5D_FILL_TIME_ALLOC; /* Update dataset creation property */ - assert(dset->dcpl_id!=H5P_DATASET_CREATE_DEFAULT); + assert(dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT); if (H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill time") } /* end if */ @@ -1943,7 +1943,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message") /* Update dataset creation property */ - assert(dset->dcpl_id!=H5P_DATASET_CREATE_DEFAULT); + assert(dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT); if (H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") } /* end if */ @@ -2139,17 +2139,22 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "dataspace extent has not been set.") /* Initialize the dataset object */ - if(NULL == (new_dset = H5D_new(dcpl_id,TRUE,has_vl_type))) + if (NULL==(new_dset = H5FL_CALLOC(H5D_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + new_dset->ent.header=HADDR_UNDEF; + + /* Initialize the shared dataset space */ + if(NULL == (new_dset->shared = H5D_new(dcpl_id,TRUE,has_vl_type))) + /* * Set the dataset's checked_filters flag to enable writing. * Make sure that H5Z_can_apply is called at the beginning of this function! */ - new_dset->checked_filters = TRUE; + new_dset->shared->checked_filters = TRUE; /* Make the "set local" filter callbacks for this dataset */ - if(H5Z_set_local(new_dset->dcpl_id,type_id)<0) + if(H5Z_set_local(new_dset->shared->dcpl_id,type_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") /* What file is the dataset being added to? */ @@ -2161,21 +2166,21 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy datatype") /* Copy dataspace for dataset */ - if((new_dset->space = H5S_copy(space, FALSE))==NULL) + if((new_dset->shared->space = H5S_copy(space, FALSE))==NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace") /* Set the dataset's dataspace to 'all' selection */ - if(H5S_select_all(new_dset->space,1)<0) + if(H5S_select_all(new_dset->shared->space,1)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Check if the dataset has a non-default DCPL & get important values, if so */ - if(new_dset->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) { + if(new_dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) { H5D_layout_t dcpl_layout; /* Dataset's layout information */ H5O_pline_t dcpl_pline; /* Dataset's I/O pipeline information */ H5D_alloc_time_t alloc_time; /* Dataset's allocation time */ /* Get new dataset's property list object */ - if (NULL == (dc_plist = H5I_object(new_dset->dcpl_id))) + if (NULL == (dc_plist = H5I_object(new_dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &dcpl_pline) < 0) @@ -2212,7 +2217,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset doesn't support late space allocation") /* Set the alloc_time for the dataset, in case the default was used */ - new_dset->alloc_time=alloc_time; + new_dset->shared->alloc_time=alloc_time; /* If MPI VFD is used, no filter support yet. */ if(IS_H5FD_MPI(file) && dcpl_pline.nused > 0) @@ -2223,19 +2228,19 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve chunk dimensions") /* Get the dataset's external file list information */ - if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, &new_dset->efl) < 0) + if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, &new_dset->shared->efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve external file list") /* Get the dataset's data storage method */ - if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, &(new_dset->layout.type)) < 0) + if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, &(new_dset->shared->layout.type)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout") } /* end if */ /* Check if this dataset is going into a parallel file and set space allocation time */ if(IS_H5FD_MPI(file)) - new_dset->alloc_time=H5D_ALLOC_TIME_EARLY; + new_dset->shared->alloc_time=H5D_ALLOC_TIME_EARLY; - switch (new_dset->layout.type) { + switch (new_dset->shared->layout.type) { case H5D_CONTIGUOUS: { hssize_t tmp_size; /* Temporary holder for raw data size */ @@ -2247,16 +2252,16 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space * Also, only the slowest varying dimension of a simple data space * can be extendible (currently only for external data storage). */ - new_dset->layout.u.contig.addr = HADDR_UNDEF; /* Initialize to no address */ + new_dset->shared->layout.u.contig.addr = HADDR_UNDEF; /* Initialize to no address */ - if ((ndims=H5S_get_simple_extent_dims(new_dset->space, dim, max_dim))<0) + if ((ndims=H5S_get_simple_extent_dims(new_dset->shared->space, dim, max_dim))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize contiguous storage") for (i=1; idim[i]) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "only the first dimension can be extendible") - if (new_dset->efl.nused>0) { - hsize_t max_points = H5S_get_npoints_max (new_dset->space); - hsize_t max_storage = H5O_efl_total_size (&new_dset->efl); + if (new_dset->shared->efl.nused>0) { + hsize_t max_points = H5S_get_npoints_max (new_dset->shared->space); + hsize_t max_storage = H5O_efl_total_size (&new_dset->shared->efl); if (H5S_UNLIMITED==max_points) { if (H5O_EFL_UNLIMITED!=max_storage) @@ -2271,9 +2276,9 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space } /* Compute the total size of a chunk */ - tmp_size = H5S_GET_EXTENT_NPOINTS(new_dset->space) * - H5T_get_size(new_dset->type); - H5_ASSIGN_OVERFLOW(new_dset->layout.u.contig.size,tmp_size,hssize_t,hsize_t); + tmp_size = H5S_GET_EXTENT_NPOINTS(new_dset->shared->space) * + H5T_get_size(new_dset->shared->type); + H5_ASSIGN_OVERFLOW(new_dset->shared->layout.u.contig.size,tmp_size,hssize_t,hsize_t); } /* end case */ break; @@ -2282,12 +2287,12 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */ /* Set up layout information */ - if((ndims=H5S_GET_EXTENT_NDIMS(new_dset->space))<0) + if((ndims=H5S_GET_EXTENT_NDIMS(new_dset->shared->space))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get rank") - new_dset->layout.u.chunk.ndims = (unsigned)ndims + 1; - assert((unsigned)(new_dset->layout.u.chunk.ndims) <= NELMTS(new_dset->layout.u.chunk.dim)); + new_dset->shared->layout.u.chunk.ndims = (unsigned)ndims + 1; + assert((unsigned)(new_dset->shared->layout.u.chunk.ndims) <= NELMTS(new_dset->shared->layout.u.chunk.dim)); - new_dset->layout.u.chunk.addr = HADDR_UNDEF; /* Initialize to no address */ + new_dset->shared->layout.u.chunk.addr = HADDR_UNDEF; /* Initialize to no address */ /* * Chunked storage allows any type of data space extension, so we @@ -2295,26 +2300,26 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space */ if(chunk_ndims != (unsigned)ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "dimensionality of chunks doesn't match the data space") - if (new_dset->efl.nused>0) + if (new_dset->shared->efl.nused>0) HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, "external storage not supported with chunked layout") /* * The chunk size of a dimension with a fixed size cannot exceed * the maximum dimension size */ - if(H5P_get(dc_plist, H5D_CRT_CHUNK_SIZE_NAME, new_dset->layout.u.chunk.dim) < 0) + if(H5P_get(dc_plist, H5D_CRT_CHUNK_SIZE_NAME, new_dset->shared->layout.u.chunk.dim) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve chunk size") - new_dset->layout.u.chunk.dim[new_dset->layout.u.chunk.ndims-1] = H5T_get_size(new_dset->type); + new_dset->shared->layout.u.chunk.dim[new_dset->shared->layout.u.chunk.ndims-1] = H5T_get_size(new_dset->shared->type); - if (H5S_get_simple_extent_dims(new_dset->space, NULL, max_dim)<0) + if (H5S_get_simple_extent_dims(new_dset->shared->space, NULL, max_dim)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to query maximum dimensions") - for (u=0; ulayout.u.chunk.ndims-1; u++) - if(max_dim[u] != H5S_UNLIMITED && max_dim[u] < new_dset->layout.u.chunk.dim[u]) + for (u=0; ushared->layout.u.chunk.ndims-1; u++) + if(max_dim[u] != H5S_UNLIMITED && max_dim[u] < new_dset->shared->layout.u.chunk.dim[u]) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "chunk size must be <= maximum dimension size for fixed-sized dimensions") /* Compute the total size of a chunk */ - for (u=1, new_dset->layout.u.chunk.size=new_dset->layout.u.chunk.dim[0]; ulayout.u.chunk.ndims; u++) - new_dset->layout.u.chunk.size *= new_dset->layout.u.chunk.dim[u]; + for (u=1, new_dset->shared->layout.u.chunk.size=new_dset->shared->layout.u.chunk.dim[0]; ushared->layout.u.chunk.ndims; u++) + new_dset->shared->layout.u.chunk.size *= new_dset->shared->layout.u.chunk.dim[u]; /* Initialize the chunk cache for the dataset */ if(H5D_istore_init(file,new_dset)<0) @@ -2335,14 +2340,14 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space * layout. */ tmp_size = H5S_GET_EXTENT_NPOINTS(space) * - H5T_get_size(new_dset->type); - H5_ASSIGN_OVERFLOW(new_dset->layout.u.compact.size,tmp_size,hssize_t,size_t); + H5T_get_size(new_dset->shared->type); + H5_ASSIGN_OVERFLOW(new_dset->shared->layout.u.compact.size,tmp_size,hssize_t,size_t); /* Verify data size is smaller than maximum header message size * (64KB) minus other layout message fields. */ - comp_data_size=H5O_MAX_SIZE-H5O_layout_meta_size(file, &(new_dset->layout)); - if(new_dset->layout.u.compact.size > comp_data_size) + comp_data_size=H5O_MAX_SIZE-H5O_layout_meta_size(file, &(new_dset->shared->layout)); + if(new_dset->shared->layout.u.compact.size > comp_data_size) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size") } /* end case */ break; @@ -2356,7 +2361,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update the metadata cache") /* Get the dataset's DCPL cache info */ - if (H5D_get_dcpl_cache(new_dset->dcpl_id,&new_dset->dcpl_cache)<0) + if (H5D_get_dcpl_cache(new_dset->shared->dcpl_id,&new_dset->shared->dcpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't fill DCPL cache") /* @@ -2367,37 +2372,46 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space if (H5G_insert(loc, name, &new_dset->ent, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset") + /* Add the dataset to the list of opened objects in the file */ + if(H5FO_insert(new_dset->ent.file,new_dset->ent.header,new_dset->shared)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") + + new_dset->shared->fo_count=1; + /* Success */ ret_value = new_dset; done: - if (!ret_value && new_dset) { - if(new_dset->layout.type==H5D_CHUNKED && chunk_init) { - if(H5D_istore_dest(new_dset->ent.file,H5AC_dxpl_id,new_dset)<0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy chunk cache") - } /* end if */ - if (new_dset->space) { - if(H5S_close(new_dset->space)<0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") - } /* end if */ - if (new_dset->type) { - if(H5I_dec_ref(new_dset->type_id)<0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") - } /* end if */ - if (H5F_addr_defined(new_dset->ent.header)) { - if(H5O_close(&(new_dset->ent))<0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") - if(file) { - if(H5O_delete(file, dxpl_id,new_dset->ent.header)<0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header") + if (!ret_value && new_dset && new_dset->shared) { + if( new_dset->shared) { + if(new_dset->shared->layout.type==H5D_CHUNKED && chunk_init) { + if(H5D_istore_dest(new_dset->ent.file,H5AC_dxpl_id,new_dset)<0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy chunk cache") } /* end if */ - } /* end if */ - if(new_dset->dcpl_id!=0) { - if(H5I_dec_ref(new_dset->dcpl_id)<0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") - } /* end if */ + if (new_dset->shared->space) { + if(H5S_close(new_dset->shared->space)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") + } /* end if */ + if (new_dset->shared->type) { + if(H5I_dec_ref(new_dset->shared->type_id)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") + } /* end if */ + if (H5F_addr_defined(new_dset->ent.header)) { + if(H5O_close(&(new_dset->ent))<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") + if(file) { + if(H5O_delete(file, dxpl_id,new_dset->ent.header)<0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header") + } /* end if */ + } /* end if */ + if(new_dset->shared->dcpl_id!=0) { + if(H5I_dec_ref(new_dset->shared->dcpl_id)<0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") + } /* end if */ + H5FL_FREE(H5D_shared_t,new_dset->shared); + } new_dset->ent.file = NULL; - H5FL_FREE(H5D_t,new_dset); + H5FL_FREE(H5D_t, new_dset); } FUNC_LEAVE_NOAPI(ret_value) @@ -2472,52 +2486,60 @@ done: * *------------------------------------------------------------------------- */ -hid_t +H5D_t* H5D_open(H5G_entry_t *ent, hid_t dxpl_id) { - hid_t ret_value; /* Return value */ + H5D_shared_t *shared_fo=NULL; + H5D_t *dataset=NULL; + H5D_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5D_open, FAIL) + FUNC_ENTER_NOAPI(H5D_open, NULL) /* check args */ assert (ent); - - /* Check if dataset was already open */ - if((ret_value=H5FO_opened(ent->file,ent->header))<0) { - H5D_t *dataset; /*the dataset which was found */ + /* Check if dataset was already open */ + if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear_stack(NULL); /* Open the dataset object */ if ((dataset=H5D_open_oid(ent, dxpl_id)) ==NULL) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") - - /* Create an atom for the dataset */ - if ((ret_value = H5I_register(H5I_DATASET, dataset)) < 0) { - (void)H5D_close(dataset); - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset") - } /* end if */ + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") /* Add the dataset to the list of opened objects in the file */ - if(H5FO_insert(ent->file,ent->header,ret_value)<0) { - (void)H5I_dec_ref(ret_value); - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert dataset into list of open objects") - } /* end if */ + if(H5FO_insert(ent->file,ent->header,dataset->shared)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects") + + dataset->shared->fo_count = 1; } /* end if */ else { - /* Dataset is already open, increment the reference count on the ID */ - if(H5I_inc_ref(ret_value)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, FAIL, "Can't increment dataset ID") - - /* Release the dataset entry we located earlier (in H5Dopen()) */ - if(H5G_free_ent_name(ent)<0) { - (void)H5I_dec_ref(ret_value); - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release group entry") - } /* end if */ + shared_fo->fo_count++; + + if(NULL == (dataset = H5FL_CALLOC(H5D_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for dataset") + + dataset->shared=shared_fo; + + /* Shallow copy (take ownership) of the group entry object */ + if(H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW)<0) + HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy group entry") } /* end else */ + ret_value = dataset; + done: + if(ret_value==NULL) { + if(dataset) { + if(shared_fo==NULL) { /* Need to free shared fo */ + H5FL_FREE(H5D_shared_t, dataset->shared); + } + H5FL_FREE(H5D_t, dataset); + } + if(shared_fo) + shared_fo->fo_count--; + } + FUNC_LEAVE_NOAPI(ret_value) } @@ -2566,7 +2588,10 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) /* Allocate the dataset structure */ /* (Set the 'vl_type' parameter to FALSE since it doesn't matter from here) */ - if(NULL==(dataset = H5D_new(H5P_DATASET_CREATE_DEFAULT,FALSE,FALSE))) + if(NULL==(dataset=H5FL_CALLOC(H5D_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + if(NULL==(dataset->shared = H5D_new(H5P_DATASET_CREATE_DEFAULT,FALSE,FALSE))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Shallow copy (take ownership) of the group entry object */ @@ -2578,17 +2603,17 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open") /* Get the type and space */ - if (NULL==(dataset->type=H5O_read(&(dataset->ent), H5O_DTYPE_ID, 0, NULL, dxpl_id))) + if (NULL==(dataset->shared->type=H5O_read(&(dataset->ent), H5O_DTYPE_ID, 0, NULL, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type info from dataset header") /* Get a datatype ID for the dataset's datatype */ - if((dataset->type_id = H5I_register(H5I_DATATYPE, dataset->type))<0) + if((dataset->shared->type_id = H5I_register(H5I_DATATYPE, dataset->shared->type))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, NULL, "unable to register type") - if (NULL==(dataset->space=H5S_read(&(dataset->ent),dxpl_id))) + if (NULL==(dataset->shared->space=H5S_read(&(dataset->ent),dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header") /* Get dataset creation property list object */ - if (NULL == (plist = H5I_object(dataset->dcpl_id))) + if (NULL == (plist = H5I_object(dataset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") /* Get the optional filters message */ @@ -2609,22 +2634,22 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) * values are copied to the dataset create plist so the user can query * them. */ - if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT_ID, 0, &(dataset->layout), dxpl_id)) + if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT_ID, 0, &(dataset->shared->layout), dxpl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to read data layout message") - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->layout.type) < 0) + if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout.type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set layout") - switch (dataset->layout.type) { + switch (dataset->shared->layout.type) { case H5D_CONTIGUOUS: /* Compute the size of the contiguous storage for versions of the * layout message less than version 3 because versions 1 & 2 would * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ - if(dataset->layout.version<3) { + if(dataset->shared->layout.version<3) { hssize_t tmp_size; /* Temporary holder for raw data size */ - tmp_size = H5S_GET_EXTENT_NPOINTS(dataset->space) * - H5T_get_size(dataset->type); - H5_ASSIGN_OVERFLOW(dataset->layout.u.contig.size,tmp_size,hssize_t,hsize_t); + tmp_size = H5S_GET_EXTENT_NPOINTS(dataset->shared->space) * + H5T_get_size(dataset->shared->type); + H5_ASSIGN_OVERFLOW(dataset->shared->layout.u.contig.size,tmp_size,hssize_t,hsize_t); } /* end if */ break; @@ -2637,11 +2662,11 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) { unsigned chunk_ndims; /* Dimensionality of chunk */ - chunk_ndims = dataset->layout.u.chunk.ndims - 1; + chunk_ndims = dataset->shared->layout.u.chunk.ndims - 1; if(H5P_set(plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set chunk dimensions") - if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, dataset->layout.u.chunk.dim) < 0) + if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, dataset->shared->layout.u.chunk.dim) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set chunk size") /* Initialize the chunk cache for the dataset */ @@ -2658,7 +2683,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) } /* end switch */ /* Point at dataset's copy, to cache it for later */ - fill_prop=&dataset->fill; + fill_prop=&dataset->shared->fill; /* Retrieve & release the previous fill-value settings */ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) @@ -2672,7 +2697,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) HDmemset(&fill, 0, sizeof(fill)); /* Set the space allocation time appropriately, based on the type of dataset storage */ - switch (dataset->layout.type) { + switch (dataset->shared->layout.type) { case H5D_COMPACT: fill.alloc_time=H5D_ALLOC_TIME_EARLY; break; @@ -2711,20 +2736,20 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) /* Set revised fill value properties */ if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") - dataset->alloc_time=fill.alloc_time; /* Cache this for later */ + dataset->shared->alloc_time=fill.alloc_time; /* Cache this for later */ if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &fill.alloc_time) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") - dataset->fill_time=fill.fill_time; /* Cache this for later */ + dataset->shared->fill_time=fill.fill_time; /* Cache this for later */ if(H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill.fill_time) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") /* Get the external file list message, which might not exist. Space is * also undefined when space allocate time is H5D_ALLOC_TIME_LATE. */ - if((dataset->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->layout.u.contig.addr)) - || (dataset->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->layout.u.chunk.addr))) { - HDmemset(&dataset->efl,0,sizeof(H5O_efl_t)); - if(NULL != H5O_read(&(dataset->ent), H5O_EFL_ID, 0, &dataset->efl, dxpl_id)) - if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->efl) < 0) + if((dataset->shared->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr)) + || (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) { + HDmemset(&dataset->shared->efl,0,sizeof(H5O_efl_t)); + if(NULL != H5O_read(&(dataset->ent), H5O_EFL_ID, 0, &dataset->shared->efl, dxpl_id)) + if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->efl) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set external file list") } @@ -2734,15 +2759,15 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) * be fully allocated before I/O can happen. */ if ((H5F_get_intent(dataset->ent.file) & H5F_ACC_RDWR) - && ((dataset->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->layout.u.contig.addr)) - || (dataset->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->layout.u.chunk.addr))) + && ((dataset->shared->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr)) + || (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) && IS_H5FD_MPI(dataset->ent.file)) { if (H5D_alloc_storage(dataset->ent.file, dxpl_id, dataset,H5D_ALLOC_OPEN, TRUE, FALSE)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize file storage") } /* Get the dataset's DCPL cache info */ - if (H5D_get_dcpl_cache(dataset->dcpl_id,&dataset->dcpl_cache)<0) + if (H5D_get_dcpl_cache(dataset->shared->dcpl_id,&dataset->shared->dcpl_cache)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't fill DCPL cache") /* Success */ @@ -2758,12 +2783,12 @@ done: if(H5O_close(&(dataset->ent))<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") } /* end if */ - if (dataset->space) { - if(H5S_close(dataset->space)<0) + if (dataset->shared->space) { + if(H5S_close(dataset->shared->space)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") } /* end if */ - if (dataset->type) { - if(H5I_dec_ref(dataset->type_id)<0) + if (dataset->shared->type) { + if(H5I_dec_ref(dataset->shared->type_id)<0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") } /* end if */ dataset->ent.file = NULL; @@ -2795,82 +2820,94 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D_close(H5D_t *dataset) { - unsigned free_failed; + unsigned free_failed=FALSE; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_close, FAIL) /* check args */ assert(dataset && dataset->ent.file); + assert(dataset->shared->fo_count >0); /* Dump debugging info */ #ifdef H5D_ISTORE_DEBUG H5D_istore_stats(dataset, FALSE); #endif /* H5F_ISTORE_DEBUG */ - /* Free the data sieve buffer, if it's been allocated */ - if(dataset->cache.contig.sieve_buf) { - assert(dataset->layout.type!=H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ - assert(dataset->cache.contig.sieve_dirty==0); /* The buffer had better be flushed... */ - dataset->cache.contig.sieve_buf = H5FL_BLK_FREE (sieve_buf,dataset->cache.contig.sieve_buf); - } /* end if */ + dataset->shared->fo_count--; + if(dataset->shared->fo_count ==0) + { + /* Free the data sieve buffer, if it's been allocated */ + if(dataset->shared->cache.contig.sieve_buf) { + assert(dataset->shared->layout.type!=H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ + assert(dataset->shared->cache.contig.sieve_dirty==0); /* The buffer had better be flushed... */ + dataset->shared->cache.contig.sieve_buf = H5FL_BLK_FREE (sieve_buf,dataset->shared->cache.contig.sieve_buf); + } /* end if */ - /* Free cached information for each kind of dataset */ - switch(dataset->layout.type) { - case H5D_CONTIGUOUS: - break; + /* Free cached information for each kind of dataset */ + switch(dataset->shared->layout.type) { + case H5D_CONTIGUOUS: + break; - case H5D_CHUNKED: - /* Flush and destroy chunks in the cache */ - if(H5D_istore_dest(dataset->ent.file,H5AC_dxpl_id,dataset)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") - break; + case H5D_CHUNKED: + /* Flush and destroy chunks in the cache */ + if(H5D_istore_dest(dataset->ent.file,H5AC_dxpl_id,dataset)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") + break; - case H5D_COMPACT: - /* Update header message of layout for compact dataset. */ - if(dataset->layout.u.compact.dirty) { - if(H5O_modify(&(dataset->ent), H5O_LAYOUT_ID, 0, 0, 1, &(dataset->layout), H5AC_dxpl_id)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to update layout message") - dataset->layout.u.compact.dirty = FALSE; - } /* end if */ + case H5D_COMPACT: + /* Update header message of layout for compact dataset. */ + if(dataset->shared->layout.u.compact.dirty) { + if(H5O_modify(&(dataset->ent), H5O_LAYOUT_ID, 0, 0, 1, &(dataset->shared->layout), H5AC_dxpl_id)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to update layout message") + dataset->shared->layout.u.compact.dirty = FALSE; + } /* end if */ - /* Free the buffer for the raw data for compact datasets */ - dataset->layout.u.compact.buf=H5MM_xfree(dataset->layout.u.compact.buf); - break; + /* Free the buffer for the raw data for compact datasets */ + dataset->shared->layout.u.compact.buf=H5MM_xfree(dataset->shared->layout.u.compact.buf); + break; - default: - assert ("not implemented yet" && 0); + default: + assert ("not implemented yet" && 0); #ifdef NDEBUG - HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") + HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") #endif /* NDEBUG */ - } /* end switch */ + } /* end switch */ - /* - * Release datatype, dataspace and creation property list -- there isn't - * much we can do if one of these fails, so we just continue. - */ - free_failed=(H5I_dec_ref(dataset->type_id)<0 || H5S_close(dataset->space)<0 || - H5I_dec_ref(dataset->dcpl_id) < 0); + /* + * Release datatype, dataspace and creation property list -- there isn't + * much we can do if one of these fails, so we just continue. + */ + free_failed=(H5I_dec_ref(dataset->shared->type_id)<0 || H5S_close(dataset->shared->space)<0 || + H5I_dec_ref(dataset->shared->dcpl_id) < 0); - /* Remove the dataset from the list of opened objects in the file */ - if(H5FO_delete(dataset->ent.file, H5AC_dxpl_id, dataset->ent.header)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") + /* Remove the dataset from the list of opened objects in the file */ + if(H5FO_delete(dataset->ent.file, H5AC_dxpl_id, dataset->ent.header)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") - /* Close the dataset object */ - /* (This closes the file, if this is the last object open) */ - if(H5O_close(&(dataset->ent))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header"); + /* Close the dataset object */ + /* (This closes the file, if this is the last object open) */ + if(H5O_close(&(dataset->ent))<0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header"); - /* - * Free memory. Before freeing the memory set the file pointer to NULL. - * We always check for a null file pointer in other H5D functions to be - * sure we're not accessing an already freed dataset (see the assert() - * above). - */ - dataset->ent.file = NULL; + /* + * Free memory. Before freeing the memory set the file pointer to NULL. + * We always check for a null file pointer in other H5D functions to be + * sure we're not accessing an already freed dataset (see the assert() + * above). + */ + dataset->ent.file = NULL; + + H5FL_FREE(H5D_shared_t,dataset->shared); + } /* end if */ + else + { + if(H5G_free_ent_name(&dataset->ent)<0) + free_failed=TRUE; + } /* end else */ H5FL_FREE(H5D_t,dataset); @@ -2923,24 +2960,24 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) * Filters need encoding if fill value is defined and a fill policy is set that requires * writing on an extend. */ - if(! dataset->checked_filters) + if(! dataset->shared->checked_filters) { - if(H5P_is_fill_value_defined(&(dataset->fill), &fill_status) < 0) + if(H5P_is_fill_value_defined(&(dataset->shared->fill), &fill_status) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset."); if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { - if( H5Pget_fill_time(dataset->dcpl_id, &fill_time) < 0) + if( H5Pget_fill_time(dataset->shared->dcpl_id, &fill_time) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill time from dataset."); if(fill_time == H5D_FILL_TIME_ALLOC || (fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED) ) { /* Filters must have encoding enabled. Ensure that all filters can be applied */ - if(H5Z_can_apply(dataset->dcpl_id, dataset->type_id) <0) + if(H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) <0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") - dataset->checked_filters = TRUE; + dataset->shared->checked_filters = TRUE; } } } @@ -2952,7 +2989,7 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) */ /* Increase the size of the data space */ - space=dataset->space; + space=dataset->shared->space; if ((changed=H5S_extend (space, size))<0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to increase size of data space") @@ -2962,12 +2999,12 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") /* Update the index values for the cached chunks for this dataset */ - if(H5D_CHUNKED == dataset->layout.type) + if(H5D_CHUNKED == dataset->shared->layout.type) if(H5D_istore_update_cache(dataset->ent.file, dxpl_id, dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") /* Allocate space for the new parts of the dataset, if appropriate */ - if(dataset->alloc_time==H5D_ALLOC_TIME_EARLY) + if(dataset->shared->alloc_time==H5D_ALLOC_TIME_EARLY) if (H5D_alloc_storage(dataset->ent.file, dxpl_id, dataset, H5D_ALLOC_EXTEND, TRUE, FALSE)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ @@ -3027,9 +3064,9 @@ H5D_typeof (const H5D_t *dset) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_typeof) assert (dset); - assert (dset->type); + assert (dset->shared->type); - FUNC_LEAVE_NOAPI(dset->type) + FUNC_LEAVE_NOAPI(dset->shared->type) } @@ -3099,9 +3136,9 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo * We assume that external storage is already * allocated by the caller, or at least will be before I/O is performed. */ - if(!(H5S_NULL == H5S_GET_EXTENT_TYPE(dset->space) || dset->efl.nused>0)) { + if(!(H5S_NULL == H5S_GET_EXTENT_TYPE(dset->shared->space) || dset->shared->efl.nused>0)) { /* Get a pointer to the dataset's layout information */ - layout=&(dset->layout); + layout=&(dset->shared->layout); switch (layout->type) { case H5D_CONTIGUOUS: @@ -3135,7 +3172,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo * the dataset, indicate that space should be allocated, so the * B-tree gets expanded. -QAK */ - if(dset->alloc_time==H5D_ALLOC_TIME_EARLY && time_alloc==H5D_ALLOC_EXTEND) + if(dset->shared->alloc_time==H5D_ALLOC_TIME_EARLY && time_alloc==H5D_ALLOC_EXTEND) init_space=1; break; @@ -3176,7 +3213,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo * fill values to the chunks they allocate space for. Yes, * this is icky. -QAK */ - if(!(dset->alloc_time==H5D_ALLOC_TIME_INCR && time_alloc==H5D_ALLOC_WRITE)) { + if(!(dset->shared->alloc_time==H5D_ALLOC_TIME_INCR && time_alloc==H5D_ALLOC_WRITE)) { if(H5D_init_storage(dset, full_overwrite, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ @@ -3185,13 +3222,13 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo H5D_fill_value_t fill_status; /* The fill value status */ /* Check the dataset's fill-value status */ - if (H5P_is_fill_value_defined(&(dset->fill), &fill_status) < 0) + if (H5P_is_fill_value_defined(&(dset->shared->fill), &fill_status) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are filling the dataset on allocation or "if set" and * the fill value _is_ set, do that now */ - if(dset->fill_time==H5D_FILL_TIME_ALLOC || - (dset->fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_USER_DEFINED)) { + if(dset->shared->fill_time==H5D_FILL_TIME_ALLOC || + (dset->shared->fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_USER_DEFINED)) { if(H5D_init_storage(dset, full_overwrite, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ @@ -3202,7 +3239,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo * set the address. (this is improves forward compatibility). */ if(time_alloc!=H5D_ALLOC_CREATE && addr_set) - if (H5O_modify (&(dset->ent), H5O_LAYOUT_ID, 0, H5O_FLAG_CONSTANT, update_time, &(dset->layout), dxpl_id) < 0) + if (H5O_modify (&(dset->ent), H5O_LAYOUT_ID, 0, H5O_FLAG_CONSTANT, update_time, &(dset->shared->layout), dxpl_id) < 0) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout message") } /* end if */ @@ -3241,25 +3278,25 @@ H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) assert(dset); - switch (dset->layout.type) { + switch (dset->shared->layout.type) { case H5D_COMPACT: { hssize_t snpoints; /* Number of points in space (for error checking) */ size_t npoints; /* Number of points in space */ /* Get the number of elements in the dataset's dataspace */ - snpoints = H5S_GET_EXTENT_NPOINTS(dset->space); + snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space); assert(snpoints>=0); H5_ASSIGN_OVERFLOW(npoints,snpoints,hssize_t,size_t); /* If we will be immediately overwriting the values, don't bother to clear them */ if(!full_overwrite) { /* If the fill value is defined, initialize the data buffer with it */ - if(dset->fill.buf) + if(dset->shared->fill.buf) /* Initialize the cached data buffer with the fill value */ - H5V_array_fill(dset->layout.u.compact.buf, dset->fill.buf, dset->fill.size, npoints); + H5V_array_fill(dset->shared->layout.u.compact.buf, dset->shared->fill.buf, dset->shared->fill.size, npoints); else /* If the fill value is default, zero set data buf. */ - HDmemset(dset->layout.u.compact.buf, 0, dset->layout.u.compact.size); + HDmemset(dset->shared->layout.u.compact.buf, 0, dset->shared->layout.u.compact.size); } /* end if */ } break; @@ -3267,7 +3304,7 @@ H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) case H5D_CONTIGUOUS: /* Don't write default fill values to external files */ /* If we will be immediately overwriting the values, don't bother to clear them */ - if((dset->efl.nused==0 || dset->fill.buf) && !full_overwrite) { + if((dset->shared->efl.nused==0 || dset->shared->fill.buf) && !full_overwrite) { if (H5D_contig_fill(dset->ent.file, dxpl_id, dset)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") } /* end if */ @@ -3359,9 +3396,9 @@ H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id) FUNC_ENTER_NOAPI(H5D_get_storage_size, 0) - switch(dset->layout.type) { + switch(dset->shared->layout.type) { case H5D_CHUNKED: - if(dset->layout.u.chunk.addr == HADDR_UNDEF) + if(dset->shared->layout.u.chunk.addr == HADDR_UNDEF) ret_value=0; else ret_value = H5D_istore_allocated(dset->ent.file, dxpl_id, dset); @@ -3369,14 +3406,14 @@ H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id) case H5D_CONTIGUOUS: /* Datasets which are not allocated yet are using no space on disk */ - if(dset->layout.u.contig.addr == HADDR_UNDEF) + if(dset->shared->layout.u.contig.addr == HADDR_UNDEF) ret_value=0; else - ret_value=dset->layout.u.contig.size; + ret_value=dset->shared->layout.u.contig.size; break; case H5D_COMPACT: - ret_value = dset->layout.u.compact.size; + ret_value = dset->shared->layout.u.compact.size; break; default: @@ -3453,7 +3490,7 @@ H5D_get_offset(const H5D_t *dset) assert(dset); - switch(dset->layout.type) { + switch(dset->shared->layout.type) { case H5D_CHUNKED: case H5D_COMPACT: break; @@ -3467,9 +3504,9 @@ H5D_get_offset(const H5D_t *dset) /* If there's user block in file, returns the absolute dataset offset * from the beginning of file. */ if(base_addr!=HADDR_UNDEF) - ret_value = dset->layout.u.contig.addr + base_addr; + ret_value = dset->shared->layout.u.contig.addr + base_addr; else - ret_value = dset->layout.u.contig.addr; + ret_value = dset->shared->layout.u.contig.addr; break; default: @@ -3917,7 +3954,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) * Get the data space *------------------------------------------------------------------------- */ - space = dset->space; + space = dset->shared->space; /*------------------------------------------------------------------------- * Check if we are shrinking or expanding any of the dimensions @@ -3951,12 +3988,12 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") /* Update the index values for the cached chunks for this dataset */ - if(H5D_CHUNKED == dset->layout.type) + if(H5D_CHUNKED == dset->shared->layout.type) if(H5D_istore_update_cache(dset->ent.file, dxpl_id, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") /* Allocate space for the new parts of the dataset, if appropriate */ - if(expand && dset->alloc_time==H5D_ALLOC_TIME_EARLY) + if(expand && dset->shared->alloc_time==H5D_ALLOC_TIME_EARLY) if(H5D_alloc_storage(dset->ent.file, dxpl_id, dset, H5D_ALLOC_EXTEND, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset storage") @@ -3966,7 +4003,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) * This removal takes place only in case we are shrinking the dateset *------------------------------------------------------------------------- */ - if(shrink && H5D_CHUNKED == dset->layout.type) { + if(shrink && H5D_CHUNKED == dset->shared->layout.type) { H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ @@ -4038,20 +4075,20 @@ H5D_flush(H5F_t *f, hid_t dxpl_id, unsigned flags) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset object") /* Flush the raw data buffer, if we have a dirty one */ - if (dataset->cache.contig.sieve_buf && dataset->cache.contig.sieve_dirty) { - assert(dataset->layout.type!=H5D_COMPACT); + if (dataset->shared->cache.contig.sieve_buf && dataset->shared->cache.contig.sieve_dirty) { + assert(dataset->shared->layout.type!=H5D_COMPACT); /* Write dirty data sieve buffer to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, dataset->cache.contig.sieve_loc, - dataset->cache.contig.sieve_size, dxpl_id, dataset->cache.contig.sieve_buf) < 0) + if (H5F_block_write(f, H5FD_MEM_DRAW, dataset->shared->cache.contig.sieve_loc, + dataset->shared->cache.contig.sieve_size, dxpl_id, dataset->shared->cache.contig.sieve_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed") /* Reset sieve buffer dirty flag */ - dataset->cache.contig.sieve_dirty=0; + dataset->shared->cache.contig.sieve_dirty=0; } /* end if */ /* Flush cached information for each kind of dataset */ - switch(dataset->layout.type) { + switch(dataset->shared->layout.type) { case H5D_CONTIGUOUS: break; @@ -4062,10 +4099,10 @@ H5D_flush(H5F_t *f, hid_t dxpl_id, unsigned flags) break; case H5D_COMPACT: - if(dataset->layout.u.compact.dirty) { - if(H5O_modify(&(dataset->ent), H5O_LAYOUT_ID, 0, 0, 1, &(dataset->layout), dxpl_id)<0) + if(dataset->shared->layout.u.compact.dirty) { + if(H5O_modify(&(dataset->ent), H5O_LAYOUT_ID, 0, 0, 1, &(dataset->shared->layout), dxpl_id)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message") - dataset->layout.u.compact.dirty = FALSE; + dataset->shared->layout.u.compact.dirty = FALSE; } /* end if */ break; @@ -4117,10 +4154,10 @@ H5Ddebug(hid_t dset_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Print B-tree information */ - if (H5D_CHUNKED==dset->layout.type) { - (void)H5D_istore_dump_btree(dset->ent.file, H5AC_dxpl_id, stdout, dset->layout.u.chunk.ndims, dset->layout.u.chunk.addr); - } else if (H5D_CONTIGUOUS==dset->layout.type) { - HDfprintf(stdout, " %-10s %a\n", "Address:", dset->layout.u.contig.addr); + if (H5D_CHUNKED==dset->shared->layout.type) { + (void)H5D_istore_dump_btree(dset->ent.file, H5AC_dxpl_id, stdout, dset->shared->layout.u.chunk.ndims, dset->shared->layout.u.chunk.addr); + } else if (H5D_CONTIGUOUS==dset->shared->layout.type) { + HDfprintf(stdout, " %-10s %a\n", "Address:", dset->shared->layout.u.contig.addr); } done: diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 0416f2b..318af13 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -69,7 +69,7 @@ H5D_compact_readvv(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const H5D_t *dset, assert(dset); /* Use the vectorized memory copy routine to do actual work */ - if((ret_value=H5V_memcpyvv(buf,mem_max_nseq,mem_curr_seq,mem_size_arr,mem_offset_arr,dset->layout.u.compact.buf,dset_max_nseq,dset_curr_seq,dset_size_arr,dset_offset_arr))<0) + if((ret_value=H5V_memcpyvv(buf,mem_max_nseq,mem_curr_seq,mem_size_arr,mem_offset_arr,dset->shared->layout.u.compact.buf,dset_max_nseq,dset_curr_seq,dset_size_arr,dset_offset_arr))<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed"); done: @@ -113,10 +113,10 @@ H5D_compact_writevv(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5D_t *dset, assert(dset); /* Use the vectorized memory copy routine to do actual work */ - if((ret_value=H5V_memcpyvv(dset->layout.u.compact.buf,dset_max_nseq,dset_curr_seq,dset_size_arr,dset_offset_arr,buf,mem_max_nseq,mem_curr_seq,mem_size_arr,mem_offset_arr))<0) + if((ret_value=H5V_memcpyvv(dset->shared->layout.u.compact.buf,dset_max_nseq,dset_curr_seq,dset_size_arr,dset_offset_arr,buf,mem_max_nseq,mem_curr_seq,mem_size_arr,mem_offset_arr))<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed"); - dset->layout.u.compact.dirty = TRUE; + dset->shared->layout.u.compact.dirty = TRUE; done: FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index a093b70..a69ab57 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -80,7 +80,7 @@ H5D_contig_create(H5F_t *f, hid_t dxpl_id, H5D_t *dset) assert(dset); /* Allocate space for the contiguous data */ - if (HADDR_UNDEF==(dset->layout.u.contig.addr=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, dset->layout.u.contig.size))) + if (HADDR_UNDEF==(dset->shared->layout.u.contig.addr=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, dset->shared->layout.u.contig.size))) HGOTO_ERROR (H5E_IO, H5E_NOSPACE, FAIL, "unable to reserve file space"); done: @@ -131,10 +131,10 @@ H5D_contig_fill(H5F_t *f, hid_t dxpl_id, H5D_t *dset) /* Check args */ assert(f); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); - assert(dset && H5D_CONTIGUOUS==dset->layout.type); - assert(H5F_addr_defined(dset->layout.u.contig.addr)); - assert(dset->layout.u.contig.size>0); - assert(dset->space); + assert(dset && H5D_CONTIGUOUS==dset->shared->layout.type); + assert(H5F_addr_defined(dset->shared->layout.u.contig.addr)); + assert(dset->shared->layout.u.contig.size>0); + assert(dset->shared->space); #ifdef H5_HAVE_PARALLEL /* Retrieve MPI parameters */ @@ -153,17 +153,17 @@ H5D_contig_fill(H5F_t *f, hid_t dxpl_id, H5D_t *dset) #endif /* H5_HAVE_PARALLEL */ /* Get size of elements */ - elmt_size=H5T_get_size(dset->type); + elmt_size=H5T_get_size(dset->shared->type); assert(elmt_size>0); /* Get the number of elements in the dataset's dataspace */ - snpoints = H5S_GET_EXTENT_NPOINTS(dset->space); + snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space); assert(snpoints>=0); H5_ASSIGN_OVERFLOW(npoints,snpoints,hssize_t,size_t); /* If fill value is not library default, use it to set the element size */ - if(dset->fill.buf) - elmt_size=dset->fill.size; + if(dset->shared->fill.buf) + elmt_size=dset->shared->fill.size; /* * Fill the entire current extent with the fill value. We can do @@ -174,12 +174,12 @@ H5D_contig_fill(H5F_t *f, hid_t dxpl_id, H5D_t *dset) bufsize = ptsperbuf*elmt_size; /* Fill the buffer with the user's fill value */ - if(dset->fill.buf) { + if(dset->shared->fill.buf) { /* Allocate temporary buffer */ if ((buf=H5FL_BLK_MALLOC(non_zero_fill,bufsize))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer"); - H5V_array_fill(buf, dset->fill.buf, elmt_size, ptsperbuf); + H5V_array_fill(buf, dset->shared->fill.buf, elmt_size, ptsperbuf); /* Indicate that a non-zero fill buffer was used */ non_zero_fill_f=1; @@ -318,9 +318,9 @@ H5D_contig_get_addr(const H5D_t *dset) /* check args */ assert(dset); - assert(dset->layout.type==H5D_CONTIGUOUS); + assert(dset->shared->layout.type==H5D_CONTIGUOUS); - FUNC_LEAVE_NOAPI(dset->layout.u.contig.addr); + FUNC_LEAVE_NOAPI(dset->shared->layout.u.contig.addr); } /* end H5D_contig_get_addr */ @@ -359,7 +359,7 @@ H5D_contig_write(H5F_t *f, hid_t dxpl_id, H5D_t *dset, assert (dset); assert (buf); - if (H5D_contig_writevv(f, dxpl_id, dset, dset->layout.u.contig.addr, dset->layout.u.contig.size, + if (H5D_contig_writevv(f, dxpl_id, dset, dset->shared->layout.u.contig.addr, dset->shared->layout.u.contig.size, 1, &dset_curr_seq, &dset_len, &dset_off, 1, &mem_curr_seq, &mem_len, &mem_off, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed"); @@ -423,9 +423,9 @@ H5D_contig_readvv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, v=*mem_curr_seq; /* Stash local copies of these value */ - if(dset->cache.contig.sieve_buf!=NULL) { - sieve_start=dset->cache.contig.sieve_loc; - sieve_size=dset->cache.contig.sieve_size; + if(dset->shared->cache.contig.sieve_buf!=NULL) { + sieve_start=dset->shared->cache.contig.sieve_loc; + sieve_size=dset->shared->cache.contig.sieve_size; sieve_end=sieve_start+sieve_size; } /* end if */ @@ -444,19 +444,19 @@ H5D_contig_readvv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, buf = (unsigned char *)_buf + mem_offset_arr[v]; /* Check if the sieve buffer is allocated yet */ - if(dset->cache.contig.sieve_buf==NULL) { + if(dset->shared->cache.contig.sieve_buf==NULL) { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(size>dset->cache.contig.sieve_buf_size) { + if(size>dset->shared->cache.contig.sieve_buf_size) { if (H5F_block_read(f, H5FD_MEM_DRAW, addr, size, dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed"); } /* end if */ else { /* Allocate room for the data sieve buffer */ - if (NULL==(dset->cache.contig.sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset->cache.contig.sieve_buf_size))) + if (NULL==(dset->shared->cache.contig.sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset->shared->cache.contig.sieve_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Determine the new sieve buffer size & location */ - dset->cache.contig.sieve_loc=addr; + dset->shared->cache.contig.sieve_loc=addr; /* Make certain we don't read off the end of the file */ if (HADDR_UNDEF==(abs_eoa=H5F_get_eoa(f))) @@ -469,21 +469,21 @@ H5D_contig_readvv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, max_data=dset_size-dset_offset_arr[u]; /* Compute the size of the sieve buffer */ - H5_ASSIGN_OVERFLOW(dset->cache.contig.sieve_size,MIN3(rel_eoa-dset->cache.contig.sieve_loc,max_data,dset->cache.contig.sieve_buf_size),hsize_t,size_t); + H5_ASSIGN_OVERFLOW(dset->shared->cache.contig.sieve_size,MIN3(rel_eoa-dset->shared->cache.contig.sieve_loc,max_data,dset->shared->cache.contig.sieve_buf_size),hsize_t,size_t); /* Read the new sieve buffer */ - if (H5F_block_read(f, H5FD_MEM_DRAW, dset->cache.contig.sieve_loc, dset->cache.contig.sieve_size, dxpl_id, dset->cache.contig.sieve_buf)<0) + if (H5F_block_read(f, H5FD_MEM_DRAW, dset->shared->cache.contig.sieve_loc, dset->shared->cache.contig.sieve_size, dxpl_id, dset->shared->cache.contig.sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed"); /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(buf,dset->cache.contig.sieve_buf,size); + HDmemcpy(buf,dset->shared->cache.contig.sieve_buf,size); /* Reset sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=0; + dset->shared->cache.contig.sieve_dirty=0; /* Stash local copies of these value */ - sieve_start=dset->cache.contig.sieve_loc; - sieve_size=dset->cache.contig.sieve_size; + sieve_start=dset->shared->cache.contig.sieve_loc; + sieve_size=dset->shared->cache.contig.sieve_size; sieve_end=sieve_start+sieve_size; } /* end else */ } /* end if */ @@ -493,7 +493,7 @@ H5D_contig_readvv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, /* If entire read is within the sieve buffer, read it from the buffer */ if(addr>=sieve_start && contig_endcache.contig.sieve_buf+(addr-sieve_start); + unsigned char *base_sieve_buf=dset->shared->cache.contig.sieve_buf+(addr-sieve_start); /* Grab the data out of the buffer */ HDmemcpy(buf,base_sieve_buf,size); @@ -501,18 +501,18 @@ H5D_contig_readvv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, /* Entire request is not within this data sieve buffer */ else { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(size>dset->cache.contig.sieve_buf_size) { + if(size>dset->shared->cache.contig.sieve_buf_size) { /* Check for any overlap with the current sieve buffer */ if((sieve_start>=addr && sieve_start<(contig_end+1)) || ((sieve_end-1)>=addr && (sieve_end-1)<(contig_end+1))) { /* Flush the sieve buffer, if it's dirty */ - if(dset->cache.contig.sieve_dirty) { + if(dset->shared->cache.contig.sieve_dirty) { /* Write to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, dset->cache.contig.sieve_buf)<0) + if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, dset->shared->cache.contig.sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed"); /* Reset sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=0; + dset->shared->cache.contig.sieve_dirty=0; } /* end if */ } /* end if */ @@ -523,17 +523,17 @@ H5D_contig_readvv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, /* Element size fits within the buffer size */ else { /* Flush the sieve buffer if it's dirty */ - if(dset->cache.contig.sieve_dirty) { + if(dset->shared->cache.contig.sieve_dirty) { /* Write to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, dset->cache.contig.sieve_buf)<0) + if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, dset->shared->cache.contig.sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed"); /* Reset sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=0; + dset->shared->cache.contig.sieve_dirty=0; } /* end if */ /* Determine the new sieve buffer size & location */ - dset->cache.contig.sieve_loc=addr; + dset->shared->cache.contig.sieve_loc=addr; /* Make certain we don't read off the end of the file */ if (HADDR_UNDEF==(abs_eoa=H5F_get_eoa(f))) @@ -547,22 +547,22 @@ H5D_contig_readvv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, /* Compute the size of the sieve buffer */ /* Don't read off the end of the file, don't read past the end of the data element and don't read more than the buffer size */ - H5_ASSIGN_OVERFLOW(dset->cache.contig.sieve_size,MIN3(rel_eoa-dset->cache.contig.sieve_loc,max_data,dset->cache.contig.sieve_buf_size),hsize_t,size_t); + H5_ASSIGN_OVERFLOW(dset->shared->cache.contig.sieve_size,MIN3(rel_eoa-dset->shared->cache.contig.sieve_loc,max_data,dset->shared->cache.contig.sieve_buf_size),hsize_t,size_t); /* Update local copies of sieve information */ - sieve_start=dset->cache.contig.sieve_loc; - sieve_size=dset->cache.contig.sieve_size; + sieve_start=dset->shared->cache.contig.sieve_loc; + sieve_size=dset->shared->cache.contig.sieve_size; sieve_end=sieve_start+sieve_size; /* Read the new sieve buffer */ - if (H5F_block_read(f, H5FD_MEM_DRAW, dset->cache.contig.sieve_loc, dset->cache.contig.sieve_size, dxpl_id, dset->cache.contig.sieve_buf)<0) + if (H5F_block_read(f, H5FD_MEM_DRAW, dset->shared->cache.contig.sieve_loc, dset->shared->cache.contig.sieve_size, dxpl_id, dset->shared->cache.contig.sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed"); /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(buf,dset->cache.contig.sieve_buf,size); + HDmemcpy(buf,dset->shared->cache.contig.sieve_buf,size); /* Reset sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=0; + dset->shared->cache.contig.sieve_dirty=0; } /* end else */ } /* end else */ } /* end else */ @@ -683,9 +683,9 @@ H5D_contig_writevv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, v=*mem_curr_seq; /* Stash local copies of these values */ - if(dset->cache.contig.sieve_buf!=NULL) { - sieve_start=dset->cache.contig.sieve_loc; - sieve_size=dset->cache.contig.sieve_size; + if(dset->shared->cache.contig.sieve_buf!=NULL) { + sieve_start=dset->shared->cache.contig.sieve_loc; + sieve_size=dset->shared->cache.contig.sieve_size; sieve_end=sieve_start+sieve_size; } /* end if */ @@ -704,19 +704,19 @@ H5D_contig_writevv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, buf = (const unsigned char *)_buf + mem_offset_arr[v]; /* No data sieve buffer yet, go allocate one */ - if(dset->cache.contig.sieve_buf==NULL) { + if(dset->shared->cache.contig.sieve_buf==NULL) { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(size>dset->cache.contig.sieve_buf_size) { + if(size>dset->shared->cache.contig.sieve_buf_size) { if (H5F_block_write(f, H5FD_MEM_DRAW, addr, size, dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed"); } /* end if */ else { /* Allocate room for the data sieve buffer */ - if (NULL==(dset->cache.contig.sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset->cache.contig.sieve_buf_size))) + if (NULL==(dset->shared->cache.contig.sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset->shared->cache.contig.sieve_buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Determine the new sieve buffer size & location */ - dset->cache.contig.sieve_loc=addr; + dset->shared->cache.contig.sieve_loc=addr; /* Make certain we don't read off the end of the file */ if (HADDR_UNDEF==(abs_eoa=H5F_get_eoa(f))) @@ -729,24 +729,24 @@ H5D_contig_writevv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, max_data=dset_size-dset_offset_arr[u]; /* Compute the size of the sieve buffer */ - H5_ASSIGN_OVERFLOW(dset->cache.contig.sieve_size,MIN3(rel_eoa-dset->cache.contig.sieve_loc,max_data,dset->cache.contig.sieve_buf_size),hsize_t,size_t); + H5_ASSIGN_OVERFLOW(dset->shared->cache.contig.sieve_size,MIN3(rel_eoa-dset->shared->cache.contig.sieve_loc,max_data,dset->shared->cache.contig.sieve_buf_size),hsize_t,size_t); /* Check if there is any point in reading the data from the file */ - if(dset->cache.contig.sieve_size>size) { + if(dset->shared->cache.contig.sieve_size>size) { /* Read the new sieve buffer */ - if (H5F_block_read(f, H5FD_MEM_DRAW, dset->cache.contig.sieve_loc, dset->cache.contig.sieve_size, dxpl_id, dset->cache.contig.sieve_buf)<0) + if (H5F_block_read(f, H5FD_MEM_DRAW, dset->shared->cache.contig.sieve_loc, dset->shared->cache.contig.sieve_size, dxpl_id, dset->shared->cache.contig.sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed"); } /* end if */ /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(dset->cache.contig.sieve_buf,buf,size); + HDmemcpy(dset->shared->cache.contig.sieve_buf,buf,size); /* Set sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=1; + dset->shared->cache.contig.sieve_dirty=1; /* Stash local copies of these values */ - sieve_start=dset->cache.contig.sieve_loc; - sieve_size=dset->cache.contig.sieve_size; + sieve_start=dset->shared->cache.contig.sieve_loc; + sieve_size=dset->shared->cache.contig.sieve_size; sieve_end=sieve_start+sieve_size; } /* end else */ } /* end if */ @@ -756,35 +756,35 @@ H5D_contig_writevv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, /* If entire write is within the sieve buffer, write it to the buffer */ if(addr>=sieve_start && contig_endcache.contig.sieve_buf+(addr-sieve_start); + unsigned char *base_sieve_buf=dset->shared->cache.contig.sieve_buf+(addr-sieve_start); /* Put the data into the sieve buffer */ HDmemcpy(base_sieve_buf,buf,size); /* Set sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=1; + dset->shared->cache.contig.sieve_dirty=1; } /* end if */ /* Entire request is not within this data sieve buffer */ else { /* Check if we can actually hold the I/O request in the sieve buffer */ - if(size>dset->cache.contig.sieve_buf_size) { + if(size>dset->shared->cache.contig.sieve_buf_size) { /* Check for any overlap with the current sieve buffer */ if((sieve_start>=addr && sieve_start<(contig_end+1)) || ((sieve_end-1)>=addr && (sieve_end-1)<(contig_end+1))) { /* Flush the sieve buffer, if it's dirty */ - if(dset->cache.contig.sieve_dirty) { + if(dset->shared->cache.contig.sieve_dirty) { /* Write to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, dset->cache.contig.sieve_buf)<0) + if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, dset->shared->cache.contig.sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed"); /* Reset sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=0; + dset->shared->cache.contig.sieve_dirty=0; } /* end if */ /* Force the sieve buffer to be re-read the next time */ - dset->cache.contig.sieve_loc=HADDR_UNDEF; - dset->cache.contig.sieve_size=0; + dset->shared->cache.contig.sieve_loc=HADDR_UNDEF; + dset->shared->cache.contig.sieve_size=0; } /* end if */ /* Write directly from the user's buffer */ @@ -795,49 +795,49 @@ H5D_contig_writevv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, else { /* Check if it is possible to (exactly) prepend or append to existing (dirty) sieve buffer */ if(((addr+size)==sieve_start || addr==sieve_end) && - (size+sieve_size)<=dset->cache.contig.sieve_buf_size && - dset->cache.contig.sieve_dirty) { + (size+sieve_size)<=dset->shared->cache.contig.sieve_buf_size && + dset->shared->cache.contig.sieve_dirty) { /* Prepend to existing sieve buffer */ if((addr+size)==sieve_start) { /* Move existing sieve information to correct location */ - HDmemmove(dset->cache.contig.sieve_buf+size,dset->cache.contig.sieve_buf,sieve_size); + HDmemmove(dset->shared->cache.contig.sieve_buf+size,dset->shared->cache.contig.sieve_buf,sieve_size); /* Copy in new information (must be first in sieve buffer) */ - HDmemcpy(dset->cache.contig.sieve_buf,buf,size); + HDmemcpy(dset->shared->cache.contig.sieve_buf,buf,size); /* Adjust sieve location */ - dset->cache.contig.sieve_loc=addr; + dset->shared->cache.contig.sieve_loc=addr; } /* end if */ /* Append to existing sieve buffer */ else { /* Copy in new information */ - HDmemcpy(dset->cache.contig.sieve_buf+sieve_size,buf,size); + HDmemcpy(dset->shared->cache.contig.sieve_buf+sieve_size,buf,size); } /* end else */ /* Adjust sieve size */ - dset->cache.contig.sieve_size += size; + dset->shared->cache.contig.sieve_size += size; /* Update local copies of sieve information */ - sieve_start=dset->cache.contig.sieve_loc; - sieve_size=dset->cache.contig.sieve_size; + sieve_start=dset->shared->cache.contig.sieve_loc; + sieve_size=dset->shared->cache.contig.sieve_size; sieve_end=sieve_start+sieve_size; } /* end if */ /* Can't add the new data onto the existing sieve buffer */ else { /* Flush the sieve buffer if it's dirty */ - if(dset->cache.contig.sieve_dirty) { + if(dset->shared->cache.contig.sieve_dirty) { /* Write to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, dset->cache.contig.sieve_buf)<0) + if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, dset->shared->cache.contig.sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed"); /* Reset sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=0; + dset->shared->cache.contig.sieve_dirty=0; } /* end if */ /* Determine the new sieve buffer size & location */ - dset->cache.contig.sieve_loc=addr; + dset->shared->cache.contig.sieve_loc=addr; /* Make certain we don't read off the end of the file */ if (HADDR_UNDEF==(abs_eoa=H5F_get_eoa(f))) @@ -851,25 +851,25 @@ H5D_contig_writevv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, /* Compute the size of the sieve buffer */ /* Don't read off the end of the file, don't read past the end of the data element and don't read more than the buffer size */ - H5_ASSIGN_OVERFLOW(dset->cache.contig.sieve_size,MIN3(rel_eoa-dset->cache.contig.sieve_loc,max_data,dset->cache.contig.sieve_buf_size),hsize_t,size_t); + H5_ASSIGN_OVERFLOW(dset->shared->cache.contig.sieve_size,MIN3(rel_eoa-dset->shared->cache.contig.sieve_loc,max_data,dset->shared->cache.contig.sieve_buf_size),hsize_t,size_t); /* Update local copies of sieve information */ - sieve_start=dset->cache.contig.sieve_loc; - sieve_size=dset->cache.contig.sieve_size; + sieve_start=dset->shared->cache.contig.sieve_loc; + sieve_size=dset->shared->cache.contig.sieve_size; sieve_end=sieve_start+sieve_size; /* Check if there is any point in reading the data from the file */ - if(dset->cache.contig.sieve_size>size) { + if(dset->shared->cache.contig.sieve_size>size) { /* Read the new sieve buffer */ - if (H5F_block_read(f, H5FD_MEM_DRAW, dset->cache.contig.sieve_loc, dset->cache.contig.sieve_size, dxpl_id, dset->cache.contig.sieve_buf)<0) + if (H5F_block_read(f, H5FD_MEM_DRAW, dset->shared->cache.contig.sieve_loc, dset->shared->cache.contig.sieve_size, dxpl_id, dset->shared->cache.contig.sieve_buf)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed"); } /* end if */ /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(dset->cache.contig.sieve_buf,buf,size); + HDmemcpy(dset->shared->cache.contig.sieve_buf,buf,size); /* Set sieve buffer dirty flag */ - dset->cache.contig.sieve_dirty=1; + dset->shared->cache.contig.sieve_dirty=1; } /* end else */ } /* end else */ diff --git a/src/H5Dio.c b/src/H5Dio.c index 6c76b09..ece6a1b 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -661,7 +661,7 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (!file_space) - file_space = dataset->space; + file_space = dataset->shared->space; if (!mem_space) mem_space = file_space; if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space))<0) @@ -702,26 +702,26 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * fill time is NEVER, there is no way to tell whether part of data * has been overwritten. So just proceed in reading. */ - if(nelmts > 0 && dataset->efl.nused==0 && - ((dataset->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->layout.u.contig.addr)) - || (dataset->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->layout.u.chunk.addr)))) { + if(nelmts > 0 && dataset->shared->efl.nused==0 && + ((dataset->shared->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr)) + || (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr)))) { H5D_fill_value_t fill_status; /* Whether/How the fill value is defined */ /* Retrieve dataset's fill-value properties */ - if(H5P_is_fill_value_defined(&dataset->dcpl_cache.fill, &fill_status)<0) + if(H5P_is_fill_value_defined(&dataset->shared->dcpl_cache.fill, &fill_status)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Should be impossible, but check anyway... */ if(fill_status == H5D_FILL_VALUE_UNDEFINED && - (dataset->dcpl_cache.fill_time == H5D_FILL_TIME_ALLOC || dataset->dcpl_cache.fill_time == H5D_FILL_TIME_IFSET)) + (dataset->shared->dcpl_cache.fill_time == H5D_FILL_TIME_ALLOC || dataset->shared->dcpl_cache.fill_time == H5D_FILL_TIME_IFSET)) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "read failed: dataset doesn't exist, no data can be read") /* If we're never going to fill this dataset, just leave the junk in the user's buffer */ - if(dataset->dcpl_cache.fill_time == H5D_FILL_TIME_NEVER) + if(dataset->shared->dcpl_cache.fill_time == H5D_FILL_TIME_NEVER) HGOTO_DONE(SUCCEED) /* Go fill the user's selection with the dataset's fill value */ - if(H5D_fill(dataset->dcpl_cache.fill.buf,dataset->type,buf,mem_type,mem_space,dxpl_id)<0) + if(H5D_fill(dataset->shared->dcpl_cache.fill.buf,dataset->shared->type,buf,mem_type,mem_space,dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "filling buf failed") else HGOTO_DONE(SUCCEED) @@ -735,11 +735,11 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * enough value in xfer_parms since turning off data type conversion also * turns off background preservation. */ - if (NULL==(tpath=H5T_path_find(dataset->type, mem_type, NULL, NULL, dxpl_id))) + if (NULL==(tpath=H5T_path_find(dataset->shared->type, mem_type, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") /* Set the storage flags for the space conversion check */ - switch(dataset->layout.type) { + switch(dataset->shared->layout.type) { case H5D_COMPACT: sconv_flags |= H5S_CONV_STORAGE_COMPACT; break; @@ -757,7 +757,7 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, } /* end switch */ /* Get dataspace functions */ - if (NULL==(sconv=H5S_find(dataset->ent.file, mem_space, file_space, sconv_flags, &use_par_opt_io, &dataset->layout))) + if (NULL==(sconv=H5S_find(dataset->ent.file, mem_space, file_space, sconv_flags, &use_par_opt_io, &dataset->shared->layout))) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from file to memory data space") #ifdef H5_HAVE_PARALLEL @@ -767,7 +767,7 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, a more general collective chunk IO algorithm is applied. */ - if(dataset->layout.type == H5D_CHUNKED) { /*only check for chunking storage */ + if(dataset->shared->layout.type == H5D_CHUNKED) { /*only check for chunking storage */ check_prop = H5Pexist(dxpl_id,H5D_XFER_COLL_CHUNK_NAME); if(check_prop < 0) HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "unable to check property list"); @@ -790,14 +790,14 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, #endif /*H5_HAVE_PARALLEL*/ /* Determine correct I/O routine to invoke */ - if(dataset->layout.type!=H5D_CHUNKED) { + if(dataset->shared->layout.type!=H5D_CHUNKED) { if(H5D_contig_read(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv, - dxpl_cache, dxpl_id, dataset->type_id, mem_type_id, buf)<0) + dxpl_cache, dxpl_id, dataset->shared->type_id, mem_type_id, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") } /* end if */ else { if(H5D_chunk_read(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv, - dxpl_cache, dxpl_id, dataset->type_id, mem_type_id, buf)<0) + dxpl_cache, dxpl_id, dataset->shared->type_id, mem_type_id, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") } /* end else */ @@ -888,12 +888,12 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") /* All filters in the DCPL must have encoding enabled. */ - if(! dataset->checked_filters) + if(! dataset->shared->checked_filters) { - if(H5Z_can_apply(dataset->dcpl_id, dataset->type_id) <0) + if(H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) <0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters") - dataset->checked_filters = TRUE; + dataset->shared->checked_filters = TRUE; } /* If MPI based VFD is used, no VL datatype support yet. */ @@ -921,7 +921,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") if (!file_space) - file_space = dataset->space; + file_space = dataset->shared->space; if (!mem_space) mem_space = file_space; if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space))<0) @@ -953,9 +953,9 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* */ /* Allocate data space and initialize it if it hasn't been. */ - if(nelmts > 0 && dataset->efl.nused==0 && - ((dataset->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->layout.u.contig.addr)) - || (dataset->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->layout.u.chunk.addr)))) { + if(nelmts > 0 && dataset->shared->efl.nused==0 && + ((dataset->shared->layout.type==H5D_CONTIGUOUS && !H5F_addr_defined(dataset->shared->layout.u.contig.addr)) + || (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr)))) { hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ hbool_t full_overwrite; /* Whether we are over-writing all the elements */ @@ -964,7 +964,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, FAIL, "can't retrieve number of elements in file dataset") /* Always allow fill values to be written if the dataset has a VL datatype */ - if(H5T_detect_class(dataset->type, H5T_VLEN)) + if(H5T_detect_class(dataset->shared->type, H5T_VLEN)) full_overwrite=FALSE; else full_overwrite=(hsize_t)file_nelmts==nelmts ? TRUE : FALSE; @@ -982,11 +982,11 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * enough value in xfer_parms since turning off data type conversion also * turns off background preservation. */ - if (NULL==(tpath=H5T_path_find(mem_type, dataset->type, NULL, NULL, dxpl_id))) + if (NULL==(tpath=H5T_path_find(mem_type, dataset->shared->type, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") /* Set the storage flags for the space conversion check */ - switch(dataset->layout.type) { + switch(dataset->shared->layout.type) { case H5D_COMPACT: sconv_flags |= H5S_CONV_STORAGE_COMPACT; break; @@ -1004,7 +1004,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, } /* end switch */ /* Get dataspace functions */ - if (NULL==(sconv=H5S_find(dataset->ent.file, mem_space, file_space, sconv_flags, &use_par_opt_io, &dataset->layout))) + if (NULL==(sconv=H5S_find(dataset->ent.file, mem_space, file_space, sconv_flags, &use_par_opt_io, &dataset->shared->layout))) HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from memory to file data space") #ifdef H5_HAVE_PARALLEL @@ -1014,7 +1014,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, a more general collective chunk IO algorithm is applied. */ - if(dataset->layout.type == H5D_CHUNKED) { /*only check for chunking storage */ + if(dataset->shared->layout.type == H5D_CHUNKED) { /*only check for chunking storage */ check_prop = H5Pexist(dxpl_id,H5D_XFER_COLL_CHUNK_NAME); if(check_prop < 0) @@ -1037,14 +1037,14 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, #endif /*H5_HAVE_PARALLEL*/ /* Determine correct I/O routine to invoke */ - if(dataset->layout.type!=H5D_CHUNKED) { + if(dataset->shared->layout.type!=H5D_CHUNKED) { if(H5D_contig_write(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv, - dxpl_cache, dxpl_id, mem_type_id, dataset->type_id, buf)<0) + dxpl_cache, dxpl_id, mem_type_id, dataset->shared->type_id, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") } /* end if */ else { if(H5D_chunk_write(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv, - dxpl_cache, dxpl_id, mem_type_id, dataset->type_id, buf)<0) + dxpl_cache, dxpl_id, mem_type_id, dataset->shared->type_id, buf)<0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") } /* end else */ @@ -1132,19 +1132,19 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, H5_timer_begin(&timer); #endif /* Sanity check dataset, then read it */ - assert(((dataset->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->layout.u.contig.addr)) - || (dataset->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->layout.u.chunk.addr))) - || dataset->efl.nused>0 || 0 == nelmts - || dataset->layout.type==H5D_COMPACT); + assert(((dataset->shared->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->shared->layout.u.contig.addr)) + || (dataset->shared->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) + || dataset->shared->efl.nused>0 || 0 == nelmts + || dataset->shared->layout.type==H5D_COMPACT); H5_CHECK_OVERFLOW(nelmts,hsize_t,size_t); status = (sconv->read)(dataset->ent.file, dxpl_cache, dxpl_id, - dataset, (H5D_storage_t *)&(dataset->efl), - (size_t)nelmts, H5T_get_size(dataset->type), + dataset, (H5D_storage_t *)&(dataset->shared->efl), + (size_t)nelmts, H5T_get_size(dataset->shared->type), file_space, mem_space, buf/*out*/); #ifdef H5S_DEBUG H5_timer_end(&(sconv->stats[1].read_timer), &timer); - sconv->stats[1].read_nbytes += nelmts * H5T_get_size(dataset->type); + sconv->stats[1].read_nbytes += nelmts * H5T_get_size(dataset->shared->type); sconv->stats[1].read_ncalls++; #endif @@ -1163,7 +1163,7 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, HGOTO_DONE(SUCCEED) /* Compute element sizes and other parameters */ - src_type_size = H5T_get_size(dataset->type); + src_type_size = H5T_get_size(dataset->shared->type); dst_type_size = H5T_get_size(mem_type); max_type_size = MAX(src_type_size, dst_type_size); target_size = dxpl_cache->max_temp_buf; @@ -1240,12 +1240,12 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, H5_timer_begin(&timer); #endif /* Sanity check that space is allocated, then read data from it */ - assert(((dataset->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->layout.u.contig.addr)) - || (dataset->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->layout.u.chunk.addr))) - || dataset->efl.nused>0 || 0 == nelmts - || dataset->layout.type==H5D_COMPACT); + assert(((dataset->shared->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->shared->layout.u.contig.addr)) + || (dataset->shared->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) + || dataset->shared->efl.nused>0 || 0 == nelmts + || dataset->shared->layout.type==H5D_COMPACT); n = H5S_select_fgath(dataset->ent.file, dxpl_cache, dxpl_id, - dataset, (H5D_storage_t *)&(dataset->efl), + dataset, (H5D_storage_t *)&(dataset->shared->efl), file_space, &file_iter, smine_nelmts, tconv_buf/*out*/); @@ -1384,8 +1384,8 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, #endif H5_CHECK_OVERFLOW(nelmts,hsize_t,size_t); status = (sconv->write)(dataset->ent.file, dxpl_cache, dxpl_id, - dataset, (H5D_storage_t *)&(dataset->efl), - (size_t)nelmts, H5T_get_size(dataset->type), + dataset, (H5D_storage_t *)&(dataset->shared->efl), + (size_t)nelmts, H5T_get_size(dataset->shared->type), file_space, mem_space, buf); #ifdef H5S_DEBUG @@ -1410,7 +1410,7 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, /* Compute element sizes and other parameters */ src_type_size = H5T_get_size(mem_type); - dst_type_size = H5T_get_size(dataset->type); + dst_type_size = H5T_get_size(dataset->shared->type); max_type_size = MAX(src_type_size, dst_type_size); target_size = dxpl_cache->max_temp_buf; /* XXX: This could cause a problem if the user sets their buffer size @@ -1449,7 +1449,7 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, * malloc() is usually less resource-intensive if we allocate/free the * same size over and over. */ - if(H5T_detect_class(dataset->type, H5T_VLEN)) { + if(H5T_detect_class(dataset->shared->type, H5T_VLEN)) { /* Old data is retrieved into background buffer for VL datatype. The * data is used later for freeing heap objects. */ need_bkg = H5T_BKG_YES; @@ -1504,7 +1504,7 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, H5_timer_begin(&timer); #endif n = H5S_select_fgath(dataset->ent.file, dxpl_cache, dxpl_id, - dataset, (H5D_storage_t *)&(dataset->efl), + dataset, (H5D_storage_t *)&(dataset->shared->efl), file_space, &bkg_iter, smine_nelmts, bkg_buf/*out*/); @@ -1523,9 +1523,9 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, if (H5T_convert(tpath, src_id, dst_id, smine_nelmts, 0, 0, tconv_buf, bkg_buf, dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") - /* Do the data transform after the type conversion (since we're using dataset->type). */ + /* Do the data transform after the type conversion (since we're using dataset->shared->type). */ if(!H5Z_xform_noop(dxpl_cache->data_xform_prop)) - if( H5Z_xform_eval(dxpl_cache->data_xform_prop, tconv_buf, smine_nelmts, dataset->type) < 0) + if( H5Z_xform_eval(dxpl_cache->data_xform_prop, tconv_buf, smine_nelmts, dataset->shared->type) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform") /* @@ -1535,7 +1535,7 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, H5_timer_begin(&timer); #endif status = H5S_select_fscat(dataset->ent.file, dxpl_cache, dxpl_id, - dataset, (H5D_storage_t *)&(dataset->efl), + dataset, (H5D_storage_t *)&(dataset->shared->efl), file_space, &file_iter, smine_nelmts, tconv_buf); #ifdef H5S_DEBUG @@ -1636,10 +1636,10 @@ H5D_chunk_read(hsize_t nelmts, H5D_t *dataset, H5_timer_begin(&timer); #endif /* Sanity check dataset, then read it */ - assert(((dataset->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->layout.u.contig.addr)) - || (dataset->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->layout.u.chunk.addr))) - || dataset->efl.nused>0 || 0 == nelmts - || dataset->layout.type==H5D_COMPACT); + assert(((dataset->shared->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->shared->layout.u.contig.addr)) + || (dataset->shared->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) + || dataset->shared->efl.nused>0 || 0 == nelmts + || dataset->shared->layout.type==H5D_COMPACT); /* Get first node in chunk tree */ chunk_node=H5TB_first(fm.fsel->root); @@ -1658,7 +1658,7 @@ H5D_chunk_read(hsize_t nelmts, H5D_t *dataset, /* Perform the actual read operation */ status = (sconv->read)(dataset->ent.file, dxpl_cache, dxpl_id, dataset, &store, - chunk_info->chunk_points, H5T_get_size(dataset->type), + chunk_info->chunk_points, H5T_get_size(dataset->shared->type), chunk_info->fspace, chunk_info->mspace, buf); @@ -1672,7 +1672,7 @@ H5D_chunk_read(hsize_t nelmts, H5D_t *dataset, #ifdef H5S_DEBUG H5_timer_end(&(sconv->stats[1].read_timer), &timer); - sconv->stats[1].read_nbytes += nelmts * H5T_get_size(dataset->type); + sconv->stats[1].read_nbytes += nelmts * H5T_get_size(dataset->shared->type); sconv->stats[1].read_ncalls++; #endif @@ -1687,7 +1687,7 @@ H5D_chunk_read(hsize_t nelmts, H5D_t *dataset, HGOTO_DONE(SUCCEED) /* Compute element sizes and other parameters */ - src_type_size = H5T_get_size(dataset->type); + src_type_size = H5T_get_size(dataset->shared->type); dst_type_size = H5T_get_size(mem_type); max_type_size = MAX(src_type_size, dst_type_size); target_size = dxpl_cache->max_temp_buf; @@ -1779,9 +1779,9 @@ H5D_chunk_read(hsize_t nelmts, H5D_t *dataset, H5_timer_begin(&timer); #endif /* Sanity check that space is allocated, then read data from it */ - assert(((dataset->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->layout.u.contig.addr)) - || (dataset->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->layout.u.chunk.addr))) - || dataset->efl.nused>0 || dataset->layout.type==H5D_COMPACT); + assert(((dataset->shared->layout.type==H5D_CONTIGUOUS && H5F_addr_defined(dataset->shared->layout.u.contig.addr)) + || (dataset->shared->layout.type==H5D_CHUNKED && H5F_addr_defined(dataset->shared->layout.u.chunk.addr))) + || dataset->shared->efl.nused>0 || dataset->shared->layout.type==H5D_COMPACT); n = H5S_select_fgath(dataset->ent.file, dxpl_cache, dxpl_id, dataset, &store, chunk_info->fspace, &file_iter, smine_nelmts, @@ -1996,7 +1996,7 @@ H5D_chunk_write(hsize_t nelmts, H5D_t *dataset, /* Perform the actual write operation */ status = (sconv->write)(dataset->ent.file, dxpl_cache, dxpl_id, dataset, &store, - chunk_info->chunk_points, H5T_get_size(dataset->type), + chunk_info->chunk_points, H5T_get_size(dataset->shared->type), chunk_info->fspace, chunk_info->mspace, buf); @@ -2042,7 +2042,7 @@ H5D_chunk_write(hsize_t nelmts, H5D_t *dataset, /* Compute element sizes and other parameters */ src_type_size = H5T_get_size(mem_type); - dst_type_size = H5T_get_size(dataset->type); + dst_type_size = H5T_get_size(dataset->shared->type); max_type_size = MAX(src_type_size, dst_type_size); target_size = dxpl_cache->max_temp_buf; /* XXX: This could cause a problem if the user sets their buffer size @@ -2070,7 +2070,7 @@ H5D_chunk_write(hsize_t nelmts, H5D_t *dataset, * malloc() is usually less resource-intensive if we allocate/free the * same size over and over. */ - if(H5T_detect_class(dataset->type, H5T_VLEN)) { + if(H5T_detect_class(dataset->shared->type, H5T_VLEN)) { /* Old data is retrieved into background buffer for VL datatype. The * data is used later for freeing heap objects. */ need_bkg = H5T_BKG_YES; @@ -2172,9 +2172,9 @@ H5D_chunk_write(hsize_t nelmts, H5D_t *dataset, tconv_buf, bkg_buf, dxpl_id)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") - /* Do the data transform after the type conversion (since we're using dataset->type) */ + /* Do the data transform after the type conversion (since we're using dataset->shared->type) */ if(!H5Z_xform_noop(dxpl_cache->data_xform_prop)) - if( H5Z_xform_eval(dxpl_cache->data_xform_prop, tconv_buf, smine_nelmts, dataset->type) < 0) + if( H5Z_xform_eval(dxpl_cache->data_xform_prop, tconv_buf, smine_nelmts, dataset->shared->type) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform") /* @@ -2388,7 +2388,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp #endif /* QAK */ /* Get layout for dataset */ - fm->layout = &(dataset->layout); + fm->layout = &(dataset->shared->layout); /* Check if the memory space is scalar & make equivalent memory space */ if((sm_ndims = H5S_GET_EXTENT_NDIMS(mem_space))<0) @@ -2397,16 +2397,16 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp hsize_t dims[H5O_LAYOUT_NDIMS]; /* Temporary dimension information */ /* Set up "equivalent" n-dimensional dataspace with size '1' in each dimension */ - for(u=0; ulayout.u.chunk.ndims-1; u++) + for(u=0; ushared->layout.u.chunk.ndims-1; u++) dims[u]=1; - if((equiv_mspace = H5S_create_simple(dataset->layout.u.chunk.ndims-1,dims,NULL))==NULL) + if((equiv_mspace = H5S_create_simple(dataset->shared->layout.u.chunk.ndims-1,dims,NULL))==NULL) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create equivalent dataspace for scalar space") /* Indicate that this space needs to be released */ equiv_mspace_init=1; /* Set the number of dimensions for the memory dataspace */ - fm->m_ndims=dataset->layout.u.chunk.ndims-1; + fm->m_ndims=dataset->shared->layout.u.chunk.ndims-1; } /* end else */ else { equiv_mspace=(H5S_t *)mem_space; /* Casting away 'const' OK... */ @@ -2416,7 +2416,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp } /* end else */ /* Get dim number and dimensionality for each dataspace */ - fm->f_ndims=f_ndims=dataset->layout.u.chunk.ndims-1; + fm->f_ndims=f_ndims=dataset->shared->layout.u.chunk.ndims-1; if(H5S_get_simple_extent_dims(file_space, fm->f_dims, NULL)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality") @@ -2427,7 +2427,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp fm->chunk_dim[u]=fm->layout->u.chunk.dim[u]; /* Round up to the next integer # of chunks, to accomodate partial chunks */ - fm->chunks[u] = ((fm->f_dims[u]+dataset->layout.u.chunk.dim[u])-1) / dataset->layout.u.chunk.dim[u]; + fm->chunks[u] = ((fm->f_dims[u]+dataset->shared->layout.u.chunk.dim[u])-1) / dataset->shared->layout.u.chunk.dim[u]; } /* end for */ /* Compute the "down" size of 'chunks' information */ @@ -2456,7 +2456,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp /* Check if file selection is a point selection */ if(fsel_type==H5S_SEL_POINTS) { /* Create temporary datatypes for selection iteration */ - if((f_tid = H5I_register(H5I_DATATYPE, H5T_copy(dataset->type, H5T_COPY_ALL)))<0) + if((f_tid = H5I_register(H5I_DATATYPE, H5T_copy(dataset->shared->type, H5T_COPY_ALL)))<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register file datatype") /* Spaces aren't the same shape, iterate over the memory selection directly */ @@ -2536,7 +2536,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp /* Create temporary datatypes for selection iteration */ if(f_tid<0) { - if((f_tid = H5I_register(H5I_DATATYPE, H5T_copy(dataset->type, H5T_COPY_ALL)))<0) + if((f_tid = H5I_register(H5I_DATATYPE, H5T_copy(dataset->shared->type, H5T_COPY_ALL)))<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register file datatype") } /* end if */ diff --git a/src/H5Distore.c b/src/H5Distore.c index a1bc302..b98b620 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -928,7 +928,10 @@ H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, hadd herr_t H5D_istore_init (H5F_t *f, H5D_t *dset) { - H5D_rdcc_t *rdcc = &(dset->cache.chunk); + H5D_istore_ud1_t udata; + H5B_shared_t *shared; /* Shared B-tree node info */ + size_t u; /* Local index variable */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_init, FAIL); @@ -942,7 +945,7 @@ H5D_istore_init (H5F_t *f, H5D_t *dset) } /* end if */ /* Allocate the shared structure */ - if(H5D_istore_shared_create(f, &dset->layout)<0) + if(H5D_istore_shared_create(f, &dset->shared->layout)<0) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") done: FUNC_LEAVE_NOAPI(ret_value); @@ -986,16 +989,16 @@ H5D_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, if (ent->dirty) { H5D_istore_ud1_t udata; /*pass through B-tree */ - udata.mesg = &dset->layout; + udata.mesg = &dset->shared->layout; udata.key.filter_mask = 0; udata.addr = HADDR_UNDEF; udata.key.nbytes = ent->chunk_size; - for (u=0; ulayout.u.chunk.ndims; u++) + for (u=0; ushared->layout.u.chunk.ndims; u++) udata.key.offset[u] = ent->offset[u]; alloc = ent->alloc_size; /* Should the chunk be filtered before writing it to disk? */ - if (dset->dcpl_cache.pline.nused) { + if (dset->shared->dcpl_cache.pline.nused) { if (!reset) { /* * Copy the chunk to a new buffer before running it through @@ -1017,7 +1020,7 @@ H5D_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, point_of_no_return = TRUE; ent->chunk = NULL; } - if (H5Z_pipeline(&(dset->dcpl_cache.pline), 0, &(udata.key.filter_mask), dxpl_cache->err_detect, + if (H5Z_pipeline(&(dset->shared->dcpl_cache.pline), 0, &(udata.key.filter_mask), dxpl_cache->err_detect, dxpl_cache->filter_cb, &(udata.key.nbytes), &alloc, &buf)<0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") } @@ -1026,14 +1029,14 @@ H5D_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, * Create the chunk it if it doesn't exist, or reallocate the chunk if * its size changed. Then write the data into the file. */ - if (H5B_insert(f, dxpl_id, H5B_ISTORE, dset->layout.u.chunk.addr, &udata)<0) + if (H5B_insert(f, dxpl_id, H5B_ISTORE, dset->shared->layout.u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk"); if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, dxpl_id, buf)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file"); /* Mark cache entry as clean */ ent->dirty = FALSE; - dset->cache.chunk.nflushes++; + dset->shared->cache.chunk.nflushes++; } /* end if */ /* Reset, but do not free or removed from list */ @@ -1042,7 +1045,7 @@ H5D_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, if(buf==ent->chunk) buf = NULL; if(ent->chunk!=NULL) - ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(dset->dcpl_cache.pline)); + ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(dset->shared->dcpl_cache.pline)); } /* end if */ done: @@ -1058,7 +1061,7 @@ done: */ if (ret_value<0 && point_of_no_return) { if(ent->chunk) - ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(dset->dcpl_cache.pline)); + ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(dset->shared->dcpl_cache.pline)); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); @@ -1087,7 +1090,7 @@ static herr_t H5D_istore_preempt(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, H5D_t *dset, H5D_rdcc_ent_t * ent, hbool_t flush) { - H5D_rdcc_t *rdcc = &(dset->cache.chunk); + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_istore_preempt); @@ -1105,7 +1108,7 @@ H5D_istore_preempt(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, else { /* Don't flush, just free chunk */ if(ent->chunk != NULL) - ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(dset->dcpl_cache.pline)); + ent->chunk = H5D_istore_chunk_xfree(ent->chunk,&(dset->shared->dcpl_cache.pline)); } /* Unlink from list */ @@ -1155,7 +1158,7 @@ H5D_istore_flush (H5F_t *f, hid_t dxpl_id, H5D_t *dset, unsigned flags) { H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ - H5D_rdcc_t *rdcc = &(dset->cache.chunk); + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); int nerrors=0; H5D_rdcc_ent_t *ent=NULL, *next=NULL; herr_t ret_value=SUCCEED; /* Return value */ @@ -1211,7 +1214,7 @@ H5D_istore_dest (H5F_t *f, hid_t dxpl_id, H5D_t *dset) { H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ - H5D_rdcc_t *rdcc = &(dset->cache.chunk); + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); int nerrors=0; H5D_rdcc_ent_t *ent=NULL, *next=NULL; herr_t ret_value=SUCCEED; /* Return value */ @@ -1239,7 +1242,7 @@ H5D_istore_dest (H5F_t *f, hid_t dxpl_id, H5D_t *dset) HDmemset (rdcc, 0, sizeof(H5D_rdcc_t)); /* Free the raw B-tree node buffer */ - if(H5RC_DEC(dset->layout.u.chunk.btree_shared)<0) + if(H5RC_DEC(dset->shared->layout.u.chunk.btree_shared)<0) HGOTO_ERROR (H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page"); done: @@ -1363,7 +1366,7 @@ H5D_istore_prune (H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, H size_t size) { int i, j, nerrors=0; - H5D_rdcc_t *rdcc = &(dset->cache.chunk); + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); size_t total = rdcc->nbytes; const int nmeth=2; /*number of methods */ int w[1]; /*weighting as an interval */ @@ -1500,11 +1503,11 @@ H5D_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, { unsigned idx=0; /*hash index number */ hbool_t found = FALSE; /*already in cache? */ - const H5O_pline_t *pline=&(dset->dcpl_cache.pline); /* I/O pipeline info */ - const H5O_layout_t *layout=&(dset->layout); /* Dataset layout */ - const H5O_fill_t *fill=&(dset->dcpl_cache.fill); /* Fill value info */ - H5D_fill_time_t fill_time=dset->dcpl_cache.fill_time; /* Fill time */ - H5D_rdcc_t *rdcc = &(dset->cache.chunk);/*raw data chunk cache*/ + const H5O_pline_t *pline=&(dset->shared->dcpl_cache.pline); /* I/O pipeline info */ + const H5O_layout_t *layout=&(dset->shared->layout); /* Dataset layout */ + const H5O_fill_t *fill=&(dset->shared->dcpl_cache.fill); /* Fill value info */ + H5D_fill_time_t fill_time=dset->shared->dcpl_cache.fill_time; /* Fill time */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk);/*raw data chunk cache*/ H5D_rdcc_ent_t *ent = NULL; /*cache entry */ unsigned u; /*counters */ size_t chunk_size=0; /*size of a chunk */ @@ -1525,11 +1528,11 @@ H5D_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, /* Search for the chunk in the cache */ if (rdcc->nslots>0) { - idx=H5D_HASH(dset,store->chunk.index); + idx=H5D_HASH(dset->shared,store->chunk.index); ent = rdcc->slot[idx]; if (ent) { - for (u=0, found=TRUE; ulayout.u.chunk.ndims; u++) { + for (u=0, found=TRUE; ushared->layout.u.chunk.ndims; u++) { if (store->chunk.offset[u]!=ent->offset[u]) { found = FALSE; break; @@ -1768,7 +1771,7 @@ H5D_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, H5D_t *dset, const H5D_storage_t *store, hbool_t dirty, unsigned idx_hint, uint8_t *chunk, size_t naccessed) { - H5D_rdcc_t *rdcc = &(dset->cache.chunk); + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); H5D_rdcc_ent_t *ent = NULL; int found = -1; unsigned u; @@ -1796,17 +1799,17 @@ H5D_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, HDmemset (&x, 0, sizeof x); x.dirty = TRUE; - for (u=0; ulayout.u.chunk.ndims; u++) + for (u=0; ushared->layout.u.chunk.ndims; u++) x.offset[u] = store->chunk.offset[u]; - assert(dset->layout.u.chunk.size>0); - H5_ASSIGN_OVERFLOW(x.chunk_size,dset->layout.u.chunk.size,hsize_t,size_t); + assert(dset->shared->layout.u.chunk.size>0); + H5_ASSIGN_OVERFLOW(x.chunk_size,dset->shared->layout.u.chunk.size,hsize_t,size_t); x.alloc_size = x.chunk_size; x.chunk = chunk; H5D_istore_flush_entry (f, dxpl_cache, dxpl_id, dset, &x, TRUE); } else { if(chunk) - H5D_istore_chunk_xfree (chunk,&(dset->dcpl_cache.pline)); + H5D_istore_chunk_xfree (chunk,&(dset->shared->dcpl_cache.pline)); } } else { /* @@ -1859,8 +1862,8 @@ H5D_istore_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxp /* Check args */ assert(f); assert(dxpl_cache); - assert(dset && H5D_CHUNKED==dset->layout.type); - assert(dset->layout.u.chunk.ndims>0 && dset->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); + assert(dset && H5D_CHUNKED==dset->shared->layout.type); + assert(dset->shared->layout.u.chunk.ndims>0 && dset->shared->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); assert(store); assert(chunk_len_arr); assert(chunk_offset_arr); @@ -1869,19 +1872,19 @@ H5D_istore_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxp assert(buf); #ifndef NDEBUG - for (u=0; ulayout.u.chunk.ndims; u++) + for (u=0; ushared->layout.u.chunk.ndims; u++) assert(store->chunk.offset[u]>=0); /*negative coordinates not supported (yet) */ #endif /* Get the address of this chunk on disk */ #ifdef QAK HDfprintf(stderr,"%s: store->chunk.offset={",FUNC); -for(u=0; ulayout.u.chunk.ndims; u++) - HDfprintf(stderr,"%Hd%s",store->chunk.offset[u],(u<(dset->layout.u.chunk.ndims-1) ? ", " : "}\n")); +for(u=0; ushared->layout.u.chunk.ndims; u++) + HDfprintf(stderr,"%Hd%s",store->chunk.offset[u],(u<(dset->shared->layout.u.chunk.ndims-1) ? ", " : "}\n")); #endif /* QAK */ - chunk_addr=H5D_istore_get_addr(f, dxpl_id, &(dset->layout), store->chunk.offset, &udata); + chunk_addr=H5D_istore_get_addr(f, dxpl_id, &(dset->shared->layout), store->chunk.offset, &udata); #ifdef QAK -HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Zu\n",FUNC,chunk_addr,dset->layout.u.chunk.size); +HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Zu\n",FUNC,chunk_addr,dset->shared->layout.u.chunk.size); HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: chunk_offset_arr[%Zu]=%Hu\n",FUNC,*chunk_curr_seq,chunk_offset_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: mem_len_arr[%Zu]=%Zu\n",FUNC,*mem_curr_seq,mem_len_arr[*mem_curr_seq]); @@ -1899,14 +1902,14 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * writing to other elements in the same chunk. Do a direct * read-through of only the elements requested. */ - if ((dset->layout.u.chunk.size>dset->cache.chunk.nbytes && dset->dcpl_cache.pline.nused==0 && chunk_addr!=HADDR_UNDEF) + if ((dset->shared->layout.u.chunk.size>dset->shared->cache.chunk.nbytes && dset->shared->dcpl_cache.pline.nused==0 && chunk_addr!=HADDR_UNDEF) || (IS_H5FD_MPI(f) && (H5F_ACC_RDWR & H5F_get_intent(f)))) { #ifdef H5_HAVE_PARALLEL /* Additional sanity check when operating in parallel */ - if (chunk_addr==HADDR_UNDEF || dset->dcpl_cache.pline.nused>0) + if (chunk_addr==HADDR_UNDEF || dset->shared->dcpl_cache.pline.nused>0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk"); #endif /* H5_HAVE_PARALLEL */ - if ((ret_value=H5D_contig_readvv(f, dxpl_id, dset, chunk_addr, (hsize_t)dset->layout.u.chunk.size, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) + if ((ret_value=H5D_contig_readvv(f, dxpl_id, dset, chunk_addr, (hsize_t)dset->shared->layout.u.chunk.size, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "unable to read raw data to file"); } /* end if */ else { @@ -1923,20 +1926,20 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * the entire I/O operation on the chunk will be skipped. -QAK */ if(!H5F_addr_defined(chunk_addr)) { - const H5O_fill_t *fill=&(dset->dcpl_cache.fill); /* Fill value info */ - H5D_fill_time_t fill_time=dset->dcpl_cache.fill_time; /* Fill time */ + const H5O_fill_t *fill=&(dset->shared->dcpl_cache.fill); /* Fill value info */ + H5D_fill_time_t fill_time=dset->shared->dcpl_cache.fill_time; /* Fill time */ H5D_fill_value_t fill_status; - H5D_rdcc_t *rdcc = &(dset->cache.chunk);/*raw data chunk cache*/ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk);/*raw data chunk cache*/ hbool_t found = FALSE; /*already in cache? */ /* Check if the chunk is in the cache (but hasn't been written to disk yet) */ if (rdcc->nslots>0) { - unsigned idx=H5D_HASH(dset,store->chunk.index); /* Cache entry index */ + unsigned idx=H5D_HASH(dset->shared,store->chunk.index); /* Cache entry index */ H5D_rdcc_ent_t *ent = rdcc->slot[idx]; /* Cache entry */ /* Potential match... */ if (ent) { - for (u=0, found=TRUE; ulayout.u.chunk.ndims; u++) { + for (u=0, found=TRUE; ushared->layout.u.chunk.ndims; u++) { if (store->chunk.offset[u]!=ent->offset[u]) { found = FALSE; break; @@ -2052,8 +2055,8 @@ H5D_istore_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, /* Check args */ assert(f); assert(dxpl_cache); - assert(dset && H5D_CHUNKED==dset->layout.type); - assert(dset->layout.u.chunk.ndims>0 && dset->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); + assert(dset && H5D_CHUNKED==dset->shared->layout.type); + assert(dset->shared->layout.u.chunk.ndims>0 && dset->shared->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); assert(store); assert(chunk_len_arr); assert(chunk_offset_arr); @@ -2062,19 +2065,19 @@ H5D_istore_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, assert(buf); #ifndef NDEBUG - for (u=0; ulayout.u.chunk.ndims; u++) + for (u=0; ushared->layout.u.chunk.ndims; u++) assert(store->chunk.offset[u]>=0); /*negative coordinates not supported (yet) */ #endif /* Get the address of this chunk on disk */ #ifdef QAK HDfprintf(stderr,"%s: store->chunk.offset={",FUNC); -for(u=0; ulayout.u.chunk.ndims; u++) - HDfprintf(stderr,"%Hd%s",store->chunk.offset[u],(u<(dset->layout.u.chunk.ndims-1) ? ", " : "}\n")); +for(u=0; ushared->layout.u.chunk.ndims; u++) + HDfprintf(stderr,"%Hd%s",store->chunk.offset[u],(u<(dset->shared->layout.u.chunk.ndims-1) ? ", " : "}\n")); #endif /* QAK */ - chunk_addr=H5D_istore_get_addr(f, dxpl_id, &(dset->layout), store->chunk.offset, &udata); + chunk_addr=H5D_istore_get_addr(f, dxpl_id, &(dset->shared->layout), store->chunk.offset, &udata); #ifdef QAK -HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Zu\n",FUNC,chunk_addr,dset->layout.u.chunk.size); +HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Zu\n",FUNC,chunk_addr,dset->shared->layout.u.chunk.size); HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: chunk_offset_arr[%Zu]=%Hu\n",FUNC,*chunk_curr_seq,chunk_offset_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: mem_len_arr[%Zu]=%Zu\n",FUNC,*mem_curr_seq,mem_len_arr[*mem_curr_seq]); @@ -2092,14 +2095,14 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * writing to other elements in the same chunk. Do a direct * write-through of only the elements requested. */ - if ((dset->layout.u.chunk.size>dset->cache.chunk.nbytes && dset->dcpl_cache.pline.nused==0 && chunk_addr!=HADDR_UNDEF) + if ((dset->shared->layout.u.chunk.size>dset->shared->cache.chunk.nbytes && dset->shared->dcpl_cache.pline.nused==0 && chunk_addr!=HADDR_UNDEF) || (IS_H5FD_MPI(f) && (H5F_ACC_RDWR & H5F_get_intent(f)))) { #ifdef H5_HAVE_PARALLEL /* Additional sanity check when operating in parallel */ - if (chunk_addr==HADDR_UNDEF || dset->dcpl_cache.pline.nused>0) + if (chunk_addr==HADDR_UNDEF || dset->shared->dcpl_cache.pline.nused>0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk"); #endif /* H5_HAVE_PARALLEL */ - if ((ret_value=H5D_contig_writevv(f, dxpl_id, dset, chunk_addr, (hsize_t)dset->layout.u.chunk.size, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) + if ((ret_value=H5D_contig_writevv(f, dxpl_id, dset, chunk_addr, (hsize_t)dset->shared->layout.u.chunk.size, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file"); } /* end if */ else { @@ -2119,7 +2122,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * be to lock the chunk in the dataset I/O routine (setting the relax flag * appropriately) and then unlock it after all the I/O the chunk was finished. -QAK */ - if(chunk_max_nseq==1 && chunk_len_arr[0] == dset->layout.u.chunk.size) + if(chunk_max_nseq==1 && chunk_len_arr[0] == dset->shared->layout.u.chunk.size) relax = TRUE; else relax = FALSE; @@ -2128,13 +2131,13 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a total_bytes=0; for(u=*chunk_curr_seq; ulayout.u.chunk.size) + if(total_bytes!=dset->shared->layout.u.chunk.size) relax=FALSE; if(relax) { total_bytes=0; for(u=*mem_curr_seq; ulayout.u.chunk.size) + if(total_bytes!=dset->shared->layout.u.chunk.size) relax=FALSE; } /* end if */ #endif /* OLD_WAY */ @@ -2234,7 +2237,7 @@ done: hsize_t H5D_istore_allocated(H5F_t *f, hid_t dxpl_id, H5D_t *dset) { - H5D_rdcc_t *rdcc = &(dset->cache.chunk); /*raw data chunk cache */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent; /*cache entry */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache=&_dxpl_cache; /* Data transfer property cache */ @@ -2255,8 +2258,8 @@ H5D_istore_allocated(H5F_t *f, hid_t dxpl_id, H5D_t *dset) } /* end for */ HDmemset(&udata, 0, sizeof udata); - udata.mesg = &dset->layout; - if (H5B_iterate(f, dxpl_id, H5B_ISTORE, H5D_istore_iter_allocated, dset->layout.u.chunk.addr, &udata)<0) + udata.mesg = &dset->shared->layout; + if (H5B_iterate(f, dxpl_id, H5B_ISTORE, H5D_istore_iter_allocated, dset->shared->layout.u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree"); /* Set return value */ @@ -2482,18 +2485,18 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, /* Check args */ assert(f); assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); - assert(dset && H5D_CHUNKED==dset->layout.type); - assert(dset->layout.u.chunk.ndims>0 && dset->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); - assert(H5F_addr_defined(dset->layout.u.chunk.addr)); + assert(dset && H5D_CHUNKED==dset->shared->layout.type); + assert(dset->shared->layout.u.chunk.ndims>0 && dset->shared->layout.u.chunk.ndims<=H5O_LAYOUT_NDIMS); + assert(H5F_addr_defined(dset->shared->layout.u.chunk.addr)); /* Get dataset's creation property list */ - if (NULL == (dc_plist = H5I_object(dset->dcpl_id))) + if (NULL == (dc_plist = H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* We only handle simple data spaces so far */ - if ((space_ndims=H5S_get_simple_extent_dims(dset->space, space_dim, NULL))<0) + if ((space_ndims=H5S_get_simple_extent_dims(dset->shared->space, space_dim, NULL))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get simple data space info") - space_dim[space_ndims] = dset->layout.u.chunk.dim[space_ndims]; + space_dim[space_ndims] = dset->shared->layout.u.chunk.dim[space_ndims]; /* Get necessary properties from dataset creation property list */ if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) @@ -2531,9 +2534,9 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, * Setup indice to go through all chunks. (Future improvement * should allocate only chunks that have no file space assigned yet. */ - for (u=0; ulayout.u.chunk.ndims; u++) + for (u=0; ushared->layout.u.chunk.ndims; u++) chunk_offset[u] = 0; - chunk_size = dset->layout.u.chunk.size; + chunk_size = dset->shared->layout.u.chunk.size; /* Check the dataset's fill-value status */ if (H5P_is_fill_value_defined(&fill, &fill_status) < 0) @@ -2589,8 +2592,8 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, while (carry==0) { /* Check if the chunk exists yet on disk */ chunk_exists=1; - if(H5D_istore_get_addr(f,dxpl_id,&(dset->layout),chunk_offset, NULL)==HADDR_UNDEF) { - const H5D_rdcc_t *rdcc = &(dset->cache.chunk); /*raw data chunk cache */ + if(H5D_istore_get_addr(f,dxpl_id,&(dset->shared->layout),chunk_offset, NULL)==HADDR_UNDEF) { + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent = NULL; /*cache entry */ /* Didn't find the chunk on disk */ @@ -2600,7 +2603,7 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, for(ent = rdcc->head; ent && !chunk_exists; ent = ent->next) { /* Assume a match */ chunk_exists = 1; - for(u = 0; u < dset->layout.u.chunk.ndims && chunk_exists; u++) { + for(u = 0; u < dset->shared->layout.u.chunk.ndims && chunk_exists; u++) { if(ent->offset[u] != chunk_offset[u]) chunk_exists = 0; /* Reset if no match */ } /* end for */ @@ -2609,16 +2612,16 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, if(!chunk_exists) { /* Initialize the chunk information */ - udata.mesg = &dset->layout; + udata.mesg = &dset->shared->layout; udata.key.filter_mask = filter_mask; udata.addr = HADDR_UNDEF; H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t); udata.key.nbytes = (size_t)chunk_size; - for (u=0; ulayout.u.chunk.ndims; u++) + for (u=0; ushared->layout.u.chunk.ndims; u++) udata.key.offset[u] = chunk_offset[u]; /* Allocate the chunk with all processes */ - if (H5B_insert(f, dxpl_id, H5B_ISTORE, dset->layout.u.chunk.addr, &udata)<0) + if (H5B_insert(f, dxpl_id, H5B_ISTORE, dset->shared->layout.u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk"); /* Check if fill values should be written to blocks */ @@ -2647,8 +2650,8 @@ H5D_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, } /* end if */ /* Increment indices */ - for (i=dset->layout.u.chunk.ndims-1, carry=1; i>=0 && carry; --i) { - chunk_offset[i] += dset->layout.u.chunk.dim[i]; + for (i=dset->shared->layout.u.chunk.ndims-1, carry=1; i>=0 && carry; --i) { + chunk_offset[i] += dset->shared->layout.u.chunk.dim[i]; if (chunk_offset[i] >= (hssize_t)(space_dim[i])) chunk_offset[i] = 0; else @@ -2782,7 +2785,7 @@ herr_t H5D_istore_prune_by_extent(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, H5D_t *dset) { - H5D_rdcc_t *rdcc = &(dset->cache.chunk); /*raw data chunk cache */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent = NULL, *next = NULL; /*cache entry */ unsigned u; /*counters */ int found; /*remove this entry */ @@ -2795,12 +2798,12 @@ H5D_istore_prune_by_extent(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, /* Check args */ assert(f); assert(dxpl_cache); - assert(dset && H5D_CHUNKED == dset->layout.type); - assert(dset->layout.u.chunk.ndims > 0 && dset->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); - assert(H5F_addr_defined(dset->layout.u.chunk.addr)); + assert(dset && H5D_CHUNKED == dset->shared->layout.type); + assert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + assert(H5F_addr_defined(dset->shared->layout.u.chunk.addr)); /* Go get the rank & dimensions */ - if(H5S_get_simple_extent_dims(dset->space, curr_dims, NULL) < 0) + if(H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions"); /*------------------------------------------------------------------------- @@ -2812,7 +2815,7 @@ H5D_istore_prune_by_extent(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, for(ent = rdcc->head; ent; ent = next) { next = ent->next; - for(u = 0; u < dset->layout.u.chunk.ndims - 1; u++) { + for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) { if((hsize_t)ent->offset[u] > curr_dims[u]) { found = 1; break; @@ -2822,7 +2825,7 @@ H5D_istore_prune_by_extent(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, if(found) { #ifdef H5D_ISTORE_DEBUG HDfputs("cache:remove:[", stderr); - for(u = 0; u < dset->layout.u.chunk.ndims - 1; u++) + for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) HDfprintf(stderr, "%s%Hd", u ? ", " : "", ent->offset[u]); HDfputs("]\n", stderr); #endif @@ -2842,10 +2845,10 @@ H5D_istore_prune_by_extent(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, HDmemset(&udata, 0, sizeof udata); udata.stream = stdout; - udata.mesg = &dset->layout; + udata.mesg = &dset->shared->layout; udata.dims = curr_dims; - if(H5B_iterate(f, dxpl_id, H5B_ISTORE, H5D_istore_prune_extent, dset->layout.u.chunk.addr, &udata) < 0) + if(H5B_iterate(f, dxpl_id, H5B_ISTORE, H5D_istore_prune_extent, dset->shared->layout.u.chunk.addr, &udata) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree"); done: @@ -3012,12 +3015,12 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca /* Check args */ assert(f); assert(dxpl_cache); - assert(dset && H5D_CHUNKED == dset->layout.type); - assert(dset->layout.u.chunk.ndims > 0 && dset->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); - assert(H5F_addr_defined(dset->layout.u.chunk.addr)); + assert(dset && H5D_CHUNKED == dset->shared->layout.type); + assert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + assert(H5F_addr_defined(dset->shared->layout.u.chunk.addr)); /* Get dataset's creation property list */ - if (NULL == (dc_plist = H5I_object(dset->dcpl_id))) + if (NULL == (dc_plist = H5I_object(dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get necessary properties from property list */ @@ -3033,7 +3036,7 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca HDmemset(count, 0, sizeof(count)); /* Go get the rank & dimensions */ - if((srank = H5S_get_simple_extent_dims(dset->space, curr_dims, NULL)) < 0) + if((srank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions"); H5_ASSIGN_OVERFLOW(rank,srank,int,unsigned); @@ -3042,9 +3045,9 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca size[u] = curr_dims[u]; /* Round up to the next integer # of chunks, to accomodate partial chunks */ - chunks[u] = ((curr_dims[u]+dset->layout.u.chunk.dim[u])-1) / dset->layout.u.chunk.dim[u]; + chunks[u] = ((curr_dims[u]+dset->shared->layout.u.chunk.dim[u])-1) / dset->shared->layout.u.chunk.dim[u]; } /* end for */ - size[u] = dset->layout.u.chunk.dim[u]; + size[u] = dset->shared->layout.u.chunk.dim[u]; /* Get the "down" sizes for each dimension */ if(H5V_array_down(rank,chunks,down_chunks)<0) @@ -3052,7 +3055,7 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca /* Create a data space for a chunk & set the extent */ for(u = 0; u < rank; u++) - chunk_dims[u] = dset->layout.u.chunk.dim[u]; + chunk_dims[u] = dset->shared->layout.u.chunk.dim[u]; if(NULL == (space_chunk = H5S_create_simple(rank,chunk_dims,NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace"); @@ -3061,18 +3064,18 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca * loop through the chunks copying each chunk from the application to the * chunk cache. */ - for(u = 0; u < dset->layout.u.chunk.ndims; u++) { - idx_max[u] = (size[u] - 1) / dset->layout.u.chunk.dim[u] + 1; + for(u = 0; u < dset->shared->layout.u.chunk.ndims; u++) { + idx_max[u] = (size[u] - 1) / dset->shared->layout.u.chunk.dim[u] + 1; idx_cur[u] = 0; } /* end for */ /* Loop over all chunks */ carry=0; while(carry==0) { - for(u = 0, naccessed = 1; u < dset->layout.u.chunk.ndims; u++) { + for(u = 0, naccessed = 1; u < dset->shared->layout.u.chunk.ndims; u++) { /* The location and size of the chunk being accessed */ - chunk_offset[u] = idx_cur[u] * (hssize_t)(dset->layout.u.chunk.dim[u]); - sub_size[u] = MIN((idx_cur[u] + 1) * dset->layout.u.chunk.dim[u], + chunk_offset[u] = idx_cur[u] * (hssize_t)(dset->shared->layout.u.chunk.dim[u]); + sub_size[u] = MIN((idx_cur[u] + 1) * dset->shared->layout.u.chunk.dim[u], size[u]) - chunk_offset[u]; naccessed *= sub_size[u]; } /* end for */ @@ -3081,8 +3084,8 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca * Figure out what chunks have to be initialized. These are the chunks where the dataspace * extent boundary is within the chunk */ - for(u = 0, found = 0; u < dset->layout.u.chunk.ndims - 1; u++) { - end_chunk = chunk_offset[u] + dset->layout.u.chunk.dim[u]; + for(u = 0, found = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) { + end_chunk = chunk_offset[u] + dset->shared->layout.u.chunk.dim[u]; if(end_chunk > size[u]) { found = 1; break; @@ -3092,7 +3095,7 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca if(found) { /* Calculate the index of this chunk */ - if(H5V_chunk_index(rank,chunk_offset,dset->layout.u.chunk.dim,down_chunks,&store.chunk.index)<0) + if(H5V_chunk_index(rank,chunk_offset,dset->shared->layout.u.chunk.dim,down_chunks,&store.chunk.index)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") store.chunk.offset=chunk_offset; @@ -3104,15 +3107,15 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space"); for(u = 0; u < rank; u++) - count[u] = MIN((idx_cur[u] + 1) * dset->layout.u.chunk.dim[u], size[u] - chunk_offset[u]); + count[u] = MIN((idx_cur[u] + 1) * dset->shared->layout.u.chunk.dim[u], size[u] - chunk_offset[u]); #ifdef H5D_ISTORE_DEBUG HDfputs("cache:initialize:offset:[", stdout); - for(u = 0; u < dset->layout.u.chunk.ndims - 1; u++) + for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) HDfprintf(stdout, "%s%Hd", u ? ", " : "", chunk_offset[u]); HDfputs("]", stdout); HDfputs(":count:[", stdout); - for(u = 0; u < dset->layout.u.chunk.ndims - 1; u++) + for(u = 0; u < dset->shared->layout.u.chunk.ndims - 1; u++) HDfprintf(stdout, "%s%Hd", u ? ", " : "", count[u]); HDfputs("]\n", stdout); #endif @@ -3135,7 +3138,7 @@ H5D_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca } /*found */ /* Increment indices */ - for(i = dset->layout.u.chunk.ndims - 1, carry = 1; i >= 0 && carry; --i) { + for(i = dset->shared->layout.u.chunk.ndims - 1, carry = 1; i >= 0 && carry; --i) { if(++idx_cur[i] >= idx_max[i]) idx_cur[i] = 0; else @@ -3219,7 +3222,7 @@ done: herr_t H5D_istore_update_cache(H5F_t *f, hid_t dxpl_id, H5D_t *dset) { - H5D_rdcc_t *rdcc = &(dset->cache.chunk); /*raw data chunk cache */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent, *next; /*cache entry */ H5D_rdcc_ent_t *old_ent; /* Old cache entry */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ @@ -3238,17 +3241,17 @@ H5D_istore_update_cache(H5F_t *f, hid_t dxpl_id, H5D_t *dset) /* Check args */ assert(f); - assert(dset && H5D_CHUNKED == dset->layout.type); - assert(dset->layout.u.chunk.ndims > 0 && dset->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + assert(dset && H5D_CHUNKED == dset->shared->layout.type); + assert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); /* Go get the rank & dimensions */ - if((srank = H5S_get_simple_extent_dims(dset->space, curr_dims, NULL)) < 0) + if((srank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions"); H5_ASSIGN_OVERFLOW(rank,srank,int,unsigned); /* Round up to the next integer # of chunks, to accomodate partial chunks */ for(u = 0; u < rank; u++) - chunks[u] = ((curr_dims[u]+dset->layout.u.chunk.dim[u])-1) / dset->layout.u.chunk.dim[u]; + chunks[u] = ((curr_dims[u]+dset->shared->layout.u.chunk.dim[u])-1) / dset->shared->layout.u.chunk.dim[u]; /* Get the "down" sizes for each dimension */ if(H5V_array_down(rank,chunks,down_chunks)<0) @@ -3263,12 +3266,12 @@ H5D_istore_update_cache(H5F_t *f, hid_t dxpl_id, H5D_t *dset) next=ent->next; /* Calculate the index of this chunk */ - if(H5V_chunk_index(rank,ent->offset,dset->layout.u.chunk.dim,down_chunks,&idx)<0) + if(H5V_chunk_index(rank,ent->offset,dset->shared->layout.u.chunk.dim,down_chunks,&idx)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") /* Compute the index for the chunk entry */ old_idx=ent->idx; /* Save for later */ - ent->idx=H5D_HASH(dset,idx); + ent->idx=H5D_HASH(dset->shared,idx); if(old_idx!=ent->idx) { /* Check if there is already a chunk at this chunk's new location */ @@ -3359,7 +3362,7 @@ done: herr_t H5D_istore_stats (H5D_t *dset, hbool_t headers) { - H5D_rdcc_t *rdcc = &(dset->cache.chunk); + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); double miss_rate; char ascii[32]; herr_t ret_value=SUCCEED; /* Return value */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 581a20a..5a2559e 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -139,13 +139,13 @@ H5D_mpio_spaces_xfer(H5F_t *f, const H5D_t *dset, size_t elmt_size, HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI file type"); /* Get the base address of the contiguous dataset or the chunk */ - if(dset->layout.type == H5D_CONTIGUOUS) + if(dset->shared->layout.type == H5D_CONTIGUOUS) addr = H5D_contig_get_addr(dset) + mpi_file_offset; else { haddr_t chunk_addr; /* for collective chunk IO */ - assert(dset->layout.type == H5D_CHUNKED); - chunk_addr=H5D_istore_get_addr(f,dxpl_id,&(dset->layout),store->chunk.offset,NULL); + assert(dset->shared->layout.type == H5D_CHUNKED); + chunk_addr=H5D_istore_get_addr(f,dxpl_id,&(dset->shared->layout),store->chunk.offset,NULL); addr = H5F_BASE_ADDR(f) + chunk_addr + mpi_file_offset; } diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 8b88e92..293d869 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -74,10 +74,13 @@ typedef struct H5D_rdcdc_t { } H5D_rdcdc_t; /* - * A dataset is the following struct. + * A dataset is made of two layers, an H5D_t struct that is unique to + * each instance of an opened datset, and a shared struct that is only + * created once for a given dataset. Thus, if a dataset is opened twice, + * there will be two IDs and two H5D_t structs, both sharing one H5D_shared_t. */ -struct H5D_t { - H5G_entry_t ent; /* cached object header stuff */ +typedef struct H5D_shared_t { + size_t fo_count; /* reference count */ hid_t type_id; /* ID for dataset's datatype */ H5T_t *type; /* datatype of this dataset */ H5S_t *space; /* dataspace of this dataset */ @@ -101,6 +104,11 @@ struct H5D_t { */ H5D_rdcc_t chunk; /* Information about chunked data */ }cache; +} H5D_shared_t; + +struct H5D_t { + H5G_entry_t ent; /* cached object header stuff */ + H5D_shared_t *shared; /* cached information from file */ }; /* Enumerated type for allocating dataset's storage */ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 409cb3f..610dab6 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -201,7 +201,8 @@ typedef struct H5D_dcpl_cache_t { /* Library-private functions defined in H5D package */ H5_DLL herr_t H5D_init(void); -H5_DLL hid_t H5D_open(H5G_entry_t *ent, hid_t dxpl_id); +H5_DLL H5D_t *H5D_open(H5G_entry_t *ent, hid_t dxpl_id); +H5_DLL herr_t H5D_close(H5D_t *dataset); H5_DLL htri_t H5D_isa(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL H5G_entry_t *H5D_entof(H5D_t *dataset); H5_DLL H5T_t *H5D_typeof(const H5D_t *dset); diff --git a/src/H5Dseq.c b/src/H5Dseq.c index b327904..044bc47 100644 --- a/src/H5Dseq.c +++ b/src/H5Dseq.c @@ -107,7 +107,7 @@ H5D_seq_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_i assert(mem_offset_arr); assert(buf); - switch (dset->layout.type) { + switch (dset->shared->layout.type) { case H5D_CONTIGUOUS: /* Read directly from file if the dataset is in an external file */ if (store && store->efl.nused>0) { @@ -124,7 +124,7 @@ H5D_seq_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_i } else { /* Pass along the vector of sequences to read */ if((ret_value=H5D_contig_readvv(f, dxpl_id, dset, - dset->layout.u.contig.addr, dset->layout.u.contig.size, + dset->shared->layout.u.contig.addr, dset->shared->layout.u.contig.size, dset_max_nseq, dset_curr_seq, dset_len_arr, dset_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) @@ -215,7 +215,7 @@ H5D_seq_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, assert(mem_offset_arr); assert(buf); - switch (dset->layout.type) { + switch (dset->shared->layout.type) { case H5D_CONTIGUOUS: /* Write directly to file if the dataset is in an external file */ if (store && store->efl.nused>0) { @@ -232,7 +232,7 @@ H5D_seq_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, } else { /* Pass along the vector of sequences to write */ if ((ret_value=H5D_contig_writevv(f, dxpl_id, dset, - dset->layout.u.contig.addr, dset->layout.u.contig.size, + dset->shared->layout.u.contig.addr, dset->shared->layout.u.contig.size, dset_max_nseq, dset_curr_seq, dset_len_arr, dset_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) diff --git a/src/H5Dtest.c b/src/H5Dtest.c index f140d03..c155e95 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -63,7 +63,7 @@ H5D_layout_version_test(hid_t did, unsigned *version) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(version) - *version=dset->layout.version; + *version=dset->shared->layout.version; done: FUNC_LEAVE_NOAPI(ret_value); @@ -102,8 +102,8 @@ H5D_layout_contig_size_test(hid_t did, hsize_t *size) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(size) { - assert(dset->layout.type==H5D_CONTIGUOUS); - *size=dset->layout.u.contig.size; + assert(dset->shared->layout.type==H5D_CONTIGUOUS); + *size=dset->shared->layout.u.contig.size; } /* end if */ done: diff --git a/src/H5Edefin.h b/src/H5Edefin.h index 0545043..fc629bb 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -20,7 +20,6 @@ #define _H5Edefin_H /* Major error IDs */ -hid_t H5E_NONE_MAJOR_g = FAIL; /* No error */ hid_t H5E_DATASET_g = FAIL; /* Dataset */ hid_t H5E_FUNC_g = FAIL; /* Function entry/exit */ hid_t H5E_STORAGE_g = FAIL; /* Data storage */ @@ -51,8 +50,6 @@ hid_t H5E_CACHE_g = FAIL; /* Object cache */ /* Minor error IDs */ -hid_t H5E_NONE_MINOR_g = FAIL; /* No error */ - /* Generic low-level file I/O errors */ hid_t H5E_SEEKERROR_g = FAIL; /* Seek failed */ hid_t H5E_READERROR_g = FAIL; /* Read failed */ diff --git a/src/H5Einit.h b/src/H5Einit.h index 962e1ff..0e43071 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -22,11 +22,7 @@ /*********************/ /* Major error codes */ /*********************/ -assert(H5E_NONE_MAJOR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MAJOR, "No Error"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NONE_MAJOR_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") + assert(H5E_DATASET_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Dataset"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") @@ -166,12 +162,7 @@ if((H5E_CACHE_g = H5I_register(H5I_ERROR_MSG, msg))<0) /*********************/ /* Minor error codes */ /*********************/ -/* No error */ -assert(H5E_NONE_MINOR_g==(-1)); -if((msg = H5E_create_msg(cls, H5E_MINOR, "Read failed"))==NULL) - HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") -if((H5E_NONE_MINOR_g = H5I_register(H5I_ERROR_MSG, msg))<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") + /* Generic low-level file I/O errors */ assert(H5E_SEEKERROR_g==(-1)); diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 761483b..e59e53b 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -23,7 +23,6 @@ /* Major error codes */ /*********************/ -#define H5E_NONE_MAJOR (H5OPEN H5E_NONE_MAJOR_g) #define H5E_DATASET (H5OPEN H5E_DATASET_g) #define H5E_FUNC (H5OPEN H5E_FUNC_g) #define H5E_STORAGE (H5OPEN H5E_STORAGE_g) @@ -51,7 +50,6 @@ #define H5E_ERROR (H5OPEN H5E_ERROR_g) #define H5E_PLINE (H5OPEN H5E_PLINE_g) #define H5E_CACHE (H5OPEN H5E_CACHE_g) -H5_DLLVAR hid_t H5E_NONE_MAJOR_g; /* No error */ H5_DLLVAR hid_t H5E_DATASET_g; /* Dataset */ H5_DLLVAR hid_t H5E_FUNC_g; /* Function entry/exit */ H5_DLLVAR hid_t H5E_STORAGE_g; /* Data storage */ @@ -83,9 +81,6 @@ H5_DLLVAR hid_t H5E_CACHE_g; /* Object cache */ /*********************/ /* Minor error codes */ /*********************/ -/* No error */ -#define H5E_NONE_MINOR (H5OPEN H5E_NONE_MINOR_g) -H5_DLLVAR hid_t H5E_NONE_MINOR_g; /* No error */ /* Generic low-level file I/O errors */ #define H5E_SEEKERROR (H5OPEN H5E_SEEKERROR_g) diff --git a/src/H5Eterm.h b/src/H5Eterm.h index e52c87b..4f5bda9 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -20,7 +20,7 @@ #define _H5Eterm_H /* Reset major error IDs */ -H5E_NONE_MAJOR_g= + H5E_DATASET_g= H5E_FUNC_g= H5E_STORAGE_g= @@ -51,8 +51,6 @@ H5E_CACHE_g= (-1); /* Reset minor error IDs */ -/* No error */ -H5E_NONE_MINOR_g= /* Generic low-level file I/O errors */ H5E_SEEKERROR_g= diff --git a/src/H5F.c b/src/H5F.c index 8ee1e94..9eee843 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -1564,7 +1564,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) } /* end if */ /* Free the memory for the root group */ - H5FL_FREE(H5G_t,f->shared->root_grp); + H5G_free(f->shared->root_grp); f->shared->root_grp=NULL; } if (H5AC_dest(f, dxpl_id)) { @@ -3401,6 +3401,7 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, unsigned lt, rt, md; /*binary search indices */ int cmp; /*binary search comparison value*/ H5G_entry_t *ent = NULL; /*temporary symbol table entry */ + H5G_entry_t mp_open_ent; /* entry of moint point to be opened */ H5RS_str_t *name_r; /* Ref-counted version of name */ herr_t ret_value = SUCCEED; /*return value */ @@ -3416,15 +3417,17 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, * that the mount wouldn't introduce a cycle in the mount tree. */ if (child->mtab.parent) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted") - if (NULL==(mount_point=H5G_open(loc, name, dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted") + if (H5G_find(loc, name, NULL, &mp_open_ent/*out*/, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found"); + if (NULL==(mount_point=H5G_open(&mp_open_ent, dxpl_id))) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") parent = H5G_fileof(mount_point); mp_ent = H5G_entof(mount_point); for (ancestor=parent; ancestor; ancestor=ancestor->mtab.parent) { - if (ancestor==child) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") + if (ancestor==child) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") } /* @@ -3436,29 +3439,29 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, rt=parent->mtab.nmounts; cmp = -1; while (ltmtab.child[md].group); - cmp = H5F_addr_cmp(mp_ent->header, ent->header); - if (cmp<0) { - rt = md; - } else if (cmp>0) { - lt = md+1; - } + md = (lt+rt)/2; + ent = H5G_entof(parent->mtab.child[md].group); + cmp = H5F_addr_cmp(mp_ent->header, ent->header); + if (cmp<0) { + rt = md; + } else if (cmp>0) { + lt = md+1; + } } if (cmp>0) md++; if (!cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ if (parent->mtab.nmounts>=parent->mtab.nalloc) { - unsigned n = MAX(16, 2*parent->mtab.nalloc); - H5F_mount_t *x = H5MM_realloc(parent->mtab.child, + unsigned n = MAX(16, 2*parent->mtab.nalloc); + H5F_mount_t *x = H5MM_realloc(parent->mtab.child, n*sizeof(parent->mtab.child[0])); - if (!x) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") - parent->mtab.child = x; - parent->mtab.nalloc = n; + if (!x) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") + parent->mtab.child = x; + parent->mtab.nalloc = n; } /* Insert into table */ @@ -3475,9 +3478,9 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, name_r=H5RS_wrap(name); assert(name_r); if (H5G_replace_name( H5G_UNKNOWN, loc, name_r, NULL, NULL, NULL, OP_MOUNT )<0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") if(H5RS_decr(name_r)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement name string") + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement name string") done: if (ret_value<0 && mount_point) @@ -3522,6 +3525,7 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) H5F_t *child = NULL; /*mounted file */ H5F_t *parent = NULL; /*file where mounted */ H5G_entry_t *ent = NULL; /*temporary symbol table entry */ + H5G_entry_t mnt_open_ent; /* entry used to open mount point*/ herr_t ret_value = FAIL; /*return value */ unsigned i; /*coutners */ unsigned lt, rt, md=0; /*binary search indices */ @@ -3537,14 +3541,16 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) * If we get the root group and the file has a parent in the mount tree, * then we must have found the mount point. */ - if (NULL==(mounted=H5G_open(loc, name, dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") + if (H5G_find(loc, name, NULL, &mnt_open_ent/*out*/, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found"); + if (NULL==(mounted=H5G_open(&mnt_open_ent, dxpl_id))) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") child = H5G_fileof(mounted); mnt_ent = H5G_entof(mounted); ent = H5G_entof(child->shared->root_grp); if (child->mtab.parent && - H5F_addr_eq(mnt_ent->header, ent->header)) { + H5F_addr_eq(mnt_ent->header, ent->header)) { /* * We've been given the root group of the child. We do a reverse * lookup in the parent's mount table to find the correct entry. diff --git a/src/H5FO.c b/src/H5FO.c index 32b3706..4f6fcce 100644 --- a/src/H5FO.c +++ b/src/H5FO.c @@ -38,7 +38,7 @@ typedef struct H5FO_open_obj_t { haddr_t addr; /* Address of object header for object */ /* THIS MUST BE FIRST FOR TBBT ROUTINES */ - hid_t id; /* Current ID for object */ + void *obj; /* Pointer to the object */ hbool_t deleted; /* Flag to indicate that the object was deleted from the file */ } H5FO_open_obj_t; @@ -90,12 +90,12 @@ done: PURPOSE Checks if an object at an address is already open in the file. USAGE - hid_t H5FO_opened(f,addr) + void * H5FO_opened(f,addr) const H5F_t *f; IN: File to check opened object info set haddr_t addr; IN: Address of object to check RETURNS - Returns a non-negative ID for the object on success, negative on failure + Returns a pointer to the object on success, NULL on failure DESCRIPTION Check is an object at an address (the address of the object's object header) is already open in the file and return the ID for that object if it is open. @@ -104,12 +104,12 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -hid_t +void * H5FO_opened(const H5F_t *f, haddr_t addr) { H5TB_NODE *obj_node; /* TBBT node holding open object */ H5FO_open_obj_t *open_obj; /* Information about open object */ - hid_t ret_value; /* Return value */ + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5FO_opened) @@ -123,11 +123,11 @@ H5FO_opened(const H5F_t *f, haddr_t addr) if((obj_node=H5TB_dfind(f->shared->open_objs,&addr,NULL))!=NULL) { open_obj=H5TB_NODE_DATA(obj_node); assert(open_obj); - ret_value=open_obj->id; + ret_value=open_obj->obj; assert(ret_value>0); } /* end if */ else - ret_value=FAIL; + ret_value=NULL; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FO_opened() */ @@ -137,12 +137,12 @@ H5FO_opened(const H5F_t *f, haddr_t addr) NAME H5FO_insert PURPOSE - Insert a newly opened object/ID pair into the opened object info set + Insert a newly opened object/pointer pair into the opened object info set USAGE - herr_t H5FO_insert(f,addr,id) + herr_t H5FO_insert(f,addr,obj) H5F_t *f; IN/OUT: File's opened object info set haddr_t addr; IN: Address of object to insert - hid_t id; IN: ID of object to insert + void *obj; IN: Pointer to object to insert int type; IN: Type of object being inserted RETURNS @@ -155,7 +155,7 @@ H5FO_opened(const H5F_t *f, haddr_t addr) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5FO_insert(const H5F_t *f, haddr_t addr, hid_t id) +H5FO_insert(const H5F_t *f, haddr_t addr, void *obj) { H5FO_open_obj_t *open_obj; /* Information about open object */ herr_t ret_value=SUCCEED; /* Return value */ @@ -167,7 +167,7 @@ H5FO_insert(const H5F_t *f, haddr_t addr, hid_t id) assert(f->shared); assert(f->shared->open_objs); assert(H5F_addr_defined(addr)); - assert(id>0); + assert(obj); /* Allocate new opened object information structure */ if((open_obj=H5FL_MALLOC(H5FO_open_obj_t))==NULL) @@ -175,7 +175,7 @@ H5FO_insert(const H5F_t *f, haddr_t addr, hid_t id) /* Assign information */ open_obj->addr=addr; - open_obj->id=id; + open_obj->obj=obj; open_obj->deleted=0; /* Insert into TBBT */ diff --git a/src/H5FOprivate.h b/src/H5FOprivate.h index 7220b75..de385f7 100644 --- a/src/H5FOprivate.h +++ b/src/H5FOprivate.h @@ -24,6 +24,7 @@ /* Private headers needed by this file */ #include "H5private.h" +#include "H5Fprivate.h" #include "H5TBprivate.h" /* TBBTs */ /* Typedefs */ @@ -35,8 +36,8 @@ typedef H5TB_TREE H5FO_t; /* Currently, all open objects are stored in TBB /* Private routines */ H5_DLL herr_t H5FO_create(const H5F_t *f); -H5_DLL hid_t H5FO_opened(const H5F_t *f, haddr_t addr); -H5_DLL herr_t H5FO_insert(const H5F_t *f, haddr_t addr, hid_t id); +H5_DLL void *H5FO_opened(const H5F_t *f, haddr_t addr); +H5_DLL herr_t H5FO_insert(const H5F_t *f, haddr_t addr, void *obj); H5_DLL herr_t H5FO_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr); H5_DLL herr_t H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted); H5_DLL htri_t H5FO_marked(const H5F_t *f, haddr_t addr); diff --git a/src/H5G.c b/src/H5G.c index 1c338e3..38fcf43 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -162,6 +162,7 @@ static size_t H5G_comp_alloc_g = 0; /*sizeof component buffer */ /* Declare a free list to manage the H5G_t struct */ H5FL_DEFINE(H5G_t); +H5FL_DEFINE(H5G_shared_t); /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); @@ -180,6 +181,7 @@ static herr_t H5G_linkval(H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/, hid_t dxpl_id); static herr_t H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc, const char *dst_name, hid_t dxpl_it); +static H5G_t * H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id); static herr_t H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id); static herr_t H5G_get_num_objs(H5G_entry_t *grp, hsize_t *num_objs, hid_t dxpl_id); static ssize_t H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, hid_t dxpl_id); @@ -279,25 +281,31 @@ done: hid_t H5Gopen(hid_t loc_id, const char *name) { - hid_t ret_value = FAIL; - H5G_t *grp = NULL; + hid_t ret_value = FAIL; + H5G_t *grp = NULL; H5G_entry_t *loc = NULL; + H5G_entry_t ent; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open group */ FUNC_ENTER_API(H5Gopen, FAIL); H5TRACE2("i","is",loc_id,name); /* Check args */ if (NULL==(loc=H5G_loc(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); - + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + + /* Open the parent group, making sure it's a group */ + if (H5G_find(loc, name, NULL, &ent/*out*/, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found"); + /* Open the group */ - if (NULL == (grp = H5G_open(loc, name, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group"); + if ((grp = H5G_open(&ent, H5AC_dxpl_id)) <0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group"); /* Register an atom for the group */ if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group"); + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group"); done: if(ret_value<0) { @@ -381,7 +389,6 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, { int idx; H5G_bt_ud2_t udata; - H5G_entry_t *loc = NULL; H5G_t *grp = NULL; herr_t ret_value; @@ -389,27 +396,25 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5TRACE5("e","is*Isxx",loc_id,name,idx_p,op,op_data); /* Check args */ - if (NULL==(loc=H5G_loc (loc_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); idx = (idx_p == NULL ? 0 : *idx_p); if (!idx_p) idx_p = &idx; if (idx<0) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified"); if (!op) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified"); /* * Open the group on which to operate. We also create a group ID which * we can pass to the application-defined operator. */ - if (NULL==(grp = H5G_open (loc, name, H5AC_dxpl_id))) - HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group"); - if ((udata.group_id=H5I_register (H5I_GROUP, grp))<0) { - H5G_close(grp); - HGOTO_ERROR (H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group"); + if ((udata.group_id = H5Gopen (loc_id, name)) <0) + HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group"); + if ((grp=H5I_object(udata.group_id))==NULL) { + H5Gclose(udata.group_id); + HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL, "bad group atom"); } /* Build udata to pass through H5B_iterate() to H5G_node_iterate() */ @@ -1728,9 +1733,13 @@ H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent) * never be closed. */ if (NULL==(f->shared->root_grp = H5FL_CALLOC (H5G_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + if (NULL==(f->shared->root_grp->shared = H5FL_CALLOC (H5G_shared_t))) { + H5FL_FREE(H5G_t, f->shared->root_grp); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + } f->shared->root_grp->ent = *ent; - f->shared->root_grp->nref = 1; + f->shared->root_grp->shared->fo_count = 1; assert (1==f->nopen_objs); f->nopen_objs = 0; @@ -1769,7 +1778,7 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id) { H5G_t *grp = NULL; /*new group */ H5F_t *file = NULL; /* File new group will be in */ - unsigned stab_init=0; /* Flag to indicate that the symbol stable was created successfully */ + unsigned stab_init=0; /* Flag to indicate that the symbol table was created successfully */ H5G_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5G_create, NULL); @@ -1780,7 +1789,10 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id) /* create an open group */ if (NULL==(grp = H5FL_CALLOC(H5G_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (NULL==(grp->shared = H5FL_CALLOC(H5G_t))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + /* What file is the group being added to? */ if (NULL==(file=H5G_insertion_file(loc, name, dxpl_id))) @@ -1788,14 +1800,18 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id) /* Create the group entry */ if (H5G_stab_create(file, dxpl_id, size_hint, &(grp->ent)/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp"); + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp"); stab_init=1; /* Indicate that the symbol table information is valid */ /* insert child name into parent */ if(H5G_insert(loc,name,&(grp->ent), dxpl_id)<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group"); + HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group"); - grp->nref = 1; + /* Add group to list of open objects in file */ + if(H5FO_insert(grp->ent.file, grp->ent.header, grp->shared)<0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects") + + grp->shared->fo_count = 1; /* Set return value */ ret_value=grp; @@ -1810,6 +1826,8 @@ done: HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header"); } /* end if */ if(grp!=NULL) + if(grp->shared != NULL) + H5FL_FREE(H5G_shared_t, grp->shared); H5FL_FREE(H5G_t,grp); } /* end if */ @@ -1911,25 +1929,47 @@ H5G_link_isa(H5G_entry_t *ent, hid_t UNUSED dxpl_id) *------------------------------------------------------------------------- */ H5G_t * -H5G_open(H5G_entry_t *loc, const char *name, hid_t dxpl_id) +H5G_open(H5G_entry_t *ent, hid_t dxpl_id) { - H5G_t *grp = NULL; - H5G_t *ret_value = NULL; - H5G_entry_t ent; /* group symbol table entry */ + H5G_t *grp = NULL; + H5G_shared_t *shared_fo=NULL; + H5G_t *ret_value=NULL; FUNC_ENTER_NOAPI(H5G_open, NULL); /* Check args */ - assert(loc); - assert(name && *name); + assert(ent); - /* Open the object, making sure it's a group */ - if (H5G_find(loc, name, NULL, &ent/*out*/, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found"); + /* Check if group was already open */ + if((shared_fo=H5FO_opened(ent->file, ent->header))==NULL) { + + /* Clear any errors from H5FO_opened() */ + H5E_clear_stack(NULL); - /* Open the group object */ - if ((grp=H5G_open_oid(&ent, dxpl_id)) ==NULL) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found"); + /* Open the group object */ + if ((grp=H5G_open_oid(ent, dxpl_id)) ==NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found"); + + /* Add group to list of open objects in file */ + if(H5FO_insert(grp->ent.file, grp->ent.header, grp->shared)<0) + { + H5FL_FREE(H5G_shared_t, grp->shared); + HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects") + } + + grp->shared->fo_count =1; + } + else { + if(NULL == (grp = H5FL_CALLOC(H5G_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for group") + + /* Shallow copy (take ownership) of the group entry object */ + if(H5G_ent_copy(&(grp->ent), ent, H5G_COPY_SHALLOW)<0) + HGOTO_ERROR (H5E_SYM, H5E_CANTCOPY, NULL, "can't copy group entry") + + grp->shared=shared_fo; + shared_fo->fo_count++; + } /* Set return value */ ret_value = grp; @@ -1962,7 +2002,7 @@ done: * *------------------------------------------------------------------------- */ -H5G_t * +static H5G_t * H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id) { H5G_t *grp = NULL; @@ -1977,6 +2017,8 @@ H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id) /* Open the object, making sure it's a group */ if (NULL==(grp = H5FL_CALLOC(H5G_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (NULL==(grp->shared = H5FL_CALLOC(H5G_t))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Copy over (take ownership) of the group entry object */ H5G_ent_copy(&(grp->ent),ent,H5G_COPY_SHALLOW); @@ -1988,14 +2030,16 @@ H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id) H5O_close(&(grp->ent)); HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "not a group"); } - grp->nref = 1; /* Set return value */ ret_value = grp; done: - if (!ret_value && grp) + if (!ret_value && grp) { + if(grp->shared) + H5FL_FREE(H5G_shared_t, grp->shared); H5FL_FREE(H5G_t,grp); + } FUNC_LEAVE_NOAPI(ret_value); } @@ -2061,19 +2105,63 @@ H5G_close(H5G_t *grp) FUNC_ENTER_NOAPI(H5G_close, FAIL); /* Check args */ - assert(grp); - assert(grp->nref > 0); + assert(grp && grp->shared); + assert(grp->shared->fo_count > 0); + + --grp->shared->fo_count; + + if (0 == grp->shared->fo_count) { + assert (grp!=H5G_rootof(H5G_fileof(grp))); - if (1 == grp->nref) { - assert (grp!=H5G_rootof(H5G_fileof(grp))); - if (H5O_close(&(grp->ent)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close"); - grp->nref = 0; - H5FL_FREE (H5G_t,grp); + /* Remove the dataset from the list of opened objects in the file */ + if(H5FO_delete(grp->ent.file, H5AC_dxpl_id, grp->ent.header)<0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't remove group from list of open objects") + if (H5O_close(&(grp->ent)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close"); + H5FL_FREE (H5G_shared_t, grp->shared); } else { - --grp->nref; + if(H5G_free_ent_name(&(grp->ent))<0) + { + H5FL_FREE (H5G_t,grp); + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't free group entry name"); + } } + H5FL_FREE (H5G_t,grp); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5G_free + * + * Purpose: Free memory used by an H5G_t struct (and its H5G_shared_t). + * Does not close the group or decrement the reference count. + * Used to free memory used by the root group. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: James Laird + * Tuesday, September 7, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_free(H5G_t *grp) +{ + herr_t ret_value=SUCCEED; /* Return value */ + FUNC_ENTER_NOAPI(H5G_free, FAIL); + + assert(grp && grp->shared); + + H5FL_FREE(H5G_shared_t, grp->shared); + H5FL_FREE(H5G_t, grp); + done: FUNC_LEAVE_NOAPI(ret_value); } @@ -3238,8 +3326,8 @@ H5G_free_grp_name(H5G_t *grp) FUNC_ENTER_NOAPI(H5G_free_grp_name, FAIL); /* Check args */ - assert(grp); - assert(grp->nref > 0); + assert(grp && grp->shared); + assert(grp->shared->fo_count > 0); /* Get the entry for the group */ if (NULL==( ent = H5G_entof(grp))) diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index e599905..b9693a3 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -47,12 +47,19 @@ typedef struct H5G_node_t { } H5G_node_t; /* + * Reference count shared between all instances of an open group + */ +struct H5G_shared_t { + int fo_count; /* open file object count */ +}; + +/* * A group handle passed around through layers of the library within and * above the H5G layer. */ struct H5G_t { - int nref; /*open reference count */ - H5G_entry_t ent; /*info about the group */ + H5G_shared_t* shared; /*shared file object data */ + H5G_entry_t ent; /*info about the group */ }; /* diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 5415e32..b2c96d0 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -114,6 +114,7 @@ typedef struct H5G_entry_t { } H5G_entry_t; typedef struct H5G_t H5G_t; +typedef struct H5G_shared_t H5G_shared_t; /* Type of operation being performed for call to H5G_replace_name() */ typedef enum { @@ -139,8 +140,8 @@ H5_DLL H5G_entry_t *H5G_loc(hid_t loc_id); H5_DLL herr_t H5G_mkroot(H5F_t *f, hid_t dxpl_id, H5G_entry_t *root_entry); H5_DLL H5G_entry_t *H5G_entof(H5G_t *grp); H5_DLL H5F_t *H5G_fileof(H5G_t *grp); -H5_DLL H5G_t *H5G_open(H5G_entry_t *loc, const char *name, hid_t dxpl_id); -H5_DLL H5G_t *H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id); +H5_DLL herr_t H5G_free(H5G_t *grp); +H5_DLL H5G_t *H5G_open(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5G_close(H5G_t *grp); H5_DLL H5G_obj_t H5G_get_type(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL herr_t H5G_get_objinfo(H5G_entry_t *loc, const char *name, diff --git a/src/H5O.c b/src/H5O.c index 75d18d2..587c8f8 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1244,7 +1244,7 @@ H5O_link(const H5G_entry_t *ent, int adjust, hid_t dxpl_id) /* Check if the object should be deleted */ if(oh->nlink==0) { /* Check if the object is still open by the user */ - if(H5FO_opened(ent->file,ent->header)>=0) { + if(H5FO_opened(ent->file,ent->header)!=NULL) { /* Flag the object to be deleted when it's closed */ if(H5FO_mark(ent->file,ent->header,TRUE)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion"); diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 3c44b26..807aaf3 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -68,6 +68,7 @@ const H5O_class_t H5O_DTYPE[1] = {{ /* Declare external the free list for H5T_t's */ H5FL_EXTERN(H5T_t); +H5FL_EXTERN(H5T_shared_t); /*------------------------------------------------------------------------- @@ -97,39 +98,39 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) /* check args */ assert(pp && *pp); - assert(dt); + assert(dt && dt->shared); /* decode */ UINT32DECODE(*pp, flags); version = (flags>>4) & 0x0f; if (version!=H5O_DTYPE_VERSION_COMPAT && version!=H5O_DTYPE_VERSION_UPDATED) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for data type message"); - dt->type = (H5T_class_t)(flags & 0x0f); + dt->shared->type = (H5T_class_t)(flags & 0x0f); flags >>= 8; - UINT32DECODE(*pp, dt->size); + UINT32DECODE(*pp, dt->shared->size); - switch (dt->type) { + switch (dt->shared->type) { case H5T_INTEGER: /* * Integer types... */ - dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE; - UINT16DECODE(*pp, dt->u.atomic.offset); - UINT16DECODE(*pp, dt->u.atomic.prec); + dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->shared->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE; + UINT16DECODE(*pp, dt->shared->u.atomic.offset); + UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; case H5T_BITFIELD: /* * Bit fields... */ - dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; - UINT16DECODE(*pp, dt->u.atomic.offset); - UINT16DECODE(*pp, dt->u.atomic.prec); + dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; + UINT16DECODE(*pp, dt->shared->u.atomic.offset); + UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; case H5T_OPAQUE: @@ -138,10 +139,10 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) */ z = flags & 0xff; assert(0==(z&0x7)); /*must be aligned*/ - if (NULL==(dt->u.opaque.tag=H5MM_malloc(z+1))) + if (NULL==(dt->shared->u.opaque.tag=H5MM_malloc(z+1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - HDmemcpy(dt->u.opaque.tag, *pp, z); - dt->u.opaque.tag[z] = '\0'; + HDmemcpy(dt->shared->u.opaque.tag, *pp, z); + dt->shared->u.opaque.tag[z] = '\0'; *pp += z; break; @@ -149,48 +150,48 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) /* * Floating-point types... */ - dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->shared->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO; switch ((flags >> 4) & 0x03) { case 0: - dt->u.atomic.u.f.norm = H5T_NORM_NONE; + dt->shared->u.atomic.u.f.norm = H5T_NORM_NONE; break; case 1: - dt->u.atomic.u.f.norm = H5T_NORM_MSBSET; + dt->shared->u.atomic.u.f.norm = H5T_NORM_MSBSET; break; case 2: - dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED; + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown floating-point normalization"); } - dt->u.atomic.u.f.sign = (flags >> 8) & 0xff; - UINT16DECODE(*pp, dt->u.atomic.offset); - UINT16DECODE(*pp, dt->u.atomic.prec); - dt->u.atomic.u.f.epos = *(*pp)++; - dt->u.atomic.u.f.esize = *(*pp)++; - assert(dt->u.atomic.u.f.esize > 0); - dt->u.atomic.u.f.mpos = *(*pp)++; - dt->u.atomic.u.f.msize = *(*pp)++; - assert(dt->u.atomic.u.f.msize > 0); - UINT32DECODE(*pp, dt->u.atomic.u.f.ebias); + dt->shared->u.atomic.u.f.sign = (flags >> 8) & 0xff; + UINT16DECODE(*pp, dt->shared->u.atomic.offset); + UINT16DECODE(*pp, dt->shared->u.atomic.prec); + dt->shared->u.atomic.u.f.epos = *(*pp)++; + dt->shared->u.atomic.u.f.esize = *(*pp)++; + assert(dt->shared->u.atomic.u.f.esize > 0); + dt->shared->u.atomic.u.f.mpos = *(*pp)++; + dt->shared->u.atomic.u.f.msize = *(*pp)++; + assert(dt->shared->u.atomic.u.f.msize > 0); + UINT32DECODE(*pp, dt->shared->u.atomic.u.f.ebias); break; case H5T_COMPOUND: /* * Compound data types... */ - dt->u.compnd.nmembs = flags & 0xffff; - assert(dt->u.compnd.nmembs > 0); - dt->u.compnd.packed = TRUE; /* Start off packed */ - dt->u.compnd.nalloc = dt->u.compnd.nmembs; - dt->u.compnd.memb = H5MM_calloc(dt->u.compnd.nalloc* + dt->shared->u.compnd.nmembs = flags & 0xffff; + assert(dt->shared->u.compnd.nmembs > 0); + dt->shared->u.compnd.packed = TRUE; /* Start off packed */ + dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs; + dt->shared->u.compnd.memb = H5MM_calloc(dt->shared->u.compnd.nalloc* sizeof(H5T_cmemb_t)); - if (NULL==dt->u.compnd.memb) + if (NULL==dt->shared->u.compnd.memb) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - for (i = 0; i < dt->u.compnd.nmembs; i++) { + for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { unsigned ndims=0; /* Number of dimensions of the array field */ hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */ int perm[H5O_LAYOUT_NDIMS]; /* Dimension permutations */ @@ -199,12 +200,12 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) H5T_t *temp_type; /* Temporary pointer to the field's datatype */ /* Decode the field name */ - dt->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); + dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); /*multiple of 8 w/ null terminator */ *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; /* Decode the field offset */ - UINT32DECODE(*pp, dt->u.compnd.memb[i].offset); + UINT32DECODE(*pp, dt->shared->u.compnd.memb[i].offset); /* Older versions of the library allowed a field to have * intrinsic 'arrayness'. Newer versions of the library @@ -227,16 +228,19 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) } /* end if */ /* Allocate space for the field's datatype */ - temp_type = H5FL_CALLOC (H5T_t); - if (NULL==temp_type) + if(NULL== (temp_type = H5FL_CALLOC (H5T_t))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + if(NULL== (temp_type->shared = H5FL_CALLOC (H5T_shared_t))) { + H5FL_FREE(H5T_t, temp_type); HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + } temp_type->ent.header = HADDR_UNDEF; /* Decode the field's datatype information */ if (H5O_dtype_decode_helper(f, pp, temp_type)<0) { for (j=0; j<=i; j++) - H5MM_xfree(dt->u.compnd.memb[j].name); - H5MM_xfree(dt->u.compnd.memb); + H5MM_xfree(dt->shared->u.compnd.memb[j].name); + H5MM_xfree(dt->shared->u.compnd.memb); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type"); } @@ -251,8 +255,8 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) /* Create the array datatype for the field */ if ((array_dt=H5T_array_create(temp_type,(int)ndims,dim,perm))==NULL) { for (j=0; j<=i; j++) - H5MM_xfree(dt->u.compnd.memb[j].name); - H5MM_xfree(dt->u.compnd.memb); + H5MM_xfree(dt->shared->u.compnd.memb[j].name); + H5MM_xfree(dt->shared->u.compnd.memb); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype"); } @@ -268,36 +272,36 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) * Set the "force conversion" flag if VL datatype fields exist in this * type or any component types */ - if(temp_type->force_conv==TRUE) - dt->force_conv=TRUE; + if(temp_type->shared->force_conv==TRUE) + dt->shared->force_conv=TRUE; /* Member size */ - dt->u.compnd.memb[i].size = temp_type->size; + dt->shared->u.compnd.memb[i].size = temp_type->shared->size; /* Set the field datatype (finally :-) */ - dt->u.compnd.memb[i].type=temp_type; + dt->shared->u.compnd.memb[i].type=temp_type; /* Check if the datatype stayed packed */ - if(dt->u.compnd.packed) { + if(dt->shared->u.compnd.packed) { /* Check if the member type is packed */ if(H5T_is_packed(temp_type)>0) { if(i==0) { /* If the is the first member, the datatype is not packed * if the first member isn't at offset 0 */ - if(dt->u.compnd.memb[i].offset>0) - dt->u.compnd.packed=FALSE; + if(dt->shared->u.compnd.memb[i].offset>0) + dt->shared->u.compnd.packed=FALSE; } /* end if */ else { /* If the is not the first member, the datatype is not * packed if the new member isn't adjoining the previous member */ - if(dt->u.compnd.memb[i].offset!=(dt->u.compnd.memb[i-1].offset+dt->u.compnd.memb[i-1].size)) - dt->u.compnd.packed=FALSE; + if(dt->shared->u.compnd.memb[i].offset!=(dt->shared->u.compnd.memb[i-1].offset+dt->shared->u.compnd.memb[i-1].size)) + dt->shared->u.compnd.packed=FALSE; } /* end else */ } /* end if */ else - dt->u.compnd.packed=FALSE; + dt->shared->u.compnd.packed=FALSE; } /* end if */ } break; @@ -306,46 +310,50 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) /* * Enumeration data types... */ - dt->u.enumer.nmembs = dt->u.enumer.nalloc = flags & 0xffff; - if (NULL==(dt->parent=H5FL_CALLOC(H5T_t))) + dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff; + if (NULL==(dt->shared->parent=H5FL_CALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - dt->parent->ent.header = HADDR_UNDEF; - if (H5O_dtype_decode_helper(f, pp, dt->parent)<0) + if(NULL== (dt->shared->parent->shared= H5FL_CALLOC (H5T_shared_t))) { + H5FL_FREE(H5T_t, dt->shared->parent); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + } + dt->shared->parent->ent.header = HADDR_UNDEF; + if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent data type"); - if (NULL==(dt->u.enumer.name=H5MM_calloc(dt->u.enumer.nalloc * sizeof(char*))) || - NULL==(dt->u.enumer.value=H5MM_calloc(dt->u.enumer.nalloc * - dt->parent->size))) + if (NULL==(dt->shared->u.enumer.name=H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char*))) || + NULL==(dt->shared->u.enumer.value=H5MM_calloc(dt->shared->u.enumer.nalloc * + dt->shared->parent->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Names, each a multiple of 8 with null termination */ - for (i=0; iu.enumer.nmembs; i++) { - dt->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp); + for (i=0; ishared->u.enumer.nmembs; i++) { + dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp); *pp += ((HDstrlen((const char*)*pp)+8)/8)*8; } /* Values */ - HDmemcpy(dt->u.enumer.value, *pp, - dt->u.enumer.nmembs * dt->parent->size); - *pp += dt->u.enumer.nmembs * dt->parent->size; + HDmemcpy(dt->shared->u.enumer.value, *pp, + dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); + *pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; case H5T_REFERENCE: /* Reference data types... */ - dt->u.atomic.order = H5T_ORDER_NONE; - dt->u.atomic.prec = 8 * dt->size; - dt->u.atomic.offset = 0; - dt->u.atomic.lsb_pad = H5T_PAD_ZERO; - dt->u.atomic.msb_pad = H5T_PAD_ZERO; + dt->shared->u.atomic.order = H5T_ORDER_NONE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + dt->shared->u.atomic.offset = 0; + dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; + dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; /* Set reference type */ - dt->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f); + dt->shared->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f); /* Set extra information for object references, so the hobj_ref_t gets swizzled correctly */ - if(dt->u.atomic.u.r.rtype==H5R_OBJECT) { + if(dt->shared->u.atomic.u.r.rtype==H5R_OBJECT) { /* This type is on disk */ - dt->u.atomic.u.r.loc = H5T_LOC_DISK; + dt->shared->u.atomic.u.r.loc = H5T_LOC_DISK; /* This type needs conversion */ - dt->force_conv=TRUE; + dt->shared->force_conv=TRUE; } /* end if */ break; @@ -353,75 +361,88 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) /* * Character string types... */ - dt->u.atomic.order = H5T_ORDER_NONE; - dt->u.atomic.prec = 8 * dt->size; - dt->u.atomic.offset = 0; - dt->u.atomic.lsb_pad = H5T_PAD_ZERO; - dt->u.atomic.msb_pad = H5T_PAD_ZERO; - - dt->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); - dt->u.atomic.u.s.cset = (H5T_cset_t)((flags>>4) & 0x0f); + dt->shared->u.atomic.order = H5T_ORDER_NONE; + dt->shared->u.atomic.prec = 8 * dt->shared->size; + dt->shared->u.atomic.offset = 0; + dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; + dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; + + dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); + dt->shared->u.atomic.u.s.cset = (H5T_cset_t)((flags>>4) & 0x0f); break; case H5T_VLEN: /* Variable length datatypes... */ /* Set the type of VL information, either sequence or string */ - dt->u.vlen.type = (H5T_vlen_type_t)(flags & 0x0f); - if(dt->u.vlen.type == H5T_VLEN_STRING) { - dt->u.vlen.pad = (H5T_str_t)((flags>>4) & 0x0f); - dt->u.vlen.cset = (H5T_cset_t)((flags>>8) & 0x0f); + dt->shared->u.vlen.type = (H5T_vlen_type_t)(flags & 0x0f); + if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + dt->shared->u.vlen.pad = (H5T_str_t)((flags>>4) & 0x0f); + dt->shared->u.vlen.cset = (H5T_cset_t)((flags>>8) & 0x0f); } /* end if */ /* Decode base type of VL information */ - if (NULL==(dt->parent = H5FL_CALLOC(H5T_t))) + if (NULL==(dt->shared->parent = H5FL_CALLOC(H5T_t))) + HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed"); + if(NULL== (dt->shared->parent->shared = H5FL_CALLOC (H5T_shared_t))) { + H5FL_FREE(H5T_t, dt->shared->parent); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + } + if (NULL==(dt->shared->parent->shared = H5FL_CALLOC(H5T_shared_t))) + { + H5FL_FREE(H5T_t, dt->shared->parent); HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed"); - dt->parent->ent.header = HADDR_UNDEF; - if (H5O_dtype_decode_helper(f, pp, dt->parent)<0) + } + dt->shared->parent->ent.header = HADDR_UNDEF; + if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type"); - dt->force_conv=TRUE; + dt->shared->force_conv=TRUE; /* Mark this type as on disk */ if (H5T_set_loc(dt, f, H5T_LOC_DISK)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location"); break; case H5T_TIME: /* Time datatypes */ - dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - UINT16DECODE(*pp, dt->u.atomic.prec); + dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; case H5T_ARRAY: /* Array datatypes... */ /* Decode the number of dimensions */ - dt->u.array.ndims = *(*pp)++; + dt->shared->u.array.ndims = *(*pp)++; /* Double-check the number of dimensions */ - assert(dt->u.array.ndims <= H5S_MAX_RANK); + assert(dt->shared->u.array.ndims <= H5S_MAX_RANK); /* Skip reserved bytes */ *pp += 3; /* Decode array dimension sizes & compute number of elements */ - for (j=0, dt->u.array.nelem=1; j<(unsigned)dt->u.array.ndims; j++) { - UINT32DECODE(*pp, dt->u.array.dim[j]); - dt->u.array.nelem *= dt->u.array.dim[j]; + for (j=0, dt->shared->u.array.nelem=1; j<(unsigned)dt->shared->u.array.ndims; j++) { + UINT32DECODE(*pp, dt->shared->u.array.dim[j]); + dt->shared->u.array.nelem *= dt->shared->u.array.dim[j]; } /* end for */ /* Decode array dimension permutations (even though they are unused currently) */ - for (j=0; j<(unsigned)dt->u.array.ndims; j++) - UINT32DECODE(*pp, dt->u.array.perm[j]); + for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++) + UINT32DECODE(*pp, dt->shared->u.array.perm[j]); /* Decode base type of array */ - if (NULL==(dt->parent = H5FL_CALLOC(H5T_t))) + if (NULL==(dt->shared->parent = H5FL_CALLOC(H5T_t))) HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed"); - dt->parent->ent.header = HADDR_UNDEF; - if (H5O_dtype_decode_helper(f, pp, dt->parent)<0) + if(NULL== (dt->shared->parent->shared = H5FL_CALLOC (H5T_shared_t))) { + H5FL_FREE(H5T_t, dt->shared->parent); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + } + dt->shared->parent->ent.header = HADDR_UNDEF; + if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type"); /* * Set the "force conversion" flag if a VL base datatype is used or * or if any components of the base datatype are VL types. */ - if(dt->parent->force_conv==TRUE) - dt->force_conv=TRUE; + if(dt->shared->parent->shared->force_conv==TRUE) + dt->shared->force_conv=TRUE; break; default: @@ -429,6 +450,14 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) } done: + if(ret_value <0) + { + if(dt->shared != NULL) + H5FL_FREE(H5T_shared_t, dt->shared); + if(dt != NULL) + H5FL_FREE(H5T_t, dt); + } + FUNC_LEAVE_NOAPI(ret_value); } @@ -466,14 +495,14 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) /* skip the type and class bit-field for now */ *pp += 4; - UINT32ENCODE(*pp, dt->size); + UINT32ENCODE(*pp, dt->shared->size); - switch (dt->type) { + switch (dt->shared->type) { case H5T_INTEGER: /* * Integer data types... */ - switch (dt->u.atomic.order) { + switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: break; /*nothing */ case H5T_ORDER_BE: @@ -483,7 +512,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } - switch (dt->u.atomic.lsb_pad) { + switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: @@ -493,7 +522,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } - switch (dt->u.atomic.msb_pad) { + switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: @@ -503,7 +532,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } - switch (dt->u.atomic.u.i.sign) { + switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: break; /*nothing */ case H5T_SGN_2: @@ -513,15 +542,15 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "sign scheme is not supported in file format yet"); } - UINT16ENCODE(*pp, dt->u.atomic.offset); - UINT16ENCODE(*pp, dt->u.atomic.prec); + UINT16ENCODE(*pp, dt->shared->u.atomic.offset); + UINT16ENCODE(*pp, dt->shared->u.atomic.prec); break; case H5T_BITFIELD: /* * Bitfield data types... */ - switch (dt->u.atomic.order) { + switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: break; /*nothing */ case H5T_ORDER_BE: @@ -531,7 +560,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } - switch (dt->u.atomic.lsb_pad) { + switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: @@ -541,7 +570,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } - switch (dt->u.atomic.msb_pad) { + switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: @@ -551,8 +580,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } - UINT16ENCODE(*pp, dt->u.atomic.offset); - UINT16ENCODE(*pp, dt->u.atomic.prec); + UINT16ENCODE(*pp, dt->shared->u.atomic.offset); + UINT16ENCODE(*pp, dt->shared->u.atomic.prec); break; case H5T_OPAQUE: @@ -561,10 +590,10 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) * multiple of eight characters and null padded (not necessarily * null terminated). */ - z = HDstrlen(dt->u.opaque.tag); + z = HDstrlen(dt->shared->u.opaque.tag); aligned = (z+7) & 0xf8; flags |= aligned; - HDmemcpy(*pp, dt->u.opaque.tag, MIN(z,aligned)); + HDmemcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned)); for (n=MIN(z,aligned); nu.atomic.order) { + switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: break; /*nothing */ case H5T_ORDER_BE: @@ -583,7 +612,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } - switch (dt->u.atomic.lsb_pad) { + switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: @@ -593,7 +622,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } - switch (dt->u.atomic.msb_pad) { + switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: @@ -603,7 +632,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } - switch (dt->u.atomic.u.f.pad) { + switch (dt->shared->u.atomic.u.f.pad) { case H5T_PAD_ZERO: break; /*nothing */ case H5T_PAD_ONE: @@ -613,7 +642,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet"); } - switch (dt->u.atomic.u.f.norm) { + switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_NONE: break; /*nothing */ case H5T_NORM_MSBSET: @@ -626,18 +655,18 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet"); } - flags |= (dt->u.atomic.u.f.sign << 8) & 0xff00; - UINT16ENCODE(*pp, dt->u.atomic.offset); - UINT16ENCODE(*pp, dt->u.atomic.prec); - assert (dt->u.atomic.u.f.epos<=255); - *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.epos); - assert (dt->u.atomic.u.f.esize<=255); - *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.esize); - assert (dt->u.atomic.u.f.mpos<=255); - *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.mpos); - assert (dt->u.atomic.u.f.msize<=255); - *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.msize); - UINT32ENCODE(*pp, dt->u.atomic.u.f.ebias); + flags |= (dt->shared->u.atomic.u.f.sign << 8) & 0xff00; + UINT16ENCODE(*pp, dt->shared->u.atomic.offset); + UINT16ENCODE(*pp, dt->shared->u.atomic.prec); + assert (dt->shared->u.atomic.u.f.epos<=255); + *(*pp)++ = (uint8_t)(dt->shared->u.atomic.u.f.epos); + assert (dt->shared->u.atomic.u.f.esize<=255); + *(*pp)++ = (uint8_t)(dt->shared->u.atomic.u.f.esize); + assert (dt->shared->u.atomic.u.f.mpos<=255); + *(*pp)++ = (uint8_t)(dt->shared->u.atomic.u.f.mpos); + assert (dt->shared->u.atomic.u.f.msize<=255); + *(*pp)++ = (uint8_t)(dt->shared->u.atomic.u.f.msize); + UINT32ENCODE(*pp, dt->shared->u.atomic.u.f.ebias); break; case H5T_COMPOUND: @@ -648,18 +677,18 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) /* * Compound data types... */ - flags = dt->u.compnd.nmembs & 0xffff; - for (i=0; iu.compnd.nmembs; i++) { + flags = dt->shared->u.compnd.nmembs & 0xffff; + for (i=0; ishared->u.compnd.nmembs; i++) { /* Name, multiple of eight bytes */ - HDstrcpy((char*)(*pp), dt->u.compnd.memb[i].name); - n = HDstrlen(dt->u.compnd.memb[i].name); + HDstrcpy((char*)(*pp), dt->shared->u.compnd.memb[i].name); + n = HDstrlen(dt->shared->u.compnd.memb[i].name); for (z=n+1; z%8; z++) (*pp)[z] = '\0'; *pp += z; /* Member offset */ - UINT32ENCODE(*pp, dt->u.compnd.memb[i].offset); + UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset); /* If we don't have any array fields, write out the old style * member information, for better backward compatibility @@ -686,7 +715,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) } /* end if */ /* Subtype */ - if (H5O_dtype_encode_helper(pp, dt->u.compnd.memb[i].type)<0) + if (H5O_dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type"); } break; @@ -695,58 +724,58 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) /* * Enumeration data types... */ - flags = dt->u.enumer.nmembs & 0xffff; + flags = dt->shared->u.enumer.nmembs & 0xffff; /* Parent type */ - if (H5O_dtype_encode_helper(pp, dt->parent)<0) + if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent data type"); /* Names, each a multiple of eight bytes */ - for (i=0; iu.enumer.nmembs; i++) { - HDstrcpy((char*)(*pp), dt->u.enumer.name[i]); - n = HDstrlen(dt->u.enumer.name[i]); + for (i=0; ishared->u.enumer.nmembs; i++) { + HDstrcpy((char*)(*pp), dt->shared->u.enumer.name[i]); + n = HDstrlen(dt->shared->u.enumer.name[i]); for (z=n+1; z%8; z++) (*pp)[z] = '\0'; *pp += z; } /* Values */ - HDmemcpy(*pp, dt->u.enumer.value, dt->u.enumer.nmembs * dt->parent->size); - *pp += dt->u.enumer.nmembs * dt->parent->size; + HDmemcpy(*pp, dt->shared->u.enumer.value, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); + *pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; case H5T_REFERENCE: - flags |= (dt->u.atomic.u.r.rtype & 0x0f); + flags |= (dt->shared->u.atomic.u.r.rtype & 0x0f); break; case H5T_STRING: /* * Character string types... (not fully implemented) */ - assert (dt->u.atomic.order == H5T_ORDER_NONE); - assert (dt->u.atomic.prec == 8 * dt->size); - assert (dt->u.atomic.offset == 0); - assert (dt->u.atomic.lsb_pad == H5T_PAD_ZERO); - assert (dt->u.atomic.msb_pad == H5T_PAD_ZERO); - - flags |= (dt->u.atomic.u.s.pad & 0x0f); - flags |= (dt->u.atomic.u.s.cset & 0x0f) << 4; + assert (dt->shared->u.atomic.order == H5T_ORDER_NONE); + assert (dt->shared->u.atomic.prec == 8 * dt->shared->size); + assert (dt->shared->u.atomic.offset == 0); + assert (dt->shared->u.atomic.lsb_pad == H5T_PAD_ZERO); + assert (dt->shared->u.atomic.msb_pad == H5T_PAD_ZERO); + + flags |= (dt->shared->u.atomic.u.s.pad & 0x0f); + flags |= (dt->shared->u.atomic.u.s.cset & 0x0f) << 4; break; case H5T_VLEN: /* Variable length datatypes... */ - flags |= (dt->u.vlen.type & 0x0f); - if(dt->u.vlen.type == H5T_VLEN_STRING) { - flags |= (dt->u.vlen.pad & 0x0f) << 4; - flags |= (dt->u.vlen.cset & 0x0f) << 8; + flags |= (dt->shared->u.vlen.type & 0x0f); + if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + flags |= (dt->shared->u.vlen.pad & 0x0f) << 4; + flags |= (dt->shared->u.vlen.cset & 0x0f) << 8; } /* end if */ /* Encode base type of VL information */ - if (H5O_dtype_encode_helper(pp, dt->parent)<0) + if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type"); break; case H5T_TIME: /* Time datatypes... */ - switch (dt->u.atomic.order) { + switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: break; /*nothing */ case H5T_ORDER_BE: @@ -755,15 +784,15 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet"); } - UINT16ENCODE(*pp, dt->u.atomic.prec); + UINT16ENCODE(*pp, dt->shared->u.atomic.prec); break; case H5T_ARRAY: /* Array datatypes... */ /* Double-check the number of dimensions */ - assert(dt->u.array.ndims <= H5S_MAX_RANK); + assert(dt->shared->u.array.ndims <= H5S_MAX_RANK); /* Encode the number of dimensions */ - *(*pp)++ = dt->u.array.ndims; + *(*pp)++ = dt->shared->u.array.ndims; /* Reserved */ *(*pp)++ = '\0'; @@ -771,15 +800,15 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) *(*pp)++ = '\0'; /* Encode array dimensions */ - for (j=0; j<(unsigned)dt->u.array.ndims; j++) - UINT32ENCODE(*pp, dt->u.array.dim[j]); + for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++) + UINT32ENCODE(*pp, dt->shared->u.array.dim[j]); /* Encode array dimension permutations */ - for (j=0; j<(unsigned)dt->u.array.ndims; j++) - UINT32ENCODE(*pp, dt->u.array.perm[j]); + for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++) + UINT32ENCODE(*pp, dt->shared->u.array.perm[j]); /* Encode base type of array's information */ - if (H5O_dtype_encode_helper(pp, dt->parent)<0) + if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type"); break; @@ -789,7 +818,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) } /* Encode the type's class, version and bit field */ - *hdr++ = ((unsigned)(dt->type) & 0x0f) | (((dt->type==H5T_COMPOUND && has_array) ? H5O_DTYPE_VERSION_UPDATED : H5O_DTYPE_VERSION_COMPAT )<<4); + *hdr++ = ((unsigned)(dt->shared->type) & 0x0f) | (((dt->shared->type==H5T_COMPOUND && has_array) ? H5O_DTYPE_VERSION_UPDATED : H5O_DTYPE_VERSION_COMPAT )<<4); *hdr++ = (flags >> 0) & 0xff; *hdr++ = (flags >> 8) & 0xff; *hdr++ = (flags >> 16) & 0xff; @@ -831,7 +860,11 @@ H5O_dtype_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, if (NULL==(dt = H5FL_CALLOC(H5T_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (NULL==(dt->shared=H5FL_CALLOC(H5T_shared_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); dt->ent.header = HADDR_UNDEF; + dt->shared->fo_count=1; + if (H5O_dtype_decode_helper(f, &p, dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type"); @@ -841,6 +874,8 @@ H5O_dtype_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, done: if(ret_value==NULL) { + if(dt->shared!=NULL) + H5FL_FREE(H5T_shared_t, dt->shared); if(dt!=NULL) H5FL_FREE(H5T_t,dt); } /* end if */ @@ -967,7 +1002,7 @@ H5O_dtype_size(H5F_t *f, const void *mesg) assert(mesg); /* Add in the property field length for each datatype class */ - switch (dt->type) { + switch (dt->shared->type) { case H5T_INTEGER: ret_value += 4; break; @@ -977,7 +1012,7 @@ H5O_dtype_size(H5F_t *f, const void *mesg) break; case H5T_OPAQUE: - ret_value += (HDstrlen(dt->u.opaque.tag)+7) & 0xf8; + ret_value += (HDstrlen(dt->shared->u.opaque.tag)+7) & 0xf8; break; case H5T_FLOAT: @@ -985,27 +1020,27 @@ H5O_dtype_size(H5F_t *f, const void *mesg) break; case H5T_COMPOUND: - for (i=0; iu.compnd.nmembs; i++) { - ret_value += ((HDstrlen(dt->u.compnd.memb[i].name) + 8) / 8) * 8; + for (i=0; ishared->u.compnd.nmembs; i++) { + ret_value += ((HDstrlen(dt->shared->u.compnd.memb[i].name) + 8) / 8) * 8; ret_value += 4 + /*member offset*/ 1 + /*dimensionality*/ 3 + /*reserved*/ 4 + /*permutation*/ 4 + /*reserved*/ 16; /*dimensions*/ - ret_value += H5O_dtype_size(f, dt->u.compnd.memb[i].type); + ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[i].type); } break; case H5T_ENUM: - ret_value += H5O_dtype_size(f, dt->parent); - for (i=0; iu.enumer.nmembs; i++) - ret_value += ((HDstrlen(dt->u.enumer.name[i])+8)/8)*8; - ret_value += dt->u.enumer.nmembs * dt->parent->size; + ret_value += H5O_dtype_size(f, dt->shared->parent); + for (i=0; ishared->u.enumer.nmembs; i++) + ret_value += ((HDstrlen(dt->shared->u.enumer.name[i])+8)/8)*8; + ret_value += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; break; case H5T_VLEN: - ret_value += H5O_dtype_size(f, dt->parent); + ret_value += H5O_dtype_size(f, dt->shared->parent); break; case H5T_TIME: @@ -1014,9 +1049,9 @@ H5O_dtype_size(H5F_t *f, const void *mesg) case H5T_ARRAY: ret_value += 4; /* ndims & reserved bytes*/ - ret_value += 4*dt->u.array.ndims; /* dimensions */ - ret_value += 4*dt->u.array.ndims; /* dimension permutations */ - ret_value += H5O_dtype_size(f, dt->parent); + ret_value += 4*dt->shared->u.array.ndims; /* dimensions */ + ret_value += 4*dt->shared->u.array.ndims; /* dimension permutations */ + ret_value += H5O_dtype_size(f, dt->shared->parent); break; default: @@ -1078,6 +1113,7 @@ H5O_dtype_free (void *mesg) assert (mesg); + H5FL_FREE(H5T_shared_t, ((H5T_t *) mesg)->shared); H5FL_FREE(H5T_t,mesg); FUNC_LEAVE_NOAPI(SUCCEED); @@ -1112,7 +1148,7 @@ H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg, assert (sh); if (H5F_addr_defined (dt->ent.header)) { - if(H5T_STATE_NAMED!=dt->state && H5T_STATE_OPEN!=dt->state && H5T_STATE_TRANSIENT!=dt->state) + if(H5T_STATE_NAMED!=dt->shared->state && H5T_STATE_OPEN!=dt->shared->state && H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "datatype state is not valid"); sh->in_gh = FALSE; @@ -1162,7 +1198,7 @@ H5O_dtype_set_share (H5F_t UNUSED *f, void *_mesg/*in,out*/, dt->ent.canon_path_r = NULL; /* Note that the datatype is a named datatype */ - dt->state = H5T_STATE_NAMED; + dt->shared->state = H5T_STATE_NAMED; FUNC_LEAVE_NOAPI(SUCCEED); } @@ -1206,7 +1242,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, assert(indent >= 0); assert(fwidth >= 0); - switch (dt->type) { + switch (dt->shared->type) { case H5T_INTEGER: s = "integer"; break; @@ -1241,7 +1277,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "vlen"; break; default: - sprintf(buf, "H5T_CLASS_%d", (int) (dt->type)); + sprintf(buf, "H5T_CLASS_%d", (int) (dt->shared->type)); s = buf; break; } @@ -1251,51 +1287,51 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, fprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth, "Size:", - (unsigned long)(dt->size), 1==dt->size?"":"s"); + (unsigned long)(dt->shared->size), 1==dt->shared->size?"":"s"); - if (H5T_COMPOUND == dt->type) { + if (H5T_COMPOUND == dt->shared->type) { fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Number of members:", - dt->u.compnd.nmembs); - for (i=0; iu.compnd.nmembs; i++) { + dt->shared->u.compnd.nmembs); + for (i=0; ishared->u.compnd.nmembs; i++) { sprintf(buf, "Member %d:", i); fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, - dt->u.compnd.memb[i].name); + dt->shared->u.compnd.memb[i].name); fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth-3), "Byte offset:", - (unsigned long) (dt->u.compnd.memb[i].offset)); - H5O_dtype_debug(f, dxpl_id, dt->u.compnd.memb[i].type, stream, + (unsigned long) (dt->shared->u.compnd.memb[i].offset)); + H5O_dtype_debug(f, dxpl_id, dt->shared->u.compnd.memb[i].type, stream, indent+3, MAX(0, fwidth - 3)); } - } else if (H5T_ENUM==dt->type) { + } else if (H5T_ENUM==dt->shared->type) { fprintf(stream, "%*s%s\n", indent, "", "Base type:"); - H5O_dtype_debug(f, dxpl_id, dt->parent, stream, indent+3, MAX(0, fwidth-3)); + H5O_dtype_debug(f, dxpl_id, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3)); fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Number of members:", - dt->u.enumer.nmembs); - for (i=0; iu.enumer.nmembs; i++) { + dt->shared->u.enumer.nmembs); + for (i=0; ishared->u.enumer.nmembs; i++) { sprintf(buf, "Member %d:", i); fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, - dt->u.enumer.name[i]); + dt->shared->u.enumer.name[i]); fprintf(stream, "%*s%-*s 0x", indent, "", fwidth, "Raw bytes of value:"); - for (k=0; kparent->size; k++) { + for (k=0; kshared->parent->shared->size; k++) { fprintf(stream, "%02x", - dt->u.enumer.value[i*dt->parent->size+k]); + dt->shared->u.enumer.value[i*dt->shared->parent->shared->size+k]); } fprintf(stream, "\n"); } - } else if (H5T_OPAQUE==dt->type) { + } else if (H5T_OPAQUE==dt->shared->type) { fprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth, - "Tag:", dt->u.opaque.tag); - } else if (H5T_REFERENCE==dt->type) { + "Tag:", dt->shared->u.opaque.tag); + } else if (H5T_REFERENCE==dt->shared->type) { fprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Fix dumping reference types!"); - } else if (H5T_VLEN==dt->type) { - switch (dt->u.vlen.type) { + } else if (H5T_VLEN==dt->shared->type) { + switch (dt->shared->u.vlen.type) { case H5T_VLEN_SEQUENCE: s = "sequence"; break; @@ -1303,14 +1339,14 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "string"; break; default: - sprintf(buf, "H5T_VLEN_%d", dt->u.vlen.type); + sprintf(buf, "H5T_VLEN_%d", dt->shared->u.vlen.type); s = buf; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Vlen type:", s); - switch (dt->u.vlen.loc) { + switch (dt->shared->u.vlen.loc) { case H5T_LOC_MEMORY: s = "memory"; break; @@ -1318,30 +1354,30 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "disk"; break; default: - sprintf(buf, "H5T_LOC_%d", dt->u.vlen.loc); + sprintf(buf, "H5T_LOC_%d", dt->shared->u.vlen.loc); s = buf; break; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Location:", s); - } else if (H5T_ARRAY==dt->type) { + } else if (H5T_ARRAY==dt->shared->type) { fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Rank:", - dt->u.array.ndims); + dt->shared->u.array.ndims); fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:"); - for (i=0; i<(unsigned)dt->u.array.ndims; i++) { - fprintf (stream, "%s%u", i?", ":"", (unsigned)dt->u.array.dim[i]); + for (i=0; i<(unsigned)dt->shared->u.array.ndims; i++) { + fprintf (stream, "%s%u", i?", ":"", (unsigned)dt->shared->u.array.dim[i]); } fprintf (stream, "}\n"); fprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Permutation:"); - for (i=0; i<(unsigned)dt->u.array.ndims; i++) { - fprintf (stream, "%s%d", i?", ":"", dt->u.array.perm[i]); + for (i=0; i<(unsigned)dt->shared->u.array.ndims; i++) { + fprintf (stream, "%s%d", i?", ":"", dt->shared->u.array.perm[i]); } fprintf (stream, "}\n"); fprintf(stream, "%*s%s\n", indent, "", "Base type:"); - H5O_dtype_debug(f, dxpl_id, dt->parent, stream, indent+3, MAX(0, fwidth-3)); + H5O_dtype_debug(f, dxpl_id, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3)); } else { - switch (dt->u.atomic.order) { + switch (dt->shared->u.atomic.order) { case H5T_ORDER_LE: s = "little endian"; break; @@ -1355,7 +1391,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "none"; break; default: - sprintf(buf, "H5T_ORDER_%d", dt->u.atomic.order); + sprintf(buf, "H5T_ORDER_%d", dt->shared->u.atomic.order); s = buf; break; } @@ -1365,15 +1401,15 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, fprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth, "Precision:", - (unsigned long)(dt->u.atomic.prec), - 1==dt->u.atomic.prec?"":"s"); + (unsigned long)(dt->shared->u.atomic.prec), + 1==dt->shared->u.atomic.prec?"":"s"); fprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth, "Offset:", - (unsigned long)(dt->u.atomic.offset), - 1==dt->u.atomic.offset?"":"s"); + (unsigned long)(dt->shared->u.atomic.offset), + 1==dt->shared->u.atomic.offset?"":"s"); - switch (dt->u.atomic.lsb_pad) { + switch (dt->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: s = "zero"; break; @@ -1387,7 +1423,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Low pad type:", s); - switch (dt->u.atomic.msb_pad) { + switch (dt->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: s = "zero"; break; @@ -1401,8 +1437,8 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "High pad type:", s); - if (H5T_FLOAT == dt->type) { - switch (dt->u.atomic.u.f.pad) { + if (H5T_FLOAT == dt->shared->type) { + switch (dt->shared->u.atomic.u.f.pad) { case H5T_PAD_ZERO: s = "zero"; break; @@ -1410,10 +1446,10 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "one"; break; default: - if (dt->u.atomic.u.f.pad < 0) { - sprintf(buf, "H5T_PAD_%d", -(dt->u.atomic.u.f.pad)); + if (dt->shared->u.atomic.u.f.pad < 0) { + sprintf(buf, "H5T_PAD_%d", -(dt->shared->u.atomic.u.f.pad)); } else { - sprintf(buf, "bit-%d", dt->u.atomic.u.f.pad); + sprintf(buf, "bit-%d", dt->shared->u.atomic.u.f.pad); } s = buf; break; @@ -1421,7 +1457,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Internal pad type:", s); - switch (dt->u.atomic.u.f.norm) { + switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_IMPLIED: s = "implied"; break; @@ -1432,7 +1468,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "none"; break; default: - sprintf(buf, "H5T_NORM_%d", (int) (dt->u.atomic.u.f.norm)); + sprintf(buf, "H5T_NORM_%d", (int) (dt->shared->u.atomic.u.f.norm)); s = buf; } fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, @@ -1440,30 +1476,30 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Sign bit location:", - (unsigned long) (dt->u.atomic.u.f.sign)); + (unsigned long) (dt->shared->u.atomic.u.f.sign)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Exponent location:", - (unsigned long) (dt->u.atomic.u.f.epos)); + (unsigned long) (dt->shared->u.atomic.u.f.epos)); fprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth, "Exponent bias:", - (unsigned long) (dt->u.atomic.u.f.ebias)); + (unsigned long) (dt->shared->u.atomic.u.f.ebias)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Exponent size:", - (unsigned long) (dt->u.atomic.u.f.esize)); + (unsigned long) (dt->shared->u.atomic.u.f.esize)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Mantissa location:", - (unsigned long) (dt->u.atomic.u.f.mpos)); + (unsigned long) (dt->shared->u.atomic.u.f.mpos)); fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth, "Mantissa size:", - (unsigned long) (dt->u.atomic.u.f.msize)); + (unsigned long) (dt->shared->u.atomic.u.f.msize)); - } else if (H5T_INTEGER == dt->type) { - switch (dt->u.atomic.u.i.sign) { + } else if (H5T_INTEGER == dt->shared->type) { + switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: s = "none"; break; @@ -1471,7 +1507,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "2's comp"; break; default: - sprintf(buf, "H5T_SGN_%d", (int) (dt->u.atomic.u.i.sign)); + sprintf(buf, "H5T_SGN_%d", (int) (dt->shared->u.atomic.u.i.sign)); s = buf; break; } diff --git a/src/H5R.c b/src/H5R.c index 3bbb5e5..ba699e8 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -324,8 +324,9 @@ done: static hid_t H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref) { + H5D_t *dset; /* Pointer to dataset to open */ + H5T_t *type; /* Pointer to datatype to open */ H5G_t *group; /* Pointer to group to open */ - H5T_t *datatype; /* Pointer to datatype to open */ H5G_entry_t ent; /* Symbol table entry */ uint8_t *p; /* Pointer to OID to store */ int oid_type; /* type of object being dereferenced */ @@ -389,14 +390,14 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref) if(H5O_link(&ent,0,dxpl_id)<=0) HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object"); - /* Open the dataset object */ + /* Open the object */ oid_type=H5G_get_type(&ent,dxpl_id); switch(oid_type) { case H5G_GROUP: - if ((group=H5G_open_oid(&ent,dxpl_id)) == NULL) + if ((group=H5G_open(&ent,dxpl_id)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found"); - /* Create an atom for the dataset */ + /* Create an atom for the group */ if ((ret_value = H5I_register(H5I_GROUP, group)) < 0) { H5G_close(group); HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "can't register group"); @@ -404,20 +405,26 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref) break; case H5G_TYPE: - if ((datatype=H5T_open_oid(&ent, dxpl_id)) == NULL) + if ((type=H5T_open(&ent, dxpl_id)) == NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found"); - /* Create an atom for the dataset */ - if ((ret_value = H5I_register(H5I_DATATYPE, datatype)) < 0) { - H5T_close(datatype); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "can't register group"); + /* Create an atom for the datatype */ + if ((ret_value = H5I_register(H5I_DATATYPE, type)) < 0) { + H5T_close(type); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "can't register datatype"); } break; case H5G_DATASET: /* Open the dataset */ - if ((ret_value=H5D_open(&ent,dxpl_id)) < 0) + if ((dset=H5D_open(&ent,dxpl_id)) <0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found"); + + /* Create an atom for the dataset */ + if ((ret_value = H5I_register(H5I_DATASET, dset)) < 0) { + H5D_close(dset); + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset"); + } break; default: diff --git a/src/H5T.c b/src/H5T.c index a8189e7..ed84c35 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -29,16 +29,17 @@ /* (Put before include files to avoid problems with inline functions) */ #define PABLO_MASK H5T_mask -#include "H5private.h" /*generic functions */ -#include "H5Dprivate.h" /*datasets (for H5Tcopy) */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Fpkg.h" /* File */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /*groups */ -#include "H5Iprivate.h" /*ID functions */ -#include "H5MMprivate.h" /*memory management */ -#include "H5Pprivate.h" /* Property Lists */ -#include "H5Tpkg.h" /*data-type functions */ +#include "H5private.h" /*generic functions */ +#include "H5Dprivate.h" /*datasets (for H5Tcopy) */ +#include "H5Eprivate.h" /*error handling */ +#include "H5Fpkg.h" /* File */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Gprivate.h" /*groups */ +#include "H5Iprivate.h" /*ID functions */ +#include "H5MMprivate.h" /*memory management */ +#include "H5Pprivate.h" /* Property Lists */ +#include "H5Tpkg.h" /*data-type functions */ /* Check for header needed for SGI floating-point code */ #ifdef H5_HAVE_SYS_FPU_H @@ -245,14 +246,15 @@ static struct { /* The native endianess of the platform */ H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR; -/* Declare the free list for H5T_t's */ +/* Declare the free list for H5T_t's and H5T_shared_t's */ H5FL_DEFINE(H5T_t); +H5FL_DEFINE(H5T_shared_t); /* Declare the free list for H5T_path_t's */ H5FL_DEFINE(H5T_path_t); /* Static local functions */ -static H5T_t *H5T_open(H5G_entry_t *loc, const char *name, hid_t dxpl_id); +static H5T_t *H5T_open_oid(H5G_entry_t *ent, hid_t dxpl_id); static herr_t H5T_print_stats(H5T_path_t *path, int *nprint/*in,out*/); static herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_t func, hid_t dxpl_id); @@ -279,38 +281,38 @@ static H5T_t *H5T_decode(const unsigned char *buf); /* Define the code template for bitfields for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_BITFIELD_CORE { \ - dt->type = H5T_BITFIELD; \ + dt->shared->type = H5T_BITFIELD; \ } /* Define the code template for times for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_TIME_CORE { \ - dt->type = H5T_TIME; \ + dt->shared->type = H5T_TIME; \ } /* Define the code template for types which reset the offset for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_OFFSET_CORE { \ - dt->u.atomic.offset = 0; \ + dt->shared->u.atomic.offset = 0; \ } /* Define common code for all numeric types (floating-point & int, signed & unsigned) */ #define H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) { \ - dt->u.atomic.order = ENDIANNESS; \ - dt->u.atomic.offset = 0; \ - dt->u.atomic.lsb_pad = H5T_PAD_ZERO; \ - dt->u.atomic.msb_pad = H5T_PAD_ZERO; \ + dt->shared->u.atomic.order = ENDIANNESS; \ + dt->shared->u.atomic.offset = 0; \ + dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; \ + dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; \ } /* Define the code templates for standard floats for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_FLOAT_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->u.atomic.u.f.sign = 31; \ - dt->u.atomic.u.f.epos = 23; \ - dt->u.atomic.u.f.esize = 8; \ - dt->u.atomic.u.f.ebias = 0x7f; \ - dt->u.atomic.u.f.mpos = 0; \ - dt->u.atomic.u.f.msize = 23; \ - dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + dt->shared->u.atomic.u.f.sign = 31; \ + dt->shared->u.atomic.u.f.epos = 23; \ + dt->shared->u.atomic.u.f.esize = 8; \ + dt->shared->u.atomic.u.f.ebias = 0x7f; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 23; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ } #define H5T_INIT_TYPE_FLOATLE_CORE { \ @@ -324,14 +326,14 @@ static H5T_t *H5T_decode(const unsigned char *buf); /* Define the code templates for standard doubles for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_DOUBLE_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->u.atomic.u.f.sign = 63; \ - dt->u.atomic.u.f.epos = 52; \ - dt->u.atomic.u.f.esize = 11; \ - dt->u.atomic.u.f.ebias = 0x03ff; \ - dt->u.atomic.u.f.mpos = 0; \ - dt->u.atomic.u.f.msize = 52; \ - dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ - dt->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + dt->shared->u.atomic.u.f.sign = 63; \ + dt->shared->u.atomic.u.f.epos = 52; \ + dt->shared->u.atomic.u.f.esize = 11; \ + dt->shared->u.atomic.u.f.ebias = 0x03ff; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 52; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ } #define H5T_INIT_TYPE_DOUBLELE_CORE { \ @@ -345,7 +347,7 @@ static H5T_t *H5T_decode(const unsigned char *buf); /* Define the code templates for standard signed integers for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_SINT_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->u.atomic.u.i.sign = H5T_SGN_2; \ + dt->shared->u.atomic.u.i.sign = H5T_SGN_2; \ } #define H5T_INIT_TYPE_SINTLE_CORE { \ @@ -359,7 +361,7 @@ static H5T_t *H5T_decode(const unsigned char *buf); /* Define the code templates for standard unsigned integers for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_UINT_COMMON(ENDIANNESS) { \ H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ - dt->u.atomic.u.i.sign = H5T_SGN_NONE; \ + dt->shared->u.atomic.u.i.sign = H5T_SGN_NONE; \ } #define H5T_INIT_TYPE_UINTLE_CORE { \ @@ -373,30 +375,30 @@ static H5T_t *H5T_decode(const unsigned char *buf); /* Define a macro for common code for all newly allocate datatypes */ #define H5T_INIT_TYPE_ALLOC_COMMON(TYPE) { \ dt->ent.header = HADDR_UNDEF; \ - dt->type = TYPE; \ + dt->shared->type = TYPE; \ } /* Define the code templates for opaque for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_OPAQ_CORE { \ H5T_INIT_TYPE_ALLOC_COMMON(H5T_OPAQUE) \ - dt->u.opaque.tag = H5MM_strdup(""); \ + dt->shared->u.opaque.tag = H5MM_strdup(""); \ } /* Define the code templates for strings for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_STRING_COMMON { \ H5T_INIT_TYPE_ALLOC_COMMON(H5T_STRING) \ H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ - dt->u.atomic.u.s.cset = H5T_CSET_ASCII; \ + dt->shared->u.atomic.u.s.cset = H5T_CSET_ASCII; \ } #define H5T_INIT_TYPE_CSTRING_CORE { \ H5T_INIT_TYPE_STRING_COMMON \ - dt->u.atomic.u.s.pad = H5T_STR_NULLTERM; \ + dt->shared->u.atomic.u.s.pad = H5T_STR_NULLTERM; \ } #define H5T_INIT_TYPE_FORSTRING_CORE { \ H5T_INIT_TYPE_STRING_COMMON \ - dt->u.atomic.u.s.pad = H5T_STR_SPACEPAD; \ + dt->shared->u.atomic.u.s.pad = H5T_STR_SPACEPAD; \ } /* Define the code templates for references for the "GUTS" in the H5T_INIT_TYPE macro */ @@ -407,20 +409,20 @@ static H5T_t *H5T_decode(const unsigned char *buf); #define H5T_INIT_TYPE_OBJREF_CORE { \ H5T_INIT_TYPE_REF_COMMON \ - dt->force_conv = TRUE; \ - dt->u.atomic.u.r.rtype = H5R_OBJECT; \ - dt->u.atomic.u.r.loc = H5T_LOC_MEMORY; \ + dt->shared->force_conv = TRUE; \ + dt->shared->u.atomic.u.r.rtype = H5R_OBJECT; \ + dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY; \ } #define H5T_INIT_TYPE_REGREF_CORE { \ H5T_INIT_TYPE_REF_COMMON \ - dt->u.atomic.u.r.rtype = H5R_DATASET_REGION; \ + dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION; \ } /* Define the code templates for the "SIZE_TMPL" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_SET_SIZE(SIZE) { \ - dt->size = SIZE; \ - dt->u.atomic.prec = 8*SIZE; \ + dt->shared->size = SIZE; \ + dt->shared->u.atomic.prec = 8*SIZE; \ } #define H5T_INIT_TYPE_NOSET_SIZE(SIZE) { \ @@ -437,14 +439,20 @@ static H5T_t *H5T_decode(const unsigned char *buf); /* Allocate new datatype info */ \ if (NULL==(dt = H5FL_CALLOC(H5T_t))) \ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") \ + if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t))) { \ + H5FL_FREE(H5T_t, dt); \ + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") \ + } \ + dt->shared->fo_count=1; \ } + #define H5T_INIT_TYPE(GUTS,GLOBAL,CRT_TMPL,BASE,SIZE_TMPL,SIZE) { \ /* Get new datatype struct */ \ H5_GLUE3(H5T_INIT_TYPE_,CRT_TMPL,_CREATE)(BASE) \ \ /* Adjust information for all types */ \ - dt->state = H5T_STATE_IMMUTABLE; \ + dt->shared->state = H5T_STATE_IMMUTABLE; \ H5_GLUE3(H5T_INIT_TYPE_,SIZE_TMPL,_SIZE)(SIZE) \ \ /* Adjust information for this type */ \ @@ -517,7 +525,7 @@ H5T_init_inf(void) /* Get the float datatype */ if (NULL==(dst_p=H5I_object(H5T_NATIVE_FLOAT_g))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - dst = &dst_p->u.atomic; + dst = &dst_p->shared->u.atomic; /* Check that we can re-order the bytes correctly */ if (H5T_ORDER_LE!=H5T_native_order_g && H5T_ORDER_BE!=H5T_native_order_g) @@ -531,10 +539,10 @@ H5T_init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==H5T_native_order_g) { - half_size = dst_p->size/2; + half_size = dst_p->shared->size/2; for (u=0; usize-(u+1)]; - d[dst_p->size-(u+1)] = d[u]; + uint8_t tmp = d[dst_p->shared->size-(u+1)]; + d[dst_p->shared->size-(u+1)] = d[u]; d[u] = tmp; } } @@ -547,10 +555,10 @@ H5T_init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==H5T_native_order_g) { - half_size = dst_p->size/2; + half_size = dst_p->shared->size/2; for (u=0; usize-(u+1)]; - d[dst_p->size-(u+1)] = d[u]; + uint8_t tmp = d[dst_p->shared->size-(u+1)]; + d[dst_p->shared->size-(u+1)] = d[u]; d[u] = tmp; } } @@ -558,7 +566,7 @@ H5T_init_inf(void) /* Get the double datatype */ if (NULL==(dst_p=H5I_object(H5T_NATIVE_DOUBLE_g))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); - dst = &dst_p->u.atomic; + dst = &dst_p->shared->u.atomic; /* Check that we can re-order the bytes correctly */ if (H5T_ORDER_LE!=H5T_native_order_g && H5T_ORDER_BE!=H5T_native_order_g) @@ -572,10 +580,10 @@ H5T_init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==H5T_native_order_g) { - half_size = dst_p->size/2; + half_size = dst_p->shared->size/2; for (u=0; usize-(u+1)]; - d[dst_p->size-(u+1)] = d[u]; + uint8_t tmp = d[dst_p->shared->size-(u+1)]; + d[dst_p->shared->size-(u+1)] = d[u]; d[u] = tmp; } } @@ -588,10 +596,10 @@ H5T_init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==H5T_native_order_g) { - half_size = dst_p->size/2; + half_size = dst_p->shared->size/2; for (u=0; usize-(u+1)]; - d[dst_p->size-(u+1)] = d[u]; + uint8_t tmp = d[dst_p->shared->size-(u+1)]; + d[dst_p->shared->size-(u+1)] = d[u]; d[u] = tmp; } } @@ -1202,7 +1210,10 @@ done: if(copied_dtype) H5T_close(dt); else + { + H5FL_FREE(H5T_shared_t, dt->shared); H5FL_FREE(H5T_t,dt); + } } /* end if */ } /* end if */ @@ -1234,8 +1245,8 @@ H5T_unlock_cb (void *_dt, hid_t UNUSED id, void UNUSED *key) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_unlock_cb); assert (dt); - if (H5T_STATE_IMMUTABLE==dt->state) - dt->state = H5T_STATE_RDONLY; + if (H5T_STATE_IMMUTABLE==dt->shared->state) + dt->shared->state = H5T_STATE_RDONLY; FUNC_LEAVE_NOAPI(SUCCEED); } @@ -1478,26 +1489,35 @@ done: hid_t H5Topen(hid_t loc_id, const char *name) { + H5T_t *type = NULL; H5G_entry_t *loc = NULL; - H5T_t *type = NULL; - hid_t ret_value; + H5G_entry_t ent; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ + hid_t ret_value =FAIL; FUNC_ENTER_API(H5Topen, FAIL); H5TRACE2("i","is",loc_id,name); /* Check args */ if (NULL==(loc=H5G_loc (loc_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); if (!name || !*name) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + + /* + * Find the named data type object header and read the data type message + * from it. + */ + if (H5G_find (loc, name, NULL, &ent/*out*/, dxpl_id)<0) + HGOTO_ERROR (H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found"); /* Open it */ - if (NULL==(type=H5T_open (loc, name, H5AC_dxpl_id))) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named data type"); + if ((type=H5T_open (&ent, dxpl_id)) ==NULL) + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named data type"); /* Register the type and return the ID */ if ((ret_value=H5I_register (H5I_DATATYPE, type))<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named data type"); + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named data type"); done: if(ret_value<0) { @@ -1607,7 +1627,7 @@ H5Tclose(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (H5T_STATE_IMMUTABLE==dt->state) + if (H5T_STATE_IMMUTABLE==dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable data type"); /* When the reference count reaches zero the resources are freed */ @@ -1695,7 +1715,7 @@ H5Tlock(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (H5T_STATE_NAMED==dt->state || H5T_STATE_OPEN==dt->state) + if (H5T_STATE_NAMED==dt->shared->state || H5T_STATE_OPEN==dt->shared->state) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to lock named data type"); if (H5T_lock (dt, TRUE)<0) @@ -1772,10 +1792,10 @@ H5T_get_class(const H5T_t *dt) assert(dt); /* Lie to the user if they have a VL string and tell them it's in the string class */ - if(dt->type==H5T_VLEN && dt->u.vlen.type==H5T_VLEN_STRING) + if(dt->shared->type==H5T_VLEN && dt->shared->u.vlen.type==H5T_VLEN_STRING) ret_value=H5T_STRING; else - ret_value=dt->type; + ret_value=dt->shared->type; done: FUNC_LEAVE_NOAPI(ret_value); @@ -1847,22 +1867,22 @@ H5T_detect_class (const H5T_t *dt, H5T_class_t cls) assert(cls>H5T_NO_CLASS && clstype==cls) + if(dt->shared->type==cls) HGOTO_DONE(TRUE); /* check for types that might have the correct type as a component */ - switch(dt->type) { + switch(dt->shared->type) { case H5T_COMPOUND: - for (i=0; iu.compnd.nmembs; i++) { + for (i=0; ishared->u.compnd.nmembs; i++) { htri_t nested_ret; /* Return value from nested call */ /* Check if this field's type is the correct type */ - if(dt->u.compnd.memb[i].type->type==cls) + if(dt->shared->u.compnd.memb[i].type->shared->type==cls) HGOTO_DONE(TRUE); /* Recurse if it's VL, compound, enum or array */ - if(H5T_IS_COMPLEX(dt->u.compnd.memb[i].type->type)) - if((nested_ret=H5T_detect_class(dt->u.compnd.memb[i].type,cls))!=FALSE) + if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) + if((nested_ret=H5T_detect_class(dt->shared->u.compnd.memb[i].type,cls))!=FALSE) HGOTO_DONE(nested_ret); } /* end for */ break; @@ -1870,7 +1890,7 @@ H5T_detect_class (const H5T_t *dt, H5T_class_t cls) case H5T_ARRAY: case H5T_VLEN: case H5T_ENUM: - HGOTO_DONE(H5T_detect_class(dt->parent,cls)); + HGOTO_DONE(H5T_detect_class(dt->shared->parent,cls)); default: break; @@ -1909,7 +1929,7 @@ H5Tis_variable_str(hid_t dtype_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Set return value */ - ret_value=H5T_IS_VL_STRING(dt); + ret_value=H5T_IS_VL_STRING(dt->shared); done: FUNC_LEAVE_API(ret_value); @@ -1995,15 +2015,15 @@ H5Tset_size(hid_t type_id, size_t size) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only"); if (size <= 0 && size!=H5T_VARIABLE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive"); - if (size == H5T_VARIABLE && dt->type!=H5T_STRING) + if (size == H5T_VARIABLE && dt->shared->type!=H5T_STRING) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "only strings may be variable length"); - if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) + if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined"); - if (H5T_REFERENCE==dt->type) + if (H5T_REFERENCE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for this datatype"); /* Do the work */ @@ -2085,9 +2105,9 @@ H5T_get_super(H5T_t *dt) assert(dt); - if (!dt->parent) + if (!dt->shared->parent) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type"); - if (NULL==(ret_value=H5T_copy(dt->parent, H5T_COPY_ALL))) + if (NULL==(ret_value=H5T_copy(dt->shared->parent, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type"); done: @@ -2169,8 +2189,8 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, } /* end if */ HDstrncpy (H5T_g.soft[H5T_g.nsoft].name, name, H5T_NAMELEN); H5T_g.soft[H5T_g.nsoft].name[H5T_NAMELEN-1] = '\0'; - H5T_g.soft[H5T_g.nsoft].src = src->type; - H5T_g.soft[H5T_g.nsoft].dst = dst->type; + H5T_g.soft[H5T_g.nsoft].src = src->shared->type; + H5T_g.soft[H5T_g.nsoft].dst = dst->shared->type; H5T_g.soft[H5T_g.nsoft].func = func; H5T_g.nsoft++; @@ -2185,8 +2205,8 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, /* Does the new soft conversion function apply to this path? */ if (old_path->is_hard || - old_path->src->type!=src->type || - old_path->dst->type!=dst->type) { + old_path->src->shared->type!=src->shared->type || + old_path->dst->shared->type!=dst->shared->type) { continue; } if ((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL)))<0 || @@ -2353,8 +2373,8 @@ H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, soft = H5T_g.soft+i; assert(soft); if (name && *name && HDstrcmp(name, soft->name)) continue; - if (src && src->type!=soft->src) continue; - if (dst && dst->type!=soft->dst) continue; + if (src && src->shared->type!=soft->src) continue; + if (dst && dst->shared->type!=soft->dst) continue; if (func && func!=soft->func) continue; HDmemmove(H5T_g.soft+i, H5T_g.soft+i+1, @@ -2790,13 +2810,16 @@ H5T_create(H5T_class_t type, size_t size) case H5T_COMPOUND: if (NULL==(dt = H5FL_CALLOC(H5T_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - dt->type = type; + if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + dt->shared->type = type; + if(type==H5T_COMPOUND) - dt->u.compnd.packed=TRUE; /* Start out packed */ + dt->shared->u.compnd.packed=TRUE; /* Start out packed */ else if(type==H5T_OPAQUE) /* Initialize the tag in case it's not set later. A null tag will * cause problems for later operations. */ - dt->u.opaque.tag = H5MM_strdup(""); + dt->shared->u.opaque.tag = H5MM_strdup(""); break; case H5T_ENUM: @@ -2815,8 +2838,10 @@ H5T_create(H5T_class_t type, size_t size) } if (NULL==(dt = H5FL_CALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - dt->type = type; - if (NULL==(dt->parent=H5T_copy(H5I_object(subtype), H5T_COPY_ALL))) + if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + dt->shared->type = type; + if (NULL==(dt->shared->parent=H5T_copy(H5I_object(subtype), H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy base data type"); break; @@ -2831,13 +2856,16 @@ H5T_create(H5T_class_t type, size_t size) } dt->ent.header = HADDR_UNDEF; - dt->size = size; + dt->shared->fo_count = 1; + dt->shared->size = size; /* Set return value */ ret_value=dt; done: if(ret_value==NULL) { + if(dt->shared != NULL) + H5FL_FREE(H5T_shared_t, dt->shared); if(dt!=NULL) H5FL_FREE(H5T_t,dt); } /* end if */ @@ -2898,37 +2926,61 @@ done: * *------------------------------------------------------------------------- */ -static H5T_t * -H5T_open (H5G_entry_t *loc, const char *name, hid_t dxpl_id) +H5T_t* +H5T_open (H5G_entry_t *ent, hid_t dxpl_id) { - H5T_t *dt; - H5G_entry_t ent; - H5T_t *ret_value; + H5T_shared_t *shared_fo; + H5T_t *dt; + H5T_t *ret_value; FUNC_ENTER_NOAPI(H5T_open, NULL); - assert (loc); - assert (name && *name); + assert (ent); - /* - * Find the named data type object header and read the data type message - * from it. - */ - if (H5G_find (loc, name, NULL, &ent/*out*/, dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found"); + /* Check if datatype was already open */ + if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) { + /* Clear any errors from H5FO_opened() */ + H5E_clear_stack(NULL); - /* Open the datatype object */ - if ((dt=H5T_open_oid(&ent, dxpl_id)) ==NULL) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found"); + /* Open the datatype object */ + if ((dt=H5T_open_oid(ent, dxpl_id)) ==NULL) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found"); - /* Mark any datatypes as being in memory now */ - if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") - - /* Set return value */ - ret_value=dt; + /* Add the datatype to the list of opened objects in the file */ + if(H5FO_insert(ent->file, ent->header, dt->shared)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") + + /* Mark any datatypes as being in memory now */ + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") + + dt->shared->fo_count=1; + } + else + { + if(NULL == (dt = H5FL_CALLOC(H5T_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") + + dt->shared=shared_fo; + + /* Shallow copy (take ownership) of the group entry object */ + if(H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW)<0) + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy group entry") + + shared_fo->fo_count++; + } + + ret_value = dt; done: + if(ret_value==NULL) { + if(dt) { + if(shared_fo==NULL) { /* Need to free shared fo */ + H5FL_FREE(H5T_shared_t, dt->shared); + } + H5FL_FREE(H5T_t, dt); + } + } FUNC_LEAVE_NOAPI(ret_value); } @@ -2959,13 +3011,19 @@ H5T_open_oid (H5G_entry_t *ent, hid_t dxpl_id) assert (ent); + if(NULL==(dt=H5FL_CALLOC(H5T_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if(NULL==(dt->shared=H5FL_MALLOC(H5T_shared_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (H5O_open (ent)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named data type"); - if (NULL==(dt=H5O_read (ent, H5O_DTYPE_ID, 0, NULL, dxpl_id))) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header"); + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named data type"); + /* The fourth argument to H5O_read is dt because we've already CALLOC'ed memory for it */ + if (NULL==(dt=H5O_read (ent, H5O_DTYPE_ID, 0, dt, dxpl_id))) + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header"); /* Mark the type as named and open */ - dt->state = H5T_STATE_OPEN; + dt->shared->state = H5T_STATE_OPEN; /* Shallow copy (take ownership) of the group entry object */ H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW); @@ -3022,6 +3080,7 @@ H5T_t * H5T_copy(const H5T_t *old_dt, H5T_copy_t method) { H5T_t *new_dt=NULL, *tmp=NULL; + H5T_shared_t *reopened_fo; unsigned i; char *s; H5T_t *ret_value; @@ -3034,13 +3093,17 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) /* Allocate space */ if (NULL==(new_dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if (NULL==(new_dt->shared = H5FL_MALLOC(H5T_shared_t))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Copy actual information */ - *new_dt = *old_dt; + new_dt->ent = old_dt->ent; + *(new_dt->shared) = *(old_dt->shared); + new_dt->shared->fo_count = 1; /* Copy parent information */ - if (new_dt->parent) - new_dt->parent = H5T_copy(new_dt->parent, method); + if (new_dt->shared->parent) + new_dt->shared->parent = H5T_copy(new_dt->shared->parent, method); /* Check what sort of copy we are making */ switch (method) { @@ -3048,7 +3111,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) /* * Return an unlocked transient type. */ - new_dt->state = H5T_STATE_TRANSIENT; + new_dt->shared->state = H5T_STATE_TRANSIENT; HDmemset (&(new_dt->ent), 0, sizeof(new_dt->ent)); new_dt->ent.header = HADDR_UNDEF; break; @@ -3058,10 +3121,10 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * Return a transient type (locked or unlocked) or an unopened named * type. Immutable transient types are degraded to read-only. */ - if (H5T_STATE_OPEN==new_dt->state) { - new_dt->state = H5T_STATE_NAMED; - } else if (H5T_STATE_IMMUTABLE==new_dt->state) { - new_dt->state = H5T_STATE_RDONLY; + if (H5T_STATE_OPEN==new_dt->shared->state) { + new_dt->shared->state = H5T_STATE_NAMED; + } else if (H5T_STATE_IMMUTABLE==new_dt->shared->state) { + new_dt->shared->state = H5T_STATE_RDONLY; } break; @@ -3071,16 +3134,31 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * type. Immutable transient types are degraded to read-only. */ if (H5F_addr_defined(new_dt->ent.header)) { - if (H5O_open (&(new_dt->ent))<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type"); - new_dt->state = H5T_STATE_OPEN; - } else if (H5T_STATE_IMMUTABLE==new_dt->state) { - new_dt->state = H5T_STATE_RDONLY; + /* Check if the object is already open */ + if((reopened_fo=H5FO_opened(new_dt->ent.file,new_dt->ent.header))==NULL) { + /* Clear any errors from H5FO_opened() */ + H5E_clear_stack(NULL); + if (H5O_open (&(new_dt->ent))<0) + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type"); + if(H5FO_insert(new_dt->ent.file, new_dt->ent.header,new_dt->shared)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects") + new_dt->shared->fo_count=1; + } else { + /* The object is already open. Free the H5T_shared_t struct + * we had been using and use the one that already exists. + * Not terribly efficient. */ + H5FL_FREE(H5T_shared_t, new_dt->shared); + new_dt->shared = reopened_fo; + reopened_fo->fo_count++; + } + new_dt->shared->state = H5T_STATE_OPEN; + } else if (H5T_STATE_IMMUTABLE==new_dt->shared->state) { + new_dt->shared->state = H5T_STATE_RDONLY; } break; } /* end switch */ - switch(new_dt->type) { + switch(new_dt->shared->type) { case H5T_COMPOUND: { int accum_change=0; /* Amount of change in the offset of the fields */ @@ -3090,29 +3168,29 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * name and type fields of each new member with copied values. * That is, H5T_copy() is a deep copy. */ - new_dt->u.compnd.memb = H5MM_malloc(new_dt->u.compnd.nalloc * + new_dt->shared->u.compnd.memb = H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)); - if (NULL==new_dt->u.compnd.memb) + if (NULL==new_dt->shared->u.compnd.memb) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb, - new_dt->u.compnd.nmembs * sizeof(H5T_cmemb_t)); + HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb, + new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t)); - for (i=0; iu.compnd.nmembs; i++) { + for (i=0; ishared->u.compnd.nmembs; i++) { unsigned j; int old_match; - s = new_dt->u.compnd.memb[i].name; - new_dt->u.compnd.memb[i].name = H5MM_xstrdup(s); - tmp = H5T_copy (old_dt->u.compnd.memb[i].type, method); - new_dt->u.compnd.memb[i].type = tmp; + s = new_dt->shared->u.compnd.memb[i].name; + new_dt->shared->u.compnd.memb[i].name = H5MM_xstrdup(s); + tmp = H5T_copy (old_dt->shared->u.compnd.memb[i].type, method); + new_dt->shared->u.compnd.memb[i].type = tmp; /* Apply the accumulated size change to the offset of the field */ - new_dt->u.compnd.memb[i].offset += accum_change; + new_dt->shared->u.compnd.memb[i].offset += accum_change; - if(old_dt->u.compnd.sorted != H5T_SORT_VALUE) { - for (old_match=-1, j=0; ju.compnd.nmembs; j++) { - if(!HDstrcmp(new_dt->u.compnd.memb[i].name,old_dt->u.compnd.memb[j].name)) { + if(old_dt->shared->u.compnd.sorted != H5T_SORT_VALUE) { + for (old_match=-1, j=0; jshared->u.compnd.nmembs; j++) { + if(!HDstrcmp(new_dt->shared->u.compnd.memb[i].name,old_dt->shared->u.compnd.memb[j].name)) { old_match=j; break; } /* end if */ @@ -3127,16 +3205,16 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) } /* end else */ /* If the field changed size, add that change to the accumulated size change */ - if(new_dt->u.compnd.memb[i].type->size != old_dt->u.compnd.memb[old_match].type->size) { + if(new_dt->shared->u.compnd.memb[i].type->shared->size != old_dt->shared->u.compnd.memb[old_match].type->shared->size) { /* Adjust the size of the member */ - new_dt->u.compnd.memb[i].size = (old_dt->u.compnd.memb[old_match].size*tmp->size)/old_dt->u.compnd.memb[old_match].type->size; + new_dt->shared->u.compnd.memb[i].size = (old_dt->shared->u.compnd.memb[old_match].size*tmp->shared->size)/old_dt->shared->u.compnd.memb[old_match].type->shared->size; - accum_change += (new_dt->u.compnd.memb[i].type->size - old_dt->u.compnd.memb[old_match].type->size); + accum_change += (new_dt->shared->u.compnd.memb[i].type->shared->size - old_dt->shared->u.compnd.memb[old_match].type->shared->size); } /* end if */ } /* end for */ /* Apply the accumulated size change to the size of the compound struct */ - new_dt->size += accum_change; + new_dt->shared->size += accum_change; } break; @@ -3147,17 +3225,17 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) * of each new member with copied values. That is, H5T_copy() is a * deep copy. */ - new_dt->u.enumer.name = H5MM_malloc(new_dt->u.enumer.nalloc * + new_dt->shared->u.enumer.name = H5MM_malloc(new_dt->shared->u.enumer.nalloc * sizeof(char*)); - new_dt->u.enumer.value = H5MM_malloc(new_dt->u.enumer.nalloc * - new_dt->size); - if (NULL==new_dt->u.enumer.value) + new_dt->shared->u.enumer.value = H5MM_malloc(new_dt->shared->u.enumer.nalloc * + new_dt->shared->size); + if (NULL==new_dt->shared->u.enumer.value) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - HDmemcpy(new_dt->u.enumer.value, old_dt->u.enumer.value, - new_dt->u.enumer.nmembs * new_dt->size); - for (i=0; iu.enumer.nmembs; i++) { - s = old_dt->u.enumer.name[i]; - new_dt->u.enumer.name[i] = H5MM_xstrdup(s); + HDmemcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value, + new_dt->shared->u.enumer.nmembs * new_dt->shared->size); + for (i=0; ishared->u.enumer.nmembs; i++) { + s = old_dt->shared->u.enumer.name[i]; + new_dt->shared->u.enumer.name[i] = H5MM_xstrdup(s); } break; @@ -3174,12 +3252,12 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) /* * Copy the tag name. */ - new_dt->u.opaque.tag = HDstrdup(new_dt->u.opaque.tag); + new_dt->shared->u.opaque.tag = HDstrdup(new_dt->shared->u.opaque.tag); break; case H5T_ARRAY: /* Re-compute the array's size, in case it's base type changed size */ - new_dt->size=new_dt->u.array.nelem*new_dt->parent->size; + new_dt->shared->size=new_dt->shared->u.array.nelem*new_dt->shared->parent->shared->size; break; default: @@ -3195,6 +3273,8 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) done: if(ret_value==NULL) { + if(new_dt->shared != NULL) + H5FL_FREE(H5T_shared_t, new_dt->shared); if(new_dt!=NULL) H5FL_FREE (H5T_t,new_dt); } /* end if */ @@ -3230,12 +3310,12 @@ H5T_lock (H5T_t *dt, hbool_t immutable) FUNC_ENTER_NOAPI(H5T_lock, FAIL); assert (dt); - switch (dt->state) { + switch (dt->shared->state) { case H5T_STATE_TRANSIENT: - dt->state = immutable ? H5T_STATE_IMMUTABLE : H5T_STATE_RDONLY; + dt->shared->state = immutable ? H5T_STATE_IMMUTABLE : H5T_STATE_RDONLY; break; case H5T_STATE_RDONLY: - if (immutable) dt->state = H5T_STATE_IMMUTABLE; + if (immutable) dt->shared->state = H5T_STATE_IMMUTABLE; break; case H5T_STATE_IMMUTABLE: case H5T_STATE_NAMED: @@ -3253,7 +3333,8 @@ done: * Function: H5T_free * * Purpose: Frees all memory associated with a datatype, but does not - * free the H5T_t structure (which should be done in H5T_close). + * free the H5T_t or H5D_shared_t structures (which should + * be done in H5T_close). * * Return: Non-negative on success/Negative on failure * @@ -3272,43 +3353,46 @@ H5T_free(H5T_t *dt) FUNC_ENTER_NOAPI(H5T_free, FAIL); - assert(dt); + assert(dt && dt->shared); /* - * If a named type is being closed then close the object header also. + * If a named type is being closed then close the object header and + * remove from the list of open objects in the file. */ - if (H5T_STATE_OPEN==dt->state) { - assert (H5F_addr_defined(dt->ent.header)); - if (H5O_close(&(dt->ent))<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header"); - dt->state = H5T_STATE_NAMED; + if (H5T_STATE_OPEN==dt->shared->state) { + assert (H5F_addr_defined(dt->ent.header)); + if(H5FO_delete(dt->ent.file, H5AC_dxpl_id, dt->ent.header)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't remove datatype from list of open objects") + if (H5O_close(&(dt->ent))<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header"); + dt->shared->state = H5T_STATE_NAMED; } /* * Don't free locked datatypes. */ - if (H5T_STATE_IMMUTABLE==dt->state) + if (H5T_STATE_IMMUTABLE==dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close immutable datatype"); /* Close the datatype */ - switch (dt->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - for (i=0; iu.compnd.nmembs; i++) { - H5MM_xfree(dt->u.compnd.memb[i].name); - H5T_close(dt->u.compnd.memb[i].type); + for (i=0; ishared->u.compnd.nmembs; i++) { + H5MM_xfree(dt->shared->u.compnd.memb[i].name); + H5T_close(dt->shared->u.compnd.memb[i].type); } - H5MM_xfree(dt->u.compnd.memb); + H5MM_xfree(dt->shared->u.compnd.memb); break; case H5T_ENUM: - for (i=0; iu.enumer.nmembs; i++) - H5MM_xfree(dt->u.enumer.name[i]); - H5MM_xfree(dt->u.enumer.name); - H5MM_xfree(dt->u.enumer.value); + for (i=0; ishared->u.enumer.nmembs; i++) + H5MM_xfree(dt->shared->u.enumer.name[i]); + H5MM_xfree(dt->shared->u.enumer.name); + H5MM_xfree(dt->shared->u.enumer.value); break; case H5T_OPAQUE: - H5MM_xfree(dt->u.opaque.tag); + H5MM_xfree(dt->shared->u.opaque.tag); break; default: @@ -3319,7 +3403,7 @@ H5T_free(H5T_t *dt) H5G_free_ent_name(&(dt->ent)); /* Close the parent */ - if (dt->parent && H5T_close(dt->parent)<0) + if (dt->shared->parent && H5T_close(dt->shared->parent)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close parent data type"); done: @@ -3360,13 +3444,20 @@ H5T_close(H5T_t *dt) FUNC_ENTER_NOAPI(H5T_close, FAIL); - assert(dt); + assert(dt && dt->shared); - if(H5T_free(dt)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); + if(dt->shared->state != H5T_STATE_OPEN || dt->shared->fo_count == 1) + { + if(H5T_free(dt)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); - /* Free the datatype struct */ - H5FL_FREE(H5T_t,dt); + H5FL_FREE(H5T_shared_t, dt->shared); + } else { + dt->shared->fo_count--; + + /* Free the ID to name info since we're not calling H5T_free*/ + H5G_free_ent_name(&(dt->ent)); + } done: FUNC_LEAVE_NOAPI(ret_value); @@ -3414,23 +3505,23 @@ H5T_set_size(H5T_t *dt, size_t size) /* Check args */ assert(dt); assert(size!=0); - assert(H5T_REFERENCE!=dt->type); - assert(!(H5T_ENUM==dt->type && 0==dt->u.enumer.nmembs)); - assert(!(H5T_COMPOUND==dt->type && 0==dt->u.compnd.nmembs)); + assert(H5T_REFERENCE!=dt->shared->type); + assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); + assert(!(H5T_COMPOUND==dt->shared->type && 0==dt->shared->u.compnd.nmembs)); - if (dt->parent) { - if (H5T_set_size(dt->parent, size)<0) + if (dt->shared->parent) { + if (H5T_set_size(dt->shared->parent, size)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type"); /* Adjust size of datatype appropriately */ - if(dt->type==H5T_ARRAY) - dt->size = dt->parent->size * dt->u.array.nelem; - else if(dt->type!=H5T_VLEN) - dt->size = dt->parent->size; + if(dt->shared->type==H5T_ARRAY) + dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; + else if(dt->shared->type!=H5T_VLEN) + dt->shared->size = dt->shared->parent->shared->size; } else { - if (H5T_IS_ATOMIC(dt)) { - offset = dt->u.atomic.offset; - prec = dt->u.atomic.prec; + if (H5T_IS_ATOMIC(dt->shared)) { + offset = dt->shared->u.atomic.offset; + prec = dt->shared->u.atomic.prec; /* Decrement the offset and precision if necessary */ if (prec > 8*size) @@ -3444,7 +3535,7 @@ H5T_set_size(H5T_t *dt, size_t size) prec = offset = 0; } - switch (dt->type) { + switch (dt->shared->type) { case H5T_INTEGER: case H5T_TIME: case H5T_BITFIELD: @@ -3453,7 +3544,7 @@ H5T_set_size(H5T_t *dt, size_t size) break; case H5T_COMPOUND: - if(sizesize) + if(sizeshared->size) HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "can't shrink compound datatype"); break; @@ -3467,28 +3558,28 @@ H5T_set_size(H5T_t *dt, size_t size) /* Get a copy of unsigned char type as the base/parent type */ if (NULL==(base=H5I_object(H5T_NATIVE_UCHAR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype"); - dt->parent=H5T_copy(base,H5T_COPY_ALL); + dt->shared->parent=H5T_copy(base,H5T_COPY_ALL); /* change this datatype into a VL string */ - dt->type = H5T_VLEN; + dt->shared->type = H5T_VLEN; /* * Force conversions (i.e. memory to memory conversions * should duplicate data, not point to the same VL strings) */ - dt->force_conv = TRUE; + dt->shared->force_conv = TRUE; /* Before we mess with the info in the union, extract the * values we need */ - tmp_cset=dt->u.atomic.u.s.cset; - tmp_strpad=dt->u.atomic.u.s.pad; + tmp_cset=dt->shared->u.atomic.u.s.cset; + tmp_strpad=dt->shared->u.atomic.u.s.pad; /* This is a string, not a sequence */ - dt->u.vlen.type = H5T_VLEN_STRING; + dt->shared->u.vlen.type = H5T_VLEN_STRING; /* Set character set and padding information */ - dt->u.vlen.cset = tmp_cset; - dt->u.vlen.pad = tmp_strpad; + dt->shared->u.vlen.cset = tmp_cset; + dt->shared->u.vlen.pad = tmp_strpad; /* Set up VL information */ if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) @@ -3505,9 +3596,9 @@ H5T_set_size(H5T_t *dt, size_t size) * The sign, mantissa, and exponent fields should be adjusted * first when decreasing the size of a floating point type. */ - if (dt->u.atomic.u.f.sign >= prec || - dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec || - dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) { + if (dt->shared->u.atomic.u.f.sign >= prec || + dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec || + dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first"); } break; @@ -3523,11 +3614,11 @@ H5T_set_size(H5T_t *dt, size_t size) } /* Commit (if we didn't convert this type to a VL string) */ - if(dt->type!=H5T_VLEN) { - dt->size = size; - if (H5T_IS_ATOMIC(dt)) { - dt->u.atomic.offset = offset; - dt->u.atomic.prec = prec; + if(dt->shared->type!=H5T_VLEN) { + dt->shared->size = size; + if (H5T_IS_ATOMIC(dt->shared)) { + dt->shared->u.atomic.offset = offset; + dt->shared->u.atomic.prec = prec; } } /* end if */ } @@ -3564,7 +3655,7 @@ H5T_get_size(const H5T_t *dt) /* check args */ assert(dt); - FUNC_LEAVE_NOAPI(dt->size); + FUNC_LEAVE_NOAPI(dt->shared->size); } @@ -3609,40 +3700,40 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) assert(dt2); /* compare */ - if (dt1->type < dt2->type) HGOTO_DONE(-1); - if (dt1->type > dt2->type) HGOTO_DONE(1); + if (dt1->shared->type < dt2->shared->type) HGOTO_DONE(-1); + if (dt1->shared->type > dt2->shared->type) HGOTO_DONE(1); - if (dt1->size < dt2->size) HGOTO_DONE(-1); - if (dt1->size > dt2->size) HGOTO_DONE(1); + if (dt1->shared->size < dt2->shared->size) HGOTO_DONE(-1); + if (dt1->shared->size > dt2->shared->size) HGOTO_DONE(1); - if (dt1->parent && !dt2->parent) HGOTO_DONE(-1); - if (!dt1->parent && dt2->parent) HGOTO_DONE(1); - if (dt1->parent) { - tmp = H5T_cmp(dt1->parent, dt2->parent); + if (dt1->shared->parent && !dt2->shared->parent) HGOTO_DONE(-1); + if (!dt1->shared->parent && dt2->shared->parent) HGOTO_DONE(1); + if (dt1->shared->parent) { + tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent); if (tmp<0) HGOTO_DONE(-1); if (tmp>0) HGOTO_DONE(1); } - switch(dt1->type) { + switch(dt1->shared->type) { case H5T_COMPOUND: /* * Compound data types... */ - if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs) + if (dt1->shared->u.compnd.nmembs < dt2->shared->u.compnd.nmembs) HGOTO_DONE(-1); - if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs) + if (dt1->shared->u.compnd.nmembs > dt2->shared->u.compnd.nmembs) HGOTO_DONE(1); /* Build an index for each type so the names are sorted */ - if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(unsigned))) || - NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(unsigned)))) + if (NULL==(idx1 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || + NULL==(idx2 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); - for (u=0; uu.compnd.nmembs; u++) + for (u=0; ushared->u.compnd.nmembs; u++) idx1[u] = idx2[u] = u; - for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) { + for (i=dt1->shared->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) { for (j=0, swapped=FALSE; ju.compnd.memb[idx1[j]].name, - dt1->u.compnd.memb[idx1[j+1]].name) > 0) { + if (HDstrcmp(dt1->shared->u.compnd.memb[idx1[j]].name, + dt1->shared->u.compnd.memb[idx1[j+1]].name) > 0) { tmp = idx1[j]; idx1[j] = idx1[j+1]; idx1[j+1] = tmp; @@ -3650,10 +3741,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) } } } - for (i=dt2->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) { + for (i=dt2->shared->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) { for (j=0, swapped=FALSE; ju.compnd.memb[idx2[j]].name, - dt2->u.compnd.memb[idx2[j+1]].name) > 0) { + if (HDstrcmp(dt2->shared->u.compnd.memb[idx2[j]].name, + dt2->shared->u.compnd.memb[idx2[j+1]].name) > 0) { tmp = idx2[j]; idx2[j] = idx2[j+1]; idx2[j+1] = tmp; @@ -3664,31 +3755,31 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ - for (u=0; uu.compnd.nmembs-1; u++) { - assert(HDstrcmp(dt1->u.compnd.memb[idx1[u]].name, - dt1->u.compnd.memb[idx1[u + 1]].name)); - assert(HDstrcmp(dt2->u.compnd.memb[idx2[u]].name, - dt2->u.compnd.memb[idx2[u + 1]].name)); + for (u=0; ushared->u.compnd.nmembs-1; u++) { + assert(HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, + dt1->shared->u.compnd.memb[idx1[u + 1]].name)); + assert(HDstrcmp(dt2->shared->u.compnd.memb[idx2[u]].name, + dt2->shared->u.compnd.memb[idx2[u + 1]].name)); } #endif /* Compare the members */ - for (u=0; uu.compnd.nmembs; u++) { - tmp = HDstrcmp(dt1->u.compnd.memb[idx1[u]].name, - dt2->u.compnd.memb[idx2[u]].name); + for (u=0; ushared->u.compnd.nmembs; u++) { + tmp = HDstrcmp(dt1->shared->u.compnd.memb[idx1[u]].name, + dt2->shared->u.compnd.memb[idx2[u]].name); if (tmp < 0) HGOTO_DONE(-1); if (tmp > 0) HGOTO_DONE(1); - if (dt1->u.compnd.memb[idx1[u]].offset < dt2->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(-1); - if (dt1->u.compnd.memb[idx1[u]].offset > dt2->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(1); + if (dt1->shared->u.compnd.memb[idx1[u]].offset < dt2->shared->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(-1); + if (dt1->shared->u.compnd.memb[idx1[u]].offset > dt2->shared->u.compnd.memb[idx2[u]].offset) HGOTO_DONE(1); - if (dt1->u.compnd.memb[idx1[u]].size < dt2->u.compnd.memb[idx2[u]].size) HGOTO_DONE(-1); - if (dt1->u.compnd.memb[idx1[u]].size > dt2->u.compnd.memb[idx2[u]].size) HGOTO_DONE(1); + if (dt1->shared->u.compnd.memb[idx1[u]].size < dt2->shared->u.compnd.memb[idx2[u]].size) HGOTO_DONE(-1); + if (dt1->shared->u.compnd.memb[idx1[u]].size > dt2->shared->u.compnd.memb[idx2[u]].size) HGOTO_DONE(1); - tmp = H5T_cmp(dt1->u.compnd.memb[idx1[u]].type, - dt2->u.compnd.memb[idx2[u]].type); + tmp = H5T_cmp(dt1->shared->u.compnd.memb[idx1[u]].type, + dt2->shared->u.compnd.memb[idx2[u]].type); if (tmp < 0) HGOTO_DONE(-1); if (tmp > 0) HGOTO_DONE(1); } @@ -3698,21 +3789,21 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) /* * Enumeration data types... */ - if (dt1->u.enumer.nmembs < dt2->u.enumer.nmembs) + if (dt1->shared->u.enumer.nmembs < dt2->shared->u.enumer.nmembs) HGOTO_DONE(-1); - if (dt1->u.enumer.nmembs > dt2->u.enumer.nmembs) + if (dt1->shared->u.enumer.nmembs > dt2->shared->u.enumer.nmembs) HGOTO_DONE(1); /* Build an index for each type so the names are sorted */ - if (NULL==(idx1 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(unsigned))) || - NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(unsigned)))) + if (NULL==(idx1 = H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || + NULL==(idx2 = H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); - for (u=0; uu.enumer.nmembs; u++) + for (u=0; ushared->u.enumer.nmembs; u++) idx1[u] = idx2[u] = u; - for (i=dt1->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) { + for (i=dt1->shared->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) { for (j=0, swapped=FALSE; ju.enumer.name[idx1[j]], - dt1->u.enumer.name[idx1[j+1]]) > 0) { + if (HDstrcmp(dt1->shared->u.enumer.name[idx1[j]], + dt1->shared->u.enumer.name[idx1[j+1]]) > 0) { tmp = idx1[j]; idx1[j] = idx1[j+1]; idx1[j+1] = tmp; @@ -3720,10 +3811,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) } } } - for (i=dt2->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) { + for (i=dt2->shared->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) { for (j=0, swapped=FALSE; ju.enumer.name[idx2[j]], - dt2->u.enumer.name[idx2[j+1]]) > 0) { + if (HDstrcmp(dt2->shared->u.enumer.name[idx2[j]], + dt2->shared->u.enumer.name[idx2[j+1]]) > 0) { tmp = idx2[j]; idx2[j] = idx2[j+1]; idx2[j+1] = tmp; @@ -3734,24 +3825,24 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ - for (u=0; uu.enumer.nmembs-1; u++) { - assert(HDstrcmp(dt1->u.enumer.name[idx1[u]], - dt1->u.enumer.name[idx1[u+1]])); - assert(HDstrcmp(dt2->u.enumer.name[idx2[u]], - dt2->u.enumer.name[idx2[u+1]])); + for (u=0; ushared->u.enumer.nmembs-1; u++) { + assert(HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], + dt1->shared->u.enumer.name[idx1[u+1]])); + assert(HDstrcmp(dt2->shared->u.enumer.name[idx2[u]], + dt2->shared->u.enumer.name[idx2[u+1]])); } #endif /* Compare the members */ - base_size = dt1->parent->size; - for (u=0; uu.enumer.nmembs; u++) { - tmp = HDstrcmp(dt1->u.enumer.name[idx1[u]], - dt2->u.enumer.name[idx2[u]]); + base_size = dt1->shared->parent->shared->size; + for (u=0; ushared->u.enumer.nmembs; u++) { + tmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[u]], + dt2->shared->u.enumer.name[idx2[u]]); if (tmp<0) HGOTO_DONE(-1); if (tmp>0) HGOTO_DONE(1); - tmp = HDmemcmp(dt1->u.enumer.value+idx1[u]*base_size, - dt2->u.enumer.value+idx2[u]*base_size, + tmp = HDmemcmp(dt1->shared->u.enumer.value+idx1[u]*base_size, + dt2->shared->u.enumer.value+idx2[u]*base_size, base_size); if (tmp<0) HGOTO_DONE(-1); if (tmp>0) HGOTO_DONE(1); @@ -3759,59 +3850,59 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) break; case H5T_VLEN: - assert(dt1->u.vlen.type>H5T_VLEN_BADTYPE && dt1->u.vlen.typeu.vlen.type>H5T_VLEN_BADTYPE && dt2->u.vlen.typeu.vlen.loc>H5T_LOC_BADLOC && dt1->u.vlen.locu.vlen.loc>H5T_LOC_BADLOC && dt2->u.vlen.locshared->u.vlen.type>H5T_VLEN_BADTYPE && dt1->shared->u.vlen.typeshared->u.vlen.type>H5T_VLEN_BADTYPE && dt2->shared->u.vlen.typeshared->u.vlen.loc>H5T_LOC_BADLOC && dt1->shared->u.vlen.locshared->u.vlen.loc>H5T_LOC_BADLOC && dt2->shared->u.vlen.locu.vlen.type==H5T_VLEN_SEQUENCE && - dt2->u.vlen.type==H5T_VLEN_STRING) { + if (dt1->shared->u.vlen.type==H5T_VLEN_SEQUENCE && + dt2->shared->u.vlen.type==H5T_VLEN_STRING) { HGOTO_DONE(-1); - } else if (dt1->u.vlen.type==H5T_VLEN_STRING && - dt2->u.vlen.type==H5T_VLEN_SEQUENCE) { + } else if (dt1->shared->u.vlen.type==H5T_VLEN_STRING && + dt2->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { HGOTO_DONE(1); } /* Arbitrarily sort VL datatypes in memory before disk */ - if (dt1->u.vlen.loc==H5T_LOC_MEMORY && - dt2->u.vlen.loc==H5T_LOC_DISK) { + if (dt1->shared->u.vlen.loc==H5T_LOC_MEMORY && + dt2->shared->u.vlen.loc==H5T_LOC_DISK) { HGOTO_DONE(-1); - } else if (dt1->u.vlen.loc==H5T_LOC_DISK && - dt2->u.vlen.loc==H5T_LOC_MEMORY) { + } else if (dt1->shared->u.vlen.loc==H5T_LOC_DISK && + dt2->shared->u.vlen.loc==H5T_LOC_MEMORY) { HGOTO_DONE(1); } /* Don't allow VL types in different files to compare as equal */ - if (dt1->u.vlen.f < dt2->u.vlen.f) + if (dt1->shared->u.vlen.f < dt2->shared->u.vlen.f) HGOTO_DONE(-1); - if (dt1->u.vlen.f > dt2->u.vlen.f) + if (dt1->shared->u.vlen.f > dt2->shared->u.vlen.f) HGOTO_DONE(1); break; case H5T_OPAQUE: - if(dt1->u.opaque.tag && dt2->u.opaque.tag) { - HGOTO_DONE(HDstrcmp(dt1->u.opaque.tag,dt2->u.opaque.tag)); + if(dt1->shared->u.opaque.tag && dt2->shared->u.opaque.tag) { + HGOTO_DONE(HDstrcmp(dt1->shared->u.opaque.tag,dt2->shared->u.opaque.tag)); } case H5T_ARRAY: - if (dt1->u.array.ndims < dt2->u.array.ndims) + if (dt1->shared->u.array.ndims < dt2->shared->u.array.ndims) HGOTO_DONE(-1); - if (dt1->u.array.ndims > dt2->u.array.ndims) + if (dt1->shared->u.array.ndims > dt2->shared->u.array.ndims) HGOTO_DONE(1); - for (j=0; ju.array.ndims; j++) { - if (dt1->u.array.dim[j] < dt2->u.array.dim[j]) + for (j=0; jshared->u.array.ndims; j++) { + if (dt1->shared->u.array.dim[j] < dt2->shared->u.array.dim[j]) HGOTO_DONE(-1); - if (dt1->u.array.dim[j] > dt2->u.array.dim[j]) + if (dt1->shared->u.array.dim[j] > dt2->shared->u.array.dim[j]) HGOTO_DONE(1); } - for (j=0; ju.array.ndims; j++) { - if (dt1->u.array.perm[j] < dt2->u.array.perm[j]) + for (j=0; jshared->u.array.ndims; j++) { + if (dt1->shared->u.array.perm[j] < dt2->shared->u.array.perm[j]) HGOTO_DONE(-1); - if (dt1->u.array.perm[j] > dt2->u.array.perm[j]) + if (dt1->shared->u.array.perm[j] > dt2->shared->u.array.perm[j]) HGOTO_DONE(1); } - tmp = H5T_cmp(dt1->parent, dt2->parent); + tmp = H5T_cmp(dt1->shared->parent, dt2->shared->parent); if (tmp < 0) HGOTO_DONE(-1); if (tmp > 0) @@ -3822,62 +3913,62 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) /* * Atomic datatypes... */ - if (dt1->u.atomic.order < dt2->u.atomic.order) HGOTO_DONE(-1); - if (dt1->u.atomic.order > dt2->u.atomic.order) HGOTO_DONE(1); + if (dt1->shared->u.atomic.order < dt2->shared->u.atomic.order) HGOTO_DONE(-1); + if (dt1->shared->u.atomic.order > dt2->shared->u.atomic.order) HGOTO_DONE(1); - if (dt1->u.atomic.prec < dt2->u.atomic.prec) HGOTO_DONE(-1); - if (dt1->u.atomic.prec > dt2->u.atomic.prec) HGOTO_DONE(1); + if (dt1->shared->u.atomic.prec < dt2->shared->u.atomic.prec) HGOTO_DONE(-1); + if (dt1->shared->u.atomic.prec > dt2->shared->u.atomic.prec) HGOTO_DONE(1); - if (dt1->u.atomic.offset < dt2->u.atomic.offset) HGOTO_DONE(-1); - if (dt1->u.atomic.offset > dt2->u.atomic.offset) HGOTO_DONE(1); + if (dt1->shared->u.atomic.offset < dt2->shared->u.atomic.offset) HGOTO_DONE(-1); + if (dt1->shared->u.atomic.offset > dt2->shared->u.atomic.offset) HGOTO_DONE(1); - if (dt1->u.atomic.lsb_pad < dt2->u.atomic.lsb_pad) HGOTO_DONE(-1); - if (dt1->u.atomic.lsb_pad > dt2->u.atomic.lsb_pad) HGOTO_DONE(1); + if (dt1->shared->u.atomic.lsb_pad < dt2->shared->u.atomic.lsb_pad) HGOTO_DONE(-1); + if (dt1->shared->u.atomic.lsb_pad > dt2->shared->u.atomic.lsb_pad) HGOTO_DONE(1); - if (dt1->u.atomic.msb_pad < dt2->u.atomic.msb_pad) HGOTO_DONE(-1); - if (dt1->u.atomic.msb_pad > dt2->u.atomic.msb_pad) HGOTO_DONE(1); + if (dt1->shared->u.atomic.msb_pad < dt2->shared->u.atomic.msb_pad) HGOTO_DONE(-1); + if (dt1->shared->u.atomic.msb_pad > dt2->shared->u.atomic.msb_pad) HGOTO_DONE(1); - switch (dt1->type) { + switch (dt1->shared->type) { case H5T_INTEGER: - if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign) + if (dt1->shared->u.atomic.u.i.sign < dt2->shared->u.atomic.u.i.sign) HGOTO_DONE(-1); - if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign) + if (dt1->shared->u.atomic.u.i.sign > dt2->shared->u.atomic.u.i.sign) HGOTO_DONE(1); break; case H5T_FLOAT: - if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign) + if (dt1->shared->u.atomic.u.f.sign < dt2->shared->u.atomic.u.f.sign) HGOTO_DONE(-1); - if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign) + if (dt1->shared->u.atomic.u.f.sign > dt2->shared->u.atomic.u.f.sign) HGOTO_DONE(1); - if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos) + if (dt1->shared->u.atomic.u.f.epos < dt2->shared->u.atomic.u.f.epos) HGOTO_DONE(-1); - if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos) + if (dt1->shared->u.atomic.u.f.epos > dt2->shared->u.atomic.u.f.epos) HGOTO_DONE(1); - if (dt1->u.atomic.u.f.esize < dt2->u.atomic.u.f.esize) HGOTO_DONE(-1); - if (dt1->u.atomic.u.f.esize > dt2->u.atomic.u.f.esize) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.esize < dt2->shared->u.atomic.u.f.esize) HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.esize > dt2->shared->u.atomic.u.f.esize) HGOTO_DONE(1); - if (dt1->u.atomic.u.f.ebias < dt2->u.atomic.u.f.ebias) HGOTO_DONE(-1); - if (dt1->u.atomic.u.f.ebias > dt2->u.atomic.u.f.ebias) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.ebias < dt2->shared->u.atomic.u.f.ebias) HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.ebias > dt2->shared->u.atomic.u.f.ebias) HGOTO_DONE(1); - if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos) + if (dt1->shared->u.atomic.u.f.mpos < dt2->shared->u.atomic.u.f.mpos) HGOTO_DONE(-1); - if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos) + if (dt1->shared->u.atomic.u.f.mpos > dt2->shared->u.atomic.u.f.mpos) HGOTO_DONE(1); - if (dt1->u.atomic.u.f.msize < dt2->u.atomic.u.f.msize) HGOTO_DONE(-1); - if (dt1->u.atomic.u.f.msize > dt2->u.atomic.u.f.msize) HGOTO_DONE(1); + if (dt1->shared->u.atomic.u.f.msize < dt2->shared->u.atomic.u.f.msize) HGOTO_DONE(-1); + if (dt1->shared->u.atomic.u.f.msize > dt2->shared->u.atomic.u.f.msize) HGOTO_DONE(1); - if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm) + if (dt1->shared->u.atomic.u.f.norm < dt2->shared->u.atomic.u.f.norm) HGOTO_DONE(-1); - if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm) + if (dt1->shared->u.atomic.u.f.norm > dt2->shared->u.atomic.u.f.norm) HGOTO_DONE(1); - if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad) + if (dt1->shared->u.atomic.u.f.pad < dt2->shared->u.atomic.u.f.pad) HGOTO_DONE(-1); - if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad) + if (dt1->shared->u.atomic.u.f.pad > dt2->shared->u.atomic.u.f.pad) HGOTO_DONE(1); break; @@ -3887,14 +3978,14 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) break; case H5T_STRING: - if (dt1->u.atomic.u.s.cset < dt2->u.atomic.u.s.cset) + if (dt1->shared->u.atomic.u.s.cset < dt2->shared->u.atomic.u.s.cset) HGOTO_DONE(-1); - if (dt1->u.atomic.u.s.cset > dt2->u.atomic.u.s.cset) + if (dt1->shared->u.atomic.u.s.cset > dt2->shared->u.atomic.u.s.cset) HGOTO_DONE(1); - if (dt1->u.atomic.u.s.pad < dt2->u.atomic.u.s.pad) + if (dt1->shared->u.atomic.u.s.pad < dt2->shared->u.atomic.u.s.pad) HGOTO_DONE(-1); - if (dt1->u.atomic.u.s.pad > dt2->u.atomic.u.s.pad) + if (dt1->shared->u.atomic.u.s.pad > dt2->shared->u.atomic.u.s.pad) HGOTO_DONE(1); break; @@ -3904,16 +3995,16 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) break; case H5T_REFERENCE: - if (dt1->u.atomic.u.r.rtype < dt2->u.atomic.u.r.rtype) + if (dt1->shared->u.atomic.u.r.rtype < dt2->shared->u.atomic.u.r.rtype) HGOTO_DONE(-1); - if (dt1->u.atomic.u.r.rtype > dt2->u.atomic.u.r.rtype) + if (dt1->shared->u.atomic.u.r.rtype > dt2->shared->u.atomic.u.r.rtype) HGOTO_DONE(1); - switch(dt1->u.atomic.u.r.rtype) { + switch(dt1->shared->u.atomic.u.r.rtype) { case H5R_OBJECT: - if (dt1->u.atomic.u.r.loc < dt2->u.atomic.u.r.loc) + if (dt1->shared->u.atomic.u.r.loc < dt2->shared->u.atomic.u.r.loc) HGOTO_DONE(-1); - if (dt1->u.atomic.u.r.loc > dt2->u.atomic.u.r.loc) + if (dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc) HGOTO_DONE(1); break; @@ -4026,7 +4117,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, * Only allow the no-op conversion to occur if no "force conversion" flags * are set */ - if (src->force_conv==FALSE && dst->force_conv==FALSE && 0==H5T_cmp(src, dst)) { + if (src->shared->force_conv==FALSE && dst->shared->force_conv==FALSE && 0==H5T_cmp(src, dst)) { table = H5T_g.path[0]; cmp = 0; md = 0; @@ -4109,8 +4200,8 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, */ assert(path->func || (src && dst)); for (i=H5T_g.nsoft-1; i>=0 && !path->func; --i) { - if (src->type!=H5T_g.soft[i].src || - dst->type!=H5T_g.soft[i].dst) { + if (src->shared->type!=H5T_g.soft[i].src || + dst->shared->type!=H5T_g.soft[i].dst) { continue; } if ((src_id=H5I_register(H5I_DATATYPE, @@ -4365,7 +4456,7 @@ H5T_entof (H5T_t *dt) assert (dt); - switch (dt->state) { + switch (dt->shared->state) { case H5T_STATE_TRANSIENT: case H5T_STATE_RDONLY: case H5T_STATE_IMMUTABLE: @@ -4406,7 +4497,7 @@ H5T_is_immutable(const H5T_t *dt) assert(dt); - if(dt->state == H5T_STATE_IMMUTABLE) + if(dt->shared->state == H5T_STATE_IMMUTABLE) ret_value = TRUE; done: @@ -4439,7 +4530,7 @@ H5T_is_named(const H5T_t *dt) assert(dt); - if(dt->state == H5T_STATE_OPEN || dt->state == H5T_STATE_NAMED) + if(dt->shared->state == H5T_STATE_OPEN || dt->shared->state == H5T_STATE_NAMED) ret_value = TRUE; done: @@ -4476,8 +4567,8 @@ H5T_get_ref_type(const H5T_t *dt) assert(dt); - if(dt->type==H5T_REFERENCE) - ret_value=dt->u.atomic.u.r.rtype; + if(dt->shared->type==H5T_REFERENCE) + ret_value=dt->shared->u.atomic.u.r.rtype; done: FUNC_LEAVE_NOAPI(ret_value); @@ -4510,10 +4601,10 @@ H5T_is_sensible(const H5T_t *dt) assert(dt); - switch(dt->type) { + switch(dt->shared->type) { case H5T_COMPOUND: /* Only allow compound datatypes with at least one member to be stored on disk */ - if(dt->u.compnd.nmembs > 0) + if(dt->shared->u.compnd.nmembs > 0) ret_value=TRUE; else ret_value=FALSE; @@ -4521,7 +4612,7 @@ H5T_is_sensible(const H5T_t *dt) case H5T_ENUM: /* Only allow enum datatypes with at least one member to be stored on disk */ - if(dt->u.enumer.nmembs > 0) + if(dt->shared->u.enumer.nmembs > 0) ret_value=TRUE; else ret_value=FALSE; @@ -4577,26 +4668,26 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) assert(loc>H5T_LOC_BADLOC && locforce_conv) { + if(dt->shared->force_conv) { /* Check the datatype of this element */ - switch(dt->type) { + switch(dt->shared->type) { case H5T_ARRAY: /* Recurse on VL, compound and array base element type */ /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(dt->parent->force_conv && H5T_IS_COMPLEX(dt->parent->type)) { + if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { /* Keep the old base element size for later */ - old_size=dt->parent->size; + old_size=dt->shared->parent->shared->size; /* Mark the VL, compound or array type */ - if((changed=H5T_set_loc(dt->parent,f,loc))<0) + if((changed=H5T_set_loc(dt->shared->parent,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(changed>0) ret_value=changed; /* Check if the field changed size */ - if(old_size != dt->parent->size) { + if(old_size != dt->shared->parent->shared->size) { /* Adjust the size of the array */ - dt->size = dt->u.array.nelem*dt->parent->size; + dt->shared->size = dt->shared->u.array.nelem*dt->shared->parent->shared->size; } /* end if */ } /* end if */ break; @@ -4605,20 +4696,20 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Sort the fields based on offsets */ H5T_sort_value(dt,NULL); - for (i=0,accum_change=0; iu.compnd.nmembs; i++) { + for (i=0,accum_change=0; ishared->u.compnd.nmembs; i++) { H5T_t *memb_type; /* Member's datatype pointer */ /* Apply the accumulated size change to the offset of the field */ - dt->u.compnd.memb[i].offset += accum_change; + dt->shared->u.compnd.memb[i].offset += accum_change; /* Set the member type pointer (for convenience) */ - memb_type=dt->u.compnd.memb[i].type; + memb_type=dt->shared->u.compnd.memb[i].type; /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(memb_type->force_conv && H5T_IS_COMPLEX(memb_type->type)) { + if(memb_type->shared->force_conv && H5T_IS_COMPLEX(memb_type->shared->type)) { /* Keep the old field size for later */ - old_size=memb_type->size; + old_size=memb_type->shared->size; /* Mark the VL, compound, enum or array type */ if((changed=H5T_set_loc(memb_type,f,loc))<0) @@ -4627,25 +4718,25 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) ret_value=changed; /* Check if the field changed size */ - if(old_size != memb_type->size) { + if(old_size != memb_type->shared->size) { /* Adjust the size of the member */ - dt->u.compnd.memb[i].size = (dt->u.compnd.memb[i].size*memb_type->size)/old_size; + dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size; /* Add that change to the accumulated size change */ - accum_change += (memb_type->size - (int)old_size); + accum_change += (memb_type->shared->size - (int)old_size); } /* end if */ } /* end if */ } /* end for */ /* Apply the accumulated size change to the datatype */ - dt->size += accum_change; + dt->shared->size += accum_change; break; case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL sequence */ /* Recurse if it's VL, compound, enum or array */ /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ - if(dt->parent->force_conv && H5T_IS_COMPLEX(dt->parent->type)) { - if((changed=H5T_set_loc(dt->parent,f,loc))<0) + if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + if((changed=H5T_set_loc(dt->shared->parent,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(changed>0) ret_value=changed; @@ -4660,11 +4751,11 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) case H5T_REFERENCE: /* Only need to change location of object references */ - if(dt->u.atomic.u.r.rtype==H5R_OBJECT) { + if(dt->shared->u.atomic.u.r.rtype==H5R_OBJECT) { /* Mark this reference */ - if(loc!=dt->u.atomic.u.r.loc) { + if(loc!=dt->shared->u.atomic.u.r.loc) { /* Set the location */ - dt->u.atomic.u.r.loc = loc; + dt->shared->u.atomic.u.r.loc = loc; /* Indicate that the location changed */ ret_value=TRUE; @@ -4817,7 +4908,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) assert(dt); assert(stream); - switch (dt->type) { + switch (dt->shared->type) { case H5T_INTEGER: s1 = "int"; break; @@ -4847,7 +4938,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } - switch (dt->state) { + switch (dt->shared->state) { case H5T_STATE_TRANSIENT: s2 = "[transient]"; break; @@ -4865,10 +4956,10 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } - fprintf(stream, "%s%s {nbytes=%lu", s1, s2, (unsigned long)(dt->size)); + fprintf(stream, "%s%s {nbytes=%lu", s1, s2, (unsigned long)(dt->shared->size)); - if (H5T_IS_ATOMIC(dt)) { - switch (dt->u.atomic.order) { + if (H5T_IS_ATOMIC(dt->shared)) { + switch (dt->shared->u.atomic.order) { case H5T_ORDER_BE: s1 = "BE"; break; @@ -4887,17 +4978,17 @@ H5T_debug(const H5T_t *dt, FILE *stream) } fprintf(stream, ", %s", s1); - if (dt->u.atomic.offset) { + if (dt->shared->u.atomic.offset) { fprintf(stream, ", offset=%lu", - (unsigned long) (dt->u.atomic.offset)); + (unsigned long) (dt->shared->u.atomic.offset)); } - if (dt->u.atomic.prec != 8 * dt->size) { + if (dt->shared->u.atomic.prec != 8 * dt->shared->size) { fprintf(stream, ", prec=%lu", - (unsigned long) (dt->u.atomic.prec)); + (unsigned long) (dt->shared->u.atomic.prec)); } - switch (dt->type) { + switch (dt->shared->type) { case H5T_INTEGER: - switch (dt->u.atomic.u.i.sign) { + switch (dt->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: s1 = "unsigned"; break; @@ -4912,7 +5003,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; case H5T_FLOAT: - switch (dt->u.atomic.u.f.norm) { + switch (dt->shared->u.atomic.u.f.norm) { case H5T_NORM_IMPLIED: s1 = "implied"; break; @@ -4927,21 +5018,21 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } fprintf(stream, ", sign=%lu+1", - (unsigned long) (dt->u.atomic.u.f.sign)); + (unsigned long) (dt->shared->u.atomic.u.f.sign)); fprintf(stream, ", mant=%lu+%lu (%s)", - (unsigned long) (dt->u.atomic.u.f.mpos), - (unsigned long) (dt->u.atomic.u.f.msize), s1); + (unsigned long) (dt->shared->u.atomic.u.f.mpos), + (unsigned long) (dt->shared->u.atomic.u.f.msize), s1); fprintf(stream, ", exp=%lu+%lu", - (unsigned long) (dt->u.atomic.u.f.epos), - (unsigned long) (dt->u.atomic.u.f.esize)); - tmp = dt->u.atomic.u.f.ebias >> 32; + (unsigned long) (dt->shared->u.atomic.u.f.epos), + (unsigned long) (dt->shared->u.atomic.u.f.esize)); + tmp = dt->shared->u.atomic.u.f.ebias >> 32; if (tmp) { size_t hi=(size_t)tmp; - size_t lo =(size_t)(dt->u.atomic.u.f.ebias & 0xffffffff); + size_t lo =(size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff); fprintf(stream, " bias=0x%08lx%08lx", (unsigned long)hi, (unsigned long)lo); } else { - size_t lo = (size_t)(dt->u.atomic.u.f.ebias & 0xffffffff); + size_t lo = (size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff); fprintf(stream, " bias=0x%08lx", (unsigned long)lo); } break; @@ -4951,47 +5042,47 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } - } else if (H5T_COMPOUND==dt->type) { + } else if (H5T_COMPOUND==dt->shared->type) { /* Compound data type */ - for (i=0; iu.compnd.nmembs; i++) { + for (i=0; ishared->u.compnd.nmembs; i++) { fprintf(stream, "\n\"%s\" @%lu", - dt->u.compnd.memb[i].name, - (unsigned long) (dt->u.compnd.memb[i].offset)); + dt->shared->u.compnd.memb[i].name, + (unsigned long) (dt->shared->u.compnd.memb[i].offset)); #ifdef OLD_WAY - if (dt->u.compnd.memb[i].ndims) { + if (dt->shared->u.compnd.memb[i].ndims) { fprintf(stream, "["); - for (j = 0; j < dt->u.compnd.memb[i].ndims; j++) { + for (j = 0; j < dt->shared->u.compnd.memb[i].ndims; j++) { fprintf(stream, "%s%lu", j ? ", " : "", - (unsigned long)(dt->u.compnd.memb[i].dim[j])); + (unsigned long)(dt->shared->u.compnd.memb[i].dim[j])); } fprintf(stream, "]"); } #endif /* OLD_WAY */ fprintf(stream, " "); - H5T_debug(dt->u.compnd.memb[i].type, stream); + H5T_debug(dt->shared->u.compnd.memb[i].type, stream); } fprintf(stream, "\n"); - } else if (H5T_ENUM==dt->type) { + } else if (H5T_ENUM==dt->shared->type) { /* Enumeration data type */ fprintf(stream, " "); - H5T_debug(dt->parent, stream); - base_size = dt->parent->size; - for (i=0; iu.enumer.nmembs; i++) { - fprintf(stream, "\n\"%s\" = 0x", dt->u.enumer.name[i]); + H5T_debug(dt->shared->parent, stream); + base_size = dt->shared->parent->shared->size; + for (i=0; ishared->u.enumer.nmembs; i++) { + fprintf(stream, "\n\"%s\" = 0x", dt->shared->u.enumer.name[i]); for (k=0; ku.enumer.value+i*base_size+k)); + (unsigned long)(dt->shared->u.enumer.value+i*base_size+k)); } } fprintf(stream, "\n"); - } else if (H5T_OPAQUE==dt->type) { - fprintf(stream, ", tag=\"%s\"", dt->u.opaque.tag); + } else if (H5T_OPAQUE==dt->shared->type) { + fprintf(stream, ", tag=\"%s\"", dt->shared->u.opaque.tag); } else { /* Unknown */ - fprintf(stream, "unknown class %d\n", (int)(dt->type)); + fprintf(stream, "unknown class %d\n", (int)(dt->shared->type)); } fprintf(stream, "}"); diff --git a/src/H5Tarray.c b/src/H5Tarray.c index b376899..6ee0651 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -34,6 +34,7 @@ /* Declare extern the free list for H5T_t's */ H5FL_EXTERN(H5T_t); +H5FL_EXTERN(H5T_shared_t); /*-------------------------------------------------------------------------- @@ -155,34 +156,37 @@ H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */], /* Build new type */ if (NULL==(ret_value = H5FL_CALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - + if (NULL==(ret_value->shared=H5FL_CALLOC(H5T_shared_t))) { + H5FL_FREE(H5T_t, ret_value); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + } ret_value->ent.header = HADDR_UNDEF; - ret_value->type = H5T_ARRAY; + ret_value->shared->type = H5T_ARRAY; /* Copy the base type of the array */ - ret_value->parent = H5T_copy(base, H5T_COPY_ALL); + ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL); /* Set the array parameters */ - ret_value->u.array.ndims = ndims; + ret_value->shared->u.array.ndims = ndims; /* Copy the array dimensions & compute the # of elements in the array */ - for(i=0, ret_value->u.array.nelem=1; iu.array.dim[i],dim[i],hsize_t,size_t); - ret_value->u.array.nelem *= (size_t)dim[i]; + for(i=0, ret_value->shared->u.array.nelem=1; ishared->u.array.dim[i],dim[i],hsize_t,size_t); + ret_value->shared->u.array.nelem *= (size_t)dim[i]; } /* end for */ /* Copy the dimension permutations */ for(i=0; iu.array.perm[i] = perm ? perm[i] : i; + ret_value->shared->u.array.perm[i] = perm ? perm[i] : i; /* Set the array's size (number of elements * element datatype's size) */ - ret_value->size = ret_value->parent->size * ret_value->u.array.nelem; + ret_value->shared->size = ret_value->shared->parent->shared->size * ret_value->shared->u.array.nelem; /* * Set the "force conversion" flag if the base datatype indicates */ - if(base->force_conv==TRUE) - ret_value->force_conv=TRUE; + if(base->shared->force_conv==TRUE) + ret_value->shared->force_conv=TRUE; done: FUNC_LEAVE_NOAPI(ret_value); @@ -216,7 +220,7 @@ H5Tget_array_ndims(hid_t type_id) /* Check args */ if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); - if(dt->type!=H5T_ARRAY) + if(dt->shared->type!=H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype"); /* Retrieve the number of dimensions */ @@ -251,10 +255,10 @@ H5T_get_array_ndims(H5T_t *dt) FUNC_ENTER_NOAPI(H5T_get_array_ndims, FAIL); assert(dt); - assert(dt->type==H5T_ARRAY); + assert(dt->shared->type==H5T_ARRAY); /* Retrieve the number of dimensions */ - ret_value=dt->u.array.ndims; + ret_value=dt->shared->u.array.ndims; done: FUNC_LEAVE_NOAPI(ret_value); @@ -288,7 +292,7 @@ H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[]) /* Check args */ if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); - if(dt->type!=H5T_ARRAY) + if(dt->shared->type!=H5T_ARRAY) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype"); /* Retrieve the sizes of the dimensions */ @@ -324,20 +328,20 @@ H5T_get_array_dims(H5T_t *dt, hsize_t dims[], int perm[]) FUNC_ENTER_NOAPI(H5T_get_array_dims, FAIL); assert(dt); - assert(dt->type==H5T_ARRAY); + assert(dt->shared->type==H5T_ARRAY); /* Retrieve the sizes of the dimensions */ if(dims) - for(i=0; iu.array.ndims; i++) - dims[i]=dt->u.array.dim[i]; + for(i=0; ishared->u.array.ndims; i++) + dims[i]=dt->shared->u.array.dim[i]; /* Retrieve the dimension permutations */ if(perm) - for(i=0; iu.array.ndims; i++) - perm[i]=dt->u.array.perm[i]; + for(i=0; ishared->u.array.ndims; i++) + perm[i]=dt->shared->u.array.perm[i]; /* Pass along the array rank as the return value */ - ret_value=dt->u.array.ndims; + ret_value=dt->shared->u.array.ndims; done: FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 15f3fb5..5853d16 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -28,6 +28,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5FOprivate.h" /* File objects */ #include "H5Iprivate.h" /* IDs */ #include "H5Oprivate.h" /* Object headers */ #include "H5Tpkg.h" /* Datatypes */ @@ -132,9 +133,9 @@ H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id) * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing * a named type should always succeed. */ - if (H5T_STATE_NAMED==type->state || H5T_STATE_OPEN==type->state) + if (H5T_STATE_NAMED==type->shared->state || H5T_STATE_OPEN==type->shared->state) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "data type is already committed"); - if (H5T_STATE_IMMUTABLE==type->state) + if (H5T_STATE_IMMUTABLE==type->shared->state) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "data type is immutable"); /* Find the insertion file */ @@ -160,7 +161,12 @@ H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message"); if (H5G_insert (loc, name, &(type->ent), dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to name data type"); - type->state = H5T_STATE_OPEN; + type->shared->state = H5T_STATE_OPEN; + type->shared->fo_count=1; + + /* Add datatype to the list of open objects in the file */ + if(H5FO_insert(type->ent.file, type->ent.header, type->shared)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "can't insert datatype into list of open objects") /* Mark datatype as being on memory now. Since this datatype may still be used in memory * after committed to disk, change its size back as in memory. */ @@ -169,7 +175,7 @@ H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id) done: if (ret_value<0) { - if ((type->state==H5T_STATE_TRANSIENT || type->state==H5T_STATE_RDONLY) && H5F_addr_defined(type->ent.header)) { + if ((type->shared->state==H5T_STATE_TRANSIENT || type->shared->state==H5T_STATE_RDONLY) && H5F_addr_defined(type->ent.header)) { if(H5O_close(&(type->ent))<0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header"); if(H5O_delete(file, dxpl_id,type->ent.header)<0) @@ -241,7 +247,7 @@ H5T_committed(H5T_t *type) assert (type); - FUNC_LEAVE_NOAPI(H5T_STATE_OPEN==type->state || H5T_STATE_NAMED==type->state); + FUNC_LEAVE_NOAPI(H5T_STATE_OPEN==type->shared->state || H5T_STATE_NAMED==type->shared->state); } /* end H5T_committed() */ diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index acd82ab..7abcafc 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -100,9 +100,9 @@ H5Tget_member_offset(hid_t type_id, unsigned membno) H5TRACE2("z","iIu",type_id,membno); /* Check args */ - if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->type) + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound datatype") - if (membno >= dt->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number") /* Value */ @@ -142,10 +142,10 @@ H5T_get_member_offset(const H5T_t *dt, unsigned membno) FUNC_ENTER_NOAPI(H5T_get_member_offset, 0) assert(dt); - assert(membno < dt->u.compnd.nmembs); + assert(membno < dt->shared->u.compnd.nmembs); /* Value */ - ret_value = dt->u.compnd.memb[membno].offset; + ret_value = dt->shared->u.compnd.memb[membno].offset; done: FUNC_LEAVE_NOAPI(ret_value) @@ -186,13 +186,13 @@ H5Tget_member_class(hid_t type_id, unsigned membno) H5TRACE2("Tt","iIu",type_id,membno); /* Check args */ - if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->type) + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a compound datatype") - if (membno >= dt->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5T_NO_CLASS, "invalid member number") /* Value */ - ret_value = dt->u.compnd.memb[membno].type->type; + ret_value = dt->shared->u.compnd.memb[membno].type->shared->type; done: FUNC_LEAVE_API(ret_value) @@ -241,9 +241,9 @@ H5Tget_member_type(hid_t type_id, unsigned membno) H5TRACE2("i","iIs",type_id,membno); /* Check args */ - if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->type) + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") - if (membno >= dt->u.compnd.nmembs) + if (membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") if ((memb_dt=H5T_get_member_type(dt, membno))==NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to retrieve member type") @@ -289,10 +289,10 @@ H5T_get_member_type(const H5T_t *dt, unsigned membno) FUNC_ENTER_NOAPI(H5T_get_member_type, NULL) assert(dt); - assert(membno < dt->u.compnd.nmembs); + assert(membno < dt->shared->u.compnd.nmembs); /* Copy datatype into an atom */ - if (NULL == (ret_value = H5T_copy(dt->u.compnd.memb[membno].type, H5T_COPY_REOPEN))) + if (NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_REOPEN))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy member datatype") done: @@ -337,9 +337,9 @@ H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id) /* Check args */ if (parent_id==member_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself") - if (NULL == (parent = H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_COMPOUND != parent->type) + if (NULL == (parent = H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_COMPOUND != parent->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") - if (H5T_STATE_TRANSIENT!=parent->state) + if (H5T_STATE_TRANSIENT!=parent->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name") @@ -420,82 +420,82 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member) FUNC_ENTER_NOAPI(H5T_insert, FAIL) /* check args */ - assert(parent && H5T_COMPOUND == parent->type); - assert(H5T_STATE_TRANSIENT==parent->state); + assert(parent && H5T_COMPOUND == parent->shared->type); + assert(H5T_STATE_TRANSIENT==parent->shared->state); assert(member); assert(name && *name); /* Does NAME already exist in PARENT? */ - for (i=0; iu.compnd.nmembs; i++) { - if (!HDstrcmp(parent->u.compnd.memb[i].name, name)) + for (i=0; ishared->u.compnd.nmembs; i++) { + if (!HDstrcmp(parent->shared->u.compnd.memb[i].name, name)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique") } /* Does the new member overlap any existing member ? */ - total_size=member->size; - for (i=0; iu.compnd.nmembs; i++) { - if ((offset <= parent->u.compnd.memb[i].offset && - offset + total_size > parent->u.compnd.memb[i].offset) || - (parent->u.compnd.memb[i].offset <= offset && - parent->u.compnd.memb[i].offset + - parent->u.compnd.memb[i].size > offset)) + total_size=member->shared->size; + for (i=0; ishared->u.compnd.nmembs; i++) { + if ((offset <= parent->shared->u.compnd.memb[i].offset && + offset + total_size > parent->shared->u.compnd.memb[i].offset) || + (parent->shared->u.compnd.memb[i].offset <= offset && + parent->shared->u.compnd.memb[i].offset + + parent->shared->u.compnd.memb[i].size > offset)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member overlaps with another member") } /* Does the new member overlap the end of the compound type? */ - if(offset+total_size>parent->size) + if(offset+total_size>parent->shared->size) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member extends past end of compound type") /* Increase member array if necessary */ - if (parent->u.compnd.nmembs >= parent->u.compnd.nalloc) { - size_t na = parent->u.compnd.nalloc + H5T_COMPND_INC; - H5T_cmemb_t *x = H5MM_realloc (parent->u.compnd.memb, + if (parent->shared->u.compnd.nmembs >= parent->shared->u.compnd.nalloc) { + size_t na = parent->shared->u.compnd.nalloc + H5T_COMPND_INC; + H5T_cmemb_t *x = H5MM_realloc (parent->shared->u.compnd.memb, na * sizeof(H5T_cmemb_t)); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - parent->u.compnd.nalloc = na; - parent->u.compnd.memb = x; + parent->shared->u.compnd.nalloc = na; + parent->shared->u.compnd.memb = x; } /* Add member to end of member array */ - idx = parent->u.compnd.nmembs; - parent->u.compnd.memb[idx].name = H5MM_xstrdup(name); - parent->u.compnd.memb[idx].offset = offset; - parent->u.compnd.memb[idx].size = total_size; - parent->u.compnd.memb[idx].type = H5T_copy (member, H5T_COPY_ALL); + idx = parent->shared->u.compnd.nmembs; + parent->shared->u.compnd.memb[idx].name = H5MM_xstrdup(name); + parent->shared->u.compnd.memb[idx].offset = offset; + parent->shared->u.compnd.memb[idx].size = total_size; + parent->shared->u.compnd.memb[idx].type = H5T_copy (member, H5T_COPY_ALL); - parent->u.compnd.sorted = H5T_SORT_NONE; - parent->u.compnd.nmembs++; + parent->shared->u.compnd.sorted = H5T_SORT_NONE; + parent->shared->u.compnd.nmembs++; /* Determine if the compound datatype stayed packed */ - if(parent->u.compnd.packed) { + if(parent->shared->u.compnd.packed) { /* Check if the member type is packed */ - if(H5T_is_packed(parent->u.compnd.memb[idx].type)>0) { + if(H5T_is_packed(parent->shared->u.compnd.memb[idx].type)>0) { if(idx==0) { /* If the is the first member, the datatype is not packed * if the first member isn't at offset 0 */ - if(parent->u.compnd.memb[idx].offset>0) - parent->u.compnd.packed=FALSE; + if(parent->shared->u.compnd.memb[idx].offset>0) + parent->shared->u.compnd.packed=FALSE; } /* end if */ else { /* If the is not the first member, the datatype is not * packed if the new member isn't adjoining the previous member */ - if(parent->u.compnd.memb[idx].offset!=(parent->u.compnd.memb[idx-1].offset+parent->u.compnd.memb[idx-1].size)) - parent->u.compnd.packed=FALSE; + if(parent->shared->u.compnd.memb[idx].offset!=(parent->shared->u.compnd.memb[idx-1].offset+parent->shared->u.compnd.memb[idx-1].size)) + parent->shared->u.compnd.packed=FALSE; } /* end else */ } /* end if */ else - parent->u.compnd.packed=FALSE; + parent->shared->u.compnd.packed=FALSE; } /* end if */ /* * Set the "force conversion" flag if the field's datatype indicates */ - if(member->force_conv==TRUE) - parent->force_conv=TRUE; + if(member->shared->force_conv==TRUE) + parent->shared->force_conv=TRUE; done: FUNC_LEAVE_NOAPI(ret_value) @@ -534,38 +534,38 @@ H5T_pack(H5T_t *dt) HGOTO_DONE(SUCCEED); /* Check for packing unmodifiable datatype */ - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is read-only") - if(dt->parent) { - if (H5T_pack(dt->parent) < 0) + if(dt->shared->parent) { + if (H5T_pack(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack parent of datatype") /* Adjust size of datatype appropriately */ - if(dt->type==H5T_ARRAY) - dt->size = dt->parent->size * dt->u.array.nelem; - else if(dt->type!=H5T_VLEN) - dt->size = dt->parent->size; + if(dt->shared->type==H5T_ARRAY) + dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; + else if(dt->shared->type!=H5T_VLEN) + dt->shared->size = dt->shared->parent->shared->size; } /* end if */ - else if(dt->type==H5T_COMPOUND) { + else if(dt->shared->type==H5T_COMPOUND) { /* Recursively pack the members */ - for (i=0; iu.compnd.nmembs; i++) - if (H5T_pack(dt->u.compnd.memb[i].type) < 0) + for (i=0; ishared->u.compnd.nmembs; i++) + if (H5T_pack(dt->shared->u.compnd.memb[i].type) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound datatype") /* Remove padding between members */ if(H5T_sort_value(dt, NULL)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") - for (i=0, offset=0; iu.compnd.nmembs; i++) { - dt->u.compnd.memb[i].offset = offset; - offset += dt->u.compnd.memb[i].size; + for (i=0, offset=0; ishared->u.compnd.nmembs; i++) { + dt->shared->u.compnd.memb[i].offset = offset; + offset += dt->shared->u.compnd.memb[i].size; } /* Change total size */ - dt->size = MAX(1, offset); + dt->shared->size = MAX(1, offset); /* Mark the type as packed now */ - dt->u.compnd.packed=TRUE; + dt->shared->u.compnd.packed=TRUE; } /* end if */ } /* end if */ @@ -599,12 +599,12 @@ H5T_is_packed(const H5T_t *dt) assert(dt); /* Go up the chain as far as possible */ - while(dt->parent) - dt=dt->parent; + while(dt->shared->parent) + dt=dt->shared->parent; /* If this is a compound datatype, check if it is packed */ - if(dt->type==H5T_COMPOUND) - ret_value=(htri_t)dt->u.compnd.packed; + if(dt->shared->type==H5T_COMPOUND) + ret_value=(htri_t)dt->shared->u.compnd.packed; done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 0a500b5..30f41fe 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -440,7 +440,7 @@ H5FL_BLK_DEFINE_STATIC(array_seq); if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "unable to dereference datatype object ID") \ - if (st->size!=sizeof(ST) || dt->size!=sizeof(DT)) \ + if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "disagreement about datatype size") \ CI_ALLOC_PRIV \ @@ -739,21 +739,21 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (src->size != dst->size || - 0 != src->u.atomic.offset || - 0 != dst->u.atomic.offset) + if (src->shared->size != dst->shared->size || + 0 != src->shared->u.atomic.offset || + 0 != dst->shared->u.atomic.offset) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); - if((src->type==H5T_REFERENCE && dst->type!=H5T_REFERENCE) || - (dst->type==H5T_REFERENCE && src->type!=H5T_REFERENCE)) + if((src->shared->type==H5T_REFERENCE && dst->shared->type!=H5T_REFERENCE) || + (dst->shared->type==H5T_REFERENCE && src->shared->type!=H5T_REFERENCE)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); - if(src->type!=H5T_REFERENCE && - !((H5T_ORDER_BE == src->u.atomic.order && H5T_ORDER_LE == dst->u.atomic.order) || - (H5T_ORDER_LE == src->u.atomic.order && H5T_ORDER_BE == dst->u.atomic.order))) + if(src->shared->type!=H5T_REFERENCE && + !((H5T_ORDER_BE == src->shared->u.atomic.order && H5T_ORDER_LE == dst->shared->u.atomic.order) || + (H5T_ORDER_LE == src->shared->u.atomic.order && H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); - if (src->size!=1 && src->size!=2 && src->size!=4 && - src->size!=8 && src->size!=16) + if (src->shared->size!=1 && src->shared->size!=2 && src->shared->size!=4 && + src->shared->size!=8 && src->shared->size!=16) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); - switch (src->type) { + switch (src->shared->type) { case H5T_INTEGER: case H5T_BITFIELD: case H5T_REFERENCE: @@ -761,14 +761,14 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, break; case H5T_FLOAT: - if (src->u.atomic.u.f.sign != dst->u.atomic.u.f.sign || - src->u.atomic.u.f.epos != dst->u.atomic.u.f.epos || - src->u.atomic.u.f.esize != dst->u.atomic.u.f.esize || - src->u.atomic.u.f.ebias != dst->u.atomic.u.f.ebias || - src->u.atomic.u.f.mpos != dst->u.atomic.u.f.mpos || - src->u.atomic.u.f.msize != dst->u.atomic.u.f.msize || - src->u.atomic.u.f.norm != dst->u.atomic.u.f.norm || - src->u.atomic.u.f.pad != dst->u.atomic.u.f.pad) + if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || + src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || + src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || + src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || + src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || + src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || + src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || + src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); break; @@ -785,9 +785,9 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Check for "no op" reference conversion */ - if(src->type==H5T_REFERENCE) { + if(src->shared->type==H5T_REFERENCE) { /* Sanity check */ - assert(dst->type==H5T_REFERENCE); + assert(dst->shared->type==H5T_REFERENCE); /* Check if we are on a little-endian machine (the order that * the addresses in the file must be) and just get out now, there @@ -802,8 +802,8 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, break; } /* end if */ - buf_stride = buf_stride ? buf_stride : src->size; - switch (src->size) { + buf_stride = buf_stride ? buf_stride : src->shared->size; + switch (src->shared->size) { case 1: /*no-op*/ break; @@ -1145,28 +1145,28 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (src->size != dst->size || 0 != src->u.atomic.offset || - 0 != dst->u.atomic.offset || - !((H5T_ORDER_BE == src->u.atomic.order && - H5T_ORDER_LE == dst->u.atomic.order) || - (H5T_ORDER_LE == src->u.atomic.order && - H5T_ORDER_BE == dst->u.atomic.order))) + if (src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || + 0 != dst->shared->u.atomic.offset || + !((H5T_ORDER_BE == src->shared->u.atomic.order && + H5T_ORDER_LE == dst->shared->u.atomic.order) || + (H5T_ORDER_LE == src->shared->u.atomic.order && + H5T_ORDER_BE == dst->shared->u.atomic.order))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); - switch (src->type) { + switch (src->shared->type) { case H5T_INTEGER: case H5T_BITFIELD: /* nothing to check */ break; case H5T_FLOAT: - if (src->u.atomic.u.f.sign != dst->u.atomic.u.f.sign || - src->u.atomic.u.f.epos != dst->u.atomic.u.f.epos || - src->u.atomic.u.f.esize != dst->u.atomic.u.f.esize || - src->u.atomic.u.f.ebias != dst->u.atomic.u.f.ebias || - src->u.atomic.u.f.mpos != dst->u.atomic.u.f.mpos || - src->u.atomic.u.f.msize != dst->u.atomic.u.f.msize || - src->u.atomic.u.f.norm != dst->u.atomic.u.f.norm || - src->u.atomic.u.f.pad != dst->u.atomic.u.f.pad) { + if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign || + src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos || + src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize || + src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias || + src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos || + src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize || + src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm || + src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported"); } break; @@ -1183,11 +1183,11 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - buf_stride = buf_stride ? buf_stride : src->size; - md = src->size / 2; + buf_stride = buf_stride ? buf_stride : src->shared->size; + md = src->shared->size / 2; for (i=0; isize-(j+1)); + H5_SWAP_BYTES(buf, j, src->shared->size-(j+1)); } break; @@ -1252,11 +1252,11 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (H5T_ORDER_LE!=src->u.atomic.order && - H5T_ORDER_BE!=src->u.atomic.order) + if (H5T_ORDER_LE!=src->shared->u.atomic.order && + H5T_ORDER_BE!=src->shared->u.atomic.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (H5T_ORDER_LE!=dst->u.atomic.order && - H5T_ORDER_BE!=dst->u.atomic.order) + if (H5T_ORDER_LE!=dst->shared->u.atomic.order && + H5T_ORDER_BE!=dst->shared->u.atomic.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); cdata->need_bkg = H5T_BKG_NO; break; @@ -1275,23 +1275,23 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src->size==dst->size || buf_stride) { + if (src->shared->size==dst->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; - } else if (src->size>=dst->size) { - double olap_d = HDceil((double)(dst->size)/ - (double)(src->size-dst->size)); + } else if (src->shared->size>=dst->shared->size) { + double olap_d = HDceil((double)(dst->shared->size)/ + (double)(src->shared->size-dst->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; } else { - double olap_d = HDceil((double)(src->size)/ - (double)(dst->size-src->size)); + double olap_d = HDceil((double)(src->shared->size)/ + (double)(dst->shared->size-src->shared->size)); olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->size; + sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; + dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; direction = -1; } @@ -1304,7 +1304,7 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src->size); + src_rev = (uint8_t*)H5MM_calloc(src->shared->size); /* The conversion loop */ for (elmtno=0; elmtno=sp && dpsize) || - (sp>=dp && spsize)); + assert ((dp>=sp && dpshared->size) || + (sp>=dp && spshared->size)); } else { - assert ((dpsize<=sp) || - (spsize<=dp)); + assert ((dpshared->size<=sp) || + (spshared->size<=dp)); } #endif @@ -1336,11 +1336,11 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src->u.atomic.order) { - half_size = src->size/2; + if (H5T_ORDER_BE==src->shared->u.atomic.order) { + half_size = src->shared->size/2; for (i=0; isize-(i+1)]; - s[src->size-(i+1)] = s[i]; + uint8_t tmp = s[src->shared->size-(i+1)]; + s[src->shared->size-(i+1)] = s[i]; s[i] = tmp; } } @@ -1354,51 +1354,51 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * than the destination then invoke the overflow function or copy * as many bits as possible. Zero extra bits in the destination. */ - if (src->u.atomic.prec>dst->u.atomic.prec) { + if (src->shared->u.atomic.prec>dst->shared->u.atomic.prec) { /*overflow*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->size, src->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } if(except_ret == H5T_CONV_UNHANDLED) { - H5T_bit_copy(d, dst->u.atomic.offset, - s, src->u.atomic.offset, dst->u.atomic.prec); + H5T_bit_copy(d, dst->shared->u.atomic.offset, + s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it*/ reverse = FALSE; } else { - H5T_bit_copy(d, dst->u.atomic.offset, - s, src->u.atomic.offset, - src->u.atomic.prec); - H5T_bit_set(d, dst->u.atomic.offset+src->u.atomic.prec, - dst->u.atomic.prec-src->u.atomic.prec, FALSE); + H5T_bit_copy(d, dst->shared->u.atomic.offset, + s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T_bit_set(d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, + dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); } /* * Fill the destination padding areas. */ - switch (dst->u.atomic.lsb_pad) { + switch (dst->shared->u.atomic.lsb_pad) { case H5T_PAD_ZERO: - H5T_bit_set(d, 0, dst->u.atomic.offset, FALSE); + H5T_bit_set(d, 0, dst->shared->u.atomic.offset, FALSE); break; case H5T_PAD_ONE: - H5T_bit_set(d, 0, dst->u.atomic.offset, TRUE); + H5T_bit_set(d, 0, dst->shared->u.atomic.offset, TRUE); break; default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported LSB padding"); } - msb_pad_offset = dst->u.atomic.offset + dst->u.atomic.prec; - switch (dst->u.atomic.msb_pad) { + msb_pad_offset = dst->shared->u.atomic.offset + dst->shared->u.atomic.prec; + switch (dst->shared->u.atomic.msb_pad) { case H5T_PAD_ZERO: - H5T_bit_set(d, msb_pad_offset, 8*dst->size-msb_pad_offset, + H5T_bit_set(d, msb_pad_offset, 8*dst->shared->size-msb_pad_offset, FALSE); break; case H5T_PAD_ONE: - H5T_bit_set(d, msb_pad_offset, 8*dst->size-msb_pad_offset, + H5T_bit_set(d, msb_pad_offset, 8*dst->shared->size-msb_pad_offset, TRUE); break; default: @@ -1409,11 +1409,11 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst->u.atomic.order && reverse) { - half_size = dst->size/2; + if (H5T_ORDER_BE==dst->shared->u.atomic.order && reverse) { + half_size = dst->shared->size/2; for (i=0; isize-(i+1)]; - d[dst->size-(i+1)] = d[i]; + uint8_t tmp = d[dst->shared->size-(i+1)]; + d[dst->shared->size-(i+1)] = d[i]; d[i] = tmp; } } @@ -1422,13 +1422,13 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if (d==dbuf) HDmemcpy (dp, d, dst->size); + if (d==dbuf) HDmemcpy (dp, d, dst->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { - sp += direction * src->size; - dp += direction * dst->size; + sp += direction * src->shared->size; + dp += direction * dst->shared->size; } } @@ -1489,11 +1489,11 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) * Allocate private data structure and arrays. */ if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) || - NULL==(priv->src2dst=H5MM_malloc(src->u.compnd.nmembs * + NULL==(priv->src2dst=H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(int))) || - NULL==(priv->src_memb_id=H5MM_malloc(src->u.compnd.nmembs * + NULL==(priv->src_memb_id=H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(hid_t))) || - NULL==(priv->dst_memb_id=H5MM_malloc(dst->u.compnd.nmembs * + NULL==(priv->dst_memb_id=H5MM_malloc(dst->shared->u.compnd.nmembs * sizeof(hid_t)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); src2dst = priv->src2dst; @@ -1511,22 +1511,22 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) * source and destination member data type so we can look up the * member data type conversion functions later. */ - for (i=0; iu.compnd.nmembs; i++) { + for (i=0; ishared->u.compnd.nmembs; i++) { src2dst[i] = -1; - for (j=0; ju.compnd.nmembs; j++) { - if (!HDstrcmp (src->u.compnd.memb[i].name, - dst->u.compnd.memb[j].name)) { + for (j=0; jshared->u.compnd.nmembs; j++) { + if (!HDstrcmp (src->shared->u.compnd.memb[i].name, + dst->shared->u.compnd.memb[j].name)) { src2dst[i] = j; break; } } if (src2dst[i]>=0) { - type = H5T_copy (src->u.compnd.memb[i].type, H5T_COPY_ALL); + type = H5T_copy (src->shared->u.compnd.memb[i].type, H5T_COPY_ALL); tid = H5I_register (H5I_DATATYPE, type); assert (tid>=0); priv->src_memb_id[i] = tid; - type = H5T_copy (dst->u.compnd.memb[src2dst[i]].type, + type = H5T_copy (dst->shared->u.compnd.memb[src2dst[i]].type, H5T_COPY_ALL); tid = H5I_register (H5I_DATATYPE, type); assert (tid>=0); @@ -1547,14 +1547,14 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) */ src2dst = priv->src2dst; H5MM_xfree(priv->memb_path); - if (NULL==(priv->memb_path=H5MM_malloc(src->u.compnd.nmembs * + if (NULL==(priv->memb_path=H5MM_malloc(src->shared->u.compnd.nmembs * sizeof(H5T_path_t*)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - for (i=0; iu.compnd.nmembs; i++) { + for (i=0; ishared->u.compnd.nmembs; i++) { if (src2dst[i]>=0) { - H5T_path_t *tpath = H5T_path_find(src->u.compnd.memb[i].type, - dst->u.compnd.memb[src2dst[i]].type, NULL, NULL, dxpl_id); + H5T_path_t *tpath = H5T_path_find(src->shared->u.compnd.memb[i].type, + dst->shared->u.compnd.memb[src2dst[i]].type, NULL, NULL, dxpl_id); if (NULL==(priv->memb_path[i] = tpath)) { H5MM_xfree(priv->src2dst); @@ -1652,8 +1652,8 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - assert (H5T_COMPOUND==src->type); - assert (H5T_COMPOUND==dst->type); + assert (H5T_COMPOUND==src->shared->type); + assert (H5T_COMPOUND==dst->shared->type); if (H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data"); @@ -1696,15 +1696,15 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (buf_stride) { src_delta = buf_stride; if (!bkg_stride) - bkg_stride = dst->size; - } else if (dst->size <= src->size) { - src_delta = src->size; - bkg_stride = dst->size; + bkg_stride = dst->shared->size; + } else if (dst->shared->size <= src->shared->size) { + src_delta = src->shared->size; + bkg_stride = dst->shared->size; } else { - src_delta = -(int)src->size; /*overflow shouldn't be possible*/ - bkg_stride = -(int)dst->size; /*overflow shouldn't be possible*/ - xbuf += (nelmts-1) * src->size; - xbkg += (nelmts-1) * dst->size; + src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/ + bkg_stride = -(int)dst->shared->size; /*overflow shouldn't be possible*/ + xbuf += (nelmts-1) * src->shared->size; + xbkg += (nelmts-1) * dst->shared->size; } /* Conversion loop... */ @@ -1717,10 +1717,10 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * data point as small as possible with all the free space on the * right side. */ - for (u=0, offset=0; uu.compnd.nmembs; u++) { + for (u=0, offset=0; ushared->u.compnd.nmembs; u++) { if (src2dst[u]<0) continue; /*subsetting*/ - src_memb = src->u.compnd.memb + u; - dst_memb = dst->u.compnd.memb + src2dst[u]; + src_memb = src->shared->u.compnd.memb + u; + dst_memb = dst->shared->u.compnd.memb + src2dst[u]; if (dst_memb->size <= src_memb->size) { if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u], @@ -1746,10 +1746,10 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * yet). Then copy the member to the destination offset in the * background buffer. */ - for (i=src->u.compnd.nmembs-1; i>=0; --i) { + for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { if (src2dst[i]<0) continue; /*subsetting*/ - src_memb = src->u.compnd.memb + i; - dst_memb = dst->u.compnd.memb + src2dst[i]; + src_memb = src->shared->u.compnd.memb + i; + dst_memb = dst->shared->u.compnd.memb + src2dst[i]; if (dst_memb->size > src_memb->size) { offset -= src_memb->size; @@ -1773,17 +1773,17 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, xbkg += bkg_stride; } - /* If the bkg_stride was set to -(dst->size), make it positive now */ - if(buf_stride==0 && dst->size>src->size) - bkg_stride=dst->size; + /* If the bkg_stride was set to -(dst->shared->size), make it positive now */ + if(buf_stride==0 && dst->shared->size>src->shared->size) + bkg_stride=dst->shared->size; /* * Copy the background buffer back into the in-place conversion * buffer. */ for (xbuf=buf, xbkg=bkg, elmtno=0; elmtnosize); - xbuf += buf_stride ? buf_stride : dst->size; + HDmemmove(xbuf, xbkg, dst->shared->size); + xbuf += buf_stride ? buf_stride : dst->shared->size; xbkg += bkg_stride; } break; @@ -1885,8 +1885,8 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - assert (H5T_COMPOUND==src->type); - assert (H5T_COMPOUND==dst->type); + assert (H5T_COMPOUND==src->shared->type); + assert (H5T_COMPOUND==dst->shared->type); /* Initialize data which is relatively constant */ if (H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0) @@ -1904,23 +1904,23 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * of loops as in the actual conversion except it checks that there * is room for each conversion instead of actually doing anything. */ - if (dst->size > src->size) { - for (u=0, offset=0; uu.compnd.nmembs; u++) { + if (dst->shared->size > src->shared->size) { + for (u=0, offset=0; ushared->u.compnd.nmembs; u++) { if (src2dst[u]<0) continue; - src_memb = src->u.compnd.memb + u; - dst_memb = dst->u.compnd.memb + src2dst[u]; + src_memb = src->shared->u.compnd.memb + u; + dst_memb = dst->shared->u.compnd.memb + src2dst[u]; if (dst_memb->size > src_memb->size) offset += src_memb->size; } - for (i=src->u.compnd.nmembs-1; i>=0; --i) { + for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { if (src2dst[i]<0) continue; - src_memb = src->u.compnd.memb + i; - dst_memb = dst->u.compnd.memb + src2dst[i]; + src_memb = src->shared->u.compnd.memb + i; + dst_memb = dst->shared->u.compnd.memb + src2dst[i]; if (dst_memb->size > src_memb->size) { offset -= src_memb->size; - if (dst_memb->size > src->size-offset) { + if (dst_memb->size > src->shared->size-offset) { H5MM_xfree(priv->src2dst); H5MM_xfree(priv->src_memb_id); H5MM_xfree(priv->dst_memb_id); @@ -1972,12 +1972,12 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * data element at every BUF_STRIDE bytes through the main buffer * (BUF), leaving the result of each conversion at the same * location; otherwise assume the source and destination data are - * packed tightly based on src->size and dst->size. Also, if + * packed tightly based on src->shared->size and dst->shared->size. Also, if * BUF_STRIDE and BKG_STRIDE are both non-zero then place * background data into the BKG buffer at multiples of BKG_STRIDE; * otherwise assume BKG buffer is the packed destination datatype. */ - if (!buf_stride || !bkg_stride) bkg_stride = dst->size; + if (!buf_stride || !bkg_stride) bkg_stride = dst->shared->size; /* * For each member where the destination is not larger than the @@ -1986,10 +1986,10 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * destination in the bkg buffer. Otherwise move the element as far * left as possible in the buffer. */ - for (u=0, offset=0; uu.compnd.nmembs; u++) { + for (u=0, offset=0; ushared->u.compnd.nmembs; u++) { if (src2dst[u]<0) continue; /*subsetting*/ - src_memb = src->u.compnd.memb + u; - dst_memb = dst->u.compnd.memb + src2dst[u]; + src_memb = src->shared->u.compnd.memb + u; + dst_memb = dst->shared->u.compnd.memb + src2dst[u]; if (dst_memb->size <= src_memb->size) { xbuf = buf + src_memb->offset; @@ -1997,20 +1997,20 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u], priv->dst_memb_id[src2dst[u]], nelmts, - buf_stride ? buf_stride : src->size, + buf_stride ? buf_stride : src->shared->size, bkg_stride, xbuf, xbkg, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member"); for (elmtno=0; elmtnosize); - xbuf += buf_stride ? buf_stride : src->size; + xbuf += buf_stride ? buf_stride : src->shared->size; xbkg += bkg_stride; } } else { for (xbuf=buf, elmtno=0; elmtnooffset, src_memb->size); - xbuf += buf_stride ? buf_stride : src->size; + xbuf += buf_stride ? buf_stride : src->shared->size; } offset += src_memb->size; } @@ -2022,11 +2022,11 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * is larger than the source) and them to their final position in the * bkg buffer. */ - for (i=src->u.compnd.nmembs-1; i>=0; --i) { + for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) { if (src2dst[i]<0) continue; - src_memb = src->u.compnd.memb + i; - dst_memb = dst->u.compnd.memb + src2dst[i]; + src_memb = src->shared->u.compnd.memb + i; + dst_memb = dst->shared->u.compnd.memb + src2dst[i]; if (dst_memb->size > src_memb->size) { offset -= src_memb->size; @@ -2035,13 +2035,13 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]], nelmts, - buf_stride ? buf_stride : src->size, + buf_stride ? buf_stride : src->shared->size, bkg_stride, xbuf, xbkg, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member"); for (elmtno=0; elmtnosize); - xbuf += buf_stride ? buf_stride : src->size; + xbuf += buf_stride ? buf_stride : src->shared->size; xbkg += bkg_stride; } } @@ -2049,8 +2049,8 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, /* Move background buffer into result buffer */ for (xbuf=buf, xbkg=bkg, elmtno=0; elmtnosize); - xbuf += buf_stride ? buf_stride : dst->size; + HDmemmove(xbuf, xbkg, dst->shared->size); + xbuf += buf_stride ? buf_stride : dst->shared->size; xbkg += bkg_stride; } break; @@ -2097,7 +2097,7 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) cdata->need_bkg = H5T_BKG_NO; if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(*priv)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - if (0==src->u.enumer.nmembs) + if (0==src->shared->u.enumer.nmembs) HGOTO_DONE(SUCCEED); /* @@ -2107,15 +2107,15 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) */ H5T_sort_name(src, NULL); H5T_sort_name(dst, NULL); - if (NULL==(priv->src2dst=H5MM_malloc(src->u.enumer.nmembs*sizeof(int)))) + if (NULL==(priv->src2dst=H5MM_malloc(src->shared->u.enumer.nmembs*sizeof(int)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");; for (i=0, j=0; - iu.enumer.nmembs && ju.enumer.nmembs; + ishared->u.enumer.nmembs && jshared->u.enumer.nmembs; i++, j++) { - while (ju.enumer.nmembs && - HDstrcmp(src->u.enumer.name[i], dst->u.enumer.name[j])) + while (jshared->u.enumer.nmembs && + HDstrcmp(src->shared->u.enumer.name[i], dst->shared->u.enumer.name[j])) j++; - if (j>=dst->u.enumer.nmembs) + if (j>=dst->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type"); priv->src2dst[i] = j; } @@ -2137,14 +2137,14 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) * that array are the index numbers in the destination type or negative * if the entry is unused. */ - if (1==src->size || sizeof(short)==src->size || sizeof(int)==src->size) { - for (i=0; iu.enumer.nmembs; i++) { - if (1==src->size) { - n = *((signed char*)(src->u.enumer.value+i)); - } else if (sizeof(short)==src->size) { - n = *((short*)(src->u.enumer.value+i*src->size)); + if (1==src->shared->size || sizeof(short)==src->shared->size || sizeof(int)==src->shared->size) { + for (i=0; ishared->u.enumer.nmembs; i++) { + if (1==src->shared->size) { + n = *((signed char*)(src->shared->u.enumer.value+i)); + } else if (sizeof(short)==src->shared->size) { + n = *((short*)(src->shared->u.enumer.value+i*src->shared->size)); } else { - n = *((int*)(src->u.enumer.value+i*src->size)); + n = *((int*)(src->shared->u.enumer.value+i*src->shared->size)); } if (0==i) { domain[0] = domain[1] = n; @@ -2155,21 +2155,21 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) } length = (domain[1]-domain[0])+1; - if (src->u.enumer.nmembs<2 || - (double)length/src->u.enumer.nmembs<1.2) { + if (src->shared->u.enumer.nmembs<2 || + (double)length/src->shared->u.enumer.nmembs<1.2) { priv->base = domain[0]; priv->length = length; if (NULL==(map=H5MM_malloc(length*sizeof(int)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); for (i=0; iu.enumer.nmembs; i++) { - if (1==src->size) { - n = *((signed char*)(src->u.enumer.value+i)); - } else if (sizeof(short)==src->size) { - n = *((short*)(src->u.enumer.value+i*src->size)); + for (i=0; ishared->u.enumer.nmembs; i++) { + if (1==src->shared->size) { + n = *((signed char*)(src->shared->u.enumer.value+i)); + } else if (sizeof(short)==src->shared->size) { + n = *((short*)(src->shared->u.enumer.value+i*src->shared->size)); } else { - n = *((int*)(src->u.enumer.value+i*src->size)); + n = *((int*)(src->shared->u.enumer.value+i*src->shared->size)); } n -= priv->base; assert(n>=0 && nlength); @@ -2251,8 +2251,8 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - assert (H5T_ENUM==src->type); - assert (H5T_ENUM==dst->type); + assert (H5T_ENUM==src->shared->type); + assert (H5T_ENUM==dst->shared->type); if (H5T_conv_enum_init(src, dst, cdata)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize private data"); break; @@ -2276,8 +2276,8 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - assert (H5T_ENUM==src->type); - assert (H5T_ENUM==dst->type); + assert (H5T_ENUM==src->shared->type); + assert (H5T_ENUM==dst->shared->type); /* priv->src2dst map was computed for certain sort keys. Make sure those same * sort keys are used here during conversion. See H5T_conv_enum_init(). But @@ -2292,15 +2292,15 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (buf_stride) { src_delta = dst_delta = (int)buf_stride; s = d = buf; - } else if (dst->size <= src->size) { - src_delta = (int)src->size; /*overflow shouldn't be possible*/ - dst_delta = (int)dst->size; /*overflow shouldn't be possible*/ + } else if (dst->shared->size <= src->shared->size) { + src_delta = (int)src->shared->size; /*overflow shouldn't be possible*/ + dst_delta = (int)dst->shared->size; /*overflow shouldn't be possible*/ s = d = buf; } else { - src_delta = -(int)src->size; /*overflow shouldn't be possible*/ - dst_delta = -(int)dst->size; /*overflow shouldn't be possible*/ - s = buf + (nelmts-1) * src->size; - d = buf + (nelmts-1) * dst->size; + src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/ + dst_delta = -(int)dst->shared->size; /*overflow shouldn't be possible*/ + s = buf + (nelmts-1) * src->shared->size; + d = buf + (nelmts-1) * dst->shared->size; } /* Get the plist structure */ @@ -2314,9 +2314,9 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, for (i=0; ilength) { /* Use O(1) lookup */ - if (1==src->size) { + if (1==src->shared->size) { n = *((signed char*)s); - } else if (sizeof(short)==src->size) { + } else if (sizeof(short)==src->shared->size) { n = *((short*)s); } else { n = *((int*)s); @@ -2332,23 +2332,23 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } if(except_ret == H5T_CONV_UNHANDLED) { - HDmemset(d, 0xff, dst->size); + HDmemset(d, 0xff, dst->shared->size); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") } else { HDmemcpy(d, - dst->u.enumer.value+priv->src2dst[n]*dst->size, - dst->size); + dst->shared->u.enumer.value+priv->src2dst[n]*dst->shared->size, + dst->shared->size); } } else { /* Use O(log N) lookup */ int lt = 0; - int rt = src->u.enumer.nmembs; + int rt = src->shared->u.enumer.nmembs; int md, cmp; while (ltu.enumer.value+md*src->size, - src->size); + cmp = HDmemcmp(s, src->shared->u.enumer.value+md*src->shared->size, + src->shared->size); if (cmp<0) { rt = md; } else if (cmp>0) { @@ -2365,13 +2365,13 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } if(except_ret == H5T_CONV_UNHANDLED) { - HDmemset(d, 0xff, dst->size); + HDmemset(d, 0xff, dst->shared->size); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") } else { HDmemcpy(d, - dst->u.enumer.value+priv->src2dst[md]*dst->size, - dst->size); + dst->shared->u.enumer.value+priv->src2dst[md]*dst->shared->size, + dst->shared->size); } } } @@ -2470,8 +2470,8 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - assert (H5T_VLEN==src->type); - assert (H5T_VLEN==dst->type); + assert (H5T_VLEN==src->shared->type); + assert (H5T_VLEN==dst->shared->type); /* Variable-length types don't need a background buffer */ cdata->need_bkg = H5T_BKG_NO; @@ -2492,12 +2492,12 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Initialize source & destination strides */ if (buf_stride) { - assert(buf_stride>=src->size); - assert(buf_stride>=dst->size); + assert(buf_stride>=src->shared->size); + assert(buf_stride>=dst->shared->size); s_stride = d_stride = buf_stride; } else { - s_stride = src->size; - d_stride = dst->size; + s_stride = src->shared->size; + d_stride = dst->shared->size; } if(bkg) { if(bkg_stride) @@ -2509,21 +2509,21 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, b_stride=0; /* Get the size of the base types in src & dst */ - src_base_size=H5T_get_size(src->parent); - dst_base_size=H5T_get_size(dst->parent); + src_base_size=H5T_get_size(src->shared->parent); + dst_base_size=H5T_get_size(dst->shared->parent); /* Set up conversion path for base elements */ - if (NULL==(tpath=H5T_path_find(src->parent, dst->parent, NULL, NULL, dxpl_id))) { + if (NULL==(tpath=H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id))) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes"); } else if (!H5T_path_noop(tpath)) { - if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->parent, H5T_COPY_ALL)))<0 || - (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0) + if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL)))<0 || + (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); } else noop_conv=TRUE; /* Check if we need a temporary buffer for this conversion */ - parent_is_vlen=H5T_detect_class(dst->parent,H5T_VLEN); + parent_is_vlen=H5T_detect_class(dst->shared->parent,H5T_VLEN); if(tpath->cdata.need_bkg || parent_is_vlen) { /* Set up initial background buffer */ tmp_buf_size=MAX(src_base_size,dst_base_size); @@ -2536,7 +2536,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info"); /* Set flags to indicate we are writing to or reading from the file */ - if(dst->u.vlen.f!=NULL) + if(dst->shared->u.vlen.f!=NULL) write_to_file=TRUE; /* Set the flag for nested VL case */ @@ -2580,20 +2580,20 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, for (elmtno=0; elmtnou.vlen.isnull))(src->u.vlen.f,s)) { + if((*(src->shared->u.vlen.isnull))(src->shared->u.vlen.f,s)) { /* Write "nil" sequence to destination location */ - if((*(dst->u.vlen.setnull))(dst->u.vlen.f,dxpl_id,d,b)<0) + if((*(dst->shared->u.vlen.setnull))(dst->shared->u.vlen.f,dxpl_id,d,b)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'"); } /* end if */ else { /* Get length of element sequences */ - if((seq_len=(*(src->u.vlen.getlen))(s))<0) + if((seq_len=(*(src->shared->u.vlen.getlen))(s))<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect length"); /* If we are reading from memory and there is no conversion, just get the pointer to sequence */ if(write_to_file && noop_conv) { /* Get direct pointer to sequence */ - if((conv_buf=(*(src->u.vlen.getptr))(s))==NULL) + if((conv_buf=(*(src->shared->u.vlen.getptr))(s))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer"); } /* end if */ else { @@ -2612,7 +2612,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end if */ /* Read in VL sequence */ - if((*(src->u.vlen.read))(src->u.vlen.f,dxpl_id,s,conv_buf,src_size)<0) + if((*(src->shared->u.vlen.read))(src->shared->u.vlen.f,dxpl_id,s,conv_buf,src_size)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data"); } /* end else */ @@ -2638,9 +2638,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf, tmp_buf_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } - H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&tmp, &(bg_hobjid.addr)); + H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp, &(bg_hobjid.addr)); INT32DECODE(tmp, bg_hobjid.idx); - if(H5HG_read(dst->u.vlen.f,dxpl_id,&bg_hobjid,tmp_buf)==NULL) + if(H5HG_read(dst->shared->u.vlen.f,dxpl_id,&bg_hobjid,tmp_buf)==NULL) HGOTO_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer"); } /* end if */ @@ -2658,7 +2658,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end if */ /* Write sequence to destination location */ - if((*(dst->u.vlen.write))(dst->u.vlen.f,dxpl_id,vl_alloc_info,d,conv_buf, b, (size_t)seq_len, dst_base_size)<0) + if((*(dst->shared->u.vlen.write))(dst->shared->u.vlen.f,dxpl_id,vl_alloc_info,d,conv_buf, b, (size_t)seq_len, dst_base_size)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data"); if(!noop_conv) { @@ -2673,9 +2673,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, for(u=0; u<(bg_seq_len-seq_len); u++) { UINT32DECODE(tmp_p, parent_seq_len); if(parent_seq_len>0) { - H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&tmp_p, &(parent_hobjid.addr)); + H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp_p, &(parent_hobjid.addr)); INT32DECODE(tmp_p, parent_hobjid.idx); - if(H5HG_remove(dst->u.vlen.f, dxpl_id,&parent_hobjid)<0) + if(H5HG_remove(dst->shared->u.vlen.f, dxpl_id,&parent_hobjid)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object"); } } @@ -2766,18 +2766,18 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL == (src = H5I_object(src_id)) || NULL == (dst = H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - assert (H5T_ARRAY==src->type); - assert (H5T_ARRAY==dst->type); + assert (H5T_ARRAY==src->shared->type); + assert (H5T_ARRAY==dst->shared->type); /* Check the number and sizes of the dimensions */ - if(src->u.array.ndims!=dst->u.array.ndims) + if(src->shared->u.array.ndims!=dst->shared->u.array.ndims) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions"); - for(i=0; iu.array.ndims; i++) - if(src->u.array.dim[i]!=dst->u.array.dim[i]) + for(i=0; ishared->u.array.ndims; i++) + if(src->shared->u.array.dim[i]!=dst->shared->u.array.dim[i]) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions"); #ifdef LATER - for(i=0; iu.array.ndims; i++) - if(src->u.array.perm[i]!=dst->u.array.perm[i]) + for(i=0; ishared->u.array.ndims; i++) + if(src->shared->u.array.perm[i]!=dst->shared->u.array.perm[i]) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same dimension permutations"); #endif /* LATER */ @@ -2803,36 +2803,36 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * versa? Also, how many of the elements have the source and * destination areas overlapping? */ - if (src->size>=dst->size || buf_stride>0) { + if (src->shared->size>=dst->shared->size || buf_stride>0) { sp = dp = (uint8_t*)_buf; direction = 1; } else { sp = (uint8_t*)_buf + (nelmts-1) * - (buf_stride ? buf_stride : src->size); + (buf_stride ? buf_stride : src->shared->size); dp = (uint8_t*)_buf + (nelmts-1) * - (buf_stride ? buf_stride : dst->size); + (buf_stride ? buf_stride : dst->shared->size); direction = -1; } /* * Direction & size of buffer traversal. */ - src_delta = direction * (buf_stride ? buf_stride : src->size); - dst_delta = direction * (buf_stride ? buf_stride : dst->size); + src_delta = direction * (buf_stride ? buf_stride : src->shared->size); + dst_delta = direction * (buf_stride ? buf_stride : dst->shared->size); /* Set up conversion path for base elements */ - if (NULL==(tpath=H5T_path_find(src->parent, dst->parent, NULL, NULL, dxpl_id))) { + if (NULL==(tpath=H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id))) { HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes"); } else if (!H5T_path_noop(tpath)) { - if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->parent, H5T_COPY_ALL)))<0 || - (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0) + if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL)))<0 || + (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL)))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); } /* Check if we need a background buffer for this conversion */ if(tpath->cdata.need_bkg) { /* Allocate background buffer */ - bkg_buf_size=src->u.array.nelem*MAX(src->size,dst->size); + bkg_buf_size=src->shared->u.array.nelem*MAX(src->shared->size,dst->shared->size); if ((bkg_buf=H5FL_BLK_CALLOC(array_seq,bkg_buf_size))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); } /* end if */ @@ -2840,10 +2840,10 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Perform the actual conversion */ for (elmtno=0; elmtnosize); + HDmemmove(dp, sp, src->shared->size); /* Convert array */ - if (H5T_convert(tpath, tsrc_id, tdst_id, src->u.array.nelem, 0, bkg_stride, dp, bkg_buf, dxpl_id)<0) + if (H5T_convert(tpath, tsrc_id, tdst_id, src->shared->u.array.nelem, 0, bkg_stride, dp, bkg_buf, dxpl_id)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed"); /* Advance the source & destination pointers */ @@ -2929,13 +2929,13 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL==(src=H5I_object(src_id)) || NULL==(dst=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (H5T_ORDER_LE!=src->u.atomic.order && - H5T_ORDER_BE!=src->u.atomic.order) + if (H5T_ORDER_LE!=src->shared->u.atomic.order && + H5T_ORDER_BE!=src->shared->u.atomic.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (H5T_ORDER_LE!=dst->u.atomic.order && - H5T_ORDER_BE!=dst->u.atomic.order) + if (H5T_ORDER_LE!=dst->shared->u.atomic.order && + H5T_ORDER_BE!=dst->shared->u.atomic.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (dst->size>sizeof dbuf) + if (dst->shared->size>sizeof dbuf) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); cdata->need_bkg = H5T_BKG_NO; break; @@ -2954,23 +2954,23 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src->size==dst->size || buf_stride) { + if (src->shared->size==dst->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; - } else if (src->size>=dst->size) { - double olap_d = HDceil((double)(dst->size)/ - (double)(src->size-dst->size)); + } else if (src->shared->size>=dst->shared->size) { + double olap_d = HDceil((double)(dst->shared->size)/ + (double)(src->shared->size-dst->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; } else { - double olap_d = HDceil((double)(src->size)/ - (double)(dst->size-src->size)); + double olap_d = HDceil((double)(src->shared->size)/ + (double)(dst->shared->size-src->shared->size)); olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->size; + sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; + dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; direction = -1; } @@ -2983,7 +2983,7 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src->size); + src_rev = (uint8_t*)H5MM_calloc(src->shared->size); /* The conversion loop */ for (elmtno=0; elmtno=sp && dpsize) || (sp>=dp && spsize)); + assert ((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); } else { - assert ((dpsize<=sp) || (spsize<=dp)); + assert ((dpshared->size<=sp) || (spshared->size<=dp)); } #endif @@ -3013,11 +3013,11 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * complicated. We'll do all the conversion stuff assuming * little endian and then we'll fix the order at the end. */ - if (H5T_ORDER_BE==src->u.atomic.order) { - half_size = src->size/2; + if (H5T_ORDER_BE==src->shared->u.atomic.order) { + half_size = src->shared->size/2; for (i=0; isize-(i+1)]; - s[src->size-(i+1)] = s[i]; + uint8_t tmp = s[src->shared->size-(i+1)]; + s[src->shared->size-(i+1)] = s[i]; s[i] = tmp; } } @@ -3026,7 +3026,7 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * What is the bit number for the msb bit of S which is set? The * bit number is relative to the significant part of the number. */ - sfirst = H5T_bit_find (s, src->u.atomic.offset, src->u.atomic.prec, + sfirst = H5T_bit_find (s, src->shared->u.atomic.offset, src->shared->u.atomic.prec, H5T_BIT_MSB, TRUE); first = (size_t)sfirst; @@ -3039,43 +3039,43 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * The source has no bits set and must therefore be zero. * Set the destination to zero. */ - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, FALSE); + H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); - } else if (H5T_SGN_NONE==src->u.atomic.u.i.sign && - H5T_SGN_NONE==dst->u.atomic.u.i.sign) { + } else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign && + H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) { /* * Source and destination are both unsigned, but if the * source has more precision bits than the destination then * it's possible to overflow. When overflow occurs the * destination will be set to the maximum possible value. */ - if (src->u.atomic.prec <= dst->u.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, - src->u.atomic.prec); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, - dst->u.atomic.prec-src->u.atomic.prec, FALSE); - } else if (first>=dst->u.atomic.prec) { + if (src->shared->u.atomic.prec <= dst->shared->u.atomic.prec) { + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, + dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); + } else if (first>=dst->shared->u.atomic.prec) { /*overflow*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->size, src->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } if(except_ret == H5T_CONV_UNHANDLED) { - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, TRUE); + H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; } else { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, - dst->u.atomic.prec); + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); } - } else if (H5T_SGN_2==src->u.atomic.u.i.sign && - H5T_SGN_NONE==dst->u.atomic.u.i.sign) { + } else if (H5T_SGN_2==src->shared->u.atomic.u.i.sign && + H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) { /* * If the source is signed and the destination isn't then we * can have overflow if the source contains more bits than @@ -3083,79 +3083,79 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * possible value) or overflow if the source is negative * (destination is set to zero). */ - if (first+1 == src->u.atomic.prec) { + if (first+1 == src->shared->u.atomic.prec) { /*overflow - source is negative*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->size, src->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, d, cb_struct.user_data); } if(except_ret == H5T_CONV_UNHANDLED) { - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, FALSE); + H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->u.atomic.prec < dst->u.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, - src->u.atomic.prec-1); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec-1, - (dst->u.atomic.prec-src->u.atomic.prec)+1, FALSE); - } else if (first>=dst->u.atomic.prec) { + } else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) { + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec-1); + H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec-1, + (dst->shared->u.atomic.prec-src->shared->u.atomic.prec)+1, FALSE); + } else if (first>=dst->shared->u.atomic.prec) { /*overflow - source is positive*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->size, src->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } if(except_ret == H5T_CONV_UNHANDLED) - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, TRUE); + H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE); else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; } else { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, - dst->u.atomic.prec); + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); } - } else if (H5T_SGN_NONE==src->u.atomic.u.i.sign && - H5T_SGN_2==dst->u.atomic.u.i.sign) { + } else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign && + H5T_SGN_2==dst->shared->u.atomic.u.i.sign) { /* * If the source is not signed but the destination is then * overflow can occur in which case the destination is set to * the largest possible value (all bits set except the msb). */ - if (first+1 >= dst->u.atomic.prec) { + if (first+1 >= dst->shared->u.atomic.prec) { /*overflow*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->size, src->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } if(except_ret == H5T_CONV_UNHANDLED) { - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE); - H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, FALSE); + H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE); + H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, FALSE); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->u.atomic.precu.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, - src->u.atomic.prec); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, - dst->u.atomic.prec-src->u.atomic.prec, FALSE); + } else if (src->shared->u.atomic.precshared->u.atomic.prec) { + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, + dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); } else { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, - dst->u.atomic.prec); + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); } - } else if (first+1 == src->u.atomic.prec) { + } else if (first+1 == src->shared->u.atomic.prec) { /* * Both the source and the destination are signed and the * source value is negative. We could experience overflow @@ -3163,31 +3163,31 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * destination is set to a negative number with the largest * possible magnitude. */ - ssize_t sfz = H5T_bit_find (s, src->u.atomic.offset, - src->u.atomic.prec-1, H5T_BIT_MSB, FALSE); + ssize_t sfz = H5T_bit_find (s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec-1, H5T_BIT_MSB, FALSE); size_t fz = (size_t)sfz; - if (sfz>=0 && fz+1>=dst->u.atomic.prec) { + if (sfz>=0 && fz+1>=dst->shared->u.atomic.prec) { /*overflow*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->size, src->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, d, cb_struct.user_data); } if(except_ret == H5T_CONV_UNHANDLED) { - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, FALSE); - H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, TRUE); + H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, FALSE); + H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, TRUE); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->u.atomic.precu.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, src->u.atomic.prec); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, dst->u.atomic.prec-src->u.atomic.prec, TRUE); + } else if (src->shared->u.atomic.precshared->u.atomic.prec) { + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec); + H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, TRUE); } else { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, dst->u.atomic.prec); + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec); } } else { @@ -3197,56 +3197,56 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * case the destination is set to the largest possible * positive value. */ - if (first+1>=dst->u.atomic.prec) { + if (first+1>=dst->shared->u.atomic.prec) { /*overflow*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src->size, src->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src->shared->size, src->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } if(except_ret == H5T_CONV_UNHANDLED) { - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE); - H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, FALSE); + H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE); + H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, FALSE); } else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) /*Don't reverse because user handles it already*/ reverse = FALSE; - } else if (src->u.atomic.precu.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, - src->u.atomic.prec); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, - dst->u.atomic.prec-src->u.atomic.prec, FALSE); + } else if (src->shared->u.atomic.precshared->u.atomic.prec) { + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + src->shared->u.atomic.prec); + H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, + dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE); } else { - H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, - dst->u.atomic.prec); + H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, + dst->shared->u.atomic.prec); } } /* * Set padding areas in destination. */ - if (dst->u.atomic.offset>0) { - assert (H5T_PAD_ZERO==dst->u.atomic.lsb_pad || H5T_PAD_ONE==dst->u.atomic.lsb_pad); - H5T_bit_set (d, 0, dst->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->u.atomic.lsb_pad)); + if (dst->shared->u.atomic.offset>0) { + assert (H5T_PAD_ZERO==dst->shared->u.atomic.lsb_pad || H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad); + H5T_bit_set (d, 0, dst->shared->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad)); } - if (dst->u.atomic.offset+dst->u.atomic.prec!=8*dst->size) { - assert (H5T_PAD_ZERO==dst->u.atomic.msb_pad || H5T_PAD_ONE==dst->u.atomic.msb_pad); - H5T_bit_set (d, dst->u.atomic.offset+dst->u.atomic.prec, - 8*dst->size - (dst->u.atomic.offset+ dst->u.atomic.prec), - (hbool_t)(H5T_PAD_ONE==dst->u.atomic.msb_pad)); + if (dst->shared->u.atomic.offset+dst->shared->u.atomic.prec!=8*dst->shared->size) { + assert (H5T_PAD_ZERO==dst->shared->u.atomic.msb_pad || H5T_PAD_ONE==dst->shared->u.atomic.msb_pad); + H5T_bit_set (d, dst->shared->u.atomic.offset+dst->shared->u.atomic.prec, + 8*dst->shared->size - (dst->shared->u.atomic.offset+ dst->shared->u.atomic.prec), + (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.msb_pad)); } /* * Put the destination in the correct byte order. See note at * beginning of loop. */ - if (H5T_ORDER_BE==dst->u.atomic.order && reverse) { - half_size = dst->size/2; + if (H5T_ORDER_BE==dst->shared->u.atomic.order && reverse) { + half_size = dst->shared->size/2; for (i=0; isize-(i+1)]; - d[dst->size-(i+1)] = d[i]; + uint8_t tmp = d[dst->shared->size-(i+1)]; + d[dst->shared->size-(i+1)] = d[i]; d[i] = tmp; } } @@ -3256,13 +3256,13 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * should copy the value to the true destination buffer. */ if (d==dbuf) - HDmemcpy (dp, d, dst->size); + HDmemcpy (dp, d, dst->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { - sp += direction * src->size; - dp += direction * dst->size; + sp += direction * src->shared->size; + dp += direction * dst->shared->size; } } @@ -3348,13 +3348,13 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL==(src_p=H5I_object(src_id)) || NULL==(dst_p=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - src = src_p->u.atomic; - dst = dst_p->u.atomic; + src = src_p->shared->u.atomic; + dst = dst_p->shared->u.atomic; if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (dst_p->size>sizeof(dbuf)) + if (dst_p->shared->size>sizeof(dbuf)) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); if (8*sizeof(expo)-1u.atomic; - dst = dst_p->u.atomic; + src = src_p->shared->u.atomic; + dst = dst_p->shared->u.atomic; expo_max = ((hssize_t)1 << dst.u.f.esize) - 1; /* @@ -3378,22 +3378,22 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src_p->size==dst_p->size || buf_stride) { + if (src_p->shared->size==dst_p->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; - } else if (src_p->size>=dst_p->size) { - double olap_d = HDceil((double)(dst_p->size)/ - (double)(src_p->size-dst_p->size)); + } else if (src_p->shared->size>=dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size)/ + (double)(src_p->shared->size-dst_p->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; } else { - double olap_d = HDceil((double)(src_p->size)/ - (double)(dst_p->size-src_p->size)); + double olap_d = HDceil((double)(src_p->shared->size)/ + (double)(dst_p->shared->size-src_p->shared->size)); olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->size; + sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; + dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; direction = -1; } @@ -3406,7 +3406,7 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->size); + src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); /* The conversion loop */ for (elmtno=0; elmtno=sp && dpsize) || - (sp>=dp && spsize)); + assert ((dp>=sp && dpshared->size) || + (sp>=dp && spshared->size)); } else { - assert ((dpsize<=sp) || - (spsize<=dp)); + assert ((dpshared->size<=sp) || + (spshared->size<=dp)); } #endif @@ -3442,10 +3442,10 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * little endian and then we'll fix the order at the end. */ if (H5T_ORDER_BE==src.order) { - half_size = src_p->size/2; + half_size = src_p->shared->size/2; for (i=0; isize-(i+1)]; - s[src_p->size-(i+1)] = s[i]; + uint8_t tmp = s[src_p->shared->size-(i+1)]; + s[src_p->shared->size-(i+1)] = s[i]; s[i] = tmp; } } @@ -3573,7 +3573,7 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * original byte order. */ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -3653,7 +3653,7 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * buffer we hand it is in the original byte order. */ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -3688,9 +3688,9 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); H5T_bit_set (d, 0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); } - if (dst.offset+dst.prec!=8*dst_p->size) { + if (dst.offset+dst.prec!=8*dst_p->shared->size) { assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); - H5T_bit_set (d, dst.offset+dst.prec, 8*dst_p->size - (dst.offset+dst.prec), + H5T_bit_set (d, dst.offset+dst.prec, 8*dst_p->shared->size - (dst.offset+dst.prec), (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); } @@ -3699,10 +3699,10 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * beginning of loop. */ if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->size/2; + half_size = dst_p->shared->size/2; for (i=0; isize-(i+1)]; - d[dst_p->size-(i+1)] = d[i]; + uint8_t tmp = d[dst_p->shared->size-(i+1)]; + d[dst_p->shared->size-(i+1)] = d[i]; d[i] = tmp; } } @@ -3713,13 +3713,13 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ /* next: */ if (d==dbuf) - HDmemcpy (dp, d, dst_p->size); + HDmemcpy (dp, d, dst_p->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { - sp += direction * src_p->size; - dp += direction * dst_p->size; + sp += direction * src_p->shared->size; + dp += direction * dst_p->shared->size; } } @@ -3776,14 +3776,14 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL==(src=H5I_object(src_id)) || NULL==(dst=H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (8*src->size != src->u.atomic.prec || 8*dst->size != dst->u.atomic.prec) + if (8*src->shared->size != src->shared->u.atomic.prec || 8*dst->shared->size != dst->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision"); - if (0 != src->u.atomic.offset || 0 != dst->u.atomic.offset) + if (0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset"); - if (H5T_CSET_ASCII != src->u.atomic.u.s.cset || H5T_CSET_ASCII != dst->u.atomic.u.s.cset) + if (H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset || H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character set"); - if (src->u.atomic.u.s.pad<0 || src->u.atomic.u.s.pad>=H5T_NPAD || - dst->u.atomic.u.s.pad<0 || dst->u.atomic.u.s.pad>=H5T_NPAD) + if (src->shared->u.atomic.u.s.pad<0 || src->shared->u.atomic.u.s.pad>=H5T_NPAD || + dst->shared->u.atomic.u.s.pad<0 || dst->shared->u.atomic.u.s.pad>=H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding"); cdata->need_bkg = H5T_BKG_NO; break; @@ -3802,7 +3802,7 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * how many of the elements have the source and destination areas * overlapping? */ - if (src->size==dst->size || buf_stride) { + if (src->shared->size==dst->shared->size || buf_stride) { /* * When the source and destination are the same size we can do * all the conversions in place. @@ -3810,23 +3810,23 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, sp = dp = (uint8_t*)buf; direction = 1; olap = 0; - } else if (src->size>=dst->size) { - double olapd = HDceil((double)(dst->size)/ - (double)(src->size-dst->size)); + } else if (src->shared->size>=dst->shared->size) { + double olapd = HDceil((double)(dst->shared->size)/ + (double)(src->shared->size-dst->shared->size)); olap = (size_t)olapd; sp = dp = (uint8_t*)buf; direction = 1; } else { - double olapd = HDceil((double)(src->size)/ - (double)(dst->size-src->size)); + double olapd = HDceil((double)(src->shared->size)/ + (double)(dst->shared->size-src->shared->size)); olap = (size_t)olapd; - sp = (uint8_t*)buf + (nelmts-1) * src->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->size; + sp = (uint8_t*)buf + (nelmts-1) * src->shared->size; + dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size; direction = -1; } /* Allocate the overlap buffer */ - if (NULL==(dbuf=H5MM_malloc(dst->size))) + if (NULL==(dbuf=H5MM_malloc(dst->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion"); /* The conversion loop. */ @@ -3845,22 +3845,22 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ - if (src->size==dst->size || buf_stride) { + if (src->shared->size==dst->shared->size || buf_stride) { assert(s==d); } else if (d==dbuf) { - assert((dp>=sp && dpsize) || - (sp>=dp && spsize)); + assert((dp>=sp && dpshared->size) || + (sp>=dp && spshared->size)); } else { - assert((dpsize<=sp) || - (spsize<=dp)); + assert((dpshared->size<=sp) || + (spshared->size<=dp)); } #endif /* Copy characters from source to destination */ - switch (src->u.atomic.u.s.pad) { + switch (src->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: for (nchars=0; - ncharssize && ncharssize && s[nchars]; + ncharsshared->size && ncharsshared->size && s[nchars]; nchars++) { d[nchars] = s[nchars]; } @@ -3868,17 +3868,17 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_STR_NULLPAD: for (nchars=0; - ncharssize && ncharssize && s[nchars]; + ncharsshared->size && ncharsshared->size && s[nchars]; nchars++) { d[nchars] = s[nchars]; } break; case H5T_STR_SPACEPAD: - nchars = src->size; + nchars = src->shared->size; while (nchars>0 && ' '==s[nchars-1]) --nchars; - nchars = MIN(dst->size, nchars); + nchars = MIN(dst->shared->size, nchars); HDmemcpy(d, s, nchars); break; @@ -3900,20 +3900,20 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* Terminate or pad the destination */ - switch (dst->u.atomic.u.s.pad) { + switch (dst->shared->u.atomic.u.s.pad) { case H5T_STR_NULLTERM: - while (ncharssize) + while (ncharsshared->size) d[nchars++] = '\0'; - d[dst->size-1] = '\0'; + d[dst->shared->size-1] = '\0'; break; case H5T_STR_NULLPAD: - while (ncharssize) + while (ncharsshared->size) d[nchars++] = '\0'; break; case H5T_STR_SPACEPAD: - while (ncharssize) + while (ncharsshared->size) d[nchars++] = ' '; break; @@ -3939,13 +3939,13 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * should copy the value to the true destination buffer. */ if (d==dbuf) - HDmemcpy(dp, d, dst->size); + HDmemcpy(dp, d, dst->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { - sp += direction * src->size; - dp += direction * dst->size; + sp += direction * src->shared->size; + dp += direction * dst->shared->size; } } break; @@ -8326,7 +8326,7 @@ H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, d = tmp; /* Convert the integer to a sign and magnitude */ - switch (src->u.atomic.u.i.sign) { + switch (src->shared->u.atomic.u.i.sign) { case H5T_SGN_NONE: sign = 0; break; @@ -8711,11 +8711,11 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL==(src_p=H5I_object(src_id)) || NULL==(dst_p=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - src = src_p->u.atomic; - dst = dst_p->u.atomic; + src = src_p->shared->u.atomic; + dst = dst_p->shared->u.atomic; if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (dst_p->size>sizeof(dbuf)) + if (dst_p->shared->size>sizeof(dbuf)) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); if (8*sizeof(expo)-1u.atomic; - dst = dst_p->u.atomic; + src = src_p->shared->u.atomic; + dst = dst_p->shared->u.atomic; /* * Do we process the values from beginning to end or vice versa? Also, * how many of the elements have the source and destination areas * overlapping? */ - if (src_p->size==dst_p->size || buf_stride) { + if (src_p->shared->size==dst_p->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; - } else if (src_p->size>=dst_p->size) { - double olap_d = HDceil((double)(dst_p->size)/ - (double)(src_p->size-dst_p->size)); + } else if (src_p->shared->size>=dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size)/ + (double)(src_p->shared->size-dst_p->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; } else { - double olap_d = HDceil((double)(src_p->size)/ - (double)(dst_p->size-src_p->size)); + double olap_d = HDceil((double)(src_p->shared->size)/ + (double)(dst_p->shared->size-src_p->shared->size)); olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->size; + sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; + dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; direction = -1; } @@ -8772,7 +8772,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->size); + src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); /* The conversion loop */ for (elmtno=0; elmtno=sp && dpsize) || - (sp>=dp && spsize)); + assert ((dp>=sp && dpshared->size) || + (sp>=dp && spshared->size)); } else { - assert ((dpsize<=sp) || - (spsize<=dp)); + assert ((dpshared->size<=sp) || + (spshared->size<=dp)); } #endif /* @@ -8808,10 +8808,10 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * little endian and then we'll fix the order at the end. */ if (H5T_ORDER_BE==src.order) { - half_size = src_p->size/2; + half_size = src_p->shared->size/2; for (i=0; isize-(i+1)]; - s[src_p->size-(i+1)] = s[i]; + uint8_t tmp = s[src_p->shared->size-(i+1)]; + s[src_p->shared->size-(i+1)] = s[i]; s[i] = tmp; } } @@ -8944,7 +8944,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ if(sign) { /*source is negative*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, d, cb_struct.user_data); if(except_ret == H5T_CONV_ABORT) @@ -8957,7 +8957,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (first>=dst.prec) { /*overflow*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -8971,7 +8971,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") } else if (first size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -8990,7 +8990,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if(sign) { /*source is negative*/ if(first < dst.prec-1) { if(truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -9009,7 +9009,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the sign bit because 0x80...00 is the biggest negative value. */ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -9026,7 +9026,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (first >= dst.prec-1) { /*overflow*/ if(cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -9040,7 +9040,7 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, reverse = FALSE; } else if(first < dst.prec-1) { if(truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_TRUNCATE, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -9065,10 +9065,10 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); H5T_bit_set (d, 0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); } - if (dst.offset+dst.prec!=8*dst_p->size) { + if (dst.offset+dst.prec!=8*dst_p->shared->size) { assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); H5T_bit_set (d, dst.offset+dst.prec, - 8*dst_p->size - (dst.offset+ dst.prec), + 8*dst_p->shared->size - (dst.offset+ dst.prec), (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); } @@ -9077,10 +9077,10 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * beginning of loop. */ if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->size/2; + half_size = dst_p->shared->size/2; for (i=0; isize-(i+1)]; - d[dst_p->size-(i+1)] = d[i]; + uint8_t tmp = d[dst_p->shared->size-(i+1)]; + d[dst_p->shared->size-(i+1)] = d[i]; d[i] = tmp; } } @@ -9090,13 +9090,13 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * should copy the value to the true destination buffer. */ if (d==dbuf) - HDmemcpy (dp, d, dst_p->size); + HDmemcpy (dp, d, dst_p->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { - sp += direction * src_p->size; - dp += direction * dst_p->size; + sp += direction * src_p->shared->size; + dp += direction * dst_p->shared->size; } HDmemset(int_buf, 0, buf_size); @@ -9179,11 +9179,11 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (NULL==(src_p=H5I_object(src_id)) || NULL==(dst_p=H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - src = src_p->u.atomic; - dst = dst_p->u.atomic; + src = src_p->shared->u.atomic; + dst = dst_p->shared->u.atomic; if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); - if (dst_p->size>sizeof(dbuf)) + if (dst_p->shared->size>sizeof(dbuf)) HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large"); if (8*sizeof(expo)-1u.atomic; - dst = dst_p->u.atomic; + src = src_p->shared->u.atomic; + dst = dst_p->shared->u.atomic; /* * Do we process the values from beginning to end or vice versa? Also, * how many of the elements have the source and destination areas * overlapping? */ - if (src_p->size==dst_p->size || buf_stride) { + if (src_p->shared->size==dst_p->shared->size || buf_stride) { sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; - } else if (src_p->size>=dst_p->size) { - double olap_d = HDceil((double)(dst_p->size)/ - (double)(src_p->size-dst_p->size)); + } else if (src_p->shared->size>=dst_p->shared->size) { + double olap_d = HDceil((double)(dst_p->shared->size)/ + (double)(src_p->shared->size-dst_p->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; } else { - double olap_d = HDceil((double)(src_p->size)/ - (double)(dst_p->size-src_p->size)); + double olap_d = HDceil((double)(src_p->shared->size)/ + (double)(dst_p->shared->size-src_p->shared->size)); olap = (size_t)olap_d; - sp = (uint8_t*)buf + (nelmts-1) * src_p->size; - dp = (uint8_t*)buf + (nelmts-1) * dst_p->size; + sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size; + dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size; direction = -1; } @@ -9240,7 +9240,7 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); /* Allocate space for order-reversed source buffer */ - src_rev = (uint8_t*)H5MM_calloc(src_p->size); + src_rev = (uint8_t*)H5MM_calloc(src_p->shared->size); /* The conversion loop */ for (elmtno=0; elmtno=sp && dpsize) || - (sp>=dp && spsize)); + assert ((dp>=sp && dpshared->size) || + (sp>=dp && spshared->size)); } else { - assert ((dpsize<=sp) || - (spsize<=dp)); + assert ((dpshared->size<=sp) || + (spshared->size<=dp)); } #endif @@ -9282,10 +9282,10 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * little endian and then we'll fix the order at the end. */ if (H5T_ORDER_BE==src.order) { - half_size = src_p->size/2; + half_size = src_p->shared->size/2; for (i=0; isize-(i+1)]; - s[src_p->size-(i+1)] = s[i]; + uint8_t tmp = s[src_p->shared->size-(i+1)]; + s[src_p->shared->size-(i+1)] = s[i]; s[i] = tmp; } } @@ -9374,7 +9374,7 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * precision loss. Let user's handler deal with the case if it's present */ if(cb_struct.func) { - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, src_id, dst_id, src_rev, d, cb_struct.user_data); } @@ -9441,7 +9441,7 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if(expo > expo_max) { /*overflows*/ if(cb_struct.func) { /*user's exception handler. Reverse back source order*/ - H5T_reverse_order(src_rev, s, src_p->size, src_p->u.atomic.order); /*reverse order first*/ + H5T_reverse_order(src_rev, s, src_p->shared->size, src_p->shared->u.atomic.order); /*reverse order first*/ except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, src_rev, d, cb_struct.user_data); @@ -9475,10 +9475,10 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); H5T_bit_set (d, 0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); } - if (dst.offset+dst.prec!=8*dst_p->size) { + if (dst.offset+dst.prec!=8*dst_p->shared->size) { assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); H5T_bit_set (d, dst.offset+dst.prec, - 8*dst_p->size - (dst.offset+ dst.prec), + 8*dst_p->shared->size - (dst.offset+ dst.prec), (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); } @@ -9487,10 +9487,10 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * beginning of loop. */ if (H5T_ORDER_BE==dst.order && reverse) { - half_size = dst_p->size/2; + half_size = dst_p->shared->size/2; for (i=0; isize-(i+1)]; - d[dst_p->size-(i+1)] = d[i]; + uint8_t tmp = d[dst_p->shared->size-(i+1)]; + d[dst_p->shared->size-(i+1)] = d[i]; d[i] = tmp; } } @@ -9500,13 +9500,13 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * should copy the value to the true destination buffer. */ if (d==dbuf) - HDmemcpy (dp, d, dst_p->size); + HDmemcpy (dp, d, dst_p->shared->size); if (buf_stride) { sp += direction * buf_stride; dp += direction * buf_stride; } else { - sp += direction * src_p->size; - dp += direction * dst_p->size; + sp += direction * src_p->shared->size; + dp += direction * dst_p->shared->size; } HDmemset(int_buf, 0, buf_size); diff --git a/src/H5Tcset.c b/src/H5Tcset.c index acc1064..1a9e39d 100644 --- a/src/H5Tcset.c +++ b/src/H5Tcset.c @@ -86,16 +86,16 @@ H5Tget_cset(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, "not a data type") - while (dt->parent && !H5T_IS_STRING(dt)) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_STRING(dt)) + while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_CSET_ERROR, "operation not defined for data type class") /* result */ - if(H5T_IS_FIXED_STRING(dt)) - ret_value = dt->u.atomic.u.s.cset; + if(H5T_IS_FIXED_STRING(dt->shared)) + ret_value = dt->shared->u.atomic.u.s.cset; else - ret_value = dt->u.vlen.cset; + ret_value = dt->shared->u.vlen.cset; done: FUNC_LEAVE_API(ret_value) @@ -132,20 +132,20 @@ H5Tset_cset(hid_t type_id, H5T_cset_t cset) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (cset < 0 || cset >= H5T_NCSET) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal character set type") - while (dt->parent && !H5T_IS_STRING(dt)) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_STRING(dt)) + while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for data type class") /* Commit */ - if(H5T_IS_FIXED_STRING(dt)) - dt->u.atomic.u.s.cset = cset; + if(H5T_IS_FIXED_STRING(dt->shared)) + dt->shared->u.atomic.u.s.cset = cset; else - dt->u.vlen.cset = cset; + dt->shared->u.vlen.cset = cset; done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tenum.c b/src/H5Tenum.c index 769ca12..3f8528d 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -33,8 +33,9 @@ #include "H5MMprivate.h" /*memory management */ #include "H5Tpkg.h" /*data-type functions */ -/* Declare extern the free list for H5T_t's */ +/* Declare extern the free lists for H5T_t's and H5T_shared_t's */ H5FL_EXTERN(H5T_t); +H5FL_EXTERN(H5T_shared_t); /* Static local functions */ static char *H5T_enum_nameof(H5T_t *dt, const void *value, char *name/*out*/, @@ -93,7 +94,7 @@ H5Tenum_create(hid_t parent_id) H5TRACE1("i","i",parent_id); /* Check args */ - if (NULL==(parent=H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_INTEGER!=parent->type) + if (NULL==(parent=H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_INTEGER!=parent->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type") /* Build new type */ @@ -137,11 +138,15 @@ H5T_enum_create(const H5T_t *parent) /* Build new type */ if (NULL==(ret_value = H5FL_CALLOC(H5T_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - ret_value->type = H5T_ENUM; - ret_value->parent = H5T_copy(parent, H5T_COPY_ALL); - assert(ret_value->parent); - ret_value->size = ret_value->parent->size; + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL==(ret_value->shared=H5FL_CALLOC(H5T_shared_t))) { + H5FL_FREE(H5T_t, ret_value); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + } + ret_value->shared->type = H5T_ENUM; + ret_value->shared->parent = H5T_copy(parent, H5T_COPY_ALL); + assert(ret_value->shared->parent); + ret_value->shared->size = ret_value->shared->parent->shared->size; ret_value->ent.header = HADDR_UNDEF; done: @@ -182,7 +187,7 @@ H5Tenum_insert(hid_t type, const char *name, const void *value) /* Check args */ if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_ENUM!=dt->type) + if (H5T_ENUM!=dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") @@ -232,31 +237,31 @@ H5T_enum_insert(H5T_t *dt, const char *name, const void *value) assert(value); /* The name and value had better not already exist */ - for (i=0; iu.enumer.nmembs; i++) { - if (!HDstrcmp(dt->u.enumer.name[i], name)) + for (i=0; ishared->u.enumer.nmembs; i++) { + if (!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition") - if (!HDmemcmp(dt->u.enumer.value+i*dt->size, value, dt->size)) + if (!HDmemcmp(dt->shared->u.enumer.value+i*dt->shared->size, value, dt->shared->size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition") } /* Increase table sizes */ - if (dt->u.enumer.nmembs >= dt->u.enumer.nalloc) { - unsigned n = MAX(32, 2*dt->u.enumer.nalloc); - if (NULL==(names=H5MM_realloc(dt->u.enumer.name, n*sizeof(char*)))) + if (dt->shared->u.enumer.nmembs >= dt->shared->u.enumer.nalloc) { + unsigned n = MAX(32, 2*dt->shared->u.enumer.nalloc); + if (NULL==(names=H5MM_realloc(dt->shared->u.enumer.name, n*sizeof(char*)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - dt->u.enumer.name = names; + dt->shared->u.enumer.name = names; - if (NULL==(values=H5MM_realloc(dt->u.enumer.value, n*dt->size))) + if (NULL==(values=H5MM_realloc(dt->shared->u.enumer.value, n*dt->shared->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - dt->u.enumer.value = values; - dt->u.enumer.nalloc = n; + dt->shared->u.enumer.value = values; + dt->shared->u.enumer.nalloc = n; } /* Insert new member at end of member arrays */ - dt->u.enumer.sorted = H5T_SORT_NONE; - i = dt->u.enumer.nmembs++; - dt->u.enumer.name[i] = H5MM_xstrdup(name); - HDmemcpy(dt->u.enumer.value+i*dt->size, value, dt->size); + dt->shared->u.enumer.sorted = H5T_SORT_NONE; + i = dt->shared->u.enumer.nmembs++; + dt->shared->u.enumer.name[i] = H5MM_xstrdup(name); + HDmemcpy(dt->shared->u.enumer.value+i*dt->shared->size, value, dt->shared->size); done: FUNC_LEAVE_NOAPI(ret_value) @@ -299,9 +304,9 @@ H5Tget_member_value(hid_t type, unsigned membno, void *value/*out*/) if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_ENUM!=dt->type) + if (H5T_ENUM!=dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class") - if (membno>=dt->u.enumer.nmembs) + if (membno>=dt->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number") if (!value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer") @@ -341,7 +346,7 @@ H5T_get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/) assert(dt); assert(value); - HDmemcpy(value, dt->u.enumer.value + membno*dt->size, dt->size); + HDmemcpy(value, dt->shared->u.enumer.value + membno*dt->shared->size, dt->shared->size); done: FUNC_LEAVE_NOAPI(ret_value) @@ -383,7 +388,7 @@ H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, size_t size) /* Check args */ if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_ENUM!=dt->type) + if (H5T_ENUM!=dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied") @@ -433,24 +438,24 @@ H5T_enum_nameof(H5T_t *dt, const void *value, char *name/*out*/, size_t size) FUNC_ENTER_NOAPI(H5T_enum_nameof, NULL) /* Check args */ - assert(dt && H5T_ENUM==dt->type); + assert(dt && H5T_ENUM==dt->shared->type); assert(value); assert(name || 0==size); if (name && size>0) *name = '\0'; /* Sanity check */ - if (dt->u.enumer.nmembs == 0) + if (dt->shared->u.enumer.nmembs == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "datatype has no members") /* Do a binary search over the values to find the correct one */ if(H5T_sort_value(dt, NULL)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, NULL, "value sort failed") lt = 0; - rt = dt->u.enumer.nmembs; + rt = dt->shared->u.enumer.nmembs; while (ltu.enumer.value+md*dt->size, dt->size); + cmp = HDmemcmp(value, dt->shared->u.enumer.value+md*dt->shared->size, dt->shared->size); if (cmp<0) { rt = md; } else if (cmp>0) { @@ -464,10 +469,10 @@ H5T_enum_nameof(H5T_t *dt, const void *value, char *name/*out*/, size_t size) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "value is currently not defined") /* Save result name */ - if (!name && NULL==(name=H5MM_malloc(HDstrlen(dt->u.enumer.name[md])+1))) + if (!name && NULL==(name=H5MM_malloc(HDstrlen(dt->shared->u.enumer.name[md])+1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - HDstrncpy(name, dt->u.enumer.name[md], size); - if (HDstrlen(dt->u.enumer.name[md])>=size) + HDstrncpy(name, dt->shared->u.enumer.name[md], size); + if (HDstrlen(dt->shared->u.enumer.name[md])>=size) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated") /* Set return value */ @@ -509,7 +514,7 @@ H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/) /* Check args */ if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_ENUM!=dt->type) + if (H5T_ENUM!=dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -553,23 +558,23 @@ H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/) FUNC_ENTER_NOAPI(H5T_enum_valueof, FAIL) /* Check args */ - assert(dt && H5T_ENUM==dt->type); + assert(dt && H5T_ENUM==dt->shared->type); assert(name && *name); assert(value); /* Sanity check */ - if (dt->u.enumer.nmembs == 0) + if (dt->shared->u.enumer.nmembs == 0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "datatype has no members") /* Do a binary search over the names to find the correct one */ if(H5T_sort_name(dt, NULL)<0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed") lt = 0; - rt = dt->u.enumer.nmembs; + rt = dt->shared->u.enumer.nmembs; while (ltu.enumer.name[md]); + cmp = HDstrcmp(name, dt->shared->u.enumer.name[md]); if (cmp<0) { rt = md; } else if (cmp>0) { @@ -582,7 +587,7 @@ H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/) if (cmp!=0) HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type") - HDmemcpy(value, dt->u.enumer.value+md*dt->size, dt->size); + HDmemcpy(value, dt->shared->u.enumer.value+md*dt->shared->size, dt->shared->size); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Tfields.c b/src/H5Tfields.c index 2ad9b92..48a7e22 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -125,10 +125,10 @@ H5T_get_nmembers(const H5T_t *dt) assert(dt); - if (H5T_COMPOUND==dt->type) - ret_value = (int)dt->u.compnd.nmembs; - else if (H5T_ENUM==dt->type) - ret_value = (int)dt->u.enumer.nmembs; + if (H5T_COMPOUND==dt->shared->type) + ret_value = (int)dt->shared->u.compnd.nmembs; + else if (H5T_ENUM==dt->shared->type) + ret_value = (int)dt->shared->u.enumer.nmembs; else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for type class") @@ -214,17 +214,17 @@ H5T_get_member_name(H5T_t const *dt, unsigned membno) assert(dt); - switch (dt->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - if (membno>=dt->u.compnd.nmembs) + if (membno>=dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number") - ret_value = H5MM_xstrdup(dt->u.compnd.memb[membno].name); + ret_value = H5MM_xstrdup(dt->shared->u.compnd.memb[membno].name); break; case H5T_ENUM: - if (membno>=dt->u.enumer.nmembs) + if (membno>=dt->shared->u.enumer.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number") - ret_value = H5MM_xstrdup(dt->u.enumer.name[membno]); + ret_value = H5MM_xstrdup(dt->shared->u.enumer.name[membno]); break; default: @@ -270,16 +270,16 @@ H5Tget_member_index(hid_t type_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Locate member by name */ - switch (dt->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - for(i=0; i< dt->u.compnd.nmembs; i++) { - if(!HDstrcmp(dt->u.compnd.memb[i].name, name)) + for(i=0; i< dt->shared->u.compnd.nmembs; i++) { + if(!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) HGOTO_DONE((int)i) } break; case H5T_ENUM: - for(i=0; i< dt->u.enumer.nmembs; i++) { - if(!HDstrcmp(dt->u.enumer.name[i], name)) + for(i=0; i< dt->shared->u.enumer.nmembs; i++) { + if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_DONE((int)i) } break; @@ -323,20 +323,20 @@ H5T_sort_value(H5T_t *dt, int *map) /* Check args */ assert(dt); - assert(H5T_COMPOUND==dt->type || H5T_ENUM==dt->type); + assert(H5T_COMPOUND==dt->shared->type || H5T_ENUM==dt->shared->type); /* Use a bubble sort because we can short circuit */ - if (H5T_COMPOUND==dt->type) { - if (H5T_SORT_VALUE!=dt->u.compnd.sorted) { - dt->u.compnd.sorted = H5T_SORT_VALUE; - nmembs = dt->u.compnd.nmembs; + if (H5T_COMPOUND==dt->shared->type) { + if (H5T_SORT_VALUE!=dt->shared->u.compnd.sorted) { + dt->shared->u.compnd.sorted = H5T_SORT_VALUE; + nmembs = dt->shared->u.compnd.nmembs; for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; ju.compnd.memb[j].offset > - dt->u.compnd.memb[j+1].offset) { - H5T_cmemb_t tmp = dt->u.compnd.memb[j]; - dt->u.compnd.memb[j] = dt->u.compnd.memb[j+1]; - dt->u.compnd.memb[j+1] = tmp; + if (dt->shared->u.compnd.memb[j].offset > + dt->shared->u.compnd.memb[j+1].offset) { + H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; + dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j+1]; + dt->shared->u.compnd.memb[j+1] = tmp; if (map) { int x = map[j]; map[j] = map[j+1]; @@ -349,32 +349,32 @@ H5T_sort_value(H5T_t *dt, int *map) #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; iu.compnd.memb[i].offset < - dt->u.compnd.memb[i+1].offset); + assert(dt->shared->u.compnd.memb[i].offset < + dt->shared->u.compnd.memb[i+1].offset); } #endif } - } else if (H5T_ENUM==dt->type) { - if (H5T_SORT_VALUE!=dt->u.enumer.sorted) { - dt->u.enumer.sorted = H5T_SORT_VALUE; - nmembs = dt->u.enumer.nmembs; - size = dt->size; + } else if (H5T_ENUM==dt->shared->type) { + if (H5T_SORT_VALUE!=dt->shared->u.enumer.sorted) { + dt->shared->u.enumer.sorted = H5T_SORT_VALUE; + nmembs = dt->shared->u.enumer.nmembs; + size = dt->shared->size; assert(size<=sizeof(tbuf)); for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; ju.enumer.value+j*size, - dt->u.enumer.value+(j+1)*size, + if (HDmemcmp(dt->shared->u.enumer.value+j*size, + dt->shared->u.enumer.value+(j+1)*size, size)>0) { /* Swap names */ - char *tmp = dt->u.enumer.name[j]; - dt->u.enumer.name[j] = dt->u.enumer.name[j+1]; - dt->u.enumer.name[j+1] = tmp; + char *tmp = dt->shared->u.enumer.name[j]; + dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j+1]; + dt->shared->u.enumer.name[j+1] = tmp; /* Swap values */ - HDmemcpy(tbuf, dt->u.enumer.value+j*size, size); - HDmemcpy(dt->u.enumer.value+j*size, - dt->u.enumer.value+(j+1)*size, size); - HDmemcpy(dt->u.enumer.value+(j+1)*size, tbuf, size); + HDmemcpy(tbuf, dt->shared->u.enumer.value+j*size, size); + HDmemcpy(dt->shared->u.enumer.value+j*size, + dt->shared->u.enumer.value+(j+1)*size, size); + HDmemcpy(dt->shared->u.enumer.value+(j+1)*size, tbuf, size); /* Swap map */ if (map) { @@ -390,8 +390,8 @@ H5T_sort_value(H5T_t *dt, int *map) #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; iu.enumer.value+i*size, - dt->u.enumer.value+(i+1)*size, + assert(HDmemcmp(dt->shared->u.enumer.value+i*size, + dt->shared->u.enumer.value+(i+1)*size, size)<0); } #endif @@ -434,20 +434,20 @@ H5T_sort_name(H5T_t *dt, int *map) /* Check args */ assert(dt); - assert(H5T_COMPOUND==dt->type || H5T_ENUM==dt->type); + assert(H5T_COMPOUND==dt->shared->type || H5T_ENUM==dt->shared->type); /* Use a bubble sort because we can short circuit */ - if (H5T_COMPOUND==dt->type) { - if (H5T_SORT_NAME!=dt->u.compnd.sorted) { - dt->u.compnd.sorted = H5T_SORT_NAME; - nmembs = dt->u.compnd.nmembs; + if (H5T_COMPOUND==dt->shared->type) { + if (H5T_SORT_NAME!=dt->shared->u.compnd.sorted) { + dt->shared->u.compnd.sorted = H5T_SORT_NAME; + nmembs = dt->shared->u.compnd.nmembs; for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; ju.compnd.memb[j].name, - dt->u.compnd.memb[j+1].name)>0) { - H5T_cmemb_t tmp = dt->u.compnd.memb[j]; - dt->u.compnd.memb[j] = dt->u.compnd.memb[j+1]; - dt->u.compnd.memb[j+1] = tmp; + if (HDstrcmp(dt->shared->u.compnd.memb[j].name, + dt->shared->u.compnd.memb[j+1].name)>0) { + H5T_cmemb_t tmp = dt->shared->u.compnd.memb[j]; + dt->shared->u.compnd.memb[j] = dt->shared->u.compnd.memb[j+1]; + dt->shared->u.compnd.memb[j+1] = tmp; swapped = TRUE; if (map) { int x = map[j]; @@ -460,31 +460,31 @@ H5T_sort_name(H5T_t *dt, int *map) #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; iu.compnd.memb[i].name, - dt->u.compnd.memb[i+1].name)<0); + assert(HDstrcmp(dt->shared->u.compnd.memb[i].name, + dt->shared->u.compnd.memb[i+1].name)<0); } #endif } - } else if (H5T_ENUM==dt->type) { - if (H5T_SORT_NAME!=dt->u.enumer.sorted) { - dt->u.enumer.sorted = H5T_SORT_NAME; - nmembs = dt->u.enumer.nmembs; - size = dt->size; + } else if (H5T_ENUM==dt->shared->type) { + if (H5T_SORT_NAME!=dt->shared->u.enumer.sorted) { + dt->shared->u.enumer.sorted = H5T_SORT_NAME; + nmembs = dt->shared->u.enumer.nmembs; + size = dt->shared->size; assert(size<=sizeof(tbuf)); for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) { for (j=0, swapped=FALSE; ju.enumer.name[j], - dt->u.enumer.name[j+1])>0) { + if (HDstrcmp(dt->shared->u.enumer.name[j], + dt->shared->u.enumer.name[j+1])>0) { /* Swap names */ - char *tmp = dt->u.enumer.name[j]; - dt->u.enumer.name[j] = dt->u.enumer.name[j+1]; - dt->u.enumer.name[j+1] = tmp; + char *tmp = dt->shared->u.enumer.name[j]; + dt->shared->u.enumer.name[j] = dt->shared->u.enumer.name[j+1]; + dt->shared->u.enumer.name[j+1] = tmp; /* Swap values */ - HDmemcpy(tbuf, dt->u.enumer.value+j*size, size); - HDmemcpy(dt->u.enumer.value+j*size, - dt->u.enumer.value+(j+1)*size, size); - HDmemcpy(dt->u.enumer.value+(j+1)*size, tbuf, size); + HDmemcpy(tbuf, dt->shared->u.enumer.value+j*size, size); + HDmemcpy(dt->shared->u.enumer.value+j*size, + dt->shared->u.enumer.value+(j+1)*size, size); + HDmemcpy(dt->shared->u.enumer.value+(j+1)*size, tbuf, size); /* Swap map */ if (map) { @@ -500,7 +500,7 @@ H5T_sort_name(H5T_t *dt, int *map) #ifndef NDEBUG /* I never trust a sort :-) -RPM */ for (i=0; iu.enumer.name[i], dt->u.enumer.name[i+1])<0); + assert(HDstrcmp(dt->shared->u.enumer.name[i], dt->shared->u.enumer.name[i+1])<0); #endif } } diff --git a/src/H5Tfixed.c b/src/H5Tfixed.c index 946b677..361ba8d 100644 --- a/src/H5Tfixed.c +++ b/src/H5Tfixed.c @@ -118,15 +118,15 @@ H5T_get_sign(H5T_t const *dt) assert(dt); /* Defer to parent */ - while(dt->parent) - dt = dt->parent; + while(dt->shared->parent) + dt = dt->shared->parent; /* Check args */ - if (H5T_INTEGER!=dt->type) + if (H5T_INTEGER!=dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_SGN_ERROR, "operation not defined for datatype class") /* Sign */ - ret_value = dt->u.atomic.u.i.sign; + ret_value = dt->shared->u.atomic.u.i.sign; done: FUNC_LEAVE_NOAPI(ret_value) @@ -162,19 +162,19 @@ H5Tset_sign(hid_t type_id, H5T_sign_t sign) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer datatype") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (sign < 0 || sign >= H5T_NSGN) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type") - if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) + if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_INTEGER!=dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_INTEGER!=dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ - dt->u.atomic.u.i.sign = sign; + dt->shared->u.atomic.u.i.sign = sign; done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tfloat.c b/src/H5Tfloat.c index f9a4b34..0e54468 100644 --- a/src/H5Tfloat.c +++ b/src/H5Tfloat.c @@ -91,17 +91,17 @@ H5Tget_fields(hid_t type_id, size_t *spos/*out*/, /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_FLOAT != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Get values */ - if (spos) *spos = dt->u.atomic.u.f.sign; - if (epos) *epos = dt->u.atomic.u.f.epos; - if (esize) *esize = dt->u.atomic.u.f.esize; - if (mpos) *mpos = dt->u.atomic.u.f.mpos; - if (msize) *msize = dt->u.atomic.u.f.msize; + if (spos) *spos = dt->shared->u.atomic.u.f.sign; + if (epos) *epos = dt->shared->u.atomic.u.f.epos; + if (esize) *esize = dt->shared->u.atomic.u.f.esize; + if (mpos) *mpos = dt->shared->u.atomic.u.f.mpos; + if (msize) *msize = dt->shared->u.atomic.u.f.msize; done: FUNC_LEAVE_API(ret_value) @@ -143,17 +143,17 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_FLOAT != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") - if (epos + esize > dt->u.atomic.prec) + if (epos + esize > dt->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid") - if (mpos + msize > dt->u.atomic.prec) + if (mpos + msize > dt->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid") - if (spos >= dt->u.atomic.prec) + if (spos >= dt->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid") /* Check for overlap */ @@ -166,11 +166,11 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent and mantissa fields overlap") /* Commit */ - dt->u.atomic.u.f.sign = spos; - dt->u.atomic.u.f.epos = epos; - dt->u.atomic.u.f.mpos = mpos; - dt->u.atomic.u.f.esize = esize; - dt->u.atomic.u.f.msize = msize; + dt->shared->u.atomic.u.f.sign = spos; + dt->shared->u.atomic.u.f.epos = epos; + dt->shared->u.atomic.u.f.mpos = mpos; + dt->shared->u.atomic.u.f.esize = esize; + dt->shared->u.atomic.u.f.msize = msize; done: FUNC_LEAVE_API(ret_value) @@ -206,13 +206,13 @@ H5Tget_ebias(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_FLOAT != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for datatype class") /* bias */ - H5_ASSIGN_OVERFLOW(ret_value,dt->u.atomic.u.f.ebias,uint64_t,size_t); + H5_ASSIGN_OVERFLOW(ret_value,dt->shared->u.atomic.u.f.ebias,uint64_t,size_t); done: FUNC_LEAVE_API(ret_value) @@ -247,15 +247,15 @@ H5Tset_ebias(hid_t type_id, size_t ebias) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_FLOAT != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ - dt->u.atomic.u.f.ebias = ebias; + dt->shared->u.atomic.u.f.ebias = ebias; done: FUNC_LEAVE_API(ret_value) @@ -293,13 +293,13 @@ H5Tget_norm(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a datatype") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_FLOAT != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_NORM_ERROR, "operation not defined for datatype class") /* norm */ - ret_value = dt->u.atomic.u.f.norm; + ret_value = dt->shared->u.atomic.u.f.norm; done: FUNC_LEAVE_API(ret_value) @@ -335,17 +335,17 @@ H5Tset_norm(hid_t type_id, H5T_norm_t norm) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (norm < 0 || norm > H5T_NORM_NONE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_FLOAT != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ - dt->u.atomic.u.f.norm = norm; + dt->shared->u.atomic.u.f.norm = norm; done: FUNC_LEAVE_API(ret_value) @@ -385,13 +385,13 @@ H5Tget_inpad(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a datatype") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_FLOAT != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_PAD_ERROR, "operation not defined for datatype class") /* pad */ - ret_value = dt->u.atomic.u.f.pad; + ret_value = dt->shared->u.atomic.u.f.pad; done: FUNC_LEAVE_API(ret_value) @@ -429,17 +429,17 @@ H5Tset_inpad(hid_t type_id, H5T_pad_t pad) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (pad < 0 || pad >= H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_FLOAT != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_FLOAT != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class") /* Commit */ - dt->u.atomic.u.f.pad = pad; + dt->shared->u.atomic.u.f.pad = pad; done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tnative.c b/src/H5Tnative.c index 9ae0be7..3785310 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -184,7 +184,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig if((sign = H5T_get_sign(dtype))==H5T_SGN_ERROR) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a valid signess") - prec = dtype->u.atomic.prec; + prec = dtype->shared->u.atomic.prec; if((ret_value = H5T_get_native_integer(prec, sign, direction, struct_align, offset, comp_size))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve integer type") @@ -201,7 +201,7 @@ H5T_get_native_type(H5T_t *dtype, H5T_direction_t direction, size_t *struct_alig if((ret_value=H5T_copy(dtype, H5T_COPY_TRANSIENT))==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type") - if(H5T_IS_VL_STRING(dtype)) { + if(H5T_IS_VL_STRING(dtype->shared)) { /* Update size, offset and compound alignment for parent. */ if(H5T_cmp_offset(comp_size, offset, sizeof(char *), 1, H5T_POINTER_COMP_ALIGN_g, struct_align)<0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset") diff --git a/src/H5Toffset.c b/src/H5Toffset.c index 850737c..943415e 100644 --- a/src/H5Toffset.c +++ b/src/H5Toffset.c @@ -103,13 +103,13 @@ H5Tget_offset(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_ATOMIC(dt)) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Offset */ - ret_value = (int)dt->u.atomic.offset; + ret_value = (int)dt->shared->u.atomic.offset; done: FUNC_LEAVE_API(ret_value) @@ -167,13 +167,13 @@ H5Tset_offset(hid_t type_id, size_t offset) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") - if (H5T_STRING == dt->type && offset != 0) + if (H5T_STRING == dt->shared->type && offset != 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type") - if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) + if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") - if (H5T_COMPOUND==dt->type || H5T_REFERENCE==dt->type || H5T_OPAQUE==dt->type) + if (H5T_COMPOUND==dt->shared->type || H5T_REFERENCE==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype") /* Do the real work */ @@ -233,25 +233,25 @@ H5T_set_offset(H5T_t *dt, size_t offset) /* Check args */ assert(dt); - assert(H5T_STRING!=dt->type || 0==offset); - assert(H5T_REFERENCE!=dt->type); - assert(H5T_OPAQUE!=dt->type); - assert(H5T_COMPOUND!=dt->type); - assert(!(H5T_ENUM==dt->type && 0==dt->u.enumer.nmembs)); + assert(H5T_STRING!=dt->shared->type || 0==offset); + assert(H5T_REFERENCE!=dt->shared->type); + assert(H5T_OPAQUE!=dt->shared->type); + assert(H5T_COMPOUND!=dt->shared->type); + assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); - if (dt->parent) { - if (H5T_set_offset(dt->parent, offset)<0) + if (dt->shared->parent) { + if (H5T_set_offset(dt->shared->parent, offset)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type") /* Adjust size of datatype appropriately */ - if(dt->type==H5T_ARRAY) - dt->size = dt->parent->size * dt->u.array.nelem; - else if(dt->type!=H5T_VLEN) - dt->size = dt->parent->size; + if(dt->shared->type==H5T_ARRAY) + dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; + else if(dt->shared->type!=H5T_VLEN) + dt->shared->size = dt->shared->parent->shared->size; } else { - if (offset+dt->u.atomic.prec > 8*dt->size) - dt->size = (offset + dt->u.atomic.prec + 7) / 8; - dt->u.atomic.offset = offset; + if (offset+dt->shared->u.atomic.prec > 8*dt->shared->size) + dt->shared->size = (offset + dt->shared->u.atomic.prec + 7) / 8; + dt->shared->u.atomic.offset = offset; } done: diff --git a/src/H5Topaque.c b/src/H5Topaque.c index 96fed31..0bfed4b 100644 --- a/src/H5Topaque.c +++ b/src/H5Topaque.c @@ -81,18 +81,18 @@ H5Tset_tag(hid_t type_id, const char *tag) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_OPAQUE!=dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_OPAQUE!=dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an opaque data type") if (!tag) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no tag") /* Commit */ - H5MM_xfree(dt->u.opaque.tag); - dt->u.opaque.tag = H5MM_strdup(tag); + H5MM_xfree(dt->shared->u.opaque.tag); + dt->shared->u.opaque.tag = H5MM_strdup(tag); done: FUNC_LEAVE_API(ret_value) @@ -125,13 +125,13 @@ H5Tget_tag(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_OPAQUE != dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_OPAQUE != dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "operation not defined for data type class") /* result */ - if (NULL==(ret_value=H5MM_strdup(dt->u.opaque.tag))) + if (NULL==(ret_value=H5MM_strdup(dt->shared->u.opaque.tag))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") done: diff --git a/src/H5Torder.c b/src/H5Torder.c index 48210cd..1c23de8 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -84,13 +84,13 @@ H5Tget_order(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, "not a data type") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_ATOMIC(dt)) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "operation not defined for specified data type") /* Order */ - ret_value = dt->u.atomic.order; + ret_value = dt->shared->u.atomic.order; done: FUNC_LEAVE_API(ret_value) @@ -125,19 +125,19 @@ H5Tset_order(hid_t type_id, H5T_order_t order) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (order < 0 || order > H5T_ORDER_NONE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal byte order") - if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) + if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_ATOMIC(dt)) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "operation not defined for specified data type") /* Commit */ - dt->u.atomic.order = order; + dt->shared->u.atomic.order = order; done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tpad.c b/src/H5Tpad.c index a6b818e..a4fe620 100644 --- a/src/H5Tpad.c +++ b/src/H5Tpad.c @@ -84,16 +84,16 @@ H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_ATOMIC(dt)) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Get values */ if (lsb) - *lsb = dt->u.atomic.lsb_pad; + *lsb = dt->shared->u.atomic.lsb_pad; if (msb) - *msb = dt->u.atomic.msb_pad; + *msb = dt->shared->u.atomic.msb_pad; done: FUNC_LEAVE_API(ret_value) @@ -128,20 +128,20 @@ H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only") if (lsb < 0 || lsb >= H5T_NPAD || msb < 0 || msb >= H5T_NPAD) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type") - if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) + if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_ATOMIC(dt)) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type") /* Commit */ - dt->u.atomic.lsb_pad = lsb; - dt->u.atomic.msb_pad = msb; + dt->shared->u.atomic.lsb_pad = lsb; + dt->shared->u.atomic.msb_pad = msb; done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 6b52d86..7e7203a 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -195,9 +195,10 @@ typedef enum H5T_state_t { H5T_STATE_OPEN /*named constant, open object header */ } H5T_state_t; -struct H5T_t { + /* This struct is shared between all occurances of an open named type */ +typedef struct H5T_shared_t { + hsize_t fo_count; /* number of references to this file object */ H5T_state_t state; /*current state of the type */ - H5G_entry_t ent; /*the type is a named type */ H5F_t *sh_file;/*file pointer if this is a shared type */ H5T_class_t type; /*which class of type is this? */ size_t size; /*total size of an instance of this type */ @@ -211,6 +212,11 @@ struct H5T_t { H5T_opaque_t opaque; /* an opaque datatype */ H5T_array_t array; /* an array datatype */ } u; +} H5T_shared_t; + +struct H5T_t { + H5G_entry_t ent; /* entry information if the type is a named type */ + H5T_shared_t *shared; /* all other information */ }; /* A compound datatype member */ diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index a22ff49..f5e1ef5 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -91,13 +91,13 @@ H5Tget_precision(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_ATOMIC(dt)) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_ATOMIC(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for specified datatype") /* Precision */ - ret_value = dt->u.atomic.prec; + ret_value = dt->shared->u.atomic.prec; done: FUNC_LEAVE_API(ret_value) @@ -145,15 +145,15 @@ H5Tset_precision(hid_t type_id, size_t prec) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") if (prec == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "precision must be positive") - if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) + if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "operation not allowed after members are defined") - if (H5T_STRING==dt->type) + if (H5T_STRING==dt->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "precision for this type is read-only") - if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) + if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified datatype") /* Do the work */ @@ -205,25 +205,25 @@ H5T_set_precision(H5T_t *dt, size_t prec) /* Check args */ assert(dt); assert(prec>0); - assert(H5T_OPAQUE!=dt->type); - assert(H5T_COMPOUND!=dt->type); - assert(H5T_STRING!=dt->type); - assert(!(H5T_ENUM==dt->type && 0==dt->u.enumer.nmembs)); + assert(H5T_OPAQUE!=dt->shared->type); + assert(H5T_COMPOUND!=dt->shared->type); + assert(H5T_STRING!=dt->shared->type); + assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs)); - if (dt->parent) { - if (H5T_set_precision(dt->parent, prec)<0) + if (dt->shared->parent) { + if (H5T_set_precision(dt->shared->parent, prec)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set precision for base type") /* Adjust size of datatype appropriately */ - if(dt->type==H5T_ARRAY) - dt->size = dt->parent->size * dt->u.array.nelem; - else if(dt->type!=H5T_VLEN) - dt->size = dt->parent->size; + if(dt->shared->type==H5T_ARRAY) + dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem; + else if(dt->shared->type!=H5T_VLEN) + dt->shared->size = dt->shared->parent->shared->size; } else { - if (H5T_IS_ATOMIC(dt)) { + if (H5T_IS_ATOMIC(dt->shared)) { /* Adjust the offset and size */ - offset = dt->u.atomic.offset; - size = dt->size; + offset = dt->shared->u.atomic.offset; + size = dt->shared->size; if (prec > 8*size) offset = 0; else if (offset+prec > 8 * size) @@ -232,7 +232,7 @@ H5T_set_precision(H5T_t *dt, size_t prec) size = (prec+7) / 8; /* Check that things are still kosher */ - switch (dt->type) { + switch (dt->shared->type) { case H5T_INTEGER: case H5T_TIME: case H5T_BITFIELD: @@ -245,9 +245,9 @@ H5T_set_precision(H5T_t *dt, size_t prec) * first when decreasing the precision of a floating point * type. */ - if (dt->u.atomic.u.f.sign >= prec || - dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec || - dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) + if (dt->shared->u.atomic.u.f.sign >= prec || + dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec || + dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first") break; @@ -257,9 +257,9 @@ H5T_set_precision(H5T_t *dt, size_t prec) } /* end switch */ /* Commit */ - dt->size = size; - dt->u.atomic.offset = offset; - dt->u.atomic.prec = prec; + dt->shared->size = size; + dt->shared->u.atomic.offset = offset; + dt->shared->u.atomic.prec = prec; } /* end if */ else HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified datatype") diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 965ca93..282b61e 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -67,7 +67,7 @@ typedef struct H5T_conv_cb_t { H5_DLL herr_t H5TN_init_interface(void); H5_DLL herr_t H5T_init(void); H5_DLL htri_t H5T_isa(H5G_entry_t *ent, hid_t dxpl_id); -H5_DLL H5T_t *H5T_open_oid(H5G_entry_t *ent, hid_t dxpl_id); +H5_DLL H5T_t *H5T_open(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL H5T_t *H5T_copy(const H5T_t *old_dt, H5T_copy_t method); H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable); H5_DLL herr_t H5T_close(H5T_t *dt); diff --git a/src/H5Tstrpad.c b/src/H5Tstrpad.c index 250a7bd..c764a75 100644 --- a/src/H5Tstrpad.c +++ b/src/H5Tstrpad.c @@ -87,16 +87,16 @@ H5Tget_strpad(hid_t type_id) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR, "not a datatype") - while (dt->parent && !H5T_IS_STRING(dt)) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_STRING(dt)) + while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_STR_ERROR, "operation not defined for datatype class") /* result */ - if(H5T_IS_FIXED_STRING(dt)) - ret_value = dt->u.atomic.u.s.pad; + if(H5T_IS_FIXED_STRING(dt->shared)) + ret_value = dt->shared->u.atomic.u.s.pad; else - ret_value = dt->u.vlen.pad; + ret_value = dt->shared->u.vlen.pad; done: FUNC_LEAVE_API(ret_value) @@ -144,20 +144,20 @@ H5Tset_strpad(hid_t type_id, H5T_str_t strpad) /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (H5T_STATE_TRANSIENT!=dt->state) + if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only") if (strpad < 0 || strpad >= H5T_NSTR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type") - while (dt->parent && !H5T_IS_STRING(dt)) - dt = dt->parent; /*defer to parent*/ - if (!H5T_IS_STRING(dt)) + while (dt->shared->parent && !H5T_IS_STRING(dt->shared)) + dt = dt->shared->parent; /*defer to parent*/ + if (!H5T_IS_STRING(dt->shared)) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for datatype class") /* Commit */ - if(H5T_IS_FIXED_STRING(dt)) - dt->u.atomic.u.s.pad = strpad; + if(H5T_IS_FIXED_STRING(dt->shared)) + dt->shared->u.atomic.u.s.pad = strpad; else - dt->u.vlen.pad = strpad; + dt->shared->u.vlen.pad = strpad; done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index f40b075..467327e 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -67,8 +67,9 @@ static H5T_vlen_alloc_info_t H5T_vlen_def_vl_alloc_info ={ H5D_XFER_VLEN_FREE_INFO_DEF }; -/* Declare extern the free list for H5T_t's */ +/* Declare extern the free lists for H5T_t's and H5T_shared_t's */ H5FL_EXTERN(H5T_t); +H5FL_EXTERN(H5T_shared_t); /*-------------------------------------------------------------------------- @@ -168,18 +169,22 @@ H5T_vlen_create(const H5T_t *base) /* Build new type */ if (NULL==(dt = H5FL_CALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t))) { + H5FL_FREE(H5T_t, dt); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,"memory allocation failed") + } dt->ent.header = HADDR_UNDEF; - dt->type = H5T_VLEN; + dt->shared->type = H5T_VLEN; /* * Force conversions (i.e. memory to memory conversions should duplicate * data, not point to the same VL sequences) */ - dt->force_conv = TRUE; - dt->parent = H5T_copy(base, H5T_COPY_ALL); + dt->shared->force_conv = TRUE; + dt->shared->parent = H5T_copy(base, H5T_COPY_ALL); /* This is a sequence, not a string */ - dt->u.vlen.type = H5T_VLEN_SEQUENCE; + dt->shared->u.vlen.type = H5T_VLEN_SEQUENCE; /* Set up VL information */ if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) @@ -223,7 +228,7 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) assert(loc>H5T_LOC_BADLOC && locu.vlen.loc) { + if(loc!=dt->shared->u.vlen.loc) { /* Indicate that the location changed */ ret_value=TRUE; @@ -232,62 +237,62 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) assert(f==NULL); /* Mark this type as being stored in memory */ - dt->u.vlen.loc=H5T_LOC_MEMORY; + dt->shared->u.vlen.loc=H5T_LOC_MEMORY; - if(dt->u.vlen.type==H5T_VLEN_SEQUENCE) { + if(dt->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { /* size in memory, disk size is different */ - dt->size = sizeof(hvl_t); + dt->shared->size = sizeof(hvl_t); /* Set up the function pointers to access the VL sequence in memory */ - dt->u.vlen.getlen=H5T_vlen_seq_mem_getlen; - dt->u.vlen.getptr=H5T_vlen_seq_mem_getptr; - dt->u.vlen.isnull=H5T_vlen_seq_mem_isnull; - dt->u.vlen.read=H5T_vlen_seq_mem_read; - dt->u.vlen.write=H5T_vlen_seq_mem_write; - dt->u.vlen.setnull=H5T_vlen_seq_mem_setnull; - } else if(dt->u.vlen.type==H5T_VLEN_STRING) { + dt->shared->u.vlen.getlen=H5T_vlen_seq_mem_getlen; + dt->shared->u.vlen.getptr=H5T_vlen_seq_mem_getptr; + dt->shared->u.vlen.isnull=H5T_vlen_seq_mem_isnull; + dt->shared->u.vlen.read=H5T_vlen_seq_mem_read; + dt->shared->u.vlen.write=H5T_vlen_seq_mem_write; + dt->shared->u.vlen.setnull=H5T_vlen_seq_mem_setnull; + } else if(dt->shared->u.vlen.type==H5T_VLEN_STRING) { /* size in memory, disk size is different */ - dt->size = sizeof(char *); + dt->shared->size = sizeof(char *); /* Set up the function pointers to access the VL string in memory */ - dt->u.vlen.getlen=H5T_vlen_str_mem_getlen; - dt->u.vlen.getptr=H5T_vlen_str_mem_getptr; - dt->u.vlen.isnull=H5T_vlen_str_mem_isnull; - dt->u.vlen.read=H5T_vlen_str_mem_read; - dt->u.vlen.write=H5T_vlen_str_mem_write; - dt->u.vlen.setnull=H5T_vlen_str_mem_setnull; + dt->shared->u.vlen.getlen=H5T_vlen_str_mem_getlen; + dt->shared->u.vlen.getptr=H5T_vlen_str_mem_getptr; + dt->shared->u.vlen.isnull=H5T_vlen_str_mem_isnull; + dt->shared->u.vlen.read=H5T_vlen_str_mem_read; + dt->shared->u.vlen.write=H5T_vlen_str_mem_write; + dt->shared->u.vlen.setnull=H5T_vlen_str_mem_setnull; } else { assert(0 && "Invalid VL type"); } /* Reset file ID (since this VL is in memory) */ - dt->u.vlen.f=NULL; + dt->shared->u.vlen.f=NULL; break; case H5T_LOC_DISK: /* Disk based VL datatype */ assert(f); /* Mark this type as being stored on disk */ - dt->u.vlen.loc=H5T_LOC_DISK; + dt->shared->u.vlen.loc=H5T_LOC_DISK; /* * Size of element on disk is 4 bytes for the length, plus the size * of an address in this file, plus 4 bytes for the size of a heap * ID. Memory size is different */ - dt->size = 4 + H5F_SIZEOF_ADDR(f) + 4; + dt->shared->size = 4 + H5F_SIZEOF_ADDR(f) + 4; /* Set up the function pointers to access the VL information on disk */ /* VL sequences and VL strings are stored identically on disk, so use the same functions */ - dt->u.vlen.getlen=H5T_vlen_disk_getlen; - dt->u.vlen.getptr=H5T_vlen_disk_getptr; - dt->u.vlen.isnull=H5T_vlen_disk_isnull; - dt->u.vlen.read=H5T_vlen_disk_read; - dt->u.vlen.write=H5T_vlen_disk_write; - dt->u.vlen.setnull=H5T_vlen_disk_setnull; + dt->shared->u.vlen.getlen=H5T_vlen_disk_getlen; + dt->shared->u.vlen.getptr=H5T_vlen_disk_getptr; + dt->shared->u.vlen.isnull=H5T_vlen_disk_isnull; + dt->shared->u.vlen.read=H5T_vlen_disk_read; + dt->shared->u.vlen.write=H5T_vlen_disk_write; + dt->shared->u.vlen.setnull=H5T_vlen_disk_setnull; /* Set file ID (since this VL is on disk) */ - dt->u.vlen.f=f; + dt->shared->u.vlen.f=f; break; default: @@ -1011,16 +1016,16 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi assert(dt); /* Check the datatype of this element */ - switch(dt->type) { + switch(dt->shared->type) { case H5T_ARRAY: /* Recurse on each element, if the array's base type is array, VL, enum or compound */ - if(H5T_IS_COMPLEX(dt->parent->type)) { + if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ - for(i=0; iu.array.nelem; i++) { - off=((uint8_t *)elem)+i*(dt->parent->size); - if(H5T_vlen_reclaim_recurse(off,dt->parent,free_func,free_info)<0) + for(i=0; ishared->u.array.nelem; i++) { + off=((uint8_t *)elem)+i*(dt->shared->parent->shared->size); + if(H5T_vlen_reclaim_recurse(off,dt->shared->parent,free_func,free_info)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free array element") } /* end for */ } /* end if */ @@ -1028,14 +1033,14 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi case H5T_COMPOUND: /* Check each field and recurse on VL, compound, enum or array ones */ - for (i=0; iu.compnd.nmembs; i++) { + for (i=0; ishared->u.compnd.nmembs; i++) { /* Recurse if it's VL, compound, enum or array */ - if(H5T_IS_COMPLEX(dt->u.compnd.memb[i].type->type)) { + if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) { void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ - off=((uint8_t *)elem)+dt->u.compnd.memb[i].offset; - if(H5T_vlen_reclaim_recurse(off,dt->u.compnd.memb[i].type,free_func,free_info)<0) + off=((uint8_t *)elem)+dt->shared->u.compnd.memb[i].offset; + if(H5T_vlen_reclaim_recurse(off,dt->shared->u.compnd.memb[i].type,free_func,free_info)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free compound field") } /* end if */ } /* end for */ @@ -1043,19 +1048,19 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi case H5T_VLEN: /* Recurse on the VL information if it's VL, compound, enum or array, then free VL sequence */ - if(dt->u.vlen.type==H5T_VLEN_SEQUENCE) { + if(dt->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { hvl_t *vl=(hvl_t *)elem; /* Temp. ptr to the vl info */ /* Check if there is anything actually in this sequence */ if(vl->len!=0) { /* Recurse if it's VL, array, enum or compound */ - if(H5T_IS_COMPLEX(dt->parent->type)) { + if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { void *off; /* offset of field */ /* Calculate the offset of each array element and recurse on it */ while(vl->len>0) { - off=((uint8_t *)vl->p)+(vl->len-1)*dt->parent->size; - if(H5T_vlen_reclaim_recurse(off,dt->parent,free_func,free_info)<0) + off=((uint8_t *)vl->p)+(vl->len-1)*dt->shared->parent->shared->size; + if(H5T_vlen_reclaim_recurse(off,dt->shared->parent,free_func,free_info)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free VL element") vl->len--; } /* end while */ @@ -1067,7 +1072,7 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi else H5MM_xfree(vl->p); } /* end if */ - } else if(dt->u.vlen.type==H5T_VLEN_STRING) { + } else if(dt->shared->u.vlen.type==H5T_VLEN_STRING) { /* Free the VL string */ if(free_func!=NULL) (*free_func)(*(char **)elem,free_info); diff --git a/src/H5detect.c b/src/H5detect.c index 5acfb56..ec99b49 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -507,8 +507,9 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) #include \"H5FLprivate.h\"\n\ #include \"H5Tpkg.h\"\n\ \n\ -/* Declare external the free list for H5T_t's */\n\ +/* Declare external the free lists for H5T_t's and H5T_shared_t's */\n\ H5FL_EXTERN(H5T_t);\n\ +H5FL_EXTERN(H5T_shared_t);\n\ \n\ \n"); @@ -545,15 +546,20 @@ H5TN_init_interface(void)\n\ printf("\ if (NULL==(dt = H5FL_CALLOC (H5T_t)))\n\ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,\"memory allocation failed\");\n\ - dt->state = H5T_STATE_IMMUTABLE;\n\ + if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t)))\n\ + { \ + H5FL_FREE(H5T_t, dt);\ + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, \"memory allocation failed\");\n\ + } \ + dt->shared->state = H5T_STATE_IMMUTABLE;\n\ dt->ent.header = HADDR_UNDEF;\n\ - dt->type = H5T_%s;\n\ - dt->size = %d;\n\ - dt->u.atomic.order = H5T_ORDER_%s;\n\ - dt->u.atomic.offset = %d;\n\ - dt->u.atomic.prec = %d;\n\ - dt->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\ - dt->u.atomic.msb_pad = H5T_PAD_ZERO;\n", + dt->shared->type = H5T_%s;\n\ + dt->shared->size = %d;\n\ + dt->shared->u.atomic.order = H5T_ORDER_%s;\n\ + dt->shared->u.atomic.offset = %d;\n\ + dt->shared->u.atomic.prec = %d;\n\ + dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\ + dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;\n", d[i].msize ? "FLOAT" : "INTEGER",/*class */ d[i].size, /*size */ d[i].perm[0] ? "BE" : "LE", /*byte order */ @@ -564,19 +570,19 @@ H5TN_init_interface(void)\n\ if (0 == d[i].msize) { /* The part unique to fixed point types */ printf("\ - dt->u.atomic.u.i.sign = H5T_SGN_%s;\n", + dt->shared->u.atomic.u.i.sign = H5T_SGN_%s;\n", d[i].sign ? "2" : "NONE"); } else { /* The part unique to floating point types */ printf("\ - dt->u.atomic.u.f.sign = %d;\n\ - dt->u.atomic.u.f.epos = %d;\n\ - dt->u.atomic.u.f.esize = %d;\n\ - dt->u.atomic.u.f.ebias = 0x%08lx;\n\ - dt->u.atomic.u.f.mpos = %d;\n\ - dt->u.atomic.u.f.msize = %d;\n\ - dt->u.atomic.u.f.norm = H5T_NORM_%s;\n\ - dt->u.atomic.u.f.pad = H5T_PAD_ZERO;\n", + dt->shared->u.atomic.u.f.sign = %d;\n\ + dt->shared->u.atomic.u.f.epos = %d;\n\ + dt->shared->u.atomic.u.f.esize = %d;\n\ + dt->shared->u.atomic.u.f.ebias = 0x%08lx;\n\ + dt->shared->u.atomic.u.f.mpos = %d;\n\ + dt->shared->u.atomic.u.f.msize = %d;\n\ + dt->shared->u.atomic.u.f.norm = H5T_NORM_%s;\n\ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n", d[i].sign, /*sign location */ d[i].epos, /*exponent loc */ d[i].esize, /*exponent size */ diff --git a/test/getname.c b/test/getname.c index 69f741c..29816f0 100644 --- a/test/getname.c +++ b/test/getname.c @@ -65,7 +65,7 @@ int main( void ) hid_t group_id, group2_id, group3_id, group4_id, group5_id, group6_id, group7_id; hid_t dataset_id, dataset2_id; hid_t space_id; - hid_t type_id; + hid_t type_id, type2_id; hsize_t dims[1] = { 5 }; /*buffer to hold name and its size */ @@ -1212,6 +1212,31 @@ int main( void ) PASSED(); + /*------------------------------------------------------------------------- + * Test H5Iget_name with objects that have two names + *------------------------------------------------------------------------- + */ + +TESTING("H5Iget_name with datasets that have two names"); + +/* Open dataset named "d"*/ +if ((dataset_id = H5Dopen( file_id, "/g17/d"))<0) goto out; + +/* Create link to dataset named "link" */ +if (H5Glink2(dataset_id,".",H5G_LINK_HARD,file_id,"/g17/link")<0) goto out; +if ((dataset2_id = H5Dopen( file_id, "/g17/link"))<0) goto out; + +/* Make sure that the two IDs use two different names */ +if(H5Iget_name(dataset_id, name, size)<0) goto out; +if(check_name(name, "/g17/d")!=0) goto out; + +if(H5Iget_name(dataset2_id, name, size)<0) goto out; +if(check_name(name, "/g17/link")!=0) goto out; + +if(H5Dclose(dataset_id)<0) goto out; +if(H5Dclose(dataset2_id)<0) goto out; + +PASSED(); /*------------------------------------------------------------------------- @@ -1418,6 +1443,14 @@ int main( void ) if ((group_id = H5Gcreate( file_id, "/g18", 0 ))<0) goto out; if ((group2_id = H5Gcreate( file_id, "/g18/g2", 0 ))<0) goto out; + /* Also create a dataset and a datatype */ + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; + if ((type_id = H5Tcopy(H5T_NATIVE_INT))<0) goto out; + if ((dataset_id = H5Dcreate( file_id, "g18/d2", type_id, space_id, + H5P_DEFAULT ))<0) goto out; + + if (H5Tcommit(file_id, "g18/t2", type_id) <0) goto out; + /* Create second file and group "/g3/g4/g5" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); if ((group3_id = H5Gcreate( file1_id, "/g3", 0 ))<0) goto out; @@ -1427,39 +1460,70 @@ int main( void ) /* Mount first file at "g3/g4" in the second file */ if (H5Fmount(file1_id, "/g3/g4", file_id, H5P_DEFAULT)<0) goto out; - /* Get name for the ID of the first file, should be "/g18/g2" still */ + /* Get name for the group ID in the first file, should be "/g18/g2" still */ if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ if (check_name( name, "/g18/g2" )!=0) goto out; - /* Open the mounted group */ - if ((group6_id = H5Gopen( file_id, "/g3/g4/g18/g2" ))<0) goto out; + /* Get name for the dataset ID in the first file, should be "/g18/g2/d2" still */ + if (H5Iget_name( dataset_id, name, size )<0) goto out; + if (check_name( name, "/g18/d2" )!=0) goto out; - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; + /* Get name for the datatype ID in the first file, should be "/g18/g2/t2" still */ + if (H5Iget_name( type_id, name, size )<0) goto out; + if (check_name( name, "/g18/t2" )!=0) goto out; - /* Verify */ + /* Open the mounted group, dataset, and datatype through their new names */ + if ((group6_id = H5Gopen( file1_id, "/g3/g4/g18/g2" ))<0) goto out; + if ((dataset2_id = H5Dopen( file1_id, "/g3/g4/g18/d2" ))<0) goto out; + if ((type2_id = H5Topen( file1_id, "/g3/g4/g18/t2" ))<0) goto out; + + /* Verify names */ + if (H5Iget_name( group6_id, name, size )<0) goto out; if (check_name( name, "/g3/g4/g18/g2" )!=0) goto out; + if (H5Iget_name( dataset2_id, name, size )<0) goto out; + if (check_name( name, "/g3/g4/g18/d2" )!=0) goto out; + + if (H5Iget_name( type2_id, name, size )<0) goto out; + if (check_name( name, "/g3/g4/g18/t2" )!=0) goto out; + + /* Verify that old IDs still refer to objects by their old names */ + if (H5Iget_name( group2_id, name, size )<0) goto out; + if (check_name( name, "/g18/g2" )!=0) goto out; + + if (H5Iget_name( dataset_id, name, size )<0) goto out; + if (check_name( name, "/g18/d2" )!=0) goto out; + + if (H5Iget_name( type_id, name, size )<0) goto out; + if (check_name( name, "/g18/t2" )!=0) goto out; + /* Unmount */ if (H5Funmount(file1_id, "/g3/g4")<0) goto out; - /* Get name for the ID of the first file, should be "/g18/g2" still */ + /* Get name for the IDs of the first file, should be unchanged */ if (H5Iget_name( group2_id, name, size )<0) goto out; + if (check_name( name, "/g18/g2" )!=0) goto out; - /* Verify */ - if (check_name( name, "/g18/g2" )!=0) - goto out; + if (H5Iget_name( dataset_id, name, size )<0) goto out; + if (check_name( name, "/g18/d2" )!=0) goto out; + + if (H5Iget_name( type_id, name, size )<0) goto out; + if (check_name( name, "/g18/t2" )!=0) goto out; - /* Get name for the ID of the secondt file, should be "" */ + /* Get name for the IDs of the second file, should be "" */ if (H5Iget_name( group6_id, name, size )<0) goto out; + if (check_name( name, "" )!=0) goto out; - /* Verify */ - if (check_name( name, "" )!=0) - goto out; + if (H5Iget_name( dataset2_id, name, size )<0) goto out; + if (check_name( name, "" )!=0) goto out; - /* Close */ + if (H5Iget_name( type2_id, name, size )<0) goto out; + if (check_name( name, "" )!=0) goto out; + + H5Tclose( type_id ); + H5Tclose( type2_id ); + H5Dclose( dataset_id ); + H5Dclose( dataset2_id ); H5Gclose( group_id ); H5Gclose( group2_id ); H5Gclose( group3_id ); diff --git a/test/unlink.c b/test/unlink.c index 8e6a9ac..0fa7d4f 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -29,7 +29,9 @@ const char *FILENAME[] = { "lunlink", "filespace", "slashes", - "resurrect", + "resurrect_set", + "resurrect_type", + "resurrect_group", "unlink_chunked", NULL }; @@ -44,6 +46,7 @@ const char *FILENAME[] = { #define DATASET2NAME "dataset2" #define ATTRNAME "attribute" #define TYPENAME "datatype" +#define TYPE2NAME "datatype2" #define FILESPACE_NDIMS 3 #define FILESPACE_DIM0 20 #define FILESPACE_DIM1 20 @@ -1837,6 +1840,9 @@ test_resurrect_dataset(void) /* Unlink the dataset while it's open (will mark it for deletion when closed) */ if(H5Gunlink(f, DATASETNAME)<0) TEST_ERROR; + /* Check that dataset name is NULL */ + if(H5Iget_name(d, NULL, 0) != 0) TEST_ERROR; + /* Re-link the dataset to the group hierarchy (shouldn't get deleted now) */ if(H5Glink2(d, ".", H5G_LINK_HARD, f, DATASET2NAME)<0) TEST_ERROR; @@ -1870,6 +1876,145 @@ error: /*------------------------------------------------------------------------- + * Function: test_resurrect_datatype + * + * Purpose: Tests deleting a datatype while it's still open and then + * "resurrecting" it by creating a link to it again. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: James Laird + * Wednesday, July 28, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_resurrect_datatype(void) +{ + hid_t file=-1, type=-1, fapl=-1, loc_id=-1; + char filename[1024]; + + TESTING("Resurrecting datatype after deletion"); + + /* Create file */ + fapl = h5_fileaccess(); + h5_fixname(FILENAME[7], fapl, filename, sizeof filename); + + /* Create the file */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR; + + /* Create a named datatype in the file */ + if((type = H5Tcopy (H5T_NATIVE_INT))<0) TEST_ERROR; + if(H5Tcommit (file, TYPENAME, type)<0) TEST_ERROR; + + /* Unlink the datatype while it's open (will mark it for deletion when closed) */ + if(H5Gunlink(file, TYPENAME)<0) TEST_ERROR; + + /* Check that datatype name is NULL */ + if(H5Iget_name(type, NULL, 0) != 0) TEST_ERROR; + + /* Re-link the datatype to the group hierarchy (shouldn't get deleted now) */ + if(H5Glink2(type, ".", H5G_LINK_HARD, file, TYPE2NAME) < 0) TEST_ERROR; + + /* Close things */ + if(H5Tclose(type)<0) TEST_ERROR; + if(H5Fclose(file)<0) TEST_ERROR; + + /* Re-open the file */ + if((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) TEST_ERROR; + + /* Attempt to open the datatype under the new name */ + if((type=H5Topen(file,TYPE2NAME))<0) TEST_ERROR; + + /* Close things */ + if(H5Tclose(type)<0) TEST_ERROR; + if(H5Fclose(file)<0) TEST_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(type); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* end test_resurrect_datatype() */ + + +/*------------------------------------------------------------------------- + * Function: test_resurrect_group + * + * Purpose: Tests deleting a group while it's still open and then + * "resurrecting" it by creating a link to it again. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: James Laird + * Wednesday, July 28, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_resurrect_group(void) +{ + hid_t file=-1, group=-1, fapl=-1; + char filename[1024]; + + TESTING("Resurrecting group after deletion"); + + /* Create file */ + fapl = h5_fileaccess(); + h5_fixname(FILENAME[8], fapl, filename, sizeof filename); + + /* Create the file */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR; + + /* Create a group in the file */ + if((group = H5Gcreate (file, GROUPNAME, 0))<0) TEST_ERROR; + + /* Unlink the group while it's open (will mark it for deletion when closed) */ + if(H5Gunlink(file, GROUPNAME)<0) TEST_ERROR; + + /* Check that group's name is NULL */ + if(H5Iget_name(group, NULL, 0) != 0) TEST_ERROR; + + /* Re-link the group into the group hierarchy (shouldn't get deleted now) */ + if(H5Glink2(group, ".", H5G_LINK_HARD, file, GROUP2NAME)<0) TEST_ERROR; + + /* Close things */ + if(H5Gclose(group)<0) TEST_ERROR; + if(H5Fclose(file)<0) TEST_ERROR; + + /* Re-open the file */ + if((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) TEST_ERROR; + + /* Attempt to open the datatype under the new name */ + if((group=H5Gopen(file,GROUP2NAME))<0) TEST_ERROR; + + /* Close things */ + if(H5Gclose(group)<0) TEST_ERROR; + if(H5Fclose(file)<0) TEST_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Gclose(group); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* end test_resurrect_group() */ + + +/*------------------------------------------------------------------------- * Function: test_unlink_chunked_dataset * * Purpose: Tests deleting a chunked dataset @@ -2035,6 +2180,8 @@ main(void) /* Test "resurrecting" objects */ nerrors += test_resurrect_dataset(); + nerrors += test_resurrect_datatype(); + nerrors += test_resurrect_group(); /* Test unlinking chunked datasets */ nerrors += test_unlink_chunked_dataset(); diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index 0db17f5..1a09b02 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -748,8 +748,14 @@ static const char* MapIdToName(hid_t refobj_id, { hid_t id; hid_t fid; + H5G_stat_t refstat; /* Stat for the refobj id */ + H5G_stat_t objstat; /* Stat for objects in the file */ int i; + /* obtain information to identify the referenced object uniquely */ + if(H5Gget_objinfo(refobj_id, ".", 0, &refstat) <0) + return NULL; + /* obtains the file ID given an object ID. This ID must be closed */ if ((fid = H5Iget_file_id(refobj_id))<0) { @@ -773,9 +779,11 @@ static const char* MapIdToName(hid_t refobj_id, if ((id = H5Dopen(fid,travt->objs[i].name))<0) return NULL; + if(H5Gget_objinfo(id, ".", 0, &objstat) <0) + return NULL; if (H5Dclose(id)<0) return NULL; - if (id==refobj_id) + if (refstat.fileno==objstat.fileno && refstat.objno==objstat.objno) { H5Fclose(fid); return travt->objs[i].name; diff --git a/windows/all.zip b/windows/all.zip index ff36f1b..2e30ab3 100755 Binary files a/windows/all.zip and b/windows/all.zip differ -- cgit v0.12