[svn-r16306] Description:

Bring r16305 back from revise_chunks branch:

	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 branch)
This commit is contained in:
Quincey Koziol 2009-01-14 08:09:42 -05:00
parent 84a14c0f25
commit a365f0e6aa
12 changed files with 194 additions and 19 deletions

View File

@ -104,7 +104,9 @@ $Source = "";
"H5FD_stream_fapl_t" => "x",
"H5G_iterate_t" => "x",
"H5G_info_t" => "x",
"H5I_free_t" => "x",
"H5L_class_t" => "x",
"H5L_elink_traverse_t" => "x",
"H5L_iterate_t" => "x",
"H5MM_allocate_t" => "x",
"H5MM_free_t" => "x",

68
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in 16194 2008-12-15 18:39:20Z mamcgree .
# From configure.in Id: configure.in 16220 2008-12-28 11:28:04Z hdftest .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for HDF5 1.9.27.
#
@ -46893,6 +46893,72 @@ sed 's/^/| /' conftest.$ac_ext >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: checking for C99 designated initialization support" >&5
echo $ECHO_N "checking for C99 designated initialization support... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{
typedef struct {
int x;
union {
int i;
double d;
} u;
} di_struct_t;
di_struct_t x = {0, { .d = 0.0}};
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_C99_DESIGNATED_INITIALIZER 1
_ACEOF
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: checking how to print long long" >&5

View File

@ -2060,13 +2060,27 @@ AC_TRY_COMPILE(,[int __attribute__((unused)) x],
AC_MSG_CHECKING([for __func__ extension])
AC_TRY_COMPILE(,[ const char *fname = __func__; ],
AC_DEFINE([HAVE_C99_FUNC], [1],
[Define if the compiler understand the __func__ keyword])
[Define if the compiler understands the __func__ keyword])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
AC_MSG_CHECKING([for __FUNCTION__ extension])
AC_TRY_COMPILE(,[ const char *fname = __FUNCTION__; ],
AC_DEFINE([HAVE_FUNCTION], [1],
[Define if the compiler understand the __FUNCTION__ keyword])
[Define if the compiler understands the __FUNCTION__ keyword])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
AC_MSG_CHECKING([for C99 designated initialization support])
AC_TRY_COMPILE(,[
typedef struct {
int x;
union {
int i;
double d;
} u;
} di_struct_t;
di_struct_t x = {0, { .d = 0.0}}; ],
AC_DEFINE([HAVE_C99_DESIGNATED_INITIALIZER], [1],
[Define if the compiler understands C99 designated initialization of structs and unions])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))

View File

@ -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);

View File

@ -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) */

View File

@ -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);

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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));

View File

@ -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)))

View File

@ -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. */