diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-01-14 14:01:12 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-01-14 14:01:12 (GMT) |
commit | 60915ff8aaa392bebd82826b5b95ab741fedd832 (patch) | |
tree | 0b523fbcdd8db22e7146147a0e19ca40cdca02fd /src | |
parent | bbd83d97e03960839804ef3c87eb6c17fb940acd (diff) | |
download | hdf5-60915ff8aaa392bebd82826b5b95ab741fedd832.zip hdf5-60915ff8aaa392bebd82826b5b95ab741fedd832.tar.gz hdf5-60915ff8aaa392bebd82826b5b95ab741fedd832.tar.bz2 |
[svn-r16307] Description:
Bring r16306 back from trunk:
Add detection of C99 "designated initializers" to configure script and
use new H5_HAVE_C99_DESIGNATED_INITIALIZER macro to conditionally compile
default layout variables in src/H5Pdcpl.c
Also, minor code cleanups, etc.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
(Other platforms tested on revise_chunks branch)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5HFiter.c | 3 | ||||
-rw-r--r-- | src/H5HFman.c | 9 | ||||
-rw-r--r-- | src/H5I.c | 1 | ||||
-rw-r--r-- | src/H5Ocache.c | 2 | ||||
-rw-r--r-- | src/H5Olink.c | 2 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 89 | ||||
-rw-r--r-- | src/H5Plapl.c | 4 | ||||
-rw-r--r-- | src/H5config.h.in | 9 |
8 files changed, 104 insertions, 15 deletions
diff --git a/src/H5HFiter.c b/src/H5HFiter.c index 9e95c4e..e0f7142 100644 --- a/src/H5HFiter.c +++ b/src/H5HFiter.c @@ -183,7 +183,8 @@ HDfprintf(stderr, "%s: offset = %Hu\n", FUNC, offset); curr_offset = offset - hdr->man_dtable.row_block_off[row]; /* Compute column */ - col = curr_offset / hdr->man_dtable.row_block_size[row]; + H5_CHECK_OVERFLOW((curr_offset / hdr->man_dtable.row_block_size[row]), hsize_t, unsigned); + col = (unsigned)(curr_offset / hdr->man_dtable.row_block_size[row]); #ifdef QAK HDfprintf(stderr, "%s: row = %u, col = %u\n", FUNC, row, col); HDfprintf(stderr, "%s: offset = %Hu\n", FUNC, offset); diff --git a/src/H5HFman.c b/src/H5HFman.c index e069e82..5bdc769 100644 --- a/src/H5HFman.c +++ b/src/H5HFman.c @@ -174,7 +174,8 @@ HDfprintf(stderr, "%s: sec_node->u.single.par_entry = %u\n", FUNC, sec_node->u.s /* Insert object into block */ /* Get the offset of the object within the block */ - blk_off = sec_node->sect_info.addr - dblock->block_off; + H5_CHECK_OVERFLOW((sec_node->sect_info.addr - dblock->block_off), hsize_t, size_t); + blk_off = (size_t)(sec_node->sect_info.addr - dblock->block_off); #ifdef QAK HDfprintf(stderr, "%s: blk_off = %Zu\n", FUNC, blk_off); HDfprintf(stderr, "%s: dblock->block_off = %Hu\n", FUNC, dblock->block_off); @@ -328,7 +329,8 @@ HDfprintf(stderr, "%s: entry address = %a\n", FUNC, iblock->ents[entry].addr); /* Set direct block info */ dblock_addr = iblock->ents[entry].addr; - dblock_size = hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]; + H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]), hsize_t, size_t); + dblock_size = (size_t)hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]; /* Check for offset of invalid direct block */ if(!H5F_addr_defined(dblock_addr)) { @@ -582,7 +584,8 @@ HDfprintf(stderr, "%s: entry address = %a\n", FUNC, iblock->ents[dblock_entry].a HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap ID not in allocated direct block") /* Set direct block info */ - dblock_size = hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]; + H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]), hsize_t, size_t); + dblock_size = (size_t)(hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]); /* Compute the direct block's offset in the heap's address space */ /* (based on parent indirect block's block offset) */ @@ -233,6 +233,7 @@ H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func) H5I_type_t ret_value; /* Return value */ FUNC_ENTER_API(H5Iregister_type, H5I_BADID) + H5TRACE3("It", "zIux", hash_size, reserved, free_func); /* Call H5I_register_type with a value of 0 to get a new type */ ret_value = H5I_register_type((H5I_type_t)0, hash_size, reserved, free_func); diff --git a/src/H5Ocache.c b/src/H5Ocache.c index c50f557..e5a772f 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -706,7 +706,7 @@ H5O_assert(oh); switch(oh->flags & H5O_HDR_CHUNK0_SIZE) { case 0: /* 1 byte size */ HDassert(chunk0_size < 256); - *p++ = chunk0_size; + *p++ = (uint8_t)chunk0_size; break; case 1: /* 2 byte size */ diff --git a/src/H5Olink.c b/src/H5Olink.c index 39cbfc6..a4449f0 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -324,7 +324,7 @@ H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void /* Store the link name's length */ switch(link_flags & H5O_LINK_NAME_SIZE) { case 0: /* 1 byte size */ - *p++ = len; + *p++ = (uint8_t)len; break; case 1: /* 2 byte size */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 3f6704b..d84997a 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -48,9 +48,23 @@ /****************/ /* 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}}} +#define H5D_DEF_LAYOUT_COMPACT_INIT {(hbool_t)FALSE, (size_t)0, NULL} +#define H5D_DEF_LAYOUT_CONTIG_INIT {HADDR_UNDEF, (hsize_t)0} +#define H5D_DEF_LAYOUT_CHUNK_INIT {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} +#ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, { .compact = H5D_DEF_LAYOUT_COMPACT_INIT }} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, { .contig = H5D_DEF_LAYOUT_CONTIG_INIT }} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, { .chunk = H5D_DEF_LAYOUT_CHUNK_INIT }} +#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ +/* 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 + */ +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CONTIG_INIT}} +#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* ======== Dataset creation properties ======== */ /* Definitions for storage layout property */ @@ -91,6 +105,9 @@ /* General routines */ 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); +#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Property class callbacks */ static herr_t H5P_dcrt_reg_prop(H5P_genclass_t *pclass); @@ -131,9 +148,16 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ H5FL_BLK_EXTERN(type_conv); /* Defaults for each type of layout */ +#ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER 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; +#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ +static H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; +static H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; +static H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; +static hbool_t H5P_dcrt_def_layout_init_g = FALSE; +#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -377,7 +401,6 @@ H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED si { 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) @@ -661,10 +684,8 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Tuesday, November 23, 2004 - * - * Modifications: + * Programmer: Quincey Koziol + * Tuesday, November 23, 2004 * *------------------------------------------------------------------------- */ @@ -719,6 +740,40 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_set_layout() */ +#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER + +/*------------------------------------------------------------------------- + * Function: H5P_init_def_layout + * + * Purpose: Set the default layout information for the various types of + * dataset layouts + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Tuesday, January 13, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P_init_def_layout(void) +{ + const H5O_layout_compact_t def_compact = H5D_DEF_LAYOUT_COMPACT_INIT; + const H5O_layout_chunk_t def_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5P_init_def_layout) + + /* Initialize the default layout info for non-contigous layouts */ + H5D_def_layout_compact_g.u.compact = def_compact; + H5D_def_layout_chunk_g.u.chunk = def_chunk; + + /* Note that we've initialized the default values */ + H5P_dcrt_def_layout_init_g = TRUE; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P_init_def_layout() */ +#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ + /*------------------------------------------------------------------------- * Function: H5Pset_layout @@ -757,6 +812,15 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") +#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER + /* If the compiler doesn't support C99 designated initializers, check if + * 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) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") +#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ + /* Get pointer to correct default layout */ switch(layout_type) { case H5D_COMPACT: @@ -875,6 +939,15 @@ 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") +#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER + /* If the compiler doesn't support C99 designated initializers, check if + * 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) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") +#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ + /* 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)); diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 664dab2..608240f 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -677,6 +677,7 @@ H5Pset_elink_acc_flags(hid_t lapl_id, unsigned flags) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_elink_acc_flags, FAIL) + H5TRACE2("e", "iIu", lapl_id, flags); /* Check that flags are valid */ if((flags != H5F_ACC_RDWR) && (flags != H5F_ACC_RDONLY) && (flags != H5F_ACC_DEFAULT)) @@ -715,6 +716,7 @@ H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_elink_acc_flags, FAIL) + H5TRACE2("e", "i*Iu", lapl_id, flags); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) @@ -752,6 +754,7 @@ H5Pset_elink_cb(hid_t lapl_id, H5L_elink_traverse_t func, void *op_data) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pset_elink_cb, FAIL) + H5TRACE3("e", "ix*x", lapl_id, func, op_data); /* Check if the callback function is NULL and the user data is non-NULL. * This is almost certainly an error as the user data will not be used. */ @@ -796,6 +799,7 @@ H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_elink_cb, FAIL) + H5TRACE3("e", "i*x**x", lapl_id, func, op_data); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) diff --git a/src/H5config.h.in b/src/H5config.h.in index 82a8c6d..1c70790 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -58,6 +58,13 @@ /* Define to 1 if you have the `BSDgettimeofday' function. */ #undef HAVE_BSDGETTIMEOFDAY +/* Define if the compiler understands C99 designated initialization of structs + and unions */ +#undef HAVE_C99_DESIGNATED_INITIALIZER + +/* Define if the compiler understands the __func__ keyword */ +#undef HAVE_C99_FUNC + /* Define if the function stack tracing code is to be compiled in */ #undef HAVE_CODESTACK @@ -122,7 +129,7 @@ /* Define to 1 if you have the `ftruncate64' function. */ #undef HAVE_FTRUNCATE64 -/* Define if the compiler understand the __FUNCTION__ keyword */ +/* Define if the compiler understands the __FUNCTION__ keyword */ #undef HAVE_FUNCTION /* Define to 1 if you have the `GetConsoleScreenBufferInfo' function. */ |