diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-12-23 22:00:43 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-12-23 22:00:43 (GMT) |
commit | 928d398be4143546e57c50788b429095328cb3ba (patch) | |
tree | 62e0c15ab90dead334cf25a99ba2eb4fe1322fd5 /src | |
parent | d03ae28886d062f7552334c204562a98bb7351e9 (diff) | |
parent | 92d4f32514e05a3cff1db0af0befcd489c74c1d3 (diff) | |
download | hdf5-928d398be4143546e57c50788b429095328cb3ba.zip hdf5-928d398be4143546e57c50788b429095328cb3ba.tar.gz hdf5-928d398be4143546e57c50788b429095328cb3ba.tar.bz2 |
[svn-r24593] merge from trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/H5F.c | 118 | ||||
-rw-r--r-- | src/H5Faccum.c | 2 | ||||
-rw-r--r-- | src/H5Fint.c | 189 | ||||
-rw-r--r-- | src/H5Fio.c | 2 | ||||
-rw-r--r-- | src/H5Fpkg.h | 1 | ||||
-rw-r--r-- | src/H5Fprivate.h | 2 | ||||
-rw-r--r-- | src/H5Fquery.c | 2 | ||||
-rw-r--r-- | src/H5Ocache.c | 2 | ||||
-rw-r--r-- | src/H5Osdspace.c | 2 | ||||
-rw-r--r-- | src/H5detect.c | 51 | ||||
-rw-r--r-- | src/H5public.h | 4 | ||||
-rw-r--r-- | src/H5win32defs.h | 2 | ||||
-rw-r--r-- | src/Makefile.in | 2 |
13 files changed, 263 insertions, 116 deletions
@@ -268,6 +268,32 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_get_all_count_cb + * + * Purpose: Get counter of all object types currently open. + * + * Return: Non-negative on success; negative on failure. + * + * Programmer: Mohamad Chaarawi + * May 2012 + * + *------------------------------------------------------------------------- + */ +static int +H5F_get_all_count_cb(void UNUSED *obj_ptr, hid_t UNUSED obj_id, void *key) +{ + H5F_trav_obj_cnt_t *udata = (H5F_trav_obj_cnt_t *)key; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + *(udata->obj_count) = *(udata->obj_count)+1; + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F_get_all_count_cb */ + + +/*------------------------------------------------------------------------- * Function: H5Fget_obj_count * * Purpose: Public function returning the number of opened object IDs @@ -288,21 +314,19 @@ H5Fget_obj_count(hid_t file_id, unsigned types) FUNC_ENTER_API(FAIL) H5TRACE2("Zs", "iIu", file_id, types); - if(0 == (types & H5F_OBJ_ALL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") - if(file_id != (hid_t)H5F_OBJ_ALL) { H5VL_t *vol_plugin; void *obj; /* get the file object */ - if(NULL == (obj = (void *)H5I_object(file_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + if(NULL == (obj = (void *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file id") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_COUNT, H5AC_dxpl_id, H5_EVENT_STACK_NULL, types, &ret_value) < 0) + if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_COUNT, H5AC_dxpl_id, + H5_EVENT_STACK_NULL, types, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object count in file(s)") } /* iterate over all open files and get the obj count for each */ @@ -312,8 +336,26 @@ H5Fget_obj_count(hid_t file_id, unsigned types) udata.obj_count = &ret_value; udata.types = types | H5F_OBJ_LOCAL; - if(H5I_iterate(H5I_FILE, H5F_get_obj_count_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)") + if(types & H5F_OBJ_FILE) { + if(H5I_iterate(H5I_FILE, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_DATASET) { + if(H5I_iterate(H5I_DATASET, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_GROUP) { + if(H5I_iterate(H5I_GROUP, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_DATATYPE) { + if(H5I_iterate(H5I_DATATYPE, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_ATTR) { + if(H5I_iterate(H5I_ATTR, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } } done: @@ -322,6 +364,37 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_get_all_ids_cb + * + * Purpose: Get ids of all object types currently open. + * + * Return: Non-negative on success; negative on failure. + * + * Programmer: Mohamad Chaarawi + * May 2012 + * + *------------------------------------------------------------------------- + */ +static int +H5F_get_all_ids_cb(void UNUSED *obj_ptr, hid_t obj_id, void *key) +{ + H5F_trav_obj_ids_t *udata = (H5F_trav_obj_ids_t *)key; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(*udata->obj_count >= udata->max_objs) + HGOTO_DONE(H5_ITER_STOP); + + udata->oid_list[*udata->obj_count] = obj_id; + *(udata->obj_count) = *(udata->obj_count)+1; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F_get_all_ids_cb */ + + +/*------------------------------------------------------------------------- * Function: H5Fget_object_ids * * Purpose: Public function to return a list of opened object IDs. @@ -349,7 +422,8 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) if(0 == (types & H5F_OBJ_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") - HDassert(oid_list); + if(!oid_list) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "object ID list is NULL") /* Check arguments */ if(file_id != (hid_t)H5F_OBJ_ALL) { @@ -367,16 +441,34 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object count in file(s)") } /* iterate over all open files and get the obj count for each */ - else { + else if (oid_list && max_objs){ H5F_trav_obj_ids_t udata; - udata.types = types | H5F_OBJ_LOCAL; + //udata.types = types | H5F_OBJ_LOCAL; udata.max_objs = max_objs; udata.oid_list = oid_list; udata.obj_count = &ret_value; - if(H5I_iterate(H5I_FILE, H5F_get_obj_ids_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)") + if(types & H5F_OBJ_FILE) { + if(H5I_iterate(H5I_FILE, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_DATASET) { + if(H5I_iterate(H5I_DATASET, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_GROUP) { + if(H5I_iterate(H5I_GROUP, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_DATATYPE) { + if(H5I_iterate(H5I_DATATYPE, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_ATTR) { + if(H5I_iterate(H5I_ATTR, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } } done: diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 0e549fa..e0ce292 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -426,7 +426,7 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, HDassert(f); HDassert(f->shared); - HDassert(f->intent & H5F_ACC_RDWR); + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); HDassert(buf); /* Treat global heap as raw data */ diff --git a/src/H5Fint.c b/src/H5Fint.c index 096b93b..c8cb425 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -50,13 +50,14 @@ typedef struct H5F_olist_t { } ptr; } file_info; size_t list_index; /* Current index in open ID array */ - size_t max_index; /* Maximum # of IDs to put into array */ + size_t max_nobjs; /* Maximum # of IDs to put into array */ } H5F_olist_t; /* private prototypes */ -static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); -static herr_t H5F_build_actual_name(const H5F_t *f, const struct H5P_genplist_t *fapl, - const char *name, char ** /*out*/ actual_name); +static H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, H5FD_t *lf); +static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, + const char *name, char ** /*out*/ actual_name); static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush); /* Declare a free list to manage the H5F_t struct */ @@ -200,8 +201,7 @@ done: * Purpose: H5F_get_obj_count_cb callback function. It calls in the * VOL and gets the object count for the file ID passed * - * Return: TRUE if the value has been added. - * FALSE otherwise. + * Return: Non-negative on success; negative on failure. * * Programmer: Mohamad Chaarawi * May 2012 @@ -224,8 +224,8 @@ H5F_get_obj_count_cb(void UNUSED *obj_ptr, hid_t obj_id, void *key) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the file object */ - if(NULL == (obj = (void *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + if(NULL == (obj = (void *)H5I_object_verify(obj_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file id") if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_COUNT, H5AC_dxpl_id, H5_EVENT_STACK_NULL, udata->types, &obj_count) < 0) @@ -276,8 +276,7 @@ done: * Purpose: H5F_get_obj_ids_cb callback function. It calls in the * VOL and gets the object ids for the file ID passed * - * Return: TRUE if the value has been added. - * FALSE otherwise. + * Return: Non-negative on success; negative on failure. * * Programmer: Mohamad Chaarawi * May 2012 @@ -300,11 +299,11 @@ H5F_get_obj_ids_cb(void UNUSED *obj_ptr, hid_t obj_id, void *key) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the file object */ - if(NULL == (obj = (void *)H5I_object(obj_id))) + if(NULL == (obj = (void *)H5I_object_verify(obj_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_IDS, H5AC_dxpl_id, H5_EVENT_STACK_NULL, udata->types, - udata->max_objs, udata->oid_list, &obj_count) < 0) + if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_IDS, H5AC_dxpl_id, H5_EVENT_STACK_NULL, + udata->types, udata->max_objs, udata->oid_list, &obj_count) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, H5_ITER_ERROR, "unable to get object count in file(s)") *(udata->obj_count) += obj_count; @@ -364,7 +363,8 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr) +H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, + hbool_t app_ref, size_t *obj_id_count_ptr) { size_t obj_id_count=0; /* Number of open IDs */ H5F_olist_t olist; /* Structure to hold search results */ @@ -376,10 +376,10 @@ H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_ HDassert(obj_id_count_ptr); /* Set up search information */ - olist.obj_id_list = (max_index==0 ? NULL : obj_id_list); + olist.obj_id_list = (max_nobjs==0 ? NULL : obj_id_list); olist.obj_id_count = &obj_id_count; olist.list_index = 0; - olist.max_index = max_index; + olist.max_nobjs = max_nobjs; /* Determine if we are searching for local or global objects */ if(types & H5F_OBJ_LOCAL) { @@ -399,38 +399,54 @@ H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_ HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)") } /* end if */ - /* Search through dataset IDs to count number of datasets, and put their + /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), + * or the caller wants to get the list of IDs and the list isn't full, + * search through dataset IDs to count number of datasets, and put their * IDs on the object list */ - if(types & H5F_OBJ_DATASET) { - olist.obj_type = H5I_DATASET; - if(H5I_iterate(H5I_DATASET, H5F_get_objects_cb, &olist, app_ref) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(2)") - } /* end if */ + if(!olist.max_nobjs || (olist.max_nobjs && olist.list_index<olist.max_nobjs)) { + if (types & H5F_OBJ_DATASET) { + olist.obj_type = H5I_DATASET; + if(H5I_iterate(H5I_DATASET, H5F_get_objects_cb, &olist, app_ref) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(2)") + } /* end if */ + } - /* Search through group IDs to count number of groups, and put their + /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), + * or the caller wants to get the list of IDs and the list isn't full, + * search through group IDs to count number of groups, and put their * IDs on the object list */ - if(types & H5F_OBJ_GROUP) { - olist.obj_type = H5I_GROUP; - if(H5I_iterate(H5I_GROUP, H5F_get_objects_cb, &olist, app_ref) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(3)") - } /* end if */ + if(!olist.max_nobjs || (olist.max_nobjs && olist.list_index<olist.max_nobjs)) { + if(types & H5F_OBJ_GROUP) { + olist.obj_type = H5I_GROUP; + if(H5I_iterate(H5I_GROUP, H5F_get_objects_cb, &olist, app_ref) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(3)") + } /* end if */ + } - /* Search through datatype IDs to count number of named datatypes, and put their + /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), + * or the caller wants to get the list of IDs and the list isn't full, + * search through datatype IDs to count number of named datatypes, and put their * IDs on the object list */ - if(types & H5F_OBJ_DATATYPE) { - olist.obj_type = H5I_DATATYPE; - if(H5I_iterate(H5I_DATATYPE, H5F_get_objects_cb, &olist, app_ref) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(4)") - } /* end if */ + if(!olist.max_nobjs || (olist.max_nobjs && olist.list_index<olist.max_nobjs)) { + if(types & H5F_OBJ_DATATYPE) { + olist.obj_type = H5I_DATATYPE; + if(H5I_iterate(H5I_DATATYPE, H5F_get_objects_cb, &olist, app_ref) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(4)") + } /* end if */ + } - /* Search through attribute IDs to count number of attributes, and put their + /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), + * or the caller wants to get the list of IDs and the list isn't full, + * search through attribute IDs to count number of attributes, and put their * IDs on the object list */ - if(types & H5F_OBJ_ATTR) { - olist.obj_type = H5I_ATTR; - if(H5I_iterate(H5I_ATTR, H5F_get_objects_cb, &olist, app_ref) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(5)") - } /* end if */ - + if(!olist.max_nobjs || (olist.max_nobjs && olist.list_index<olist.max_nobjs)) { + if(types & H5F_OBJ_ATTR) { + olist.obj_type = H5I_ATTR; + if(H5I_iterate(H5I_ATTR, H5F_get_objects_cb, &olist, app_ref) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(5)") + } /* end if */ + } + /* Set the number of objects currently open */ *obj_id_count_ptr = obj_id_count; @@ -458,35 +474,21 @@ int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) { H5F_olist_t *olist = (H5F_olist_t *)key; /* Alias for search info */ - int ret_value = FALSE; /* Return value */ + int ret_value = H5_ITER_CONT; /* Return value */ + hbool_t add_obj = FALSE; FUNC_ENTER_NOAPI_NOINIT HDassert(obj_ptr); HDassert(olist); - /* Check if we've filled up the array. Return TRUE only if - * we have filled up the array. Otherwise return FALSE(RET_VALUE is - * preset to FALSE) because H5I_iterate needs the return value of - * FALSE to continue the iteration. */ - if(olist->max_index>0 && olist->list_index>=olist->max_index) - HGOTO_DONE(TRUE) /* Indicate that the iterator should stop */ - /* Count file IDs */ if(olist->obj_type == H5I_FILE) { if((olist->file_info.local && (!olist->file_info.ptr.file || (olist->file_info.ptr.file && (H5F_t*)obj_ptr == olist->file_info.ptr.file) )) || (!olist->file_info.local && ( !olist->file_info.ptr.shared || (olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.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; - olist->list_index++; - } - - /* Increment the number of open objects */ - if(olist->obj_id_count) - (*olist->obj_id_count)++; + add_obj = TRUE; } } /* end if */ else { /* either count opened object IDs or put the IDs on the list */ @@ -523,6 +525,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_DATASPACE: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -530,7 +533,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_ERROR_STACK: case H5I_NTYPES: default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "unknown data object") } /* end switch */ if((olist->file_info.local && @@ -541,18 +544,29 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) ((!olist->file_info.ptr.shared && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || (!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) || (oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.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; - olist->list_index++; - } /* end if */ - - /* Increment the number of open objects */ - if(olist->obj_id_count) - (*olist->obj_id_count)++; + add_obj = TRUE; } /* end if */ } /* end else */ + if(TRUE==add_obj) { + /* 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; + olist->list_index++; + } /* end if */ + + /* Increment the number of open objects */ + if(olist->obj_id_count) + (*olist->obj_id_count)++; + + /* Check if we've filled up the array. Return H5_ITER_STOP only if + * we have filled up the array. Otherwise return H5_ITER_CONT(RET_VALUE is + * preset to H5_ITER_CONT) because H5I_iterate needs the return value of + * H5_ITER_CONT to continue the iteration. */ + if(olist->max_nobjs>0 && olist->list_index>=olist->max_nobjs) + HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ + } + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_objects_cb() */ @@ -605,6 +619,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_is_hdf5() */ + /*------------------------------------------------------------------------- * Function: H5F_new * @@ -628,7 +643,7 @@ done: *------------------------------------------------------------------------- */ static H5F_t * -H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) +H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { H5F_t *f = NULL, *ret_value; @@ -651,6 +666,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") + f->shared->flags = flags; f->shared->sohm_addr = HADDR_UNDEF; f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION; for(u = 0; u < NELMTS(f->shared->fs_addr); u++) @@ -763,8 +779,17 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) done: if(!ret_value && f) { - if(!shared) + if(!shared) { + /* Attempt to clean up some of the shared file structures */ + if(f->shared->efc) + if(H5F_efc_destroy(f->shared->efc) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "can't destroy external file cache") + if(f->shared->fcpl_id > 0) + if(H5I_dec_ref(f->shared->fcpl_id) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") + f->shared = H5FL_FREE(H5F_file_t, f->shared); + } /* end if */ f = H5FL_FREE(H5F_t, f); } /* end if */ @@ -1062,7 +1087,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only") /* Allocate new "high-level" file struct */ - if((file = H5F_new(shared, fcpl_id, fapl_id, NULL)) == NULL) + if((file = H5F_new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") } /* end if */ else { @@ -1083,25 +1108,18 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, } /* end if */ } /* end if */ - if(NULL == (file = H5F_new(NULL, fcpl_id, fapl_id, lf))) + if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") - file->shared->flags = flags; } /* end else */ + /* Retain the name the file was opened with */ + file->open_name = H5MM_xstrdup(name); + /* Short cuts */ shared = file->shared; lf = shared->lf; /* - * The intent at the top level file struct are not necessarily the same as - * the flags at the bottom. The top level describes how the file can be - * accessed through the HDF5 library. The bottom level describes how the - * file can be accessed through the C library. - */ - file->intent = flags; - file->open_name = H5MM_xstrdup(name); - - /* * Read or write the file superblock, depending on whether the file is * empty or not. */ @@ -1491,12 +1509,11 @@ H5F_reopen(H5F_t *f) FUNC_ENTER_NOAPI_NOINIT /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if(NULL == (ret_value = H5F_new(f->shared, H5P_FILE_CREATE_DEFAULT, - H5P_FILE_ACCESS_DEFAULT, NULL))) + /* Get a new "top level" file struct, sharing the same "low level" file struct */ + if(NULL == (ret_value = H5F_new(f->shared, 0, H5P_FILE_CREATE_DEFAULT, + H5P_FILE_ACCESS_DEFAULT, NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to reopen file") - /* Keep old file's read/write intent in new file */ - ret_value->intent = f->intent; /* Duplicate old file's names */ ret_value->open_name = H5MM_xstrdup(f->open_name); ret_value->actual_name = H5MM_xstrdup(f->actual_name); diff --git a/src/H5Fio.c b/src/H5Fio.c index 83c86ea..d494488 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -145,7 +145,7 @@ HDfprintf(stderr, "%s: write to addr = %a, size = %Zu\n", FUNC, addr, size); HDassert(f); HDassert(f->shared); - HDassert(f->intent & H5F_ACC_RDWR); + HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); HDassert(buf); HDassert(H5F_addr_defined(addr)); diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index dff9e88..7b62d01 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -264,7 +264,6 @@ struct H5F_file_t { * to shared H5F_file_t structs. */ struct H5F_t { - unsigned intent; /* The flags passed to H5F_open()*/ char *open_name; /* Name used to open file */ char *actual_name; /* Actual name of the file, after resolving symlinks, etc. */ char *extpath; /* Path for searching target external link file */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 1bf3d0d..68e1c4d 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -292,7 +292,7 @@ typedef struct { /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5F_PACKAGE -#define H5F_INTENT(F) ((F)->intent) +#define H5F_INTENT(F) ((F)->shared->flags) #define H5F_OPEN_NAME(F) ((F)->open_name) #define H5F_ACTUAL_NAME(F) ((F)->actual_name) #define H5F_EXTPATH(F) ((F)->extpath) diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 326b8f8..2e15191 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -98,7 +98,7 @@ H5F_get_intent(const H5F_t *f) HDassert(f); - FUNC_LEAVE_NOAPI(f->intent) + FUNC_LEAVE_NOAPI(f->shared->flags) } /* end H5F_get_intent() */ diff --git a/src/H5Ocache.c b/src/H5Ocache.c index f09f693..847bf71 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -1442,7 +1442,7 @@ H5O_chunk_proxy_dest(H5O_chunk_proxy_t *chk_proxy) HDassert(chk_proxy); /* Decrement reference count of object header */ - if(H5O_dec_rc(chk_proxy->oh) < 0) + if(chk_proxy->oh && H5O_dec_rc(chk_proxy->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count on object header") /* Release the chunk proxy object */ diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 905c4e9..9ca8436 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -526,7 +526,7 @@ H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg, HDfprintf (stream, "{"); for(u = 0; u < sdim->rank; u++) { if(H5S_UNLIMITED==sdim->max[u]) - HDfprintf (stream, "%sINF", u?", ":""); + HDfprintf (stream, "%sUNLIM", u?", ":""); else HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]); } /* end for */ diff --git a/src/H5detect.c b/src/H5detect.c index be661ea..0f8d051 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -60,9 +60,9 @@ static const char *FileHeader = "\n\ #define MAXDETECT 64 -/* The ALIGNMENT test code may generate the SIGBUS or SIGSEGV signals. We use - * setjmp/longjmp in the signal handlers for recovery. But setjmp/longjmp do - * not necessary restore the signal blocking status while sigsetjmp/siglongjmp +/* The ALIGNMENT test code may generate the SIGBUS, SIGSEGV, or SIGILL signals. + * We use setjmp/longjmp in the signal handlers for recovery. But setjmp/longjmp + * do not necessary restore the signal blocking status while sigsetjmp/siglongjmp * do. If sigsetjmp/siglongjmp are not supported, need to use sigprocmask to * unblock the signal before doing longjmp. */ @@ -124,7 +124,7 @@ static int bit_cmp(int, int *, volatile void *, volatile void *, static void fix_order(int, int, int *, const char **); static int imp_bit(int, int *, volatile void *, volatile void *, const unsigned char *); -static unsigned long find_bias(int, int, int *, void *); +static unsigned long find_bias(int, int, int *, volatile void *); static void precision (detected_t*); static void print_header(void); static void detect_C89_integers(void); @@ -139,7 +139,8 @@ static void detect_alignments(void); static size_t align_g[] = {1, 2, 4, 8, 16}; static int align_status_g = 0; /* ALIGNMENT Signal Status */ static int sigbus_handler_called_g = 0; /* how many times called */ -static int sigsegv_handler_called_g = 0; /* how many times called */ +static int sigsegv_handler_called_g = 0;/* how many times called */ +static int sigill_handler_called_g = 0; /* how many times called */ static int signal_handler_tested_g = 0; /* how many times tested */ #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) static int verify_signal_handlers(int signum, void (*handler)(int)); @@ -425,6 +426,7 @@ precision (detected_t *d) volatile size_t _ano = 0; \ void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \ void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler);\ + void (*_handler3)(int) = HDsignal(SIGILL, sigill_handler); \ \ _buf = (char*)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ if(H5SETJMP(jbuf_g)) _ano++; \ @@ -454,6 +456,7 @@ precision (detected_t *d) HDfree(_buf); \ HDsignal(SIGBUS, _handler); /*restore original handler*/ \ HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \ + HDsignal(SIGILL, _handler3); /*restore original handler*/ \ } #else #define ALIGNMENT(TYPE,INFO) { \ @@ -539,6 +542,42 @@ sigbus_handler(int UNUSED signo) #endif +#if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) +/*------------------------------------------------------------------------- + * Function: sigill_handler + * + * Purpose: Handler for SIGILL. We use signal() instead of sigaction() + * because it's more portable to non-Posix systems. Although + * it's not nearly as nice to work with, it does the job for + * this simple stuff. + * + * Return: Returns via H5LONGJMP to jbuf_g. + * + * Programmer: Raymond Lu + * 28 October 2013 + * + *------------------------------------------------------------------------- + */ +static void +sigill_handler(int UNUSED signo) +{ +#if !defined(H5HAVE_SIGJMP) && defined(H5_HAVE_SIGPROCMASK) + /* Use sigprocmask to unblock the signal if sigsetjmp/siglongjmp are not */ + /* supported. */ + sigset_t set; + + HDsigemptyset(&set); + HDsigaddset(&set, SIGILL); + HDsigprocmask(SIG_UNBLOCK, &set, NULL); +#endif + + sigill_handler_called_g++; + HDsignal(SIGILL, sigill_handler); + H5LONGJMP(jbuf_g, SIGILL); +} +#endif + + /*------------------------------------------------------------------------- * Function: print_results * @@ -1135,7 +1174,7 @@ imp_bit(int n, int *perm, volatile void *_a, volatile void *_b, *------------------------------------------------------------------------- */ static unsigned long -find_bias(int epos, int esize, int *perm, void *_a) +find_bias(int epos, int esize, int *perm, volatile void *_a) { unsigned char *a = (unsigned char *) _a; unsigned char mask; diff --git a/src/H5public.h b/src/H5public.h index 8e7a3cc..0138d01 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -75,10 +75,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 167 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 170 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.167" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.170" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/H5win32defs.h b/src/H5win32defs.h index d452925..185e9b4 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -74,7 +74,7 @@ struct timezone { extern "C" { #endif /* __cplusplus */ H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); - H5_DLL char* Wgetlogin(); + H5_DLL char* Wgetlogin(void); H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); #ifdef __cplusplus diff --git a/src/Makefile.in b/src/Makefile.in index b7fcc19..cb96d97 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -520,7 +520,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 157 +LT_VERS_REVISION = 160 LT_VERS_AGE = 0 # Our main target, the HDF5 library |