diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-07-26 19:33:59 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-07-26 19:33:59 (GMT) |
commit | 7143164de9d7de52516697bbb6bfc7cd2cf749d6 (patch) | |
tree | 107977d9f4732e672d5690072a2e85d82e1ebf28 /src/H5Pdcpl.c | |
parent | 74e00605264ffb2b782b4f28be15accc7784217c (diff) | |
download | hdf5-7143164de9d7de52516697bbb6bfc7cd2cf749d6.zip hdf5-7143164de9d7de52516697bbb6bfc7cd2cf749d6.tar.gz hdf5-7143164de9d7de52516697bbb6bfc7cd2cf749d6.tar.bz2 |
[svn-r22608] Description:
Switch propert list/class iteration from internal to external form of
iteration, cleaning up and simplifying the code a bit.
Bring other general improvements from plist_encode_decode branch back to
trunk.
Clean up many warnings.
Tested on:
Mac OSX/64 10.7.4 (amazon) w/gcc 4.7, debug and C++ & FORTRAN
(too minor to require h5committest)
Diffstat (limited to 'src/H5Pdcpl.c')
-rw-r--r-- | src/H5Pdcpl.c | 142 |
1 files changed, 70 insertions, 72 deletions
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 54654c5..2235944 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -65,7 +65,7 @@ /* Note that the compact & chunked layout initialization values are using the * contiguous layout initialization in the union, because the contiguous * layout is first in the union. These values are overridden in the - * H5P_init_def_layout() routine. -QAK + * H5P__init_def_layout() routine. -QAK */ #define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} #define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} @@ -76,7 +76,7 @@ /* Definitions for storage layout property */ #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 +#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) @@ -88,7 +88,7 @@ /* Definitions for external file list */ #define H5D_CRT_EXT_FILE_LIST_SIZE sizeof(H5O_efl_t) #define H5D_CRT_EXT_FILE_LIST_DEF {HADDR_UNDEF, 0, 0, NULL} -#define H5D_CRT_EXT_FILE_LIST_CMP H5P_dcrt_ext_file_list_cmp +#define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp /******************/ @@ -106,19 +106,19 @@ /********************/ /* General routines */ -static herr_t H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); +static herr_t H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER -static herr_t H5P_init_def_layout(void); +static herr_t H5P__init_def_layout(void); #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Property class callbacks */ -static herr_t H5P_dcrt_reg_prop(H5P_genclass_t *pclass); -static herr_t H5P_dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); -static herr_t H5P_dcrt_close(hid_t dxpl_id, void *close_data); +static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass); +static herr_t H5P__dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); +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_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); /*********************/ @@ -131,12 +131,12 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ &H5P_CLS_OBJECT_CREATE_g, /* Parent class ID */ &H5P_CLS_DATASET_CREATE_g, /* Pointer to class ID */ &H5P_LST_DATASET_CREATE_g, /* Pointer to default property list ID */ - H5P_dcrt_reg_prop, /* Default property registration routine */ + H5P__dcrt_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ - H5P_dcrt_copy, /* Class copy callback */ + H5P__dcrt_copy, /* Class copy callback */ NULL, /* Class copy callback info */ - H5P_dcrt_close, /* Class close callback */ + H5P__dcrt_close, /* Class close callback */ NULL /* Class close callback info */ }}; @@ -163,7 +163,7 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; /*------------------------------------------------------------------------- - * Function: H5P_dcrt_reg_prop + * Function: H5P__dcrt_reg_prop * * Purpose: Register the dataset creation property list class's properties * @@ -174,7 +174,7 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; *------------------------------------------------------------------------- */ static herr_t -H5P_dcrt_reg_prop(H5P_genclass_t *pclass) +H5P__dcrt_reg_prop(H5P_genclass_t *pclass) { H5O_layout_t layout = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ H5O_fill_t fill = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ @@ -182,7 +182,7 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) H5O_efl_t efl = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Register the storage layout property */ if(H5P_register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, H5D_CRT_LAYOUT_CMP, NULL) < 0) @@ -202,11 +202,11 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_reg_prop() */ +} /* end H5P__dcrt_reg_prop() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_copy + * Function: H5P__dcrt_copy * * Purpose: Callback routine which is called whenever any dataset * creation property list is copied. This routine copies @@ -222,7 +222,7 @@ done: */ /* ARGSUSED */ static herr_t -H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) +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 */ @@ -231,7 +231,7 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) H5P_genplist_t *dst_plist; /* Pointer to destination property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Verify property list IDs */ if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_plist_id))) @@ -280,6 +280,8 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) dst_layout.storage.u.chunk.ops = NULL; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HDassert(0 && "Unknown layout type!"); } /* end switch */ @@ -314,11 +316,11 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_copy() */ +} /* end H5P__dcrt_copy() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_close + * Function: H5P__dcrt_close * * Purpose: Callback routine which is called whenever any dataset create * property list is closed. This routine performs any generic @@ -334,14 +336,14 @@ done: */ /* ARGSUSED */ static herr_t -H5P_dcrt_close(hid_t dcpl_id, void UNUSED *close_data) +H5P__dcrt_close(hid_t dcpl_id, void UNUSED *close_data) { H5O_fill_t fill; /* Fill value */ H5O_efl_t efl; /* External file list */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) @@ -362,11 +364,11 @@ H5P_dcrt_close(hid_t dcpl_id, void UNUSED *close_data) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_close() */ +} /* end H5P__dcrt_close() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_layout_cmp + * Function: H5P__dcrt_layout_cmp * * Purpose: Callback routine which is called whenever the layout * property in the dataset creation property list is @@ -382,13 +384,13 @@ done: *------------------------------------------------------------------------- */ static int -H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED size) +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; herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(layout1); @@ -425,13 +427,15 @@ H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED si } /* end case */ break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HDassert(0 && "Unknown layout type!"); } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_layout_cmp() */ +} /* end H5P__dcrt_layout_cmp() */ /*------------------------------------------------------------------------- @@ -496,7 +500,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5P_dcrt_ext_file_list_cmp + * Function: H5P__dcrt_ext_file_list_cmp * * Purpose: Callback routine which is called whenever the external file * list property in the dataset creation property list is @@ -512,14 +516,14 @@ done: *------------------------------------------------------------------------- */ static int -H5P_dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED size) +H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED size) { const H5O_efl_t *efl1 = (const H5O_efl_t *)_efl1, /* Create local aliases for values */ *efl2 = (const H5O_efl_t *)_efl2; int cmp_value; /* Value from comparison */ herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(efl1); @@ -573,11 +577,11 @@ H5P_dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED s done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_ext_file_list_cmp() */ +} /* end H5P__dcrt_ext_file_list_cmp() */ /*------------------------------------------------------------------------- - * Function: H5P_set_layout + * Function: H5P__set_layout * * Purpose: Sets the layout of raw data in the file. * @@ -589,12 +593,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_set_layout(H5P_genplist_t *plist, const H5O_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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Get the allocation time state */ if(H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) @@ -622,6 +626,8 @@ H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) fill.alloc_time = H5D_ALLOC_TIME_INCR; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ @@ -637,12 +643,12 @@ H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_set_layout() */ +} /* end H5P__set_layout() */ #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /*------------------------------------------------------------------------- - * Function: H5P_init_def_layout + * Function: H5P__init_def_layout * * Purpose: Set the default layout information for the various types of * dataset layouts @@ -655,13 +661,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_init_def_layout(void) +H5P__init_def_layout(void) { const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; const H5O_storage_compact_t def_store_compact = H5D_DEF_STORAGE_COMPACT_INIT; const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Initialize the default layout info for non-contigous layouts */ H5D_def_layout_compact_g.storage.u.compact = def_store_compact; @@ -672,7 +678,7 @@ H5P_init_def_layout(void) H5P_dcrt_def_layout_init_g = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_init_def_layout() */ +} /* end H5P__init_def_layout() */ #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -718,7 +724,7 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) * the default layout structs have been initialized yet or not. *ick* -QAK */ if(!H5P_dcrt_def_layout_init_g) - if(H5P_init_def_layout() < 0) + if(H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -736,12 +742,14 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) layout = &H5D_def_layout_chunk_g; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: 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: @@ -845,7 +853,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) * the default layout structs have been initialized yet or not. *ick* -QAK */ if(!H5P_dcrt_def_layout_init_g) - if(H5P_init_def_layout() < 0) + if(H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -870,7 +878,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) /* Set chunk information in property list */ chunk_layout.u.chunk.ndims = (unsigned)ndims; - if(H5P_set_layout(plist, &chunk_layout) < 0) + if(H5P__set_layout(plist, &chunk_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") done: @@ -959,18 +967,6 @@ done: * Programmer: Robb Matzke * Tuesday, March 3, 1998 * - * Modifications: - * - * Raymond Lu - * Tuesday, October 2, 2001 - * Changed the way to check parameter and set property for - * generic property list. - * - * Raymond Lu - * 7 April 2011 - * Starting from the 1.8.7 release, we allow dataspace to have - * zero dimension size. So the external storage size for - * dataset can be zero. *------------------------------------------------------------------------- */ herr_t @@ -979,16 +975,16 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) size_t idx; hsize_t total, tmp; H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*soh", plist_id, name, offset, size); /* Check arguments */ - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if (offset<0) + if(offset < 0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset") /* Get the plist structure */ @@ -997,14 +993,14 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") - if(efl.nused > 0 && H5O_EFL_UNLIMITED==efl.slot[efl.nused-1].size) + if(efl.nused > 0 && H5O_EFL_UNLIMITED == efl.slot[efl.nused - 1].size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "previous file size is unlimited") - if (H5O_EFL_UNLIMITED!=size) { - for (idx=0, total=size; idx<efl.nused; idx++, total=tmp) { + if(H5O_EFL_UNLIMITED != size) { + for(idx = 0, total = size; idx < efl.nused; idx++, total = tmp) { tmp = total + efl.slot[idx].size; - if (tmp <= total) - HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "total external data size overflowed") + if(tmp <= total) + HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "total external data size overflowed") } /* end for */ } /* end if */ @@ -1015,23 +1011,23 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl.slot, na * sizeof(H5O_efl_entry_t)); if(!x) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed") efl.nalloc = na; efl.slot = x; } /* end if */ idx = efl.nused; efl.slot[idx].name_offset = 0; /*not entered into heap yet*/ - efl.slot[idx].name = H5MM_xstrdup (name); + efl.slot[idx].name = H5MM_xstrdup(name); efl.slot[idx].offset = offset; efl.slot[idx].size = size; efl.nused++; if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set external file list") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_external() */ /*------------------------------------------------------------------------- @@ -1199,7 +1195,7 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Always set K13 compression (and un-set CHIP compression) */ - options_mask &= (~H5_SZIP_CHIP_OPTION_MASK); + options_mask &= (unsigned)(~H5_SZIP_CHIP_OPTION_MASK); options_mask |= H5_SZIP_ALLOW_K13_OPTION_MASK; /* Always set "raw" (no szip header) flag for data */ @@ -1207,7 +1203,7 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) /* Mask off the LSB and MSB options, if they were given */ /* (The HDF5 library sets them internally, as needed) */ - options_mask &= ~(H5_SZIP_LSB_OPTION_MASK|H5_SZIP_MSB_OPTION_MASK); + options_mask &= (unsigned)(~(H5_SZIP_LSB_OPTION_MASK | H5_SZIP_MSB_OPTION_MASK)); /* Set the parameters for the filter */ cd_values[0]=options_mask; @@ -1805,6 +1801,8 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) alloc_time = H5D_ALLOC_TIME_INCR; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ |