summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-01-14 12:10:53 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-01-14 12:10:53 (GMT)
commite0bb475838f0c31743018e5c1c770b30b9373440 (patch)
tree295663cfdc5d032aa77e0f32e387adca39013183 /src
parent2ac77da499ca7e4dc5df553f7bf7d2ac279eb2de (diff)
downloadhdf5-e0bb475838f0c31743018e5c1c770b30b9373440.zip
hdf5-e0bb475838f0c31743018e5c1c770b30b9373440.tar.gz
hdf5-e0bb475838f0c31743018e5c1c770b30b9373440.tar.bz2
[svn-r16305] Description:
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 FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.6 (amazon) in debug mode Mac OS X/32 10.5.6 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5HFiter.c3
-rw-r--r--src/H5HFman.c9
-rw-r--r--src/H5I.c1
-rw-r--r--src/H5Ocache.c2
-rw-r--r--src/H5Olink.c2
-rw-r--r--src/H5Oprivate.h7
-rw-r--r--src/H5Pdcpl.c89
-rw-r--r--src/H5config.h.in8
8 files changed, 105 insertions, 16 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) */
diff --git a/src/H5I.c b/src/H5I.c
index b308712..c6fcb17 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -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/H5Oprivate.h b/src/H5Oprivate.h
index 39dfb5c..3ef3fc3 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -339,6 +339,13 @@ typedef struct H5O_efl_t {
*/
#define H5O_LAYOUT_VERSION_3 3
+/* This version adds different types of indices to chunked datasets */
+#define H5O_LAYOUT_VERSION_4 4
+
+/* The latest version of the format. Look through the 'encode'
+ * and 'size' callbacks for places to change when updating this. */
+#define H5O_LAYOUT_VERSION_LATEST H5O_LAYOUT_VERSION_4
+
/* Forward declaration of structs used below */
struct H5D_layout_ops_t; /* Defined in H5Dpkg.h */
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/H5config.h.in b/src/H5config.h.in
index 1436211..1c70790 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -58,7 +58,11 @@
/* Define to 1 if you have the `BSDgettimeofday' function. */
#undef HAVE_BSDGETTIMEOFDAY
-/* Define if the compiler understand the __func__ keyword */
+/* 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 */
@@ -125,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. */