From 093c14b8db58051b116b4f39dc65247a0c637ad8 Mon Sep 17 00:00:00 2001 From: James Laird Date: Tue, 28 Sep 2004 15:52:15 -0500 Subject: [svn-r9334] Purpose: Feature Description: (Same change to release branch) 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 | 603 +++++++++++++++------------- src/H5Dcompact.c | 6 +- src/H5Dcontig.c | 180 ++++----- src/H5Dio.c | 140 +++---- src/H5Distore.c | 226 +++++------ src/H5Dpkg.h | 14 +- src/H5Dprivate.h | 3 +- src/H5Dseq.c | 8 +- src/H5Dtest.c | 6 +- src/H5F.c | 20 +- src/H5FO.c | 26 +- src/H5FOprivate.h | 5 +- src/H5G.c | 196 +++++++--- src/H5Gpkg.h | 9 +- src/H5Gprivate.h | 5 +- src/H5O.c | 2 +- src/H5Odtype.c | 522 +++++++++++++------------ src/H5Pdcpl.c | 2 +- src/H5R.c | 25 +- src/H5T.c | 869 +++++++++++++++++++++++------------------ src/H5Tarray.c | 47 ++- src/H5Tbit.c | 4 +- src/H5Tcommit.c | 16 +- src/H5Tcompound.c | 130 +++--- src/H5Tconv.c | 770 ++++++++++++++++++------------------ src/H5Tcset.c | 30 +- src/H5Tenum.c | 82 ++-- src/H5Tfields.c | 138 +++---- src/H5Tfixed.c | 20 +- src/H5Tfloat.c | 94 ++--- src/H5Tnative.c | 2 +- src/H5Toffset.c | 44 +-- src/H5Topaque.c | 20 +- src/H5Torder.c | 20 +- src/H5Tpad.c | 24 +- src/H5Tpkg.h | 10 +- src/H5Tprecis.c | 54 +-- src/H5Tprivate.h | 2 +- src/H5Tstrpad.c | 30 +- src/H5Tvlen.c | 133 ++++--- src/H5detect.c | 40 +- test/getname.c | 106 +++-- test/unlink.c | 149 ++++++- tools/h5repack/h5repack_refs.c | 11 +- windows/all.zip | Bin 335303 -> 335406 bytes 45 files changed, 2686 insertions(+), 2157 deletions(-) diff --git a/src/H5D.c b/src/H5D.c index 273db9d..701619b 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -22,7 +22,7 @@ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ +#include "H5FOprivate.h" /* File objects */ #include "H5HLprivate.h" /* Local heaps */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ @@ -38,7 +38,7 @@ static int interface_initialize_g = 0; /* Local functions */ static herr_t H5D_init_interface(void); 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); @@ -47,7 +47,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); @@ -64,8 +63,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); @@ -77,7 +77,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; @@ -351,7 +351,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. @@ -1093,10 +1093,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) { @@ -1132,26 +1128,32 @@ done: hid_t H5Dopen(hid_t loc_id, const char *name) { - H5G_entry_t *loc = NULL; /*location holding the dataset */ + H5D_t *dset; + H5G_entry_t *loc = NULL; /*location holding the dataset */ H5G_entry_t ent; /*dataset symbol table entry */ - hid_t ret_value; + hid_t ret_value; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open dataset */ 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_CANTREGISTER, 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) @@ -1206,7 +1208,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5Dget_space + * Function: H5Dget_space * * Purpose: Returns a copy of the file data space for a dataset. * @@ -1240,7 +1242,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 */ @@ -1328,7 +1330,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 */ @@ -1336,7 +1338,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 */ @@ -1353,7 +1355,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 */ @@ -1402,7 +1404,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 VL datatypes as being in memory now */ @@ -1468,7 +1470,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 */ @@ -1483,7 +1485,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 */ @@ -1566,16 +1568,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 @@ -1583,7 +1585,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") @@ -1591,7 +1593,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))) @@ -1600,8 +1602,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; @@ -1610,7 +1610,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 */ @@ -1661,15 +1661,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_vlen_mark(dset->type, file, H5T_VLEN_DISK)<0) + if(H5T_vlen_mark(dset->shared->type, file, H5T_VLEN_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 */ @@ -1678,8 +1678,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: @@ -1738,11 +1738,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) @@ -1757,18 +1757,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) @@ -1782,10 +1782,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 */ @@ -1835,7 +1835,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 */ @@ -2027,17 +2027,23 @@ 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))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* * 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? */ @@ -2049,21 +2055,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) @@ -2100,7 +2106,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) @@ -2111,26 +2117,26 @@ 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; /* Set up layout information */ - new_dset->layout.unused.ndims = H5S_GET_EXTENT_NDIMS(new_dset->space) + 1; - assert((unsigned)(new_dset->layout.unused.ndims) <= NELMTS(new_dset->layout.unused.dim)); - if (H5S_get_simple_extent_dims(new_dset->space, new_dset->layout.unused.dim, NULL)<0) + new_dset->shared->layout.unused.ndims = H5S_GET_EXTENT_NDIMS(new_dset->shared->space) + 1; + assert((unsigned)(new_dset->shared->layout.unused.ndims) <= NELMTS(new_dset->shared->layout.unused.dim)); + if (H5S_get_simple_extent_dims(new_dset->shared->space, new_dset->shared->layout.unused.dim, NULL)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize storage info") - new_dset->layout.unused.dim[new_dset->layout.unused.ndims-1] = H5T_get_size(new_dset->type); + new_dset->shared->layout.unused.dim[new_dset->shared->layout.unused.ndims-1] = H5T_get_size(new_dset->shared->type); - switch (new_dset->layout.type) { + switch (new_dset->shared->layout.type) { case H5D_CONTIGUOUS: { hssize_t tmp_size; /* Temporary holder for raw data size */ @@ -2141,16 +2147,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, NULL, max_dim))<0) + if ((ndims=H5S_get_simple_extent_dims(new_dset->shared->space, NULL, max_dim))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize contiguous storage") for (i=1; inew_dset->layout.unused.dim[i]) + if (max_dim[i]>new_dset->shared->layout.unused.dim[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) @@ -2160,14 +2166,14 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space } else if (max_points * H5T_get_size (type) > max_storage) { HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "data space size exceeds external storage size") } - } else if (ndims>0 && max_dim[0]>new_dset->layout.unused.dim[0]) { + } else if (ndims>0 && max_dim[0]>new_dset->shared->layout.unused.dim[0]) { HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "extendible contiguous non-external dataset") } /* 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; @@ -2176,12 +2182,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 @@ -2189,26 +2195,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) @@ -2229,14 +2235,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; @@ -2250,7 +2256,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") /* @@ -2261,37 +2267,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) @@ -2366,52 +2381,61 @@ 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=NULL; /* 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 */ + if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear(); /* 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) } @@ -2459,8 +2483,11 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) assert (ent); /* Allocate the dataset structure */ + if(NULL==(dataset=H5FL_CALLOC(H5D_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + /* (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->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 */ @@ -2472,17 +2499,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 */ @@ -2503,22 +2530,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; @@ -2531,11 +2558,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 */ @@ -2552,7 +2579,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) @@ -2566,7 +2593,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; @@ -2605,20 +2632,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") } @@ -2628,15 +2655,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 */ @@ -2652,12 +2679,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; @@ -2689,87 +2716,99 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D_close(H5D_t *dataset) { - unsigned free_failed; - herr_t ret_value=SUCCEED; /* Return value */ + 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 && dataset->ent.file && dataset->shared); + 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; - - default: - assert ("not implemented yet" && 0); -#ifdef NDEBUG - HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") -#endif /* NDEBUG */ - } /* end switch */ + /* 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); + #ifdef NDEBUG + HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") + #endif /* NDEBUG */ + } /* 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); + H5FL_FREE(H5D_t, dataset); if (free_failed) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free the type or creation property list, but the dataset was freed anyway.") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free the type or creation property list, but the dataset was freed anyway.") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2817,24 +2856,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; } } } @@ -2846,7 +2885,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") @@ -2856,12 +2895,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 */ @@ -2921,9 +2960,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) } @@ -2993,9 +3032,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(dset->efl.nused==0) { + if(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: @@ -3029,7 +3068,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; @@ -3070,7 +3109,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 */ @@ -3079,13 +3118,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 */ @@ -3096,7 +3135,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 */ @@ -3135,25 +3174,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; @@ -3161,7 +3200,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 */ @@ -3253,9 +3292,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); @@ -3263,14 +3302,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: @@ -3347,7 +3386,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; @@ -3361,9 +3400,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: @@ -3811,7 +3850,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 @@ -3845,12 +3884,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") @@ -3860,7 +3899,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 */ @@ -3932,20 +3971,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); /* We should never have a sieve buffer for compact storage */ + if (dataset->shared->cache.contig.sieve_buf && dataset->shared->cache.contig.sieve_dirty) { + assert(dataset->shared->layout.type!=H5D_COMPACT); /* We should never have a sieve buffer for compact storage */ /* 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; @@ -3956,10 +3995,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; @@ -4011,10 +4050,10 @@ H5Ddebug(hid_t dset_id, unsigned UNUSED flags) 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 3701221..76f900d 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -73,7 +73,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: @@ -117,10 +117,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 32af4d8..f4d6f76 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -84,7 +84,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: @@ -135,10 +135,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 */ @@ -157,17 +157,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 @@ -178,12 +178,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; @@ -324,10 +324,10 @@ 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); /* Get the address */ - ret_value=dset->layout.u.contig.addr; + ret_value=dset->shared->layout.u.contig.addr; done: FUNC_LEAVE_NOAPI(ret_value); @@ -369,7 +369,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"); @@ -411,7 +411,7 @@ H5D_contig_readvv(H5F_t *f, hid_t dxpl_id, H5D_t *dset, size_t u; /* Counting variable */ size_t v; /* Counting variable */ ssize_t ret_value=0; /* Return value */ - + FUNC_ENTER_NOAPI(H5D_contig_readvv, FAIL); /* Check args */ @@ -433,12 +433,12 @@ 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 */ - + /* Works through sequences as fast as possible */ for(; ucache.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))) @@ -479,21 +481,22 @@ 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 */ @@ -503,7 +506,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); @@ -511,18 +514,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 */ @@ -533,17 +536,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))) @@ -557,22 +560,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 */ @@ -693,9 +696,9 @@ H5D_contig_writevv(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 */ @@ -714,19 +717,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))) @@ -739,24 +742,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 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 */ @@ -766,35 +769,33 @@ 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 */ @@ -805,49 +806,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))) @@ -861,26 +862,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 */ } /* end else */ diff --git a/src/H5Dio.c b/src/H5Dio.c index 40b1700..bf8ecaa 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 */ @@ -1130,19 +1130,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 @@ -1161,7 +1161,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; @@ -1238,12 +1238,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 || - 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, (H5D_storage_t *)&(dataset->efl), + dataset, (H5D_storage_t *)&(dataset->shared->efl), file_space, &file_iter, smine_nelmts, tconv_buf/*out*/); @@ -1375,8 +1375,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 @@ -1401,7 +1401,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 @@ -1440,7 +1440,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; @@ -1495,7 +1495,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*/); @@ -1521,7 +1521,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 @@ -1620,10 +1620,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); @@ -1642,7 +1642,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); @@ -1656,7 +1656,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 @@ -1671,7 +1671,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; @@ -1763,9 +1763,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, @@ -1973,7 +1973,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); @@ -2019,7 +2019,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 @@ -2047,7 +2047,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; @@ -2360,7 +2360,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) @@ -2369,16 +2369,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... */ @@ -2388,7 +2388,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") @@ -2399,7 +2399,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 */ @@ -2428,7 +2428,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 */ @@ -2508,7 +2508,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 82f1469..172a29b 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -932,7 +932,7 @@ 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_rdcc_t *rdcc = &(dset->shared->cache.chunk); herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_init, FAIL); @@ -946,7 +946,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); @@ -990,16 +990,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 @@ -1021,7 +1021,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") } @@ -1030,14 +1030,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 */ @@ -1046,7 +1046,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: @@ -1062,7 +1062,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); @@ -1091,7 +1091,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); @@ -1109,7 +1109,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 */ @@ -1159,7 +1159,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 */ @@ -1215,7 +1215,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 */ @@ -1243,7 +1243,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: @@ -1367,7 +1367,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 */ @@ -1504,11 +1504,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 */ @@ -1529,11 +1529,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; @@ -1772,7 +1772,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; @@ -1800,17 +1800,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 { /* @@ -1863,8 +1863,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); @@ -1873,19 +1873,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]); @@ -1903,14 +1903,17 @@ 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 { @@ -1927,20 +1930,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; @@ -2056,8 +2059,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); @@ -2066,19 +2069,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]); @@ -2096,14 +2099,15 @@ 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) 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 { @@ -2123,7 +2127,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; @@ -2132,13 +2136,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 */ @@ -2238,7 +2242,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 */ @@ -2259,8 +2263,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 */ @@ -2486,18 +2490,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) @@ -2535,9 +2539,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) @@ -2593,8 +2597,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 */ @@ -2604,7 +2608,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 */ @@ -2613,16 +2617,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 */ @@ -2651,8 +2655,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 @@ -2786,7 +2790,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 */ @@ -2799,12 +2803,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"); /*------------------------------------------------------------------------- @@ -2816,7 +2820,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; @@ -2826,7 +2830,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 @@ -2846,10 +2850,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: @@ -3016,12 +3020,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 */ @@ -3037,7 +3041,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); @@ -3046,9 +3050,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) @@ -3056,7 +3060,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"); @@ -3065,18 +3069,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 */ @@ -3085,8 +3089,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; @@ -3096,7 +3100,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; @@ -3108,15 +3112,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 @@ -3139,7 +3143,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 @@ -3223,7 +3227,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 */ @@ -3242,17 +3246,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) @@ -3267,12 +3271,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 */ @@ -3363,7 +3367,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/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 f8fef09..7956c7d 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 5585315..f413666 100644 --- a/src/H5Dseq.c +++ b/src/H5Dseq.c @@ -111,7 +111,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) { @@ -128,7 +128,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) @@ -219,7 +219,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) { @@ -236,7 +236,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 d3339df..e22be5d 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -67,7 +67,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); @@ -106,8 +106,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/H5F.c b/src/H5F.c index 420c2db..1de663c 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -1161,7 +1161,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) if( (!olist->shared && olist->obj_type==H5I_DATATYPE && H5T_is_immutable((H5T_t*)obj_ptr)==FALSE) || (!olist->shared && olist->obj_type!=H5I_DATATYPE) - || (ent && ent->file->shared == olist->shared) ) { + || (ent && ent->file && ent->file->shared == olist->shared) ) { /* Add the object's ID to the ID list, if appropriate */ if(olist->obj_id_list) { olist->obj_id_list[olist->list_index] = obj_id; @@ -1595,7 +1595,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)) { @@ -3093,6 +3093,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 */ @@ -3108,9 +3109,11 @@ 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); @@ -3214,6 +3217,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 */ @@ -3229,8 +3233,10 @@ 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); diff --git a/src/H5FO.c b/src/H5FO.c index 7f34556..849a4db 100644 --- a/src/H5FO.c +++ b/src/H5FO.c @@ -40,9 +40,9 @@ static int interface_initialize_g = 0; /* Information about object objects in a file */ typedef struct H5FO_open_obj_t { - haddr_t addr; /* Address of object header for object */ + 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; @@ -94,7 +94,7 @@ 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 @@ -108,14 +108,14 @@ 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(H5FO_opened,FAIL) + FUNC_ENTER_NOAPI(H5FO_opened,NULL) /* Sanity check */ assert(f); @@ -127,11 +127,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; done: FUNC_LEAVE_NOAPI(ret_value) @@ -144,10 +144,10 @@ done: PURPOSE Insert a newly opened object/ID 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 @@ -160,7 +160,7 @@ done: 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 */ @@ -172,7 +172,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) @@ -180,7 +180,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..1f48f8b 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 894ee5c..e78a457 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -164,6 +164,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); @@ -182,6 +183,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 *grp, hsize_t idx, char* name, size_t size, hid_t dxpl_id); @@ -281,25 +283,32 @@ 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 object, 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, 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) { @@ -383,7 +392,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; @@ -391,8 +399,6 @@ 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); @@ -407,13 +413,13 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, * 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() */ udata.skip = idx; udata.ent = &(grp->ent); @@ -1771,9 +1777,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; @@ -1812,7 +1822,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); @@ -1823,7 +1833,9 @@ 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))) @@ -1831,14 +1843,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; @@ -1852,8 +1868,11 @@ done: if(H5O_delete(file, dxpl_id,grp->ent.header)<0) HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header"); } /* end if */ - if(grp!=NULL) + if(grp!=NULL) { + if(grp->shared!=NULL) + H5FL_FREE(H5G_shared_t, grp->shared); H5FL_FREE(H5G_t,grp); + } } /* end if */ FUNC_LEAVE_NOAPI(ret_value); @@ -1954,27 +1973,48 @@ 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) { - /* Open the group object */ - if ((grp=H5G_open_oid(&ent, dxpl_id)) ==NULL) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found"); + /* Clear any errors from H5FO_opened() */ + H5E_clear(); + + /* 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; done: @@ -2005,7 +2045,7 @@ done: * *------------------------------------------------------------------------- */ -H5G_t * +static H5G_t * H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id) { H5G_t *grp = NULL; @@ -2020,6 +2060,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); @@ -2031,14 +2073,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); } @@ -2104,24 +2148,68 @@ 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 (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); + if (0 == grp->shared->fo_count) { + assert (grp!=H5G_rootof(H5G_fileof(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); +} + /*------------------------------------------------------------------------- * Function: H5G_rootof * @@ -2194,13 +2282,13 @@ H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent, hid_t dxpl_id) * Lookup and insert the name -- it shouldn't exist yet. */ if (H5G_namei(loc, name, NULL, NULL, NULL, H5G_TARGET_NORMAL, NULL, H5G_NAMEI_INSERT, ent, dxpl_id)<0) - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists"); + HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists"); /* * Insert the object into a symbol table. */ if (H5O_link(ent, 1, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "unable to increment hard link count"); + HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "unable to increment hard link count"); done: FUNC_LEAVE_NOAPI(ret_value); @@ -3285,8 +3373,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 27fceff..7010aa6 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -47,11 +47,18 @@ 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_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 e082dff..bd40d8d 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 int 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 a3b1618..412b302 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1188,7 +1188,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 c2015c0..7009670 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -72,6 +72,7 @@ static int interface_initialize_g = 0; /* Declare external the free list for H5T_t's */ H5FL_EXTERN(H5T_t); +H5FL_EXTERN(H5T_shared_t); /*------------------------------------------------------------------------- @@ -101,39 +102,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: @@ -142,10 +143,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; @@ -153,48 +154,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++) { int 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 */ @@ -203,12 +204,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 @@ -231,16 +232,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"); } @@ -255,8 +259,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,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"); } @@ -272,36 +276,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; @@ -310,112 +314,121 @@ 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; - assert(dt->u.enumer.nmembs>=0); - if (NULL==(dt->parent=H5FL_CALLOC(H5T_t))) + dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff; + assert(dt->shared->u.enumer.nmembs>=0); + if (NULL==(dt->shared->parent=H5FL_CALLOC(H5T_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + if (NULL==(dt->shared->parent->shared=H5FL_CALLOC(H5T_shared_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) + dt->shared->parent->ent.header = HADDR_UNDEF; + dt->shared->parent->shared->fo_count=1; + 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->u.atomic.u.r.rtype = (H5R_type_t)(flags & 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.r.rtype = (H5R_type_t)(flags & 0x0f); break; case H5T_STRING: /* * 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"); - 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))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + dt->shared->parent->ent.header = HADDR_UNDEF; + dt->shared->parent->shared->fo_count=1; + 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_vlen_mark(dt, f, H5T_VLEN_DISK)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL 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; ju.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; jshared->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; ju.array.ndims; j++) - UINT32DECODE(*pp, dt->u.array.perm[j]); + for (j=0; jshared->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))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + dt->shared->parent->ent.header = HADDR_UNDEF; + dt->shared->parent->shared->fo_count=1; + 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->type==H5T_VLEN || dt->parent->force_conv==TRUE) - dt->force_conv=TRUE; + if(dt->shared->parent->shared->type==H5T_VLEN || dt->shared->parent->shared->force_conv==TRUE) + dt->shared->force_conv=TRUE; break; default: @@ -423,6 +436,13 @@ 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); } @@ -460,14 +480,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: @@ -477,7 +497,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: @@ -487,7 +507,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: @@ -497,7 +517,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: @@ -507,15 +527,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: @@ -525,7 +545,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: @@ -535,7 +555,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: @@ -545,8 +565,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: @@ -555,10 +575,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: @@ -577,7 +597,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: @@ -587,7 +607,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: @@ -597,7 +617,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: @@ -607,7 +627,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: @@ -620,18 +640,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: @@ -642,18 +662,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 @@ -680,7 +700,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; @@ -689,58 +709,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: @@ -749,15 +769,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'; @@ -765,15 +785,15 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) *(*pp)++ = '\0'; /* Encode array dimensions */ - for (j=0; ju.array.ndims; j++) - UINT32ENCODE(*pp, dt->u.array.dim[j]); + for (j=0; jshared->u.array.ndims; j++) + UINT32ENCODE(*pp, dt->shared->u.array.dim[j]); /* Encode array dimension permutations */ - for (j=0; ju.array.ndims; j++) - UINT32ENCODE(*pp, dt->u.array.perm[j]); + for (j=0; jshared->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; @@ -782,7 +802,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) break; } - *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; @@ -824,7 +844,10 @@ 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"); @@ -834,6 +857,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 */ @@ -960,7 +985,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; @@ -970,7 +995,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: @@ -978,27 +1003,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: @@ -1007,9 +1032,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: @@ -1076,6 +1101,7 @@ H5O_dtype_free (void *mesg) assert (mesg); + H5FL_FREE(H5T_shared_t, ((H5T_t *) mesg)->shared); H5FL_FREE(H5T_t,mesg); done: @@ -1111,7 +1137,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 +1188,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; done: FUNC_LEAVE_NOAPI(ret_value); @@ -1208,7 +1234,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; @@ -1243,7 +1269,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; } @@ -1253,51 +1279,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; @@ -1305,14 +1331,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_VLEN_MEMORY: s = "memory"; break; @@ -1320,30 +1346,30 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "disk"; break; default: - sprintf(buf, "H5T_VLEN_%d", dt->u.vlen.loc); + sprintf(buf, "H5T_VLEN_%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; iu.array.ndims; i++) { - fprintf (stream, "%s%u", i?", ":"", (unsigned)dt->u.array.dim[i]); + for (i=0; ishared->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; iu.array.ndims; i++) { - fprintf (stream, "%s%d", i?", ":"", dt->u.array.perm[i]); + for (i=0; ishared->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; @@ -1357,7 +1383,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; } @@ -1367,15 +1393,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; @@ -1389,7 +1415,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; @@ -1403,8 +1429,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; @@ -1412,10 +1438,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; @@ -1423,7 +1449,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; @@ -1434,7 +1460,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, @@ -1442,30 +1468,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; @@ -1473,7 +1499,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/H5Pdcpl.c b/src/H5Pdcpl.c index 62e12e6..b3473fb 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -718,7 +718,7 @@ H5Pget_filter(hid_t plist_id, int idx, unsigned int *flags/*out*/, FUNC_ENTER_API(H5Pget_filter, H5Z_FILTER_ERROR); H5TRACE7("Zf","iIsx*zxzx",plist_id,idx,flags,cd_nelmts,cd_values,namelen, name); - + /* Check args */ if (cd_nelmts || cd_values) { if (cd_nelmts && *cd_nelmts>256) diff --git a/src/H5R.c b/src/H5R.c index d79443d..c92c3dd 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -330,8 +330,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 */ @@ -404,10 +405,10 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref) 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"); @@ -415,20 +416,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))<0) 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 3bcd0f0..1f133cf 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -29,6 +29,7 @@ #include "H5Dprivate.h" /*datasets (for H5Tcopy) */ #include "H5Eprivate.h" /*error handling */ #include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ #include "H5Gprivate.h" /*groups */ #include "H5Iprivate.h" /*ID functions */ #include "H5MMprivate.h" /*memory management */ @@ -244,14 +245,15 @@ static struct { /* The overflow handler */ H5T_overflow_t H5T_overflow_g = NULL; -/* Declare the free list for H5T_t's */ +/* Declare the free lists 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); @@ -273,38 +275,38 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, /* 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 { \ @@ -318,14 +320,14 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, /* 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 { \ @@ -339,7 +341,7 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, /* 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 { \ @@ -353,7 +355,7 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, /* 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 { \ @@ -367,37 +369,37 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, /* 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 */ #define H5T_INIT_TYPE_REF_COMMON(RTYPE) { \ H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \ H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ - dt->u.atomic.u.r.rtype = RTYPE; \ + dt->shared->u.atomic.u.r.rtype = RTYPE; \ } #define H5T_INIT_TYPE_OBJREF_CORE { \ @@ -410,8 +412,8 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, /* 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) { \ @@ -428,6 +430,11 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, /* 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) { \ @@ -435,7 +442,7 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, 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 */ \ @@ -508,7 +515,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!=dst->order && H5T_ORDER_BE!=dst->order) @@ -522,10 +529,10 @@ H5T_init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==dst->order) { - 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; } } @@ -538,10 +545,10 @@ H5T_init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==dst->order) { - 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; } } @@ -549,7 +556,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!=dst->order && H5T_ORDER_BE!=dst->order) @@ -563,10 +570,10 @@ H5T_init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==dst->order) { - 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; } } @@ -579,10 +586,10 @@ H5T_init_inf(void) /* Swap the bytes if the machine architecture is big-endian */ if (H5T_ORDER_BE==dst->order) { - 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; } } @@ -1106,7 +1113,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 */ @@ -1138,8 +1148,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); } @@ -1382,32 +1392,40 @@ 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"); + /* Register an atom for the datatype */ + if ((ret_value = H5I_register(H5I_DATATYPE, type)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register type"); done: - if(ret_value<0) { - if(type!=NULL) - H5T_close (type); - } /* end if */ + if(ret_value <0) + if(type !=NULL) + H5T_close(type); FUNC_LEAVE_API(ret_value); } @@ -1511,7 +1529,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 */ @@ -1599,7 +1617,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) @@ -1676,10 +1694,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); @@ -1751,22 +1769,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; @@ -1774,7 +1792,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; @@ -1845,7 +1863,7 @@ H5T_is_variable_str(H5T_t *dt) assert(dt); - if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type) + if(H5T_VLEN == dt->shared->type && H5T_VLEN_STRING == dt->shared->u.vlen.type) ret_value = TRUE; done: @@ -1932,15 +1950,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 */ @@ -2022,9 +2040,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: @@ -2106,8 +2124,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++; @@ -2122,8 +2140,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 || @@ -2290,8 +2308,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, @@ -2625,13 +2643,15 @@ 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: @@ -2650,8 +2670,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; @@ -2666,13 +2688,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 */ @@ -2733,37 +2758,64 @@ 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(); - /* 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_vlen_mark(dt, NULL, H5T_VLEN_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_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") + + dt->shared->fo_count=1; + } + else + { + shared_fo->fo_count++; + + 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") + } + + 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); + } + if(shared_fo) + shared_fo->fo_count--; + } + FUNC_LEAVE_NOAPI(ret_value); } @@ -2794,16 +2846,21 @@ 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_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))) + 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); - + /* Set return value */ ret_value=dt; @@ -2857,6 +2914,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; int i; char *s; H5T_t *ret_value; @@ -2867,15 +2925,19 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) assert(old_dt); /* Allocate space */ - if (NULL==(new_dt = H5FL_MALLOC(H5T_t))) + if (NULL==(new_dt = H5FL_CALLOC(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 && 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) { @@ -2883,7 +2945,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; @@ -2893,10 +2955,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; @@ -2906,16 +2968,30 @@ 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; + if((reopened_fo=H5FO_opened(new_dt->ent.file,new_dt->ent.header))==NULL) { + /* Clear any errors from H5FO_opened() */ + H5E_clear(); + 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 */ @@ -2925,29 +3001,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++) { int 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 */ @@ -2962,16 +3038,17 @@ 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; @@ -2982,17 +3059,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; @@ -3008,12 +3085,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: @@ -3023,12 +3100,14 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) /* Deep copy of the symbol table entry */ if (H5G_ent_copy(&(new_dt->ent), &(old_dt->ent),H5G_COPY_DEEP)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to copy entry"); - + /* Set return value */ ret_value=new_dt; 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 */ @@ -3064,12 +3143,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: @@ -3087,7 +3166,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 H5T_shared_t structures (which should + * be done in H5T_close). * * Return: Non-negative on success/Negative on failure * @@ -3106,43 +3186,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 (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)); + /* Remove the dataset from the list of opened objects in the file */ + 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: @@ -3153,7 +3236,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: @@ -3194,10 +3277,20 @@ H5T_close(H5T_t *dt) FUNC_ENTER_NOAPI(H5T_close, FAIL); - assert(dt); + assert(dt && dt->shared); + + 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"); - if(H5T_free(dt)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); + 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)); + } /* Free the datatype struct */ H5FL_FREE(H5T_t,dt); @@ -3232,7 +3325,7 @@ H5T_is_atomic(const H5T_t *dt) assert(dt); - if (!H5T_IS_COMPLEX(dt->type) && H5T_OPAQUE!=dt->type) + if (!H5T_IS_COMPLEX(dt->shared->type) && H5T_OPAQUE!=dt->shared->type) ret_value = TRUE; else ret_value = FALSE; @@ -3283,23 +3376,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; + offset = dt->shared->u.atomic.offset; + prec = dt->shared->u.atomic.prec; /* Decrement the offset and precision if necessary */ if (prec > 8*size) @@ -3313,7 +3406,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: @@ -3322,7 +3415,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; @@ -3336,28 +3429,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_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) @@ -3374,9 +3467,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; @@ -3392,11 +3485,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(dt->shared->type!=H5T_VLEN) { + dt->shared->size = size; if (H5T_is_atomic(dt)) { - dt->u.atomic.offset = offset; - dt->u.atomic.prec = prec; + dt->shared->u.atomic.offset = offset; + dt->shared->u.atomic.prec = prec; } } /* end if */ } @@ -3433,7 +3526,7 @@ H5T_get_size(const H5T_t *dt) /* check args */ assert(dt); - FUNC_LEAVE_NOAPI(dt->size); + FUNC_LEAVE_NOAPI(dt->shared->size); } @@ -3476,40 +3569,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(int))) || - NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(int)))) + if (NULL==(idx1 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(int))) || + NULL==(idx2 = H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(int)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); - for (i=0; iu.compnd.nmembs; i++) + for (i=0; ishared->u.compnd.nmembs; i++) idx1[i] = idx2[i] = i; - 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; @@ -3517,10 +3610,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; @@ -3531,35 +3624,35 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2) #ifdef H5T_DEBUG /* I don't quite trust the code above yet :-) --RPM */ - for (i=0; iu.compnd.nmembs-1; i++) { - assert(HDstrcmp(dt1->u.compnd.memb[idx1[i]].name, - dt1->u.compnd.memb[idx1[i + 1]].name)); - assert(HDstrcmp(dt2->u.compnd.memb[idx2[i]].name, - dt2->u.compnd.memb[idx2[i + 1]].name)); + for (i=0; ishared->u.compnd.nmembs-1; i++) { + assert(HDstrcmp(dt1->shared->u.compnd.memb[idx1[i]].name, + dt1->shared->u.compnd.memb[idx1[i + 1]].name)); + assert(HDstrcmp(dt2->shared->u.compnd.memb[idx2[i]].name, + dt2->shared->u.compnd.memb[idx2[i + 1]].name)); } #endif /* Compare the members */ - for (i=0; iu.compnd.nmembs; i++) { - tmp = HDstrcmp(dt1->u.compnd.memb[idx1[i]].name, - dt2->u.compnd.memb[idx2[i]].name); + for (i=0; ishared->u.compnd.nmembs; i++) { + tmp = HDstrcmp(dt1->shared->u.compnd.memb[idx1[i]].name, + dt2->shared->u.compnd.memb[idx2[i]].name); if (tmp < 0) HGOTO_DONE(-1); if (tmp > 0) HGOTO_DONE(1); - if (dt1->u.compnd.memb[idx1[i]].offset < - dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(-1); - if (dt1->u.compnd.memb[idx1[i]].offset > - dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1); + if (dt1->shared->u.compnd.memb[idx1[i]].offset < + dt2->shared->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(-1); + if (dt1->shared->u.compnd.memb[idx1[i]].offset > + dt2->shared->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1); - if (dt1->u.compnd.memb[idx1[i]].size < - dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(-1); - if (dt1->u.compnd.memb[idx1[i]].size > - dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(1); + if (dt1->shared->u.compnd.memb[idx1[i]].size < + dt2->shared->u.compnd.memb[idx2[i]].size) HGOTO_DONE(-1); + if (dt1->shared->u.compnd.memb[idx1[i]].size > + dt2->shared->u.compnd.memb[idx2[i]].size) HGOTO_DONE(1); - tmp = H5T_cmp(dt1->u.compnd.memb[idx1[i]].type, - dt2->u.compnd.memb[idx2[i]].type); + tmp = H5T_cmp(dt1->shared->u.compnd.memb[idx1[i]].type, + dt2->shared->u.compnd.memb[idx2[i]].type); if (tmp < 0) HGOTO_DONE(-1); if (tmp > 0) HGOTO_DONE(1); } @@ -3569,21 +3662,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(int))) || - NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(int)))) + if (NULL==(idx1 = H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(int))) || + NULL==(idx2 = H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(int)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); - for (i=0; iu.enumer.nmembs; i++) + for (i=0; ishared->u.enumer.nmembs; i++) idx1[i] = idx2[i] = i; - 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; @@ -3591,10 +3684,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; @@ -3605,24 +3698,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 (i=0; iu.enumer.nmembs-1; i++) { - assert(HDstrcmp(dt1->u.enumer.name[idx1[i]], - dt1->u.enumer.name[idx1[i+1]])); - assert(HDstrcmp(dt2->u.enumer.name[idx2[i]], - dt2->u.enumer.name[idx2[i+1]])); + for (i=0; ishared->u.enumer.nmembs-1; i++) { + assert(HDstrcmp(dt1->shared->u.enumer.name[idx1[i]], + dt1->shared->u.enumer.name[idx1[i+1]])); + assert(HDstrcmp(dt2->shared->u.enumer.name[idx2[i]], + dt2->shared->u.enumer.name[idx2[i+1]])); } #endif /* Compare the members */ - base_size = dt1->parent->size; - for (i=0; iu.enumer.nmembs; i++) { - tmp = HDstrcmp(dt1->u.enumer.name[idx1[i]], - dt2->u.enumer.name[idx2[i]]); + base_size = dt1->shared->parent->shared->size; + for (i=0; ishared->u.enumer.nmembs; i++) { + tmp = HDstrcmp(dt1->shared->u.enumer.name[idx1[i]], + dt2->shared->u.enumer.name[idx2[i]]); if (tmp<0) HGOTO_DONE(-1); if (tmp>0) HGOTO_DONE(1); - tmp = HDmemcmp(dt1->u.enumer.value+idx1[i]*base_size, - dt2->u.enumer.value+idx2[i]*base_size, + tmp = HDmemcmp(dt1->shared->u.enumer.value+idx1[i]*base_size, + dt2->shared->u.enumer.value+idx2[i]*base_size, base_size); if (tmp<0) HGOTO_DONE(-1); if (tmp>0) HGOTO_DONE(1); @@ -3630,59 +3723,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_VLEN_BADLOC && dt1->u.vlen.locu.vlen.loc>H5T_VLEN_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_VLEN_BADLOC && dt1->shared->u.vlen.locshared->u.vlen.loc>H5T_VLEN_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_VLEN_MEMORY && - dt2->u.vlen.loc==H5T_VLEN_DISK) { + if (dt1->shared->u.vlen.loc==H5T_VLEN_MEMORY && + dt2->shared->u.vlen.loc==H5T_VLEN_DISK) { HGOTO_DONE(-1); - } else if (dt1->u.vlen.loc==H5T_VLEN_DISK && - dt2->u.vlen.loc==H5T_VLEN_MEMORY) { + } else if (dt1->shared->u.vlen.loc==H5T_VLEN_DISK && + dt2->shared->u.vlen.loc==H5T_VLEN_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) @@ -3693,62 +3786,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; @@ -3758,14 +3851,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; @@ -3775,12 +3868,12 @@ 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: case H5R_DATASET_REGION: /* Does this need more to distinguish it? -QAK 11/30/98 */ @@ -3891,7 +3984,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; @@ -3974,8 +4067,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, @@ -4230,7 +4323,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: @@ -4271,7 +4364,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: @@ -4304,7 +4397,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: @@ -4341,8 +4434,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); @@ -4375,10 +4468,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; @@ -4386,7 +4479,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; @@ -4536,7 +4629,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; @@ -4566,7 +4659,7 @@ H5T_debug(const H5T_t *dt, FILE *stream) break; } - switch (dt->state) { + switch (dt->shared->state) { case H5T_STATE_TRANSIENT: s2 = "[transient]"; break; @@ -4584,10 +4677,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) { + switch (dt->shared->u.atomic.order) { case H5T_ORDER_BE: s1 = "BE"; break; @@ -4606,17 +4699,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; @@ -4631,7 +4724,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; @@ -4646,21 +4739,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; @@ -4670,47 +4763,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 29c3faa..1dc4b8e 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -36,6 +36,7 @@ static herr_t H5T_init_array_interface(void); /* Declare extern the free list for H5T_t's */ H5FL_EXTERN(H5T_t); +H5FL_EXTERN(H5T_shared_t); /*-------------------------------------------------------------------------- @@ -157,34 +158,38 @@ 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->fo_count=1; + 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); @@ -218,7 +223,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 */ @@ -253,10 +258,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); @@ -290,7 +295,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 */ @@ -326,20 +331,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/H5Tbit.c b/src/H5Tbit.c index 5650999..a3537f1 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -189,7 +189,7 @@ H5T_bit_get_d (uint8_t *buf, size_t offset, size_t size) assert (8*sizeof(val)>=size); H5T_bit_copy ((uint8_t*)&val, 0, buf, offset, size); - switch (((H5T_t*)(H5I_object(H5T_NATIVE_INT_g)))->u.atomic.order) { + switch (((H5T_t*)(H5I_object(H5T_NATIVE_INT_g)))->shared->u.atomic.order) { case H5T_ORDER_LE: break; @@ -234,7 +234,7 @@ H5T_bit_set_d (uint8_t *buf, size_t offset, size_t size, hsize_t val) assert (8*sizeof(val)>=size); - switch (((H5T_t*)(H5I_object(H5T_NATIVE_INT_g)))->u.atomic.order) { + switch (((H5T_t*)(H5I_object(H5T_NATIVE_INT_g)))->shared->u.atomic.order) { case H5T_ORDER_LE: break; diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index a924ee0..75e78de 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -26,6 +26,7 @@ #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5Iprivate.h" /*ID functions */ +#include "H5FOprivate.h" /* File objects */ #include "H5Tpkg.h" /*data-type functions */ /* Interface initialization */ @@ -134,9 +135,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 */ @@ -161,7 +162,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 because this datatype may be still used in * memory after committed to disk. So we need to change its size back. */ @@ -170,7 +176,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 dcedcc9..f50676f 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -94,9 +94,9 @@ H5Tget_member_offset(hid_t type_id, int membno) H5TRACE2("z","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, 0, "not a compound data type"); - if (membno < 0 || membno >= dt->u.compnd.nmembs) + if (membno < 0 || membno >= dt->shared->u.compnd.nmembs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number"); /* Value */ @@ -136,10 +136,10 @@ H5T_get_member_offset(H5T_t *dt, int membno) FUNC_ENTER_NOAPI(H5T_get_member_offset, 0); assert(dt); - assert(membno >= 0 && membno < dt->u.compnd.nmembs); + assert(membno >= 0 && 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); @@ -172,13 +172,13 @@ H5Tget_member_class(hid_t type_id, int membno) H5TRACE2("Tt","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, H5T_NO_CLASS, "not a compound data type"); - if (membno < 0 || membno >= dt->u.compnd.nmembs) + if (membno < 0 || 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); @@ -219,9 +219,9 @@ H5Tget_member_type(hid_t type_id, int 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 data type"); - if (membno < 0 || membno >= dt->u.compnd.nmembs) + if (membno < 0 || 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"); @@ -265,10 +265,10 @@ H5T_get_member_type(H5T_t *dt, int membno) FUNC_ENTER_NOAPI(H5T_get_member_type, NULL); assert(dt); - assert(membno >=0 && membno < dt->u.compnd.nmembs); + assert(membno >=0 && membno < dt->shared->u.compnd.nmembs); /* Copy data type 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 data type"); done: @@ -313,9 +313,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 data type"); - 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"); @@ -396,82 +396,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 = (int)na; - parent->u.compnd.memb = x; + parent->shared->u.compnd.nalloc = (int)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); @@ -510,37 +510,37 @@ 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 data type"); /* Remove padding between members */ H5T_sort_value(dt, NULL); - 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 */ @@ -574,12 +574,12 @@ H5T_is_packed(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=dt->u.compnd.packed; + if(dt->shared->type==H5T_COMPOUND) + ret_value=dt->shared->u.compnd.packed; done: FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 2bce779..8e2433b 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -336,7 +336,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 \ @@ -623,32 +623,32 @@ 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 || - !((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"); - 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: /* 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; @@ -664,8 +664,8 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, 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; - switch (src->size) { + buf_stride = buf_stride ? buf_stride : src->shared->size; + switch (src->shared->size) { case 1: /*no-op*/ break; @@ -1007,28 +1007,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; @@ -1045,11 +1045,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; @@ -1109,11 +1109,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; @@ -1132,23 +1132,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; } @@ -1169,11 +1169,11 @@ H5T_conv_b_b(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 (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 @@ -1182,11 +1182,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; } } @@ -1196,41 +1196,41 @@ 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) { if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - 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 { - 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: @@ -1241,11 +1241,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) { - half_size = dst->size/2; + if (H5T_ORDER_BE==dst->shared->u.atomic.order) { + 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; } } @@ -1254,13 +1254,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; } } @@ -1318,11 +1318,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; @@ -1340,22 +1340,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); @@ -1376,14 +1376,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); @@ -1480,8 +1480,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"); @@ -1524,15 +1524,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... */ @@ -1545,10 +1545,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 (i=0, offset=0; iu.compnd.nmembs; i++) { + for (i=0, offset=0; ishared->u.compnd.nmembs; 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) { if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], @@ -1574,10 +1574,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; @@ -1601,17 +1601,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; @@ -1712,8 +1712,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) @@ -1731,23 +1731,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 (i=0, offset=0; iu.compnd.nmembs; i++) { + if (dst->shared->size > src->shared->size) { + for (i=0, offset=0; ishared->u.compnd.nmembs; 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; } - 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); @@ -1799,12 +1799,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 @@ -1813,10 +1813,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 (i=0, offset=0; iu.compnd.nmembs; i++) { + for (i=0, offset=0; ishared->u.compnd.nmembs; 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) { xbuf = buf + src_memb->offset; @@ -1824,20 +1824,20 @@ 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; } } 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; } @@ -1849,11 +1849,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; @@ -1862,13 +1862,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; } } @@ -1876,8 +1876,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; @@ -1924,7 +1924,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); /* @@ -1934,15 +1934,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; } @@ -1964,14 +1964,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; @@ -1982,21 +1982,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); @@ -2075,8 +2075,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; @@ -2100,8 +2100,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 @@ -2116,23 +2116,23 @@ 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; } 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); @@ -2141,22 +2141,22 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (n<0 || n>=priv->length || priv->src2dst[n]<0) { if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - HDmemset(d, 0xff, dst->size); + HDmemset(d, 0xff, dst->shared->size); } } 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) { @@ -2168,12 +2168,12 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (lt>=rt) { if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - HDmemset(d, 0xff, dst->size); + HDmemset(d, 0xff, dst->shared->size); } } 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); } } } @@ -2272,8 +2272,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; @@ -2294,12 +2294,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) @@ -2311,21 +2311,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); @@ -2338,7 +2338,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 */ @@ -2382,20 +2382,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 { @@ -2414,7 +2414,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 */ @@ -2440,9 +2440,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 */ @@ -2460,7 +2460,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) { @@ -2475,9 +2475,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"); } } @@ -2569,18 +2569,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 */ @@ -2606,36 +2606,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 */ @@ -2643,10 +2643,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 */ @@ -2722,13 +2722,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; @@ -2747,23 +2747,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; } @@ -2784,9 +2784,9 @@ H5T_conv_i_i (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 (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 @@ -2795,11 +2795,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; } } @@ -2808,7 +2808,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; @@ -2817,33 +2817,33 @@ 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 (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - 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 { - 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 @@ -2851,50 +2851,50 @@ 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*/ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - 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 (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*/ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - 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 { - 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 (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - 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 (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 @@ -2902,21 +2902,21 @@ 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 (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - 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 (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 { @@ -2926,46 +2926,46 @@ 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 (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - 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 (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) { - half_size = dst->size/2; + if (H5T_ORDER_BE==dst->shared->u.atomic.order) { + 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; } } @@ -2975,13 +2975,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; } } @@ -3060,13 +3060,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; /* @@ -3090,22 +3090,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; } @@ -3125,11 +3125,11 @@ H5T_conv_f_f (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 (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 @@ -3139,10 +3139,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; } } @@ -3271,13 +3271,13 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ if (H5T_overflow_g) { uint8_t over_src[256]; - assert(src_p->size<=sizeof over_src); + assert(src_p->shared->size<=sizeof over_src); if (H5T_ORDER_BE==src.order) { - for (i=0; isize; i++) { - over_src[src_p->size-(i+1)] = s[i]; + for (i=0; ishared->size; i++) { + over_src[src_p->shared->size-(i+1)] = s[i]; } } else { - for (i=0; isize; i++) { + for (i=0; ishared->size; i++) { over_src[i] = s[i]; } } @@ -3353,12 +3353,12 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ if (H5T_overflow_g) { uint8_t over_src[256]; - assert(src_p->size<=sizeof over_src); + assert(src_p->shared->size<=sizeof over_src); if (H5T_ORDER_BE==src.order) { - for (i=0; isize; i++) - over_src[src_p->size-(i+1)] = s[i]; + for (i=0; ishared->size; i++) + over_src[src_p->shared->size-(i+1)] = s[i]; } else { - for (i=0; isize; i++) + for (i=0; ishared->size; i++) over_src[i] = s[i]; } if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0) @@ -3386,9 +3386,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)); } @@ -3397,10 +3397,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) { - 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; } } @@ -3411,13 +3411,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; } } @@ -3472,14 +3472,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; @@ -3498,7 +3498,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. @@ -3506,23 +3506,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. */ @@ -3541,22 +3541,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]; } @@ -3564,17 +3564,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; @@ -3596,20 +3596,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; @@ -3635,13 +3635,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; @@ -6739,7 +6739,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; diff --git a/src/H5Tcset.c b/src/H5Tcset.c index 32f5fa9..f9fe4e6 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_CANTINIT, H5T_CSET_ERROR, "operation not defined for data type class"); /* result */ - if(H5T_STRING == dt->type) - ret_value = dt->u.atomic.u.s.cset; - else if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type) - ret_value = dt->u.vlen.cset; + if(H5T_STRING == dt->shared->type) + ret_value = dt->shared->u.atomic.u.s.cset; + else if(H5T_VLEN == dt->shared->type && H5T_VLEN_STRING == dt->shared->u.vlen.type) + ret_value = dt->shared->u.vlen.cset; else HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_CSET_ERROR, "can't get cset info"); @@ -134,20 +134,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_CANTINIT, FAIL, "operation not defined for data type class"); /* Commit */ - if(H5T_STRING == dt->type) - dt->u.atomic.u.s.cset = cset; - else if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type) - dt->u.vlen.cset = cset; + if(H5T_STRING == dt->shared->type) + dt->shared->u.atomic.u.s.cset = cset; + else if(H5T_VLEN == dt->shared->type && H5T_VLEN_STRING == dt->shared->u.vlen.type) + dt->shared->u.vlen.cset = cset; else HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "can't set cset info"); diff --git a/src/H5Tenum.c b/src/H5Tenum.c index fa8cf4f..f1e6e5f 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -35,6 +35,7 @@ static herr_t H5T_init_enum_interface(void); /* Declare extern the free list for H5T_t's */ H5FL_EXTERN(H5T_t); +H5FL_EXTERN(H5T_shared_t); /* Static local functions */ static char *H5T_enum_nameof(H5T_t *dt, 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,16 @@ H5T_enum_create(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->fo_count=1; + 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 +188,7 @@ H5Tenum_insert(hid_t type, const char *name, 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 +238,31 @@ H5T_enum_insert(H5T_t *dt, const char *name, 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) { - int 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) { + int 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); @@ -291,9 +297,9 @@ H5Tget_member_value(hid_t type, int 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<0 || membno>=dt->u.enumer.nmembs) + if (membno<0 || 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"); @@ -333,7 +339,7 @@ H5T_get_member_value(H5T_t *dt, int 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); @@ -375,7 +381,7 @@ H5Tenum_nameof(hid_t type, 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"); @@ -425,24 +431,24 @@ H5T_enum_nameof(H5T_t *dt, 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 */ H5T_sort_value(dt, NULL); lt = 0; - rt = dt->u.enumer.nmembs; + rt = dt->shared->u.enumer.nmembs; md = -1; 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) { @@ -456,10 +462,10 @@ H5T_enum_nameof(H5T_t *dt, 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 */ @@ -501,7 +507,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"); @@ -545,23 +551,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 */ H5T_sort_name(dt, NULL); lt = 0; - rt = dt->u.enumer.nmembs; + rt = dt->shared->u.enumer.nmembs; md = -1; while (ltu.enumer.name[md]); + cmp = HDstrcmp(name, dt->shared->u.enumer.name[md]); if (cmp<0) { rt = md; } else if (cmp>0) { @@ -574,7 +580,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 97a91be..50539f9 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 = dt->u.compnd.nmembs; - else if (H5T_ENUM==dt->type) - ret_value = dt->u.enumer.nmembs; + if (H5T_COMPOUND==dt->shared->type) + ret_value = dt->shared->u.compnd.nmembs; + else if (H5T_ENUM==dt->shared->type) + ret_value = dt->shared->u.enumer.nmembs; else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for type class"); @@ -206,17 +206,17 @@ H5T_get_member_name(H5T_t *dt, int membno) assert(dt); - switch (dt->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - if (membno<0 || membno>=dt->u.compnd.nmembs) + if (membno<0 || 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<0 || membno>=dt->u.enumer.nmembs) + if (membno<0 || 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: @@ -262,18 +262,18 @@ H5Tget_member_index(hid_t type_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Locate member by name */ - switch (dt->type) { + switch (dt->shared->type) { case H5T_COMPOUND: - nmembs = dt->u.compnd.nmembs; + nmembs = dt->shared->u.compnd.nmembs; for(i=0; iu.compnd.memb[i].name, name)) + if(!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) HGOTO_DONE(i); } break; case H5T_ENUM: - nmembs = dt->u.enumer.nmembs; + nmembs = dt->shared->u.enumer.nmembs; for(i=0; iu.enumer.name[i], name)) + if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_DONE(i); } break; @@ -317,20 +317,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]; @@ -343,32 +343,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) { @@ -384,8 +384,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 @@ -428,20 +428,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]; @@ -454,31 +454,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) { @@ -494,7 +494,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 03f20d6..6baf253 100644 --- a/src/H5Tfixed.c +++ b/src/H5Tfixed.c @@ -118,15 +118,15 @@ H5T_get_sign(H5T_t *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 data type 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 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 (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 data type 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 e1f9456..7b7ac98 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 data 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 data type 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 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_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 data type 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 data 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, 0, "operation not defined for data type 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 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_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 data type 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 data 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, H5T_NORM_ERROR, "operation not defined for data type 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 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 (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 data type 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 data 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, H5T_PAD_ERROR, "operation not defined for data type 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 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 (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 data type 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 7ea9073..8b774fd 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"); diff --git a/src/H5Toffset.c b/src/H5Toffset.c index 8ab9ac6..f8c9fdb 100644 --- a/src/H5Toffset.c +++ b/src/H5Toffset.c @@ -103,14 +103,14 @@ 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_COMPOUND==dt->type || H5T_OPAQUE==dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified data type"); /* Offset */ assert(H5T_is_atomic(dt)); - ret_value = (int)dt->u.atomic.offset; + ret_value = (int)dt->shared->u.atomic.offset; done: FUNC_LEAVE_API(ret_value); @@ -168,13 +168,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_CANTINIT, FAIL, "operation not defined for this datatype"); /* Do the real work */ @@ -234,25 +234,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 a7bacfd..d2a9df6 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 0b6146b..004f513 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -84,14 +84,14 @@ 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_COMPOUND==dt->type || H5T_OPAQUE==dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR, "operation not defined for specified data type"); /* Order */ assert(H5T_is_atomic(dt)); - ret_value = dt->u.atomic.order; + ret_value = dt->shared->u.atomic.order; done: FUNC_LEAVE_API(ret_value); @@ -126,20 +126,20 @@ 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_COMPOUND==dt->type || H5T_OPAQUE==dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR, "operation not defined for specified data type"); /* Commit */ assert(H5T_is_atomic(dt)); - 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 22cec83..0f9085c 100644 --- a/src/H5Tpad.c +++ b/src/H5Tpad.c @@ -84,17 +84,17 @@ 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_COMPOUND==dt->type || H5T_OPAQUE==dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified data type"); /* Get values */ assert(H5T_is_atomic(dt)); 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); @@ -129,21 +129,21 @@ 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_COMPOUND==dt->type || H5T_OPAQUE==dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified data type"); /* Commit */ assert(H5T_is_atomic(dt)); - 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 72bcd5f..bc2841f 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -184,9 +184,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 */ @@ -200,6 +201,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 7de9442..02c33cf 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -91,14 +91,14 @@ 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 data type"); - while (dt->parent) - dt = dt->parent; /*defer to parent*/ - if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) + while (dt->shared->parent) + dt = dt->shared->parent; /*defer to parent*/ + if (H5T_COMPOUND==dt->shared->type || H5T_OPAQUE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for specified data type"); /* Precision */ assert(H5T_is_atomic(dt)); - ret_value = dt->u.atomic.prec; + ret_value = dt->shared->u.atomic.prec; done: FUNC_LEAVE_API(ret_value); @@ -146,15 +146,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 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 (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_CANTINIT, 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_CANTINIT, FAIL, "operation not defined for specified data type"); /* Do the work */ @@ -206,25 +206,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_CANTINIT, 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)) { /* 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) @@ -233,7 +233,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: @@ -246,9 +246,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; @@ -258,10 +258,10 @@ H5T_set_precision(H5T_t *dt, size_t prec) } /* Commit */ - dt->size = size; + dt->shared->size = size; if (H5T_is_atomic(dt)) { - dt->u.atomic.offset = offset; - dt->u.atomic.prec = prec; + dt->shared->u.atomic.offset = offset; + dt->shared->u.atomic.prec = prec; } } else diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 48958d8..8b279e7 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -61,7 +61,7 @@ typedef struct { 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 10a3e15..275f5c3 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 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_CANTINIT, H5T_STR_ERROR, "operation not defined for data type class"); /* result */ - if(H5T_STRING == dt->type) - ret_value = dt->u.atomic.u.s.pad; - else if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type) - ret_value = dt->u.vlen.pad; + if(H5T_STRING == dt->shared->type) + ret_value = dt->shared->u.atomic.u.s.pad; + else if(H5T_VLEN == dt->shared->type && H5T_VLEN_STRING == dt->shared->u.vlen.type) + ret_value = dt->shared->u.vlen.pad; else HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_STR_ERROR, "can't get strpad info"); @@ -146,20 +146,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 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 (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_CANTINIT, FAIL, "operation not defined for data type class"); /* Commit */ - if(H5T_STRING == dt->type) - dt->u.atomic.u.s.pad = strpad; - else if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type) - dt->u.vlen.pad = strpad; + if(H5T_STRING == dt->shared->type) + dt->shared->u.atomic.u.s.pad = strpad; + else if(H5T_VLEN == dt->shared->type && H5T_VLEN_STRING == dt->shared->u.vlen.type) + dt->shared->u.vlen.pad = strpad; else HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_STR_ERROR, "can't set strpad info"); diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 2de8db6..643f36d 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -71,6 +71,7 @@ static H5T_vlen_alloc_info_t H5T_vlen_def_vl_alloc_info ={ /* Declare extern the free list for H5T_t's */ H5FL_EXTERN(H5T_t); +H5FL_EXTERN(H5T_shared_t); /*-------------------------------------------------------------------------- @@ -170,18 +171,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_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) @@ -225,7 +230,7 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc) assert(loc>H5T_VLEN_BADLOC && locu.vlen.loc) { + if(loc!=dt->shared->u.vlen.loc) { /* Indicate that the location changed */ ret_value=TRUE; @@ -234,62 +239,62 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc) assert(f==NULL); /* Mark this type as being stored in memory */ - dt->u.vlen.loc=H5T_VLEN_MEMORY; + dt->shared->u.vlen.loc=H5T_VLEN_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_VLEN_DISK: /* Disk based VL datatype */ assert(f); /* Mark this type as being stored on disk */ - dt->u.vlen.loc=H5T_VLEN_DISK; + dt->shared->u.vlen.loc=H5T_VLEN_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: @@ -1013,16 +1018,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 */ @@ -1030,14 +1035,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; i<(unsigned)dt->u.compnd.nmembs; i++) { + for (i=0; i<(unsigned)dt->shared->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 */ @@ -1045,19 +1050,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 */ @@ -1069,7 +1074,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); @@ -1236,71 +1241,71 @@ H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc) assert(loc>H5T_VLEN_BADLOC && loctype) { + switch(dt->shared->type) { case H5T_ARRAY: /* Recurse on VL, compound and array base element type */ /* Recurse if it's VL, compound or array */ /* (If the type is compound and 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((vlen_changed=H5T_vlen_mark(dt->parent,f,loc))<0) + if((vlen_changed=H5T_vlen_mark(dt->shared->parent,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(vlen_changed>0) ret_value=vlen_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; case H5T_COMPOUND: /* Check each field and recurse on VL, compound and array type */ /* Compound datatypes can't change in size if the force_conv flag is not set */ - if(dt->force_conv) { + if(dt->shared->force_conv) { /* Sort the fields based on offsets */ H5T_sort_value(dt,NULL); - for (i=0; iu.compnd.nmembs; i++) { + for (i=0; ishared->u.compnd.nmembs; i++) { /* 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; /* 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->u.compnd.memb[i].type->force_conv && H5T_IS_COMPLEX(dt->u.compnd.memb[i].type->type)) { + if(dt->shared->u.compnd.memb[i].type->shared->force_conv && H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) { /* Keep the old field size for later */ - old_size=dt->u.compnd.memb[i].type->size; + old_size=dt->shared->u.compnd.memb[i].type->shared->size; /* Mark the VL, compound, enum or array type */ - if((vlen_changed=H5T_vlen_mark(dt->u.compnd.memb[i].type,f,loc))<0) + if((vlen_changed=H5T_vlen_mark(dt->shared->u.compnd.memb[i].type,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(vlen_changed>0) ret_value=vlen_changed; /* Check if the field changed size */ - if(old_size != dt->u.compnd.memb[i].type->size) { + if(old_size != dt->shared->u.compnd.memb[i].type->shared->size) { /* Adjust the size of the member */ - dt->u.compnd.memb[i].size = (dt->u.compnd.memb[i].size*dt->u.compnd.memb[i].type->size)/old_size; + dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*dt->shared->u.compnd.memb[i].type->shared->size)/old_size; /* Add that change to the accumulated size change */ - accum_change += (dt->u.compnd.memb[i].type->size - (int)old_size); + accum_change += (dt->shared->u.compnd.memb[i].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; } /* end if */ 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 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((vlen_changed=H5T_vlen_mark(dt->parent,f,loc))<0) + if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + if((vlen_changed=H5T_vlen_mark(dt->shared->parent,f,loc))<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(vlen_changed>0) ret_value=vlen_changed; diff --git a/src/H5detect.c b/src/H5detect.c index 57b5444..6cf519f 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -513,6 +513,7 @@ static int interface_initialize_g = 0;\n\ \n\ /* Declare external the free list for H5T_t's */\n\ H5FL_EXTERN(H5T_t);\n\ +H5FL_EXTERN(H5T_shared_t);\n\ \n\ \n"); @@ -548,15 +549,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 */ @@ -566,19 +572,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..3e714f8 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 */ @@ -1197,7 +1197,6 @@ int main( void ) /* Get datatype*/ if((type_id=H5Dget_type(dataset_id))<0) goto out; - /* Get name */ if (H5Iget_name( type_id, name, size )< 0) goto out; @@ -1212,7 +1211,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(); /*------------------------------------------------------------------------- * Test H5Iget_name with different files, test1 @@ -1365,7 +1388,6 @@ int main( void ) if ( name3 ) free(name3); - /* Close */ H5Gclose( group_id ); @@ -1373,8 +1395,6 @@ int main( void ) PASSED(); - - /*------------------------------------------------------------------------- * Test H5Iget_name with invalid IDs *------------------------------------------------------------------------- @@ -1418,6 +1438,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 +1455,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 secondt 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 ); @@ -1467,9 +1526,8 @@ int main( void ) H5Gclose( group5_id ); H5Gclose( group6_id ); H5Fclose( file1_id ); - - PASSED(); +PASSED(); /*------------------------------------------------------------------------- diff --git a/test/unlink.c b/test/unlink.c index a2cd391..d0cfbaa 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 @@ -1842,6 +1845,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; @@ -1875,6 +1881,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 @@ -2044,6 +2189,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..0dc5535 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,12 @@ 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[0]==objstat.fileno[0] && refstat.fileno[1]==objstat.fileno[1] + && refstat.objno[0]==objstat.objno[0] && refstat.objno[1]==objstat.objno[1]) { H5Fclose(fid); return travt->objs[i].name; diff --git a/windows/all.zip b/windows/all.zip index 628e23c..6950643 100755 Binary files a/windows/all.zip and b/windows/all.zip differ -- cgit v0.12