From 79158424981ffc6cf5ce69a64cd096e4c928d842 Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Thu, 5 Mar 1998 16:27:38 -0500 Subject: [svn-r306] Changes since 19980305 ---------------------- ./src/H5D.c ./test/external.c A contiguous dataset can now be stored in external files in such a way that the slowest varying dimension can be increased after the dataset is created and even written. The user must have reserved enough space in the external file and the data space must allow an increase the the slowest varying dimension. See test_3() of ./test/external.c ./src/H5Oefl.c ./configure.in ./src/H5Fprivate.h Fixed an overflow bug with unlimited external storage. ./src/H5V.c Fixed a cast warning. ./test/dsets.c Make better use of automatic error reporting. --- configure | 232 +++++++++++++++++++++++++++++++---------- configure.in | 7 +- src/H5D.c | 87 +++++++++++----- src/H5Fprivate.h | 11 ++ src/H5Oefl.c | 21 ++-- src/H5V.c | 2 +- src/H5config.h.in | 9 ++ test/dsets.c | 305 ++++++++++++++++++++++++------------------------------ test/external.c | 75 ++++++++++---- 9 files changed, 470 insertions(+), 279 deletions(-) diff --git a/configure b/configure index 04c7116..48182b7 100755 --- a/configure +++ b/configure @@ -1077,16 +1077,55 @@ EOF fi +for ac_hdr in unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1085: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1095: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:1085: checking for off_t" >&5 +echo "configure:1124: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1114,12 +1153,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1118: checking for size_t" >&5 +echo "configure:1157: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1152,12 +1191,12 @@ fi for ac_func in getpwuid gethostname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1156: checking for $ac_func" >&5 +echo "configure:1195: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1223: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1206,24 +1245,24 @@ done cat > conftest.$ac_ext < int main() { off64_t n = 0; ; return 0; } EOF -if { (eval echo configure:1217: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1256: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* for ac_func in lseek64 fseek64 do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1222: checking for $ac_func" >&5 +echo "configure:1261: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1280,14 +1319,14 @@ rm -f conftest* echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:1284: checking whether byte ordering is bigendian" >&5 +echo "configure:1323: checking whether byte ordering is bigendian" >&5 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext < #include @@ -1298,11 +1337,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1302: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1341: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext < #include @@ -1313,7 +1352,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1317: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1356: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -1333,7 +1372,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1389: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -1370,7 +1409,7 @@ EOF fi echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:1374: checking size of short" >&5 +echo "configure:1413: checking size of short" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1378,7 +1417,7 @@ else ac_cv_sizeof_short=2 else cat > conftest.$ac_ext < main() @@ -1389,7 +1428,7 @@ main() exit(0); } EOF -if { (eval echo configure:1393: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_short=`cat conftestval` else @@ -1409,7 +1448,7 @@ EOF echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:1413: checking size of int" >&5 +echo "configure:1452: checking size of int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1417,7 +1456,7 @@ else ac_cv_sizeof_int=4 else cat > conftest.$ac_ext < main() @@ -1428,7 +1467,7 @@ main() exit(0); } EOF -if { (eval echo configure:1432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else @@ -1448,7 +1487,7 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:1452: checking size of long" >&5 +echo "configure:1491: checking size of long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1456,7 +1495,7 @@ else ac_cv_sizeof_long=4 else cat > conftest.$ac_ext < main() @@ -1467,7 +1506,7 @@ main() exit(0); } EOF -if { (eval echo configure:1471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else @@ -1487,7 +1526,7 @@ EOF echo $ac_n "checking size of long long""... $ac_c" 1>&6 -echo "configure:1491: checking size of long long" >&5 +echo "configure:1530: checking size of long long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1495,7 +1534,7 @@ else ac_cv_sizeof_long_long=8 else cat > conftest.$ac_ext < main() @@ -1506,7 +1545,7 @@ main() exit(0); } EOF -if { (eval echo configure:1510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long_long=`cat conftestval` else @@ -1526,7 +1565,7 @@ EOF echo $ac_n "checking size of float""... $ac_c" 1>&6 -echo "configure:1530: checking size of float" >&5 +echo "configure:1569: checking size of float" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1534,7 +1573,7 @@ else ac_cv_sizeof_float=4 else cat > conftest.$ac_ext < main() @@ -1545,7 +1584,7 @@ main() exit(0); } EOF -if { (eval echo configure:1549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_float=`cat conftestval` else @@ -1565,7 +1604,7 @@ EOF echo $ac_n "checking size of double""... $ac_c" 1>&6 -echo "configure:1569: checking size of double" >&5 +echo "configure:1608: checking size of double" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1573,7 +1612,7 @@ else ac_cv_sizeof_double=8 else cat > conftest.$ac_ext < main() @@ -1584,7 +1623,7 @@ main() exit(0); } EOF -if { (eval echo configure:1588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_double=`cat conftestval` else @@ -1603,17 +1642,98 @@ cat >> confdefs.h <&6 +echo "configure:1647: checking size of size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_sizeof_size_t=4 +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(size_t)); + exit(0); +} +EOF +if { (eval echo configure:1666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_size_t=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_size_t=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_size_t" 1>&6 +cat >> confdefs.h <>confdefs.h <<\EOF +#include /*for off_t definition*/ +EOF +echo $ac_n "checking size of off_t""... $ac_c" 1>&6 +echo "configure:1689: checking size of off_t" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_off_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_sizeof_off_t=4 +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(off_t)); + exit(0); +} +EOF +if { (eval echo configure:1708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_off_t=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_off_t=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_off_t" 1>&6 +cat >> confdefs.h <&6 -echo "configure:1612: checking for working const" >&5 +echo "configure:1732: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1786: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1683,21 +1803,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:1687: checking for inline" >&5 +echo "configure:1807: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1821: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -1724,16 +1844,16 @@ esac echo $ac_n "checking for __attribute__ extension""... $ac_c" 1>&6 -echo "configure:1728: checking for __attribute__ extension" >&5 +echo "configure:1848: checking for __attribute__ extension" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1857: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_ATTRIBUTE 1 @@ -1749,16 +1869,16 @@ fi rm -f conftest* echo $ac_n "checking for __FUNCTION__ extension""... $ac_c" 1>&6 -echo "configure:1753: checking for __FUNCTION__ extension" >&5 +echo "configure:1873: checking for __FUNCTION__ extension" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1882: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_FUNCTION 1 @@ -1781,7 +1901,7 @@ if test "${enable_parallel+set}" = set; then fi echo $ac_n "checking for parallel support""... $ac_c" 1>&6 -echo "configure:1785: checking for parallel support" >&5; +echo "configure:1905: checking for parallel support" >&5; RUNTEST="" @@ -1807,7 +1927,7 @@ EOF CPPFLAGS="$CPPFLAGS $MPI_INC" CFLAGS="$CFLAGS $MPI_LIB" echo $ac_n "checking for main in -lmpi""... $ac_c" 1>&6 -echo "configure:1811: checking for main in -lmpi" >&5 +echo "configure:1931: checking for main in -lmpi" >&5 ac_lib_var=`echo mpi'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1815,14 +1935,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lmpi $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1849,7 +1969,7 @@ else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking for main in -lmpio""... $ac_c" 1>&6 -echo "configure:1853: checking for main in -lmpio" >&5 +echo "configure:1973: checking for main in -lmpio" >&5 ac_lib_var=`echo mpio'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1857,14 +1977,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lmpio $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else diff --git a/configure.in b/configure.in index 1686261..4df9317 100644 --- a/configure.in +++ b/configure.in @@ -93,7 +93,7 @@ dnl ---------------------------------------------------------------------- dnl Check for header files. dnl AC_HEADER_STDC - +AC_CHECK_HEADERS(unistd.h) dnl ---------------------------------------------------------------------- @@ -125,6 +125,11 @@ AC_CHECK_SIZEOF(long, 4) AC_CHECK_SIZEOF(long long, 8) AC_CHECK_SIZEOF(float, 4) AC_CHECK_SIZEOF(double, 8) +AC_CHECK_SIZEOF(size_t, 4) +cat >>confdefs.h <<\EOF +#include /*for off_t definition*/ +EOF +AC_CHECK_SIZEOF(off_t, 4) diff --git a/src/H5D.c b/src/H5D.c index da470d3..8d20c85 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -746,7 +746,9 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, { H5D_t *new_dset = NULL; H5D_t *ret_value = NULL; - intn i; + intn i, ndims; + size_t max_dim[H5O_LAYOUT_NDIMS]; + H5O_efl_t *efl = NULL; FUNC_ENTER(H5D_create, NULL); @@ -763,6 +765,7 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, new_dset->type = H5T_copy(type); new_dset->space = H5S_copy(space); new_dset->create_parms = H5P_copy (H5P_DATASET_CREATE, create_parms); + efl = &(new_dset->create_parms->efl); /* Total raw data size */ new_dset->layout.type = new_dset->create_parms->layout; @@ -772,26 +775,53 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, switch (new_dset->create_parms->layout) { case H5D_CONTIGUOUS: - if (H5S_get_dims(space, new_dset->layout.dim, NULL) < 0) { + /* + * The maximum size of the dataset cannot exceed the storage size. + * Also, only the slowest varying dimension of a simple data space + * can be extendible. + */ + if ((ndims=H5S_get_dims(space, new_dset->layout.dim, max_dim)) < 0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize contiguous storage"); } - if (new_dset->create_parms->efl.nused>0) { + for (i=1; inew_dset->layout.dim[i]) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "only the first dimension can be extendible"); + } + } + if (efl->nused>0) { size_t max_points = H5S_get_npoints_max (space); - if (max_points*H5T_get_size (type) > - H5O_efl_total_size (&(new_dset->create_parms->efl))) { + size_t max_storage = H5O_efl_total_size (efl); + + if (H5S_UNLIMITED==max_points) { + if (H5O_EFL_UNLIMITED!=max_storage) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "unlimited data space but finite storage"); + } + } else if (max_points * H5T_get_size (type) < max_points) { HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, - "max size exceeds external storage size"); + "data space * type size overflowed"); + } else if (max_points * H5T_get_size (type) > max_storage) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "data space size exceeds external storage size"); } + } else if (max_dim[0]>new_dset->layout.dim[0]) { + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, + "extendible contiguous non-external dataset"); } break; case H5D_CHUNKED: + /* + * Chunked storage allows any type of data space extension, so we + * don't even bother checking. + */ if (new_dset->create_parms->chunk_ndims != H5S_get_ndims(space)) { HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "dimensionality of chunks doesn't match the data space"); } - if (new_dset->create_parms->efl.nused>0) { + if (efl->nused>0) { HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, "external storage not supported with chunked layout"); } @@ -818,8 +848,12 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, "can't update type or space header messages"); } - /* Initialize storage */ - if (0==new_dset->create_parms->efl.nused) { + /* + * Initialize storage. We assume that external storage is already + * initialized by the caller, or at least will be before I/O is + * performed. + */ + if (0==efl->nused) { if (H5F_arr_create(f, &(new_dset->layout)) < 0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize storage"); @@ -827,26 +861,27 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, } else { H5F_addr_undef (&(new_dset->layout.addr)); } + + /* Update layout message */ if (H5O_modify (&(new_dset->ent), H5O_LAYOUT, 0, H5O_FLAG_CONSTANT, &(new_dset->layout)) < 0) { HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unable to update layout message"); } - if (new_dset->create_parms->efl.nused>0) { + + /* Update external storage message */ + if (efl->nused>0) { size_t heap_size = H5H_ALIGN (1); - for (i=0; icreate_parms->efl.nused; i++) { - size_t n = strlen (new_dset->create_parms->efl.slot[i].name)+1; - heap_size += H5H_ALIGN (n); + for (i=0; inused; i++) { + heap_size += H5H_ALIGN (strlen (efl->slot[i].name)+1); } - if (H5H_create (f, H5H_LOCAL, heap_size, - &(new_dset->create_parms->efl.heap_addr))<0 || - H5H_insert (f, &(new_dset->create_parms->efl.heap_addr), - 1, "")<0) { + if (H5H_create (f, H5H_LOCAL, heap_size, &(efl->heap_addr))<0 || + (size_t)(-1)==H5H_insert (f, &(efl->heap_addr), 1, "")) { HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unable to create external file list name heap"); } if (H5O_modify (&(new_dset->ent), H5O_EFL, 0, H5O_FLAG_CONSTANT, - &(new_dset->create_parms->efl))<0) { + efl)<0) { HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unable to update external file list message"); } @@ -1368,16 +1403,12 @@ H5D_extend (H5D_t *dataset, const size_t *size) assert (dataset); assert (size); - if (dataset->create_parms->efl.nused>0) { - HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, - "extending externally-stored data is not implemente yet"); - } - - /* This is only allowed for data spaces with chunked layout */ - if (H5D_CHUNKED!=dataset->layout.type) { - HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, - "size can only be increased for chunked datasets"); - } + /* + * Restrictions on extensions were checked when the dataset was created. + * All extensions are allowed here since none should be able to muck + * things up. + */ + /*void*/ /* Increase the size of the data space */ if ((changed=H5S_extend (dataset->space, size))<0) { diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 497a9a0..77a299f 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -209,6 +209,17 @@ #define NBYTEDECODE(s, d, n) { HDmemcpy(d,s,n); p+=n } /* + * Macros that check for overflows. These are somewhat dangerous to fiddle + * with. + */ +#if (SIZEOF_SIZE_T >= SIZEOF_OFF_T) +# define H5F_OVERFLOW_SIZET2OFFT(X) \ + ((size_t)(X)>=(size_t)((size_t)1<<(8*sizeof(off_t)-1))) +#else +# define H5F_OVERFLOW_SIZET2OFFT(X) 0 +#endif + +/* * File-creation property list. */ typedef struct H5F_create_t { diff --git a/src/H5Oefl.c b/src/H5Oefl.c index ac65101..1b3fa6a 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -386,7 +386,8 @@ H5O_efl_read (H5F_t *f, const H5O_efl_t *efl, haddr_t *addr, size_t size, /* Find the first efl member from which to read */ for (i=0, cur=0; inused; i++) { - if (addr->offset < cur+efl->slot[i].size) { + if (H5O_EFL_UNLIMITED==efl->slot[i].size || + addr->offset < cur+efl->slot[i].size) { skip = addr->offset - cur; break; } @@ -399,11 +400,15 @@ H5O_efl_read (H5F_t *f, const H5O_efl_t *efl, haddr_t *addr, size_t size, HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file"); } + if (H5F_OVERFLOW_SIZET2OFFT (efl->slot[i].offset+skip)) { + HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, + "external file address overflowed"); + } if ((fd=open (efl->slot[i].name, O_RDONLY))<0) { HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file"); } - if (lseek (fd, efl->slot[i].offset+skip, SEEK_SET)<0) { + if (lseek (fd, (off_t)(efl->slot[i].offset+skip), SEEK_SET)<0) { HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file"); } @@ -454,7 +459,6 @@ H5O_efl_write (H5F_t *f, const H5O_efl_t *efl, haddr_t *addr, size_t size, { int i, fd=-1; size_t to_write, cur, skip; - ssize_t n; herr_t ret_value = FAIL; FUNC_ENTER (H5O_efl_write, FAIL); @@ -466,7 +470,8 @@ H5O_efl_write (H5F_t *f, const H5O_efl_t *efl, haddr_t *addr, size_t size, /* Find the first efl member in which to write */ for (i=0, cur=0; inused; i++) { - if (addr->offset < cur+efl->slot[i].size) { + if (H5O_EFL_UNLIMITED==efl->slot[i].size || + addr->offset < cur+efl->slot[i].size) { skip = addr->offset - cur; break; } @@ -479,6 +484,10 @@ H5O_efl_write (H5F_t *f, const H5O_efl_t *efl, haddr_t *addr, size_t size, HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file"); } + if (H5F_OVERFLOW_SIZET2OFFT (efl->slot[i].offset+skip)) { + HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, + "external file address overflowed"); + } if ((fd=open (efl->slot[i].name, O_RDWR))<0) { if (access (efl->slot[i].name, F_OK)<0) { HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, @@ -488,12 +497,12 @@ H5O_efl_write (H5F_t *f, const H5O_efl_t *efl, haddr_t *addr, size_t size, "unable to open external raw data file"); } } - if (lseek (fd, efl->slot[i].offset+skip, SEEK_SET)<0) { + if (lseek (fd, (off_t)(efl->slot[i].offset+skip), SEEK_SET)<0) { HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file"); } to_write = MIN(efl->slot[i].size-skip, size); - if ((n=write (fd, buf, to_write))!=to_write) { + if (write (fd, buf, to_write)!=to_write) { HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file"); } diff --git a/src/H5V.c b/src/H5V.c index e686e29..85d8752 100644 --- a/src/H5V.c +++ b/src/H5V.c @@ -166,7 +166,7 @@ H5V_hyper_stride(intn n, const size_t *size, for (i = n - 2, acc = 1; i >= 0; --i) { size_t tmp = acc * (total_size[i+1] - size[i+1]); assert (tmp<((size_t)1<<(8*sizeof(ssize_t)-1))); - stride[i] = (size_t)tmp; /*overflow checked*/ + stride[i] = (ssize_t)tmp; /*overflow checked*/ acc *= total_size[i+1]; skip += acc * (offset ? offset[i] : 0); } diff --git a/src/H5config.h.in b/src/H5config.h.in index 6f8eef1..ebba10f 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -43,9 +43,15 @@ /* The number of bytes in a long long. */ #undef SIZEOF_LONG_LONG +/* The number of bytes in a off_t. */ +#undef SIZEOF_OFF_T + /* The number of bytes in a short. */ #undef SIZEOF_SHORT +/* The number of bytes in a size_t. */ +#undef SIZEOF_SIZE_T + /* Define if you have the fseek64 function. */ #undef HAVE_FSEEK64 @@ -58,6 +64,9 @@ /* Define if you have the lseek64 function. */ #undef HAVE_LSEEK64 +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + /* Define if you have the mpi library (-lmpi). */ #undef HAVE_LIBMPI diff --git a/test/dsets.c b/test/dsets.c index df19ba1..c92824c 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -1,11 +1,11 @@ /* * Copyright (C) 1997 NCSA - * All rights reserved. + * All rights reserved. * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * - * Purpose: Tests the dataset interface (H5D) + * Purpose: Tests the dataset interface (H5D) */ #include #include @@ -18,25 +18,51 @@ #undef __FUNCTION__ #define __FUNCTION__ "" #endif -#define AT() printf (" at %s:%d in %s()...\n", \ - __FILE__, __LINE__, __FUNCTION__); +#define AT() printf (" at %s:%d in %s()...\n", \ + __FILE__, __LINE__, __FUNCTION__); + +#define DSET_DEFAULT_NAME "default" +#define DSET_CHUNKED_NAME "chunked" +#define DSET_SIMPLE_IO_NAME "simple_io" +#define DSET_TCONV_NAME "tconv" + + +/*------------------------------------------------------------------------- + * Function: display_error_cb + * + * Purpose: Displays the error stack after printing "*FAILED*". + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Wednesday, March 4, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +display_error_cb (void *client_data) +{ + puts ("*FAILED*"); + H5Eprint (stdout); + return 0; +} -#define DSET_DEFAULT_NAME "default" -#define DSET_CHUNKED_NAME "chunked" -#define DSET_SIMPLE_IO_NAME "simple_io" -#define DSET_TCONV_NAME "tconv" /*------------------------------------------------------------------------- - * Function: test_create + * Function: test_create * - * Purpose: Attempts to create a dataset. + * Purpose: Attempts to create a dataset. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Modifications: * @@ -45,10 +71,12 @@ static herr_t test_create(hid_t file) { - hid_t dataset, space, create_parms; - size_t dims[2]; - herr_t status; - size_t csize[2]; + hid_t dataset, space, create_parms; + size_t dims[2]; + herr_t status; + size_t csize[2]; + herr_t (*func)(void*) = NULL; + void *client_data = NULL; printf("%-70s", "Testing create/open/close"); @@ -59,85 +87,54 @@ test_create(hid_t file) assert(space>=0); /* - * Create a dataset using the default dataset creation properties. We're + * Create a dataset using the default dataset creation properties. We're * not sure what they are, so we won't check. */ dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT); - if (dataset < 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Cannot create initial dataset.\n"); - } - goto error; - } + H5P_DEFAULT); + if (dataset<0) goto error; + /* Close the dataset */ - if (H5Dclose(dataset) < 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Cannot close initial dataset.\n"); - } - goto error; - } + if (H5Dclose(dataset) < 0) goto error; /* * Try creating a dataset that already exists. This should fail since a * dataset can only be created once. Temporarily turn off error * reporting. */ + H5Eget_auto (&func, &client_data); H5Eset_auto (NULL, NULL); dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, - H5P_DEFAULT); - H5Eset_auto ((herr_t(*)(void*))H5Eprint, stdout); + H5P_DEFAULT); + H5Eset_auto (func, client_data); if (dataset >= 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Library allowed overwrite of existing dataset.\n"); - } - goto error; + puts("*FAILED*"); + printf(" Library allowed overwrite of existing dataset.\n"); + goto error; } /* * Open the dataset we created above and then close it. This is how * existing datasets are accessed. */ - dataset = H5Dopen(file, DSET_DEFAULT_NAME); - if (dataset < 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Cannot open dataset `%s'.\n", DSET_DEFAULT_NAME); - } - goto error; - } - if (H5Dclose(dataset) < 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Cannot close dataset.\n"); - } - goto error; - } + if ((dataset = H5Dopen(file, DSET_DEFAULT_NAME))<0) goto error; + if (H5Dclose(dataset) < 0) goto error; /* * Try opening a non-existent dataset. This should fail since new datasets * cannot be created with this function. Temporarily turn off error * reporting. */ + H5Eget_auto (&func, &client_data); H5Eset_auto (NULL, NULL); dataset = H5Dopen(file, "does_not_exist"); - H5Eset_auto ((herr_t(*)(void*))H5Eprint, stdout); + H5Eset_auto (func, client_data); if (dataset >= 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Opened a non-existent dataset.\n"); - } - goto error; + puts("*FAILED*"); + printf(" Opened a non-existent dataset.\n"); + goto error; } + /* * Create a new dataset that uses chunked storage instead of the default * layout. @@ -150,46 +147,35 @@ test_create(hid_t file) assert(status >= 0); dataset = H5Dcreate(file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space, - create_parms); - if (dataset < 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Could not create a chunked dataset.\n"); - } - goto error; - } + create_parms); + if (dataset < 0) goto error; + /* * Close the chunked dataset. */ - if (H5Dclose(dataset) < 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Cannot close chunked dataset.\n"); - } - goto error; - } + if (H5Dclose(dataset) < 0) goto error; + puts(" PASSED"); return 0; - error: + error: return -1; } + /*------------------------------------------------------------------------- - * Function: test_simple_io + * Function: test_simple_io * - * Purpose: Tests simple I/O. That is, reading and writing a complete - * multi-dimensional array without data type or data space - * conversions, without compression, and stored contiguously. + * Purpose: Tests simple I/O. That is, reading and writing a complete + * multi-dimensional array without data type or data space + * conversions, without compression, and stored contiguously. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke - * Wednesday, December 10, 1997 + * Programmer: Robb Matzke + * Wednesday, December 10, 1997 * * Modifications: * @@ -198,19 +184,19 @@ test_create(hid_t file) static herr_t test_simple_io(hid_t file) { - hid_t dataset, space; - herr_t status; - int points[100][200], check[100][200]; - int i, j, n; - size_t dims[2]; + hid_t dataset, space; + herr_t status; + int points[100][200], check[100][200]; + int i, j, n; + size_t dims[2]; printf("%-70s", "Testing simple I/O"); /* Initialize the dataset */ for (i = n = 0; i < 100; i++) { - for (j = 0; j < 100; j++) { - points[i][j] = n++; - } + for (j = 0; j < 100; j++) { + points[i][j] = n++; + } } /* Create the data space */ @@ -221,44 +207,29 @@ test_simple_io(hid_t file) /* Create the dataset */ dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, - H5P_DEFAULT); + H5P_DEFAULT); assert(dataset >= 0); /* Write the data to the dataset */ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, points); - if (status < 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" H5Dwrite() failed\n"); - } - goto error; - } + H5P_DEFAULT, points); + if (status<0) goto error; + /* Read the dataset back */ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, check); - if (status < 0) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" H5Dread() failed\n"); - } - goto error; - } + H5P_DEFAULT, check); + if (status<0) goto error; + /* Check that the values read are the same as the values written */ for (i = 0; i < 100; i++) { - for (j = 0; j < 200; j++) { - if (points[i][j] != check[i][j]) { - puts("*FAILED*"); - if (!isatty(1)) { - AT(); - printf(" Read different values than written.\n"); - printf(" At index %d,%d\n", i, j); - } - goto error; - } - } + for (j = 0; j < 200; j++) { + if (points[i][j] != check[i][j]) { + puts("*FAILED*"); + printf(" Read different values than written.\n"); + printf(" At index %d,%d\n", i, j); + goto error; + } + } } H5Dclose(dataset); @@ -271,16 +242,16 @@ test_simple_io(hid_t file) } /*------------------------------------------------------------------------- - * Function: test_tconv + * Function: test_tconv * - * Purpose: Test some simple data type conversion stuff. + * Purpose: Test some simple data type conversion stuff. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke - * Wednesday, January 14, 1998 + * Programmer: Robb Matzke + * Wednesday, January 14, 1998 * * Modifications: * @@ -317,26 +288,26 @@ test_tconv(hid_t file) /* Create the data set */ dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_NATIVE_INT32, space, - H5P_DEFAULT); + H5P_DEFAULT); assert(dataset >= 0); /* Write the data to the dataset */ status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, - H5P_DEFAULT, out); + H5P_DEFAULT, out); assert(status >= 0); /* Create a new type with the opposite byte order */ type = H5Tcopy(H5T_NATIVE_INT32); switch (H5Tget_order(type)) { case H5T_ORDER_BE: - H5Tset_order(type, H5T_ORDER_LE); - break; + H5Tset_order(type, H5T_ORDER_LE); + break; case H5T_ORDER_LE: - H5Tset_order(type, H5T_ORDER_BE); - break; + H5Tset_order(type, H5T_ORDER_BE); + break; default: - assert("funny byte order" && 0); - break; + assert("funny byte order" && 0); + break; } /* Read data with byte order conversion */ @@ -345,10 +316,10 @@ test_tconv(hid_t file) /* Check */ for (i = 0; i < 1000000; i++) { - assert(in[4 * i + 0] == out[4 * i + 3]); - assert(in[4 * i + 1] == out[4 * i + 2]); - assert(in[4 * i + 2] == out[4 * i + 1]); - assert(in[4 * i + 3] == out[4 * i + 0]); + assert(in[4 * i + 0] == out[4 * i + 3]); + assert(in[4 * i + 1] == out[4 * i + 2]); + assert(in[4 * i + 2] == out[4 * i + 1]); + assert(in[4 * i + 3] == out[4 * i + 0]); } H5Dclose(dataset); @@ -359,16 +330,16 @@ test_tconv(hid_t file) } /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Tests the dataset interface (H5D) + * Purpose: Tests the dataset interface (H5D) * - * Return: Success: exit(0) + * Return: Success: exit(0) * - * Failure: exit(1) + * Failure: exit(1) * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Modifications: * @@ -377,15 +348,15 @@ test_tconv(hid_t file) int main(void) { - hid_t file; - herr_t status; - int nerrors = 0; + hid_t file; + herr_t status; + int nerrors = 0; status = H5open (); assert (status>=0); /* Automatic error reporting to standard output */ - H5Eset_auto ((herr_t(*)(void*))H5Eprint, stdout); + H5Eset_auto (display_error_cb, NULL); unlink("dataset.h5"); file = H5Fcreate("dataset.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -403,13 +374,9 @@ main(void) status = H5Fclose(file); if (nerrors) { - printf("***** %d DATASET TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); - if (isatty(1)) { - printf("(Redirect output to a pager or a file to see debug " - "output)\n"); - } - exit(1); + printf("***** %d DATASET TEST%s FAILED! *****\n", + nerrors, 1 == nerrors ? "" : "S"); + exit(1); } printf("All dataset tests passed.\n"); diff --git a/test/external.c b/test/external.c index 53f1c15..1e0df7e 100644 --- a/test/external.c +++ b/test/external.c @@ -630,16 +630,16 @@ test_2 (void) static void test_3 (void) { - hid_t file, plist, space, dset; + hid_t file, plist, mem_space, file_space, dset; herr_t status; - int i; - int part[25], whole[100]; - size_t size; + int i, fd; + int part[25], whole[100], hs_start=100; + size_t size=100, max_size=200, hs_count=100; /* - * Open the file from test_2(). + * Create another file */ - file = H5Fcreate ("extern_2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate ("extern_3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); /* Create the external file list */ @@ -651,31 +651,37 @@ test_3 (void) assert (status>=0); status = H5Pset_external (plist, "extern_3b.raw", 20, sizeof(part)); assert (status>=0); - status = H5Pset_external (plist, "extern_4b.raw", 30, sizeof(part)); + status = H5Pset_external (plist, "extern_4b.raw", 30, H5F_UNLIMITED); assert (status>=0); - /* Touch the files so they exist */ - system ("touch extern_1b.raw extern_2b.raw extern_3b.raw extern_4b.raw"); + /* Make sure the output files are fresh*/ + fd = open ("extern_1b.raw", O_RDWR|O_CREAT|O_TRUNC, 0666); + close (fd); + fd = open ("extern_2b.raw", O_RDWR|O_CREAT|O_TRUNC, 0666); + close (fd); + fd = open ("extern_3b.raw", O_RDWR|O_CREAT|O_TRUNC, 0666); + close (fd); + fd = open ("extern_4b.raw", O_RDWR|O_CREAT|O_TRUNC, 0666); + close (fd); /* Create the data space */ - size = 100; - space = H5Screate_simple (1, &size, NULL); - assert (space>=0); + mem_space = H5Screate_simple (1, &size, &max_size); + assert (mem_space>=0); + file_space = H5Scopy (mem_space); /* Create the dataset */ - dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist); + dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, file_space, plist); assert (dset>=0); /* * Write the entire dataset and compare with the original */ do { - /* Write to the dataset */ printf ("%-70s", "...writing entire dataset"); fflush (stdout); - for (i=0; i<100; i++) whole[i] = i; - status = H5Dwrite (dset, H5T_NATIVE_INT, space, space, + for (i=0; i=0); + status = H5Dwrite (dset, H5T_NATIVE_INT, mem_space, file_space, + H5P_DEFAULT, whole); + if (status<0) break; + puts (" PASSED"); + } while (0); + + H5Dclose (dset); H5Pclose (plist); - H5Sclose (space); + H5Sclose (mem_space); + H5Sclose (file_space); H5Fclose (file); } @@ -732,5 +771,5 @@ main (void) printf ("%d TEST%s FAILED.\n", nerrors_g, 1==nerrors_g?"":"s"); } - exit (nerrors_g?1:0); + return (nerrors_g?1:0); } -- cgit v0.12