summaryrefslogtreecommitdiffstats
path: root/Python/thread_cthread.h
Commit message (Expand)AuthorAgeFilesLines
* Fix syntax error. Submitted by Bill Bumgarner. Apparently this isGuido van Rossum2000-11-131-1/+1
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
* Mass ANSIfication of function definitions. Doesn't cover all 'extern'Thomas Wouters2000-07-221-17/+34
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
* Trent Mick <trentm@activestate.com>:Fred Drake2000-06-301-10/+10
* Thanks to Chris Herborth, the thread primitives now have proper Py*Guido van Rossum1998-12-211-42/+42
* New permission notice, includes CNRI.Guido van Rossum1996-10-251-13/+20
* Sjoerd's thread changes (including down_sema typo fix).Guido van Rossum1996-10-081-2/+3
* Changes needed by NeXT (the only platform that seems to use this).Guido van Rossum1996-07-301-3/+38
* Added 1995 to copyright message.Guido van Rossum1995-01-041-2/+2
* ceval.c: dict of local mapping is now a tupleGuido van Rossum1994-05-231-0/+6
* Tim's changes; removed some remaining non-functional ifdefsGuido van Rossum1994-05-111-4/+0
* Split thread.c into a number of system-specific files.Guido van Rossum1994-05-091-0/+158
ASET, H5E_CANTINIT, FAIL, "unlimited data space but finite storage") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unlimited dataspace but finite storage") } /* end if */ else if((max_points * dt_size) < max_points) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data space * type size overflowed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace * type size overflowed") else if((max_points * dt_size) > max_storage) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data space size exceeds external storage size") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "dataspace size exceeds external storage size") /* Compute the total size of dataset */ tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * dt_size; @@ -261,12 +260,11 @@ H5D_efl_read(const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf) #else /* NDEBUG */ to_read = MIN((size_t)(efl->slot[u].size-skip), size); #endif /* NDEBUG */ - if ((n=HDread (fd, buf, to_read))<0) { - HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file") - } else if ((size_t)nbuf) { + htri_t has_vlen_type; /* Whether the datatype has a VL component */ + /* Detect whether the datatype has a VL component */ - fb_info->has_vlen_fill_type = H5T_detect_class(dset_type, H5T_VLEN); + if((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to detect vlen datatypes?") + fb_info->has_vlen_fill_type = (hbool_t)has_vlen_type; /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ if(fb_info->has_vlen_fill_type) { @@ -466,7 +470,8 @@ H5D_fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, } /* end if */ else { /* If fill value is not library default, use it to set the element size */ - fb_info->max_elmt_size = fb_info->file_elmt_size = fb_info->mem_elmt_size = fill->size; + HDassert(fill->size >= 0); + fb_info->max_elmt_size = fb_info->file_elmt_size = fb_info->mem_elmt_size = (size_t)fill->size; /* Compute the number of elements that fit within a buffer to write */ if(total_nelmts > 0) diff --git a/src/H5Dint.c b/src/H5Dint.c index 221d448..37a4701 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -171,8 +171,8 @@ H5D_init_interface(void) if(NULL == (def_dcpl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_CREATE_g))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get default dataset creation property list") - /* Get the default data storage method */ - if(H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout.type) < 0) + /* Get the default data storage layout */ + if(H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Get the default dataset creation properties */ @@ -1063,7 +1063,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Check if the dataset has a non-default DCPL & get important values, if so */ if(new_dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) { - H5D_layout_t *layout; /* Dataset's layout information */ + H5O_layout_t *layout; /* Dataset's layout information */ H5O_pline_t *pline; /* Dataset's I/O pipeline information */ H5O_fill_t *fill; /* Dataset's fill value info */ @@ -1083,10 +1083,10 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, pline = &new_dset->shared->dcpl_cache.pline; if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve pipeline filter") - layout = &new_dset->shared->layout.type; + layout = &new_dset->shared->layout; if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout") - if(pline->nused > 0 && H5D_CHUNKED != *layout) + if(pline->nused > 0 && H5D_CHUNKED != layout->type) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "filters can only be used with chunked layout") fill = &new_dset->shared->dcpl_cache.fill; if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill) < 0) @@ -1097,7 +1097,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "invalid space allocation state") /* Don't allow compact datasets to allocate space later */ - if(*layout == H5D_COMPACT && fill->alloc_time != H5D_ALLOC_TIME_EARLY) + if(layout->type == H5D_COMPACT && fill->alloc_time != H5D_ALLOC_TIME_EARLY) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset must have early space allocation") /* If MPI VFD is used, no filter support yet. */ @@ -1352,8 +1352,14 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) */ if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout.type) < 0) + /* Adjust chunk dimensions to omit datatype size (in last dimension) for creation property */ + if(H5D_CHUNKED == dataset->shared->layout.type) + dataset->shared->layout.u.chunk.ndims--; + if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout") + /* Adjust chunk dimensions back again (*sigh*) */ + if(H5D_CHUNKED == dataset->shared->layout.type) + dataset->shared->layout.u.chunk.ndims++; /* Get the external file list message, which might not exist. Space is * also undefined when space allocate time is H5D_ALLOC_TIME_LATE. */ @@ -1396,25 +1402,9 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) break; case H5D_CHUNKED: - /* - * Chunked storage. The creation plist's dimension is one less than - * the chunk dimension because the chunk includes a dimension for the - * individual bytes of the datatype. - */ - { - unsigned chunk_ndims; /* Dimensionality of chunk */ - - 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, FAIL, "can't set chunk dimensions") - if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, dataset->shared->layout.u.chunk.dim) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk size") - - /* Initialize the chunk cache for the dataset */ - if(H5D_chunk_init(dataset->oloc.file, dapl_id, dxpl_id, dataset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") - } + /* Initialize the chunk cache for the dataset */ + if(H5D_chunk_init(dataset->oloc.file, dapl_id, dxpl_id, dataset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") break; case H5D_COMPACT: @@ -1464,7 +1454,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) /* If "old" fill value size is 0 (undefined), map it to -1 */ if(fill_prop->size == 0) - fill_prop->size = (size_t)-1; + fill_prop->size = (ssize_t)-1; } /* end if */ alloc_time_state = 0; if((dataset->shared->layout.type == H5D_COMPACT && fill_prop->alloc_time == H5D_ALLOC_TIME_EARLY) @@ -1605,7 +1595,7 @@ H5D_close(H5D_t *dataset) * 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, FALSE) < 0 || H5S_close(dataset->shared->space) < 0 || + free_failed = (unsigned)(H5I_dec_ref(dataset->shared->type_id, FALSE) < 0 || H5S_close(dataset->shared->space) < 0 || H5I_dec_ref(dataset->shared->dcpl_id, FALSE) < 0); /* Remove the dataset from the list of opened objects in the file */ diff --git a/src/H5Dio.c b/src/H5Dio.c index b7c1d72..9308c33 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -550,7 +550,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, if(H5T_detect_class(dataset->shared->type, H5T_VLEN)) full_overwrite = FALSE; else - full_overwrite = (hsize_t)file_nelmts == nelmts ? TRUE : FALSE; + full_overwrite = (hbool_t)((hsize_t)file_nelmts == nelmts ? TRUE : FALSE); /* Allocate storage */ if(H5D_alloc_storage(dataset, dxpl_id, H5D_ALLOC_WRITE, full_overwrite) < 0) @@ -780,8 +780,8 @@ H5D_typeinfo_init(const H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hbool_t default_buffer_info; /* Whether the buffer information are the defaults */ /* Detect if we have all default settings for buffers */ - default_buffer_info = (H5D_TEMP_BUF_SIZE == dxpl_cache->max_temp_buf) - && (NULL == dxpl_cache->tconv_buf) && (NULL == dxpl_cache->bkgr_buf); + default_buffer_info = (hbool_t)((H5D_TEMP_BUF_SIZE == dxpl_cache->max_temp_buf) + && (NULL == dxpl_cache->tconv_buf) && (NULL == dxpl_cache->bkgr_buf)); /* Check if we are using the default buffer info */ if(default_buffer_info) diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 96a35cc..7f044e5 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -43,8 +43,6 @@ /* ======== Dataset creation property names ======== */ #define H5D_CRT_LAYOUT_NAME "layout" /* Storage layout */ -#define H5D_CRT_CHUNK_DIM_NAME "chunk_ndims" /* Chunk dimensionality */ -#define H5D_CRT_CHUNK_SIZE_NAME "chunk_size" /* Chunk size */ #define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ #define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ #define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index 867303f..bb9f46b 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -160,9 +160,9 @@ H5D_scatter_file(const H5D_io_info_t *_io_info, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_scatter_file() */ @@ -261,9 +261,9 @@ H5D_gather_file(const H5D_io_info_t *_io_info, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_gather_file() */ @@ -346,9 +346,9 @@ H5D_scatter_mem (const void *_tscat_buf, const H5S_t *space, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_scatter_mem() */ @@ -433,9 +433,9 @@ H5D_gather_mem(const void *_buf, const H5S_t *space, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* H5D_gather_mem() */ @@ -826,9 +826,9 @@ H5D_compound_opt_read(size_t nelmts, const H5S_t *space, done: /* Release resources, if allocated */ if(len && len != _len) - H5FL_SEQ_FREE(size_t, len); + len = H5FL_SEQ_FREE(size_t, len); if(off && off != _off) - H5FL_SEQ_FREE(hsize_t, off); + off = H5FL_SEQ_FREE(hsize_t, off); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_compound_opt_read() */ diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 947c81e..6dade5c 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -160,7 +160,7 @@ H5D_select_io(const H5D_io_info_t *io_info, size_t elmt_size, } /* end else */ /* Decrement number of elements left to process */ - HDassert((tmp_file_len % elmt_size) == 0); + HDassert(((size_t)tmp_file_len % elmt_size) == 0); } /* end if */ else { size_t mem_nelem; /* Number of elements used in memory sequences */ @@ -218,8 +218,8 @@ H5D_select_io(const H5D_io_info_t *io_info, size_t elmt_size, } /* end else */ /* Decrement number of elements left to process */ - HDassert((tmp_file_len % elmt_size) == 0); - nelmts -= (tmp_file_len / elmt_size); + HDassert(((size_t)tmp_file_len % elmt_size) == 0); + nelmts -= ((size_t)tmp_file_len / elmt_size); } /* end while */ } /* end else */ @@ -236,13 +236,13 @@ done: /* Release vector arrays, if allocated */ if(file_len && file_len != _file_len) - H5FL_SEQ_FREE(size_t, file_len); + file_len = H5FL_SEQ_FREE(size_t, file_len); if(file_off && file_off != _file_off) - H5FL_SEQ_FREE(hsize_t, file_off); + file_off = H5FL_SEQ_FREE(hsize_t, file_off); if(mem_len && mem_len != _mem_len) - H5FL_SEQ_FREE(size_t, mem_len); + mem_len = H5FL_SEQ_FREE(size_t, mem_len); if(mem_off && mem_off != _mem_off) - H5FL_SEQ_FREE(hsize_t, mem_off); + mem_off = H5FL_SEQ_FREE(hsize_t, mem_off); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_select_io() */ diff --git a/src/H5F.c b/src/H5F.c index 3789fec..50e26d8 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -394,7 +394,7 @@ H5Fget_obj_count(hid_t file_id, unsigned types) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") /* H5F_get_obj_count doesn't fail */ - ret_value = H5F_get_obj_count(f, types, TRUE); + ret_value = (ssize_t)H5F_get_obj_count(f, types, TRUE); done: FUNC_LEAVE_API(ret_value) @@ -468,7 +468,7 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) HDassert(oid_list); /* H5F_get_objects doesn't fail */ - ret_value = H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE); + ret_value = (ssize_t)H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Fmount.c b/src/H5Fmount.c index a428cd6..ff4b1eb 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -339,7 +339,7 @@ H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) for(u = 0; u < parent->shared->mtab.nmounts; u++) { if(parent->shared->mtab.child[u].file->shared == child->shared) { /* Found the correct index */ - child_idx = u; + child_idx = (int)u; break; } /* end if */ } /* end for */ @@ -368,7 +368,7 @@ H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Found the correct index, set the info about the child */ - child_idx = md; + child_idx = (int)md; H5G_loc_free(&mp_loc); mp_loc_setup = FALSE; mp_loc.oloc = mnt_oloc; @@ -397,8 +397,8 @@ H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ - HDmemmove(parent->shared->mtab.child + child_idx, parent->shared->mtab.child + child_idx + 1, - (parent->shared->mtab.nmounts - child_idx - 1) * sizeof(parent->shared->mtab.child[0])); + HDmemmove(parent->shared->mtab.child + (unsigned)child_idx, (parent->shared->mtab.child + (unsigned)child_idx) + 1, + ((parent->shared->mtab.nmounts - (unsigned)child_idx) - 1) * sizeof(parent->shared->mtab.child[0])); parent->shared->mtab.nmounts -= 1; parent->nmounts -= 1; diff --git a/src/H5Gname.c b/src/H5Gname.c index 0634aef..205f2a2 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1147,10 +1147,8 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * /* Check for finding the object */ if(found_obj) { - size_t full_path_len = HDstrlen(udata.path) + 1; /* Length of path + 1 (for "/") */ - /* Set the length of the full path */ - ret_value = full_path_len; + ret_value = (ssize_t)(HDstrlen(udata.path) + 1); /* Length of path + 1 (for "/") */ /* If there's a buffer provided, copy into it, up to the limit of its size */ if(name) { diff --git a/src/H5Gtest.c b/src/H5Gtest.c index d7f102f..1f09048 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -529,14 +529,14 @@ H5G_user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigne /* Retrieve a copy of the user path and put it into the buffer */ if(obj_path->user_path_r) { - size_t len = H5RS_len(obj_path->user_path_r); + ssize_t len = H5RS_len(obj_path->user_path_r); /* Set the user path, if given */ if(user_path) HDstrcpy(user_path, H5RS_get_str(obj_path->user_path_r)); /* Set the length of the path */ - *user_path_len = len; + *user_path_len = (size_t)len; /* Set the user path hidden flag */ *obj_hidden = obj_path->obj_hidden; diff --git a/src/H5L.c b/src/H5L.c index 4ad2f2d..368272b 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -2700,7 +2700,7 @@ H5L_exists_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5L_exists_cb) /* Check if the name in this group resolved to a valid link */ - *udata = (lnk != NULL); + *udata = (hbool_t)(lnk != NULL); /* Indicate that this callback didn't take ownership of the group * * location for the object */ @@ -2725,8 +2725,8 @@ H5L_exists_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, static htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { - hbool_t exists = FALSE; /* Whether the link exists in the group */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t exists = FALSE; /* Whether the link exists in the group */ + htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5L_exists) @@ -2735,7 +2735,7 @@ H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "path doesn't exist") /* Set return value */ - ret_value = exists; + ret_value = (htri_t)exists; done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Ofill.c b/src/H5Ofill.c index 43ec1a4..02706ec 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -378,7 +378,7 @@ H5O_fill_new_encode(H5F_t UNUSED *f, uint8_t *p, const void *_fill) *p++ = fill->fill_time; /* Whether fill value is defined */ - *p++ = fill->fill_defined; + *p++ = (uint8_t)fill->fill_defined; /* Only write out the size and fill value if it is defined */ if(fill->fill_defined) { @@ -624,14 +624,14 @@ H5O_fill_new_size(const H5F_t UNUSED *f, const void *_fill) 1; /* Fill value defined */ if(fill->fill_defined) ret_value += 4 + /* Fill value size */ - (fill->size > 0 ? fill->size : 0); /* Size of fill value */ + (fill->size > 0 ? (size_t)fill->size : 0); /* Size of fill value */ } /* end if */ else { ret_value = 1 + /* Version number */ 1; /* Status flags */ if(fill->size > 0) ret_value += 4 + /* Fill value size */ - fill->size; /* Size of fill value */ + (size_t)fill->size; /* Size of fill value */ } /* end else */ FUNC_LEAVE_NOAPI(ret_value) @@ -662,7 +662,7 @@ H5O_fill_old_size(const H5F_t UNUSED *f, const void *_fill) HDassert(fill); - FUNC_LEAVE_NOAPI(4 + fill->size) + FUNC_LEAVE_NOAPI(4 + (size_t)fill->size) } /* end H5O_fill_old_size() */ diff --git a/src/H5Olayout.c b/src/H5Olayout.c index f2b6b30..59cd7db 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -72,12 +72,6 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{ H5O_layout_debug /*debug the message */ }}; -/* For forward and backward compatibility. Version is 1 when space is - * allocated; 2 when space is delayed for allocation; 3 is default now and - * is revised to just store information needed for each storage type. */ -#define H5O_LAYOUT_VERSION_1 1 -#define H5O_LAYOUT_VERSION_2 2 -#define H5O_LAYOUT_VERSION_3 3 /* Declare a free list to manage the H5O_layout_t struct */ H5FL_DEFINE(H5O_layout_t); @@ -334,7 +328,7 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi case H5D_CHUNKED: /* Number of dimensions */ HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); - *p++ = mesg->u.chunk.ndims; + *p++ = (uint8_t)mesg->u.chunk.ndims; /* B-tree address */ H5F_addr_encode(f, &p, mesg->u.chunk.addr); @@ -386,7 +380,7 @@ H5O_layout_copy(const void *_mesg, void *_dest) *dest = *mesg; /* Deep copy the buffer for compact datasets also */ - if(mesg->type == H5D_COMPACT) { + if(mesg->type == H5D_COMPACT && mesg->u.compact.size > 0) { /* Allocate memory for the raw data */ if(NULL == (dest->u.compact.buf = H5MM_malloc(dest->u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index f65b15d..39dfb5c 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -322,10 +322,24 @@ typedef struct H5O_efl_t { /* * Data Layout Message. - * (Data structure in memory) + * (Data structure in file) */ #define H5O_LAYOUT_NDIMS (H5S_MAX_RANK+1) +/* Initial version of the layout information. Used when space is allocated */ +#define H5O_LAYOUT_VERSION_1 1 + +/* This version added support for delaying allocation */ +#define H5O_LAYOUT_VERSION_2 2 + +/* This version is revised to store just the information needed for each + * storage type, and to straighten out problems with contiguous layout's + * sizes (was encoding them as 4-byte values when they were really n-byte + * values (where n usually is 8)). + */ +#define H5O_LAYOUT_VERSION_3 3 + + /* Forward declaration of structs used below */ struct H5D_layout_ops_t; /* Defined in H5Dpkg.h */ struct H5D_chunk_ops_t; /* Defined in H5Dpkg.h */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index c523544..3f6704b 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -47,17 +47,16 @@ /* Local Macros */ /****************/ +/* Define default layout information */ +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, { .compact = {(hbool_t)FALSE, (size_t)0, NULL}}} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, { .contig = {HADDR_UNDEF, (hsize_t)0}}} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, { .chunk = {HADDR_UNDEF, (unsigned)1, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, (uint32_t)0, NULL, NULL}}} + /* ======== Dataset creation properties ======== */ /* Definitions for storage layout property */ -#define H5D_CRT_LAYOUT_SIZE sizeof(H5D_layout_t) -#define H5D_CRT_LAYOUT_DEF H5D_CONTIGUOUS -/* Definitions for chunk dimensionality property */ -#define H5D_CRT_CHUNK_DIM_SIZE sizeof(unsigned) -#define H5D_CRT_CHUNK_DIM_DEF 1 -/* Definitions for chunk size */ -#define H5D_CRT_CHUNK_SIZE_SIZE sizeof(uint32_t[H5O_LAYOUT_NDIMS]) -#define H5D_CRT_CHUNK_SIZE_DEF {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,\ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} +#define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) +#define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG +#define H5D_CRT_LAYOUT_CMP H5P_dcrt_layout_cmp /* Definitions for fill value. size=0 means fill value will be 0 as * library default; size=-1 means fill value is undefined. */ #define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) @@ -91,7 +90,7 @@ /********************/ /* General routines */ -static herr_t H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout); +static herr_t H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); /* Property class callbacks */ static herr_t H5P_dcrt_reg_prop(H5P_genclass_t *pclass); @@ -99,6 +98,7 @@ static herr_t H5P_dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_dat static herr_t H5P_dcrt_close(hid_t dxpl_id, void *close_data); /* Property callbacks */ +static int H5P_dcrt_layout_cmp(const void *value1, const void *value2, size_t size); static int H5P_dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); static int H5P_dcrt_data_pipeline_cmp(const void *value1, const void *value2, size_t size); @@ -130,6 +130,11 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); +/* Defaults for each type of layout */ +static const H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; +static const H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; +static const H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; + /*------------------------------------------------------------------------- @@ -146,9 +151,7 @@ H5FL_BLK_EXTERN(type_conv); static herr_t H5P_dcrt_reg_prop(H5P_genclass_t *pclass) { - H5D_layout_t layout = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ - unsigned chunk_ndims = H5D_CRT_CHUNK_DIM_DEF; /* Default rank for chunks */ - uint32_t chunk_size[H5O_LAYOUT_NDIMS] = H5D_CRT_CHUNK_SIZE_DEF; /* Default chunk size */ + H5O_layout_t layout = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ H5O_fill_t fill = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ unsigned alloc_time_state = H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ H5O_efl_t efl = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ @@ -158,15 +161,7 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) FUNC_ENTER_NOAPI_NOINIT(H5P_dcrt_reg_prop) /* Register the storage layout property */ - if(H5P_register(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the chunking dimensionality property */ - if(H5P_register(pclass, H5D_CRT_CHUNK_DIM_NAME, H5D_CRT_CHUNK_DIM_SIZE, &chunk_ndims, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the chunking size property */ - if(H5P_register(pclass, H5D_CRT_CHUNK_SIZE_NAME, H5D_CRT_CHUNK_SIZE_SIZE, chunk_size, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if(H5P_register(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, H5D_CRT_LAYOUT_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value property */ @@ -215,6 +210,7 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) H5O_fill_t src_fill, dst_fill; /* Source & destination fill values */ H5O_efl_t src_efl, dst_efl; /* Source & destination external file lists */ H5O_pline_t src_pline, dst_pline; /* Source & destination I/O pipelines */ + H5O_layout_t src_layout, dst_layout; /* Source & destination layout */ H5P_genplist_t *src_plist; /* Pointer to source property list */ H5P_genplist_t *dst_plist; /* Pointer to destination property list */ herr_t ret_value = SUCCEED; /* Return value */ @@ -227,8 +223,11 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_plist_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") - /* Get the fill value, external file list, and data pipeline properties - * from the old property list */ + /* Get the layout, fill value, external file list, and data pipeline + * properties from the old property list + */ + if(H5P_get(src_plist, H5D_CRT_LAYOUT_NAME, &src_layout) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") if(H5P_get(src_plist, H5D_CRT_FILL_VALUE_NAME, &src_fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") if(H5P_get(src_plist, H5D_CRT_EXT_FILE_LIST_NAME, &src_efl) < 0) @@ -236,32 +235,61 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) if(H5P_get(src_plist, H5D_CRT_DATA_PIPELINE_NAME, &src_pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - /* Make copies of fill value, external file list, and data pipeline */ + /* Make copy of layout */ + if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, &src_layout, &dst_layout)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy layout") + + /* Reset layout values set when dataset is created */ + dst_layout.ops = NULL; + switch(dst_layout.type) { + case H5D_COMPACT: + dst_layout.u.compact.buf = H5MM_xfree(dst_layout.u.compact.buf); + HDmemset(&dst_layout.u.compact, 0, sizeof(dst_layout.u.compact)); + break; + + case H5D_CONTIGUOUS: + dst_layout.u.contig.addr = HADDR_UNDEF; + dst_layout.u.contig.size = 0; + break; + + case H5D_CHUNKED: + dst_layout.u.chunk.addr = HADDR_UNDEF; + dst_layout.u.chunk.size = 0; + dst_layout.u.chunk.btree_shared = NULL; + dst_layout.u.chunk.ops = NULL; + break; + + default: + HDassert(0 && "Unknown layout type!"); + } /* end switch */ + + /* Make copy of fill value */ if(NULL == H5O_msg_copy(H5O_FILL_ID, &src_fill, &dst_fill)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy fill value") + + /* Make copy of external file list */ HDmemset(&dst_efl, 0, sizeof(H5O_efl_t)); if(NULL == H5O_msg_copy(H5O_EFL_ID, &src_efl, &dst_efl)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy external file list") - /* reset efl name_offset and heap_addr, these are the values when the dataset is created */ - if (dst_efl.slot) - { + /* Reset efl name_offset and heap_addr, these are the values when the dataset is created */ + if(dst_efl.slot) { unsigned int i; dst_efl.heap_addr = HADDR_UNDEF; - for ( i = 0; i < dst_efl.nused; i++) - { + for(i = 0; i < dst_efl.nused; i++) dst_efl.slot[i].name_offset = 0; - } - - } - + } /* end if */ + /* Make copy of data pipeline */ if(NULL == H5O_msg_copy(H5O_PLINE_ID, &src_pline, &dst_pline)) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy data pipeline") - /* Set the fill value, external file list, and data pipeline property - * for the destination property list */ + /* Set the layout, fill value, external file list, and data pipeline + * properties for the destination property list + */ + if(H5P_set(dst_plist, H5D_CRT_LAYOUT_NAME, &dst_layout) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") if(H5P_set(dst_plist, H5D_CRT_FILL_VALUE_NAME, &dst_fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") if(H5P_set(dst_plist, H5D_CRT_EXT_FILE_LIST_NAME, &dst_efl) < 0) @@ -329,6 +357,76 @@ done: /*------------------------------------------------------------------------- + * Function: H5P_dcrt_layout_cmp + * + * Purpose: Callback routine which is called whenever the layout + * property in the dataset creation property list is + * compared. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. + * + * Programmer: Quincey Koziol + * Tuesday, December 23, 2008 + * + *------------------------------------------------------------------------- + */ +static int +H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED size) +{ + const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ + *layout2 = (const H5O_layout_t *)_layout2; + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_dcrt_layout_cmp) + + /* Sanity check */ + HDassert(layout1); + HDassert(layout1); + HDassert(size == sizeof(H5O_layout_t)); + + /* Check for different layout type */ + if(layout1->type < layout2->type) HGOTO_DONE(-1) + if(layout1->type > layout2->type) HGOTO_DONE(1) + + /* Check for different layout version */ + if(layout1->version < layout2->version) HGOTO_DONE(-1) + if(layout1->version > layout2->version) HGOTO_DONE(1) + + /* Compare non-dataset-specific fields in layout info */ + switch(layout1->type) { + case H5D_COMPACT: + case H5D_CONTIGUOUS: + break; + + case H5D_CHUNKED: + { + unsigned u; /* Local index variable */ + + /* Check the number of dimensions */ + if(layout1->u.chunk.ndims < layout2->u.chunk.ndims) HGOTO_DONE(-1) + if(layout1->u.chunk.ndims > layout2->u.chunk.ndims) HGOTO_DONE(1) + + /* Compare the chunk dims */ + for(u = 0; u < layout1->u.chunk.ndims - 1; u++) { + if(layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) HGOTO_DONE(-1) + if(layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) HGOTO_DONE(1) + } /* end for */ + } /* end case */ + break; + + default: + HDassert(0 && "Unknown layout type!"); + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_dcrt_layout_cmp() */ + + +/*------------------------------------------------------------------------- * Function: H5P_fill_value_cmp * * Purpose: Callback routine which is called whenever the fill value @@ -571,7 +669,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout) +H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) { unsigned alloc_time_state; /* State of allocation time property */ herr_t ret_value = SUCCEED; /* return value */ @@ -591,7 +689,7 @@ H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set the default based on layout */ - switch(layout) { + switch(layout->type) { case H5D_COMPACT: fill.alloc_time = H5D_ALLOC_TIME_EARLY; break; @@ -605,16 +703,16 @@ H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout) break; default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layou t type") + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ /* Set updated fill value info */ if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocat ion time") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time") } /* end if */ /* Set layout value */ - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: @@ -642,29 +740,48 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pset_layout(hid_t plist_id, H5D_layout_t layout) +H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + const H5O_layout_t *layout; /* Pointer to default layout information for type specified */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_layout, FAIL) - H5TRACE2("e", "iDl", plist_id, layout); + H5TRACE2("e", "iDl", plist_id, layout_type); /* Check arguments */ - if (layout < 0 || layout >= H5D_NLAYOUTS) + if(layout_type < 0 || layout_type >= H5D_NLAYOUTS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "raw data layout method is not valid") /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + /* Get pointer to correct default layout */ + switch(layout_type) { + case H5D_COMPACT: + layout = &H5D_def_layout_compact_g; + break; + + case H5D_CONTIGUOUS: + layout = &H5D_def_layout_contig_g; + break; + + case H5D_CHUNKED: + layout = &H5D_def_layout_chunk_g; + break; + + default: + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") + } /* end switch */ + /* Set value */ - if(H5P_set_layout (plist, layout) < 0) + if(H5P_set_layout(plist, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_layout() */ /*------------------------------------------------------------------------- @@ -692,7 +809,8 @@ H5D_layout_t H5Pget_layout(hid_t plist_id) { H5P_genplist_t *plist; /* Property list pointer */ - H5D_layout_t ret_value = H5D_LAYOUT_ERROR; + H5O_layout_t layout; /* Layout property */ + H5D_layout_t ret_value; /* Return value */ FUNC_ENTER_API(H5Pget_layout, H5D_LAYOUT_ERROR) H5TRACE1("Dl", "i", plist_id); @@ -701,13 +819,16 @@ H5Pget_layout(hid_t plist_id) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5D_LAYOUT_ERROR, "can't find object for ID") - /* Get value */ - if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &ret_value) < 0) + /* Get layout property */ + if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5D_LAYOUT_ERROR, "can't get layout") + /* Set return value */ + ret_value = layout.type; + done: FUNC_LEAVE_API(ret_value) -} +} /* ed H5Pget_layout() */ /*------------------------------------------------------------------------- @@ -715,7 +836,7 @@ done: * * Purpose: Sets the number of dimensions and the size of each chunk to * the values specified. The dimensionality of the chunk should - * match the dimensionality of the data space. + * match the dimensionality of the dataspace. * * As a side effect, the layout method is changed to * H5D_CHUNKED. @@ -738,7 +859,7 @@ herr_t H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) { H5P_genplist_t *plist; /* Property list pointer */ - uint32_t real_dims[H5O_LAYOUT_NDIMS]; /* Full-sized array to hold chunk dims */ + H5O_layout_t chunk_layout; /* Layout information for setting chunk info */ uint64_t chunk_nelmts; /* Number of elements in chunk */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -754,8 +875,9 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) if(!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no chunk dimensions specified") - /* Verify & initialize internal chunk dims */ - HDmemset(real_dims, 0, sizeof(real_dims)); + /* Verify & initialize property's chunk dims */ + HDmemcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g)); + HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim)); chunk_nelmts = 1; for(u = 0; u < (unsigned)ndims; u++) { if(dim[u] == 0) @@ -765,7 +887,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) chunk_nelmts *= dim[u]; if(chunk_nelmts > (uint64_t)0xffffffff) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of elements in chunk must be < 4GB") - real_dims[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */ + chunk_layout.u.chunk.dim[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */ } /* end for */ /* Get the plist structure */ @@ -773,12 +895,9 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set chunk information in property list */ - if(H5P_set_layout(plist, H5D_CHUNKED) < 0) + chunk_layout.u.chunk.ndims = (unsigned)ndims; + if(H5P_set_layout(plist, &chunk_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") - if(H5P_set(plist, H5D_CRT_CHUNK_DIM_NAME, &ndims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set chunk dimensionanlity") - if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, real_dims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set chunk size") done: FUNC_LEAVE_API(ret_value) @@ -812,10 +931,9 @@ done: int H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) { - int ndims; - H5D_layout_t layout; H5P_genplist_t *plist; /* Property list pointer */ - int ret_value; + H5O_layout_t layout; /* Layout information */ + int ret_value; /* Return value */ FUNC_ENTER_API(H5Pget_chunk, FAIL) H5TRACE3("Is", "iIsx", plist_id, max_ndims, dim); @@ -824,28 +942,22 @@ H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + /* Retrieve the layout property */ if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") - if(H5D_CHUNKED != layout) + if(H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") - if(H5P_get(plist, H5D_CRT_CHUNK_DIM_NAME, &ndims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get chunk dimensionality") - if(dim) { - int i; - uint32_t chunk_size[H5O_LAYOUT_NDIMS]; - - if(H5P_get(plist, H5D_CRT_CHUNK_SIZE_NAME, chunk_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get chunk size") + unsigned u; /* Local index variable */ /* Get the dimension sizes */ - for(i = 0; i < ndims && i < max_ndims; i++) - dim[i] = chunk_size[i]; + for(u = 0; u < layout.u.chunk.ndims && u < (unsigned)max_ndims; u++) + dim[u] = layout.u.chunk.dim[u]; } /* end if */ /* Set the return value */ - ret_value = ndims; + ret_value = (int)layout.u.chunk.ndims; done: FUNC_LEAVE_API(ret_value) @@ -865,7 +977,7 @@ done: * should be defined in order. The total size of the dataset is * the sum of the SIZE arguments for all the external files. If * the total size is larger than the size of a dataset then the - * dataset can be extended (provided the data space also allows + * dataset can be extended (provided the dataspace also allows * the extending). * * Return: Non-negative on success/Negative on failure @@ -1623,24 +1735,24 @@ done: htri_t H5Pall_filters_avail(hid_t plist_id) { - H5O_pline_t pline; /* Filter pipeline */ H5P_genplist_t *plist; /* Property list pointer */ - hbool_t ret_value = TRUE; /* return value */ + H5O_pline_t pline; /* Filter pipeline */ + htri_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Pall_filters_avail, UFAIL) + FUNC_ENTER_API(H5Pall_filters_avail, FAIL) H5TRACE1("t", "i", plist_id); /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, UFAIL, "can't find object for ID") + if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get pipeline info */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get pipeline") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - /* Set return value */ - if(UFAIL == (ret_value = H5Z_all_filters_avail(&pline))) - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, UFAIL, "can't check pipeline information") + /* Check if all filters are available */ + if((ret_value = H5Z_all_filters_avail(&pline)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't check pipeline information") done: FUNC_LEAVE_API(ret_value) @@ -1970,8 +2082,10 @@ H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_fac if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + if(scale_factor < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "scale factor must be > 0") if(scale_type!=H5Z_SO_FLOAT_DSCALE && scale_type!=H5Z_SO_FLOAT_ESCALE && scale_type!=H5Z_SO_INT) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid scale type") /* Get the plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) @@ -1986,7 +2100,7 @@ H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_fac * if scale_factor = 0, then filter calculates minimum number of bits */ cd_values[0] = scale_type; - cd_values[1] = scale_factor; + cd_values[1] = (unsigned)scale_factor; /* Add the scaleoffset filter */ if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) @@ -2099,7 +2213,7 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) /* Set the fill value */ if(NULL == (fill.type = H5T_copy(type, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy datatype") - fill.size = H5T_get_size(type); + fill.size = (ssize_t)H5T_get_size(type); if(NULL == (fill.buf = H5MM_malloc((size_t)fill.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value") HDmemcpy(fill.buf, value, (size_t)fill.size); @@ -2430,14 +2544,14 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) /* Check for resetting to default for layout type */ if(alloc_time == H5D_ALLOC_TIME_DEFAULT) { - H5D_layout_t layout; /* Type of storage layout */ + H5O_layout_t layout; /* Type of storage layout */ /* Retrieve the storage layout */ if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") /* Set the default based on layout */ - switch(layout) { + switch(layout.type) { case H5D_COMPACT: alloc_time = H5D_ALLOC_TIME_EARLY; break; diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index c51f750..e082e9c 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -1984,7 +1984,7 @@ H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set values */ - latest = (low == H5F_LIBVER_LATEST) ? TRUE : FALSE; + latest = (hbool_t)((low == H5F_LIBVER_LATEST) ? TRUE : FALSE); if(H5P_set(plist, H5F_ACS_LATEST_FORMAT_NAME, &latest) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set library version bounds") diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index a4aff51..913c5f1 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -257,8 +257,8 @@ H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dens ginfo.store_link_phase_change = TRUE; else ginfo.store_link_phase_change = FALSE; - ginfo.max_compact = max_compact; - ginfo.min_dense = min_dense; + ginfo.max_compact = (uint16_t)max_compact; + ginfo.min_dense = (uint16_t)min_dense; /* Set group info */ if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) @@ -361,8 +361,8 @@ H5Pset_est_link_info(hid_t plist_id, unsigned