From 665f528813749ce6b1ce9afdf104262a65a4a2cd Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Tue, 28 Apr 2009 14:41:42 -0500 Subject: [svn-r16875] Merged changes from the trunk into the branch: svn merge -r16602:16869 https://svn.hdfgroup.uiuc.edu/hdf5/trunk Tested on: smirom --- COPYING | 18 +- MANIFEST | 6 + Makefile.am | 21 + Makefile.in | 28 +- README.txt | 2 +- aclocal.m4 | 35 +- bin/make_overflow | 219 ++ bin/reconfigure | 8 +- c++/Makefile.in | 8 +- c++/examples/Makefile.in | 6 +- c++/examples/testh5c++.sh.in | 4 +- c++/src/H5Attribute.cpp | 183 +- c++/src/H5Attribute.h | 3 + c++/src/Makefile.am | 4 + c++/src/Makefile.in | 40 +- c++/test/Makefile.in | 8 +- c++/test/dsets.cpp | 2 +- c++/test/tattr.cpp | 90 +- c++/test/tfilter.cpp | 2 +- config/gnu-flags | 77 +- config/lt_vers.am | 2 +- configure | 572 +++- configure.in | 22 +- examples/Makefile.in | 6 +- examples/h5_shared_mesg.c | 4 +- examples/testh5cc.sh.in | 4 +- fortran/Makefile.in | 8 +- fortran/examples/Makefile.in | 6 +- fortran/examples/testh5fc.sh.in | 4 +- fortran/src/H5Df.c | 28 + fortran/src/H5Dff.f90 | 46 +- fortran/src/H5If.c | 30 + fortran/src/H5Iff.f90 | 42 + fortran/src/H5Pf.c | 67 + fortran/src/H5Pff.f90 | 118 + fortran/src/H5Sff.f90 | 2 +- fortran/src/H5_f.c | 3 + fortran/src/H5f90global.f90 | 15 +- fortran/src/H5f90proto.h | 9 + fortran/src/Makefile.am | 4 + fortran/src/Makefile.in | 40 +- fortran/src/hdf5_fortrandll.def | 4 + fortran/test/Makefile.in | 8 +- fortran/test/fortranlib_test.f90 | 5 +- fortran/test/fortranlib_test_1_8.f90 | 2 + fortran/test/tH5I.f90 | 24 + fortran/test/tH5P.f90 | 275 +- fortran/testpar/Makefile.in | 8 +- hl/Makefile.in | 8 +- hl/c++/Makefile.in | 8 +- hl/c++/examples/Makefile.in | 6 +- hl/c++/src/Makefile.am | 4 + hl/c++/src/Makefile.in | 40 +- hl/c++/test/Makefile.in | 8 +- hl/examples/Makefile.in | 6 +- hl/fortran/Makefile.in | 8 +- hl/fortran/examples/Makefile.in | 6 +- hl/fortran/src/Makefile.am | 4 + hl/fortran/src/Makefile.in | 40 +- hl/fortran/test/Makefile.in | 8 +- hl/src/H5DS.c | 222 +- hl/src/H5IM.c | 1817 +++++----- hl/src/H5LT.c | 3354 +++++++++---------- hl/src/H5TB.c | 2346 ++++++------- hl/src/Makefile.am | 3 + hl/src/Makefile.in | 40 +- hl/test/Makefile.am | 2 +- hl/test/Makefile.in | 10 +- hl/test/test_ds.c | 379 ++- hl/test/test_image.c | 463 +-- hl/test/test_lite.c | 1486 ++++----- hl/test/test_table.c | 676 ++-- hl/tools/Makefile.in | 8 +- hl/tools/gif2h5/Makefile.in | 8 +- perform/Makefile.in | 8 +- perform/chunk.c | 2 +- release_docs/RELEASE.txt | 85 +- src/H5.c | 14 +- src/H5AC.c | 127 +- src/H5ACprivate.h | 17 +- src/H5Apkg.h | 16 +- src/H5Aprivate.h | 1 - src/H5B.c | 6 +- src/H5B2cache.c | 6 +- src/H5B2int.c | 6 +- src/H5B2pkg.h | 4 +- src/H5B2test.c | 2 +- src/H5Bcache.c | 1 + src/H5Bprivate.h | 2 - src/H5C.c | 295 +- src/H5Cprivate.h | 55 +- src/H5Dchunk.c | 40 +- src/H5Dcompact.c | 12 +- src/H5Dcontig.c | 38 +- src/H5Defl.c | 12 +- src/H5Dint.c | 48 +- src/H5Dmpio.c | 5 +- src/H5Dpkg.h | 16 +- src/H5Dscatgath.c | 11 +- src/H5EA.c | 60 +- src/H5EAcache.c | 263 +- src/H5EAdbg.c | 14 +- src/H5EAdblkpage.c | 19 +- src/H5EAdblock.c | 40 +- src/H5EAhdr.c | 11 +- src/H5EAiblock.c | 24 +- src/H5EAint.c | 63 + src/H5EApkg.h | 89 +- src/H5EAprivate.h | 32 +- src/H5EAsblock.c | 39 +- src/H5EAtest.c | 5 +- src/H5Edefin.h | 1 + src/H5Einit.h | 5 + src/H5Eprivate.h | 2 +- src/H5Epubgen.h | 2 + src/H5Eterm.h | 3 +- src/H5F.c | 18 +- src/H5FDfamily.c | 17 +- src/H5FDint.c | 21 +- src/H5FDsec2.c | 6 - src/H5FL.c | 581 +++- src/H5FLprivate.h | 30 +- src/H5FO.c | 4 +- src/H5FScache.c | 4 +- src/H5FSsection.c | 31 +- src/H5Fpkg.h | 6 +- src/H5Fsuper.c | 33 +- src/H5Ftest.c | 40 + src/H5G.c | 167 +- src/H5Gbtree2.c | 8 +- src/H5Gcache.c | 1 + src/H5Gobj.c | 109 - src/H5Gpkg.h | 19 +- src/H5Gprivate.h | 8 +- src/H5Groot.c | 368 +++ src/H5Gstab.c | 3 +- src/H5Gtest.c | 56 + src/H5HFcache.c | 3 + src/H5HG.c | 5 +- src/H5HGcache.c | 1 + src/H5HLcache.c | 1 + src/H5I.c | 40 +- src/H5L.c | 18 +- src/H5O.c | 2 +- src/H5Ocache.c | 1 + src/H5Ocopy.c | 2 +- src/H5Opline.c | 4 +- src/H5Oprivate.h | 10 +- src/H5Pdapl.c | 2 +- src/H5Pdcpl.c | 2 +- src/H5Pint.c | 20 +- src/H5SL.c | 859 +++-- src/H5SLprivate.h | 4 +- src/H5SMcache.c | 2 + src/H5Tconv.c | 54 +- src/H5Z.c | 74 +- src/H5Zdeflate.c | 6 +- src/H5Zfletcher32.c | 2 +- src/H5Znbit.c | 2 +- src/H5Zpkg.h | 14 +- src/H5Zprivate.h | 5 +- src/H5Zpublic.h | 26 +- src/H5Zscaleoffset.c | 2 +- src/H5Zshuffle.c | 2 +- src/H5Zszip.c | 2 +- src/H5config.h.in | 6 + src/H5detect.c | 64 + src/H5err.txt | 1 + src/H5overflow.h | 1381 ++++++++ src/H5overflow.txt | 43 + src/H5private.h | 114 +- src/H5public.h | 4 +- src/H5trace.c | 2 +- src/H5vers.txt | 1 + src/H5version.h | 16 + src/H5win32defs.h | 1 + src/Makefile.am | 8 +- src/Makefile.in | 25 +- test/Makefile.am | 13 +- test/Makefile.in | 25 +- test/big.c | 8 +- test/cache.c | 292 +- test/cache_common.c | 52 +- test/cache_common.h | 4 +- test/dsets.c | 428 ++- test/dtransform.c | 59 +- test/earray.c | 80 +- test/family_v16_00000.h5 | Bin 5120 -> 5120 bytes test/links.c | 84 +- test/mount.c | 1 + test/objcopy.c | 25 +- test/tfile.c | 175 + test/tid.c | 43 +- test/tmisc.c | 82 + test/tskiplist.c | 92 +- test/vfd.c | 75 +- testpar/Makefile.in | 8 +- testpar/t_cache.c | 3 +- testpar/t_chunk_alloc.c | 114 +- testpar/t_posix_compliant.c | 4 +- testpar/testphdf5.c | 17 +- testpar/testphdf5.h | 2 + tools/Makefile.in | 8 +- tools/h5copy/Makefile.in | 8 +- tools/h5diff/Makefile.in | 8 +- tools/h5diff/h5diffgentest.c | 1108 ++++--- tools/h5diff/testfiles/h5diff_201.txt | 2 +- tools/h5diff/testfiles/h5diff_202.txt | 2 +- tools/h5diff/testfiles/h5diff_203.txt | 2 +- tools/h5diff/testfiles/h5diff_204.txt | 2 +- tools/h5diff/testfiles/h5diff_205.txt | 4 +- tools/h5diff/testfiles/h5diff_206.txt | 2 +- tools/h5diff/testfiles/h5diff_207.txt | 4 +- tools/h5diff/testfiles/h5diff_57.txt | 2 +- tools/h5diff/testfiles/h5diff_70.txt | 2 +- tools/h5diff/testfiles/h5diff_80.txt | 8 +- tools/h5diff/testfiles/h5diff_90.txt | 4 +- tools/h5diff/testfiles/h5diff_dset1.h5 | Bin 22752 -> 23624 bytes tools/h5diff/testfiles/h5diff_dset2.h5 | Bin 22752 -> 23624 bytes tools/h5dump/Makefile.in | 8 +- tools/h5dump/h5dump.c | 8 +- tools/h5dump/h5dumpgentest.c | 47 +- tools/h5dump/testh5dump.sh.in | 1 + tools/h5import/Makefile.in | 8 +- tools/h5jam/Makefile.in | 8 +- tools/h5ls/Makefile.in | 8 +- tools/h5repack/Makefile.am | 3 + tools/h5repack/Makefile.in | 11 +- tools/h5repack/h5repack.c | 287 +- tools/h5repack/h5repack.h | 2 +- tools/h5repack/h5repack.sh.in | 12 +- tools/h5repack/h5repack_copy.c | 1590 +++++---- tools/h5repack/h5repack_filters.c | 24 +- tools/h5repack/h5repack_parse.c | 6 +- tools/h5repack/h5repack_refs.c | 76 +- tools/h5repack/h5repack_verify.c | 88 +- tools/h5repack/h5repacktst.c | 3476 ++++++++++++-------- tools/h5repack/testfiles/h5repack_named_dtypes.h5 | Bin 0 -> 4304 bytes tools/h5repack/testfiles/h5repack_objs.h5 | Bin 19589 -> 19770 bytes tools/h5stat/Makefile.in | 8 +- tools/lib/Makefile.in | 8 +- tools/lib/h5diff_array.c | 655 +++- tools/lib/h5diff_dset.c | 22 +- tools/lib/h5tools.c | 9 +- tools/lib/h5tools_ref.c | 2 +- tools/misc/Makefile.in | 8 +- tools/testfiles/tall-2A.h5.xml | 2 +- tools/testfiles/tall.h5.xml | 2 +- tools/testfiles/tarray1.h5.xml | 2 +- tools/testfiles/tarray2.h5.xml | 2 +- tools/testfiles/tarray3.h5.xml | 2 +- tools/testfiles/tarray6.h5.xml | 2 +- tools/testfiles/tarray7.h5.xml | 2 +- tools/testfiles/tattr.h5.xml | 2 +- tools/testfiles/tbitfields.h5.xml | 2 +- tools/testfiles/tcompound.h5.xml | 2 +- tools/testfiles/tcompound2.h5.xml | 2 +- tools/testfiles/tcompound_complex.h5.xml | 2 +- tools/testfiles/tdatareg.h5.xml | 2 +- tools/testfiles/tdset.h5.xml | 2 +- tools/testfiles/tdset2.h5.xml | 2 +- tools/testfiles/tempty-dtd-2.h5.xml | 2 +- tools/testfiles/tempty-dtd.h5.xml | 2 +- tools/testfiles/tempty-nons-2.h5.xml | 2 +- tools/testfiles/tempty-nons.h5.xml | 2 +- tools/testfiles/tempty-ns-2.h5.xml | 2 +- tools/testfiles/tempty-ns.h5.xml | 2 +- tools/testfiles/tempty.h5.xml | 2 +- tools/testfiles/tenum.h5.xml | 2 +- tools/testfiles/textlink.h5.xml | 2 +- tools/testfiles/tgroup.h5.xml | 2 +- tools/testfiles/thlink.h5.xml | 2 +- tools/testfiles/tloop.h5.xml | 2 +- tools/testfiles/tloop2.h5.xml | 2 +- tools/testfiles/tmany.h5.xml | 2 +- tools/testfiles/tname-amp.h5.xml | 2 +- tools/testfiles/tname-apos.h5.xml | 2 +- tools/testfiles/tname-gt.h5.xml | 2 +- tools/testfiles/tname-lt.h5.xml | 2 +- tools/testfiles/tname-quot.h5.xml | 2 +- tools/testfiles/tname-sp.h5.xml | 2 +- tools/testfiles/tnamed_dtype_attr.h5.xml | 2 +- tools/testfiles/tnestedcomp.h5.xml | 2 +- tools/testfiles/tnodata.h5.xml | 2 +- tools/testfiles/tobjref.h5.xml | 2 +- tools/testfiles/topaque.h5.xml | 2 +- tools/testfiles/torderattr1.h5.xml | 2 +- tools/testfiles/torderattr2.h5.xml | 2 +- tools/testfiles/torderattr3.h5.xml | 2 +- tools/testfiles/torderattr4.h5.xml | 2 +- tools/testfiles/tref-escapes-at.h5.xml | 2 +- tools/testfiles/tref-escapes.h5.xml | 2 +- tools/testfiles/tref.h5.xml | 2 +- tools/testfiles/tsaf.h5.xml | 2 +- tools/testfiles/tslink.h5.xml | 2 +- tools/testfiles/tstr.h5.xml | 2 +- tools/testfiles/tstr2.h5.xml | 2 +- tools/testfiles/tstring-at.h5.xml | 2 +- tools/testfiles/tstring.h5.xml | 2 +- tools/testfiles/tudlink.h5.xml | 2 +- tools/testfiles/tvldtypes1.h5.xml | 2 +- tools/testfiles/tvldtypes2.h5.xml | 2 +- tools/testfiles/tvldtypes3.h5.xml | 2 +- tools/testfiles/tvldtypes4.h5.xml | 2 +- tools/testfiles/tvldtypes5.h5.xml | 2 +- tools/testfiles/tvlstr.h5.xml | 2 +- vms/src/h5pubconf.h | 6 +- vms/src/make.com | 2 +- vms/test/check.com | 5 - vms/test/make.com | 6 - vms/tools/h5repack/check_h5repack.com | 3 + windows/copy_hdf.bat | 1 - windows/proj/hdf5/hdf5.vcproj | 42 + windows/proj/hdf5dll/hdf5dll.vcproj | 40 + windows/src/H5pubconf.h | 6 +- windows/tools/h5repack/h5repack.bat | 14 +- windows/tools/testfiles/h5difftst/h5difftst.vcproj | 12 +- windows_vnet/proj/hdf5/hdf5.vcproj | 35 + windows_vnet/proj/hdf5dll/hdf5dll.vcproj | 34 + 319 files changed, 18226 insertions(+), 10271 deletions(-) create mode 100644 bin/make_overflow create mode 100644 src/H5Groot.c create mode 100644 src/H5overflow.h create mode 100644 src/H5overflow.txt create mode 100644 tools/h5repack/testfiles/h5repack_named_dtypes.h5 diff --git a/COPYING b/COPYING index 43c4534..5ba610b 100644 --- a/COPYING +++ b/COPYING @@ -11,11 +11,6 @@ Copyright 1998-2006 by the Board of Trustees of the University of Illinois. All rights reserved. -Contributors: National Center for Supercomputing Applications (NCSA) at -the University of Illinois, Fortner Software, Unidata Program Center (netCDF), -The Independent JPEG Group (JPEG), Jean-loup Gailly and Mark Adler (gzip), -and Digital Equipment Corporation (DEC). - Redistribution and use in source and binary forms, with or without modification, are permitted for any purpose (including commercial purposes) provided that the following conditions are met: @@ -39,8 +34,8 @@ provided that the following conditions are met: 5. Neither the name of The HDF Group, the name of the University, nor the name of any Contributor may be used to endorse or promote products derived - from this software without specific prior written permission from the - University, The HDF Group, or the Contributor, respectively. + from this software without specific prior written permission from + The HDF Group, the University, or the Contributor, respectively. DISCLAIMER: THIS SOFTWARE IS PROVIDED BY THE HDF GROUP AND THE CONTRIBUTORS @@ -50,6 +45,15 @@ suffered by the users arising out of the use of this software, even if advised of the possibility of such damage. ----------------------------------------------------------------------------- +----------------------------------------------------------------------------- + +Contributors: National Center for Supercomputing Applications (NCSA) at +the University of Illinois, Fortner Software, Unidata Program Center (netCDF), +The Independent JPEG Group (JPEG), Jean-loup Gailly and Mark Adler (gzip), +and Digital Equipment Corporation (DEC). + +----------------------------------------------------------------------------- + Portions of HDF5 were developed with support from the University of California, Lawrence Livermore National Laboratory (UC LLNL). The following statement applies to those portions of the product and must diff --git a/MANIFEST b/MANIFEST index 014d47a..f64b893 100644 --- a/MANIFEST +++ b/MANIFEST @@ -57,6 +57,7 @@ ./bin/locate_sw ./bin/ltmain.sh ./bin/make_err +./bin/make_overflow ./bin/make_vers ./bin/makehelp ./bin/missing @@ -427,6 +428,8 @@ ./src/H5err.txt ./src/H5config.h.in ./src/H5detect.c +./src/H5overflow.txt +./src/H5overflow.h ./src/H5private.h ./src/H5public.h ./src/H5system.c @@ -582,6 +585,7 @@ ./src/H5Gpkg.h ./src/H5Gprivate.h ./src/H5Gpublic.h +./src/H5Groot.c ./src/H5Gstab.c ./src/H5Gtest.c ./src/H5Gtraverse.c @@ -1309,6 +1313,7 @@ ./tools/testfiles/tfpformat.ddl ./tools/testfiles/tfpformat.h5 + # Expected output from h5ls tests ./tools/testfiles/nosuchfile.ls ./tools/testfiles/help-1.ls @@ -1519,6 +1524,7 @@ ./tools/h5repack/testfiles/h5repack_ext.bin ./tools/h5repack/testfiles/h5repack_ext.h5 ./tools/h5repack/testfiles/ublock.bin +./tools/h5repack/testfiles/h5repack_named_dtypes.h5 # jam utility and tests diff --git a/Makefile.am b/Makefile.am index c0d6827..7acc2db 100755 --- a/Makefile.am +++ b/Makefile.am @@ -79,6 +79,9 @@ DIST_SUBDIRS = src test testpar tools . c++ fortran hl perform examples # Some files generated during configure that should be cleaned DISTCLEANFILES=config/stamp1 config/stamp2 +# Some files/directories generated during check that should be cleaned +CHECK_CLEANFILES+=*-tmp + # Define rules for lib, progs, check, and tests. # These simply involve recursing into subdirectories. test _test: check @@ -113,6 +116,7 @@ check-clean: (cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ fi; \ done + $(RM) -rf prefix-tmp destdir-tmp # Some C++ compilers/linkers will create a directory named ii_files in # the root directory, which should be cleaned. @@ -150,6 +154,23 @@ installcheck-local: # check-install is just a synonym for installcheck check-install: installcheck +# check-all-install tests all installation methods. +# Install via different mechanism and then compare against the default. +# Fine if only libXXX.a files are different since they may have been ranlib'ed. +check-all-install: + @echo Installing to default location + $(MAKE) install + @echo Installing to different prefix location + $(MAKE) prefix=${ROOT}/prefix-tmp install + @echo Compare against the default installation. + @echo Fine if only libXXX.a files are different. + -diff -r prefix-tmp ${prefix} + @echo Installing to different $$\DESTDIR location + env DESTDIR=${ROOT}/destdir-tmp $(MAKE) install + @echo Compare against the default installation. + @echo Fine if only libXXX.a files are different. + -diff -r destdir-tmp${prefix} ${prefix} + # Only source files in the src directory include tracing information, # so 'make trace' only needs to recurse into that directory. trace: diff --git a/Makefile.in b/Makefile.in index 9ab76bd..6e0e40b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -350,7 +350,9 @@ TRACE = perl $(top_srcdir)/bin/trace # .chkexe files are used to mark tests that have run successfully. # .chklog files are output from those tests. # *.clog are from the MPE option. -CHECK_CLEANFILES = *.chkexe *.chklog *.clog + +# Some files/directories generated during check that should be cleaned +CHECK_CLEANFILES = *.chkexe *.chklog *.clog *-tmp @BUILD_PARALLEL_CONDITIONAL_FALSE@TESTPARALLEL_DIR = # Define subdirectories to build. @@ -418,7 +420,7 @@ clean-libtool: -rm -rf .libs _libs distclean-libtool: - -rm -f libtool + -rm -f libtool config.lt # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. @@ -495,7 +497,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -853,6 +855,7 @@ check-clean: (cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ fi; \ done + $(RM) -rf prefix-tmp destdir-tmp # Some C++ compilers/linkers will create a directory named ii_files in # the root directory, which should be cleaned. @@ -890,6 +893,23 @@ installcheck-local: # check-install is just a synonym for installcheck check-install: installcheck +# check-all-install tests all installation methods. +# Install via different mechanism and then compare against the default. +# Fine if only libXXX.a files are different since they may have been ranlib'ed. +check-all-install: + @echo Installing to default location + $(MAKE) install + @echo Installing to different prefix location + $(MAKE) prefix=${ROOT}/prefix-tmp install + @echo Compare against the default installation. + @echo Fine if only libXXX.a files are different. + -diff -r prefix-tmp ${prefix} + @echo Installing to different $$\DESTDIR location + env DESTDIR=${ROOT}/destdir-tmp $(MAKE) install + @echo Compare against the default installation. + @echo Fine if only libXXX.a files are different. + -diff -r destdir-tmp${prefix} ${prefix} + # Only source files in the src directory include tracing information, # so 'make trace' only needs to recurse into that directory. trace: diff --git a/README.txt b/README.txt index 200c970..c4cff13 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.36 currently under development +HDF5 version 1.9.39 currently under development ==> README.txt <== Messages to be sent to the list should be sent to "@hdfgroup.org". diff --git a/aclocal.m4 b/aclocal.m4 index 73f8129..86d521d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.10.1 -*- Autoconf -*- +# generated automatically by aclocal 1.10.2 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -13,13 +13,13 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(AC_AUTOCONF_VERSION, [2.61],, +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.61],, [m4_warning([this file was generated for autoconf 2.61. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) -# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -34,7 +34,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.10' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.10.1], [], +m4_if([$1], [1.10.2], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -48,12 +48,12 @@ m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.10.1])dnl +[AM_AUTOMAKE_VERSION([1.10.2])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)]) +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- @@ -303,19 +303,28 @@ _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -#serial 3 +#serial 4 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[for mf in $CONFIG_FILES; do +[# Autoconf 2.62 quotes --file arguments for eval, but not when files +# are listed without --file. Let's play safe and only enable the eval +# if we detect the quoting. +case $CONFIG_FILES in +*\'*) eval set x "$CONFIG_FILES" ;; +*) set x $CONFIG_FILES ;; +esac +shift +for mf +do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. @@ -688,13 +697,13 @@ esac # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 3 +# serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- @@ -711,7 +720,7 @@ AC_DEFUN([_AM_SET_OPTION], # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], -[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- diff --git a/bin/make_overflow b/bin/make_overflow new file mode 100644 index 0000000..ced486a --- /dev/null +++ b/bin/make_overflow @@ -0,0 +1,219 @@ +#!/usr/bin/perl -w +require 5.003; +use strict; + +# Global settings + +# List of supported C types to generate overflow assignment code for +my @ctypes = ( () ); + +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# + +# Create assignment overflow #ifdefs +# +# Programmer: Quincey Koziol +# Creation Date: 2009/04/09 + +############################################################################## +# Parse a meaningful line (not a comment or blank line) into the appropriate +# data structure +# +sub parse_line ($) { + my $line = shift; # Get the line to parse + + # Parse get the type name and whether it's signed or unsigned +#print "line=$line\n"; + if($line =~ /.*SIGNED\s*;\s*$/ || $line =~ /.*UNSIGNED\s*;\s*$/) { + my $name; # The name of the type + my $signed; # Whether the type is signed or not + + # Get the type's name & signed status + ($name, $signed) = ($line =~ /^\s*(\w*)\s*,\s*(\w*)\s*;\s*$/); +#print "name = '$name', signed = '$signed'\n"; + + # Append the type to the list of C types already parsed + push @ctypes, [$name, $signed]; + + } + # Unknown keyword + else { + die "unknown keyword: $line"; + } +} + +############################################################################## +# Print the copyright into an open file +# +sub print_copyright ($) { + my $fh = shift; + + print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"; + print $fh " * Copyright by The HDF Group. *\n"; + print $fh " * Copyright by the Board of Trustees of the University of Illinois. *\n"; + print $fh " * All rights reserved. *\n"; + print $fh " * *\n"; + print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n"; + print $fh " * terms governing use, modification, and redistribution, is contained in *\n"; + print $fh " * the files COPYING and Copyright.html. COPYING can be found at the root *\n"; + print $fh " * of the source code distribution tree; Copyright.html can be found at the *\n"; + print $fh " * root level of an installed copy of the electronic HDF5 document set and *\n"; + print $fh " * is linked from the top-level documents page. It can also be found at *\n"; + print $fh " * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n"; + print $fh " * access to either file, you may request a copy from help\@hdfgroup.org. *\n"; + print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"; +} + +############################################################################## +# Print the "do not change this file" warning +# +sub print_warning ($) { + my $fh = shift; + + print $fh "\n/* Generated automatically by bin/make_overflow -- do not edit */\n"; + print $fh "/* Add new types to H5overflow.txt file */\n\n"; +} + +############################################################################## +# Print start of ifdef's to prevent a file from being re-included +# +sub print_startprotect ($$) { + my ($fh, $file) = @_; + + # Clip off the ".h" part of the name + $file =~ s/(\w*)\.h/$1/; + + # Print the ifdef info + print $fh "\n#ifndef _${file}_H\n"; + print $fh "#define _${file}_H\n"; +} + +############################################################################## +# Print assignment overflow macros for each type +# +sub print_typemacros ($) { + my $fh = shift; # File handle for output file + my ($src_aref, $dst_aref); # References for each type's information + + # Print the descriptive comment + print $fh "\n\n/* Each type in this file is tested for assignment to the other types,\n"; + print $fh " * and range checks are defined for bad assignments at run-time.\n"; + print $fh " */\n"; + + for $src_aref (@ctypes) { + # Print a descriptive comment + print $fh "\n/* Assignment checks for @$src_aref[0] */\n\n"; + + for $dst_aref (@ctypes) { + if (@$src_aref[0] ne @$dst_aref[0]) { + # Print a descriptive comment + print $fh "/* src: @$src_aref[0], dst: @$dst_aref[0] */\n"; + + # Print actual type size checks & macro definitions + print $fh "#if H5_SIZEOF_", uc @$src_aref[0], " < H5_SIZEOF_", uc @$dst_aref[0], "\n"; + print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; + if ( @$src_aref[1] eq @$dst_aref[1]) { + print $fh " ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype)\n"; + } elsif ( @$src_aref[1] eq "SIGNED") { + print $fh " ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype)\n"; + } else { + print $fh " ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype)\n"; + } + print $fh "#elif H5_SIZEOF_", uc @$src_aref[0], " > H5_SIZEOF_", uc @$dst_aref[0], "\n"; + print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; + print $fh " ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype)\n"; + print $fh "#else /* H5_SIZEOF_", uc @$src_aref[0], " == H5_SIZEOF_", uc @$dst_aref[0], " */\n"; + print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; + if ( @$src_aref[1] eq @$dst_aref[1]) { + print $fh " ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype)\n"; + } elsif ( @$src_aref[1] eq "SIGNED") { + print $fh " ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype)\n"; + } else { + print $fh " ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype)\n"; + } + print $fh "#endif /* src: @$src_aref[0] dst: @$dst_aref[0] */\n\n"; + } + } + } + +} + +############################################################################## +# Print end of ifdef's to prevent a file from being re-included +# +sub print_endprotect ($$) { + my ($fh, $file) = @_; + + # Clip off the ".h" part of the name + $file =~ s/(\w*)\.h/$1/; + + # Print the endif info + print $fh "#endif /* ${file}_H */\n\n"; +} + +############################################################################## +# Create the generated portion of the public header file +# +sub create_public ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5overflow.h"; # Name of file to generate + my $name; # Name of function + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + print_typemacros(*HEADER); + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + +############################################################################## +# Read symbol version file (given as command-line argument) in and process it +# into internal data structures, then create header files. +# +my $file; # Filename of input file + +for $file (@ARGV) { + my $prefix; # Local prefix for generated files + my $line; # Line from input file + +#print "file = '$file'\n"; + ($prefix) = ($file =~ /(^.*\/)/); +#print "prefix = '$prefix'\n"; + # Read in the entire file + open SOURCE, $file or die "$file: $!\n"; + while ( defined ($line=) ) { + # Skip blank lines and those lines whose first character is a '#' + if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) { + # Construct data structures for later printing + parse_line($line); + } + } + close SOURCE; + + # Create header files + print "Generating 'H5overflow.h'\n"; + create_public($prefix); +} + diff --git a/bin/reconfigure b/bin/reconfigure index 05e52ba..1fffa45 100755 --- a/bin/reconfigure +++ b/bin/reconfigure @@ -29,9 +29,9 @@ # HDF5 currently uses the following versions of the autotools: AUTOCONF_VERSION="autoconf (GNU Autoconf) 2.61" -AUTOMAKE_VERSION="automake (GNU automake) 1.10.1" +AUTOMAKE_VERSION="automake (GNU automake) 1.10.2" AUTOHEADER_VERSION="autoheader (GNU Autoconf) 2.61" -ACLOCAL_VERSION="aclocal (GNU automake) 1.10.1" +ACLOCAL_VERSION="aclocal (GNU automake) 1.10.2" LIBTOOL_VERSION="(GNU libtool) 2.2.6" # # When upgrading automake's version, don't forget to also update its @@ -44,13 +44,13 @@ if test -z ${AUTOCONF}; then AUTOCONF=/mnt/hdf/packages/autoconf/autoconf-2.61/bin/autoconf fi if test -z ${AUTOMAKE}; then - AUTOMAKE=/mnt/hdf/packages/automake/automake-1.10.1/bin/automake-1.10 + AUTOMAKE=/mnt/hdf/packages/automake/automake-1.10.2/bin/automake-1.10 fi if test -z ${AUTOHEADER}; then AUTOHEADER=/mnt/hdf/packages/autoconf/autoconf-2.61/bin/autoheader fi if test -z ${ACLOCAL}; then - ACLOCAL=/mnt/hdf/packages/automake/automake-1.10.1/bin/aclocal-1.10 + ACLOCAL=/mnt/hdf/packages/automake/automake-1.10.2/bin/aclocal-1.10 fi if test -z ${LIBTOOL}; then LIBTOOL=/mnt/hdf/packages/libtool/libtool-2.2.6a/bin/libtool diff --git a/c++/Makefile.in b/c++/Makefile.in index 8796ca7..1016377 100644 --- a/c++/Makefile.in +++ b/c++/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -347,8 +347,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -454,7 +454,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/c++/examples/Makefile.in b/c++/examples/Makefile.in index 63cce0a..e5749e6 100644 --- a/c++/examples/Makefile.in +++ b/c++/examples/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -364,8 +364,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ diff --git a/c++/examples/testh5c++.sh.in b/c++/examples/testh5c++.sh.in index c9474bf..2b7bbfe 100755 --- a/c++/examples/testh5c++.sh.in +++ b/c++/examples/testh5c++.sh.in @@ -22,8 +22,8 @@ # Initializations # Where the tool is installed. prefix="${prefix:-@prefix@}" -AR=@AR@ -RANLIB=@RANLIB@ +AR="@AR@" +RANLIB="@RANLIB@" H5TOOL="h5c++" # The tool name H5TOOL_BIN="${prefix}/bin/${H5TOOL}" # The path of the tool binary diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index c90076c..a844b77 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -34,6 +34,7 @@ #include "H5DataSpace.h" #include "H5File.h" #include "H5Attribute.h" +#include "H5private.h" // for HDfree #ifndef H5_NO_NAMESPACE namespace H5 { @@ -95,23 +96,40 @@ void Attribute::write( const DataType& mem_type, const void *buf ) const //-------------------------------------------------------------------------- // Function: Attribute::write ///\brief This is an overloaded member function, provided for convenience. -/// It writes a \a std::string to this attribute. +/// It writes a \a H5std_string to this attribute. ///\param mem_type - IN: Attribute datatype (in memory) ///\param strg - IN: Data to be written ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Apr, 2003 //-------------------------------------------------------------------------- -void Attribute::write( const DataType& mem_type, const H5std_string& strg ) const +void Attribute::write(const DataType& mem_type, const H5std_string& strg) const { - // Convert string to C-string - const char* strg_C; - strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str + // Check if this attribute has variable-len string or fixed-len string and + // proceed appropriately. + htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); + if (is_variable_len < 0) + { + throw AttributeIException("Attribute::write", "H5Tis_variable_str failed"); + } + // Convert string to C-string + const char* strg_C; + strg_C = strg.c_str(); // strg_C refers to the contents of strg as a C-str + herr_t ret_value = 0; - herr_t ret_value = H5Awrite( id, mem_type.getId(), &strg_C ); - if( ret_value < 0 ) - { - throw AttributeIException("Attribute::write", "H5Awrite failed"); - } + // Pass string in differently depends on variable or fixed length + if (!is_variable_len) + { + ret_value = H5Awrite(id, mem_type.getId(), strg_C); + } + else + { + // passing third argument by address + ret_value = H5Awrite(id, mem_type.getId(), &strg_C); + } + if (ret_value < 0) + { + throw AttributeIException("Attribute::write", "H5Awrite failed"); + } } //-------------------------------------------------------------------------- @@ -127,14 +145,58 @@ void Attribute::read( const DataType& mem_type, void *buf ) const herr_t ret_value = H5Aread( id, mem_type.getId(), buf ); if( ret_value < 0 ) { - throw AttributeIException("Attribute::read", "H5Aread failed"); + throw AttributeIException("Attribute::read", "H5Aread failed"); } } //-------------------------------------------------------------------------- +// Function: Attribute::getInMemDataSize +///\brief Gets the size in memory of the attribute's data. +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +size_t Attribute::getInMemDataSize() const +{ + // Get the data type of this attribute + hid_t mem_type_id = H5Aget_type(id); + if (mem_type_id <= 0) + { + throw AttributeIException("Attribute::getDataSize", "H5Aget_type failed"); + } + + // Get the data type's size + hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); + if (native_type < 0) + { + throw AttributeIException("Attribute::read", "H5Tget_native_type failed"); + } + size_t type_size = H5Tget_size(native_type); + if (type_size == 0) + { + throw AttributeIException("Attribute::read", "H5Tget_size failed"); + } + + // Get number of elements of the attribute + hid_t space_id = H5Aget_space(id); + if (space_id < 0) + { + throw AttributeIException("Attribute::read", "H5Aget_space failed"); + } + hssize_t num_elements = H5Sget_simple_extent_npoints(space_id); + if (num_elements < 0) + { + throw AttributeIException("Attribute::read", "H5Sget_simple_extent_npoints failed"); + } + + // Calculate and return the size of the data + size_t data_size = type_size * num_elements; + return(data_size); +} + +//-------------------------------------------------------------------------- // Function: Attribute::read ///\brief This is an overloaded member function, provided for convenience. -/// It reads a \a std::string from this attribute. +/// It reads a \a H5std_string from this attribute. ///\param mem_type - IN: Attribute datatype (in memory) ///\param strg - IN: Buffer for read string ///\exception H5::AttributeIException @@ -145,31 +207,72 @@ void Attribute::read( const DataType& mem_type, void *buf ) const // space for the buffer. Obtained the attribute size and // allocated memory properly. - BMR //-------------------------------------------------------------------------- -void Attribute::read( const DataType& mem_type, H5std_string& strg ) const +void Attribute::read(const DataType& mem_type, H5std_string& strg) const { - // Get the attribute size and allocate temporary C-string for C API - hsize_t attr_size = H5Aget_storage_size(id); - if (attr_size <= 0) - { - throw AttributeIException("Attribute::read", "Unable to get attribute size before reading"); - } - char* strg_C = new char [(size_t)attr_size+1]; - if (strg_C == NULL) - { - throw AttributeIException("Attribute::read", "Unable to allocate buffer to read the attribute"); - } - // Call C API to get the attribute data, a string of chars - herr_t ret_value = H5Aread(id, mem_type.getId(), &strg_C); - if( ret_value < 0 ) - { - throw AttributeIException("Attribute::read", "H5Aread failed"); - } + // Check if this attribute has variable-len string or fixed-len string and + // proceed appropriately. + htri_t is_variable_len = H5Tis_variable_str(mem_type.getId()); + if (is_variable_len < 0) + { + throw AttributeIException("Attribute::write", "H5Tis_variable_str failed"); + } + + // Prepare and call C API to read attribute. + char *strg_C; + herr_t ret_value = 0; + size_t attr_size; + if (!is_variable_len) // only allocate for fixed-len string + { + // Get the size of the attribute's data + attr_size = getInMemDataSize(); + + if (attr_size > 0) + { + strg_C = new char [(size_t)attr_size+1]; + if (strg_C == NULL) + { + throw AttributeIException("Attribute::read", + "Unable to allocate buffer to read the attribute"); + } + ret_value = H5Aread(id, mem_type.getId(), strg_C); + } + else + HDstrcpy(strg_C, ""); + } + else + { + // no allocation for variable-len string; C library will + ret_value = H5Aread(id, mem_type.getId(), &strg_C); + } + if( ret_value < 0 ) + { + if (!is_variable_len) // only de-allocate for fixed-len string + delete []strg_C; + throw AttributeIException("Attribute::read", "H5Aread failed"); + } - // Get 'string' from the C char* and release resource - strg_C[attr_size] = '\0'; - strg = strg_C; - delete []strg_C; + if( ret_value < 0 ) + { + if (!is_variable_len) // only de-allocate for fixed-len string + delete []strg_C; + throw AttributeIException("Attribute::read", "H5Aread failed"); + } + + // Get string from the C char* and release resource allocated locally + if (!is_variable_len) + { + if (strg_C != "") + strg_C[attr_size] = '\0'; + strg = strg_C; + delete []strg_C; + } + // Get string from the C char* and release resource allocated by C API + else + { + strg = strg_C; + HDfree(strg_C); + } } //-------------------------------------------------------------------------- @@ -342,21 +445,21 @@ hid_t Attribute::getId() const ///\brief Sets the identifier of this object to a new value. /// ///\exception H5::IdComponentException when the attempt to close the HDF5 -/// object fails +/// object fails // Description: -// The underlaying reference counting in the C library ensures -// that the current valid id of this object is properly closed. -// Then the object's id is reset to the new id. +// The underlaying reference counting in the C library ensures +// that the current valid id of this object is properly closed. +// Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void Attribute::p_setId(const hid_t new_id) { // handling references to this old id try { - close(); + close(); } catch (Exception close_error) { - throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); + throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id id = new_id; diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index 9cf91ba..00a08a5 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -40,6 +40,9 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent { // Returns the amount of storage size required for this attribute. hsize_t getStorageSize() const; + // Returns the in memory size of this attribute's data. + size_t getInMemDataSize() const; + // Reads data from this attribute. void read( const DataType& mem_type, void *buf ) const; void read( const DataType& mem_type, H5std_string& strg ) const; diff --git a/c++/src/Makefile.am b/c++/src/Makefile.am index 3b1ed0d..c18b990 100644 --- a/c++/src/Makefile.am +++ b/c++/src/Makefile.am @@ -19,6 +19,7 @@ # include $(top_srcdir)/config/commence.am +include $(top_srcdir)/config/lt_vers.am # Include src directory INCLUDES=-I$(top_srcdir)/src @@ -26,6 +27,9 @@ INCLUDES=-I$(top_srcdir)/src # This is our main target lib_LTLIBRARIES=libhdf5_cpp.la +# Add libtool numbers to the HDF5 C++ library (from config/lt_vers.am) +libhdf5_cpp_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Shared C++ libraries aren't universally supported. if CXX_SHARED_CONDITIONAL else diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index 9d50223..abe8590 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -54,7 +54,8 @@ host_triplet = @host@ DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/h5c++.in \ $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am + $(top_srcdir)/config/conclude.am \ + $(top_srcdir)/config/lt_vers.am TESTS = subdir = c++/src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -83,6 +84,9 @@ am_libhdf5_cpp_la_OBJECTS = H5Exception.lo H5IdComponent.lo \ H5StrType.lo H5ArrayType.lo H5VarLenType.lo H5CompType.lo \ H5DataSet.lo H5CommonFG.lo H5Group.lo H5File.lo libhdf5_cpp_la_OBJECTS = $(am_libhdf5_cpp_la_OBJECTS) +libhdf5_cpp_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(libhdf5_cpp_la_LDFLAGS) $(LDFLAGS) -o $@ binSCRIPT_INSTALL = $(INSTALL_SCRIPT) SCRIPTS = $(bin_SCRIPTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src @@ -353,12 +357,21 @@ TRACE = perl $(top_srcdir)/bin/trace # *.clog are from the MPE option. CHECK_CLEANFILES = *.chkexe *.chklog *.clog +# Add libtool shared library version numbers to the HDF5 library +# See libtool versioning documentation online. +LT_VERS_INTERFACE = 6 +LT_VERS_REVISION = 29 +LT_VERS_AGE = 0 + # Include src directory INCLUDES = -I$(top_srcdir)/src # This is our main target lib_LTLIBRARIES = libhdf5_cpp.la +# Add libtool numbers to the HDF5 C++ library (from config/lt_vers.am) +libhdf5_cpp_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Shared C++ libraries aren't universally supported. @CXX_SHARED_CONDITIONAL_FALSE@AM_LDFLAGS = -static bin_SCRIPTS = h5c++ @@ -408,12 +421,12 @@ all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/lt_vers.am $(top_srcdir)/config/conclude.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -467,7 +480,7 @@ clean-libLTLIBRARIES: rm -f "$${dir}/so_locations"; \ done libhdf5_cpp.la: $(libhdf5_cpp_la_OBJECTS) $(libhdf5_cpp_la_DEPENDENCIES) - $(CXXLINK) -rpath $(libdir) $(libhdf5_cpp_la_OBJECTS) $(libhdf5_cpp_la_LIBADD) $(LIBS) + $(libhdf5_cpp_la_LINK) -rpath $(libdir) $(libhdf5_cpp_la_OBJECTS) $(libhdf5_cpp_la_LIBADD) $(LIBS) install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @@ -570,7 +583,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -762,6 +775,19 @@ uninstall-am: uninstall-binSCRIPTS uninstall-includeHEADERS \ help: @$(top_srcdir)/bin/makehelp +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. + # Some C++ compilers/linkers (PGI?) create a directory named "ii_files" that # holds *.ii files, which are template entity instantiations. # This entire directory should be cleaned. diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index 9bbb475..0452ea0 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -382,8 +382,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -471,7 +471,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 319f894..6a5f223 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -352,7 +352,7 @@ test_tconv( H5File& file) } // test_tconv /* This message derives from H5Z */ -const H5Z_class_t H5Z_BOGUS[1] = {{ +const H5Z_class2_t H5Z_BOGUS[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ H5Z_FILTER_BOGUS, /* Filter id number */ 1, 1, /* Encode and decode enabled */ diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 73b5a91..48a3200 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -356,7 +356,7 @@ static void test_attr_basic_read() for(i=0; i signed char conversion in the test/dt_arith test). + # There's either a bug in gcc or our code. Need further investigation. + # Turn off all optimizations to allow the tests to pass for now. + # - AKC - 2009/04/19 + PROD_CFLAGS="-O0" + ;; + gcc-3.[0-4]*|gcc-4.[012]*) # The optimization level is reduced for gcc 3.* and 4.* due to problems # with code generation for src/H5Tconv.c with the -O2 & -O3 # optimization levels (which shows up as failures for various integer @@ -153,10 +163,6 @@ case "$cc_vendor-$cc_version" in # later versions of gcc will fix this bug... - QAK - 2003/10/20 PROD_CFLAGS="-O" ;; - gcc-4*) - # Be optimistic about future versions of gcc.. :-) - QAK - 2003/10/20 - PROD_CFLAGS="-O3" - ;; *) PROD_CFLAGS="-O" ;; @@ -184,10 +190,67 @@ esac # the information from the previous version and adding modifications to that. case "$cc_vendor-$cc_version" in -# Closer to the gcc 4.4 release, we should check for additional flags to +# Closer to the gcc 4.5 release, we should check for additional flags to # include and break it out into it's own section, like the other versions # below. -QAK - gcc-4.[34]*) + gcc-4.[45]*) + # Replace -ansi flag with -std=c99 flag + H5_CFLAGS="`echo $H5_CFLAGS | sed -e 's/-ansi/-std=c99/g'`" + + # Disable warnings about using 'long long' type + H5_CFLAGS="$H5_CFLAGS -Wno-long-long" + + # Append warning flags from gcc-3* case + # (don't use -Wpadded flag for normal builds, many of the warnings its + # issuing can't be fixed and they are making it hard to detect other, + # more important warnings) + #H5_CFLAGS="$H5_CFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" + H5_CFLAGS="$H5_CFLAGS -Wfloat-equal -Wmissing-format-attribute" + + # Append warning flags from gcc-3.2* case + H5_CFLAGS="$H5_CFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" + + # Enable more format checking flags, beyond the basic -Wformat included + # in -Wall + H5_CFLAGS="$H5_CFLAGS -Wformat=2" + + # The "unreachable code" warning appears to be reliable now... + H5_CFLAGS="$H5_CFLAGS -Wunreachable-code" + + # Append warning flags from gcc-3.3* case + H5_CFLAGS="$H5_CFLAGS -Wendif-labels" + + # Append warning flags from gcc-3.4* case + H5_CFLAGS="$H5_CFLAGS -Wdeclaration-after-statement -Wold-style-definition -Winvalid-pch" + + # Replace old -W flag with new -Wextra flag + H5_CFLAGS="`echo $H5_CFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" + + # Append more extra warning flags that only gcc4.0+ know about + H5_CFLAGS="$H5_CFLAGS -Wvariadic-macros -Wnonnull -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" + + # Append more extra warning flags that only gcc 4.1+ know about + H5_CFLAGS="$H5_CFLAGS -Wunsafe-loop-optimizations -Wc++-compat" + + # Append more extra warning flags that only gcc 4.2+ know about + H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow" + + # Append more extra warning flags that only gcc 4.3+ know about + # + # Technically, variable-length arrays are part of the C99 standard, but + # we should approach them a bit cautiously... -QAK + H5_CFLAGS="$H5_CFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" + + # Append more extra warning flags that only gcc 4.4+ know about + H5_CFLAGS="$H5_CFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" + + # Try out the new "stack protector" feature in gcc 4.1 + # (Strictly speaking this isn't really a "warning" flag, so it's added to + # the debugging flags) + #DEBUG_CFLAGS="$DEBUG_CFLAGS -Wstack-protector -fstack-protector-all" + ;; + + gcc-4.3*) # Replace -ansi flag with -std=c99 flag H5_CFLAGS="`echo $H5_CFLAGS | sed -e 's/-ansi/-std=c99/g'`" diff --git a/config/lt_vers.am b/config/lt_vers.am index c5af888..c460133 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -17,7 +17,7 @@ # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 26 +LT_VERS_REVISION = 29 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and diff --git a/configure b/configure index 3bd216d..b386709 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Id: configure.in 16554 2009-03-09 17:50:53Z mamcgree . +# From configure.in Id: configure.in 16579 2009-03-15 11:36:28Z lrknox . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for HDF5 1.9.36. +# Generated by GNU Autoconf 2.61 for HDF5 1.9.39. # # Report bugs to . # @@ -724,8 +724,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='HDF5' PACKAGE_TARNAME='hdf5' -PACKAGE_VERSION='1.9.36' -PACKAGE_STRING='HDF5 1.9.36' +PACKAGE_VERSION='1.9.39' +PACKAGE_STRING='HDF5 1.9.39' PACKAGE_BUGREPORT='help@hdfgroup.org' ac_unique_file="src/H5.c" @@ -1502,7 +1502,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures HDF5 1.9.36 to adapt to many kinds of systems. +\`configure' configures HDF5 1.9.39 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1572,7 +1572,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of HDF5 1.9.36:";; + short | recursive ) echo "Configuration of HDF5 1.9.39:";; esac cat <<\_ACEOF @@ -1646,6 +1646,8 @@ Optional Features: --enable-strict-format-checks Enable strict file format checks, default=yes if debug flag is enabled, no otherwise + --enable-embedded-libinfo + Enable embedded library information [default=yes] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1754,7 +1756,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -HDF5 configure 1.9.36 +HDF5 configure 1.9.39 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1768,7 +1770,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by HDF5 $as_me 1.9.36, which was +It was created by HDF5 $as_me 1.9.39, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2463,7 +2465,7 @@ fi # Define the identity of the package. PACKAGE='hdf5' - VERSION='1.9.36' + VERSION='1.9.39' cat >>confdefs.h <<_ACEOF @@ -8078,13 +8080,13 @@ if test "${lt_cv_nm_interface+set}" = set; then else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:8081: $ac_compile\"" >&5) + (eval echo "\"\$as_me:8083: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:8084: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:8086: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:8087: output\"" >&5) + (eval echo "\"\$as_me:8089: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -9305,7 +9307,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 9308 "configure"' > conftest.$ac_ext + echo '#line 9310 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -12176,11 +12178,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12179: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12181: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12183: \$? = $ac_status" >&5 + echo "$as_me:12185: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12515,11 +12517,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12518: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12520: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12522: \$? = $ac_status" >&5 + echo "$as_me:12524: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12620,11 +12622,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12623: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12625: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12627: \$? = $ac_status" >&5 + echo "$as_me:12629: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12675,11 +12677,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12678: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12680: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12682: \$? = $ac_status" >&5 + echo "$as_me:12684: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15511,7 +15513,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 15514 "configure" +#line 15516 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15607,7 +15609,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 15610 "configure" +#line 15612 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17635,11 +17637,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17638: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17640: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:17642: \$? = $ac_status" >&5 + echo "$as_me:17644: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -17734,11 +17736,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17737: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17739: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:17741: \$? = $ac_status" >&5 + echo "$as_me:17743: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17786,11 +17788,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17789: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17791: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:17793: \$? = $ac_status" >&5 + echo "$as_me:17795: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -19331,11 +19333,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19334: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19336: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19338: \$? = $ac_status" >&5 + echo "$as_me:19340: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19430,11 +19432,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19433: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19435: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19437: \$? = $ac_status" >&5 + echo "$as_me:19439: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -19482,11 +19484,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19485: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19487: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19489: \$? = $ac_status" >&5 + echo "$as_me:19491: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -25859,6 +25861,467 @@ cat >>confdefs.h <<_ACEOF _ACEOF +{ echo "$as_me:$LINENO: checking for unsigned" >&5 +echo $ECHO_N "checking for unsigned... $ECHO_C" >&6; } +if test "${ac_cv_type_unsigned+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef unsigned ac__type_new_; +#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 () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 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 + ac_cv_type_unsigned=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_unsigned=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_unsigned" >&5 +echo "${ECHO_T}$ac_cv_type_unsigned" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of unsigned" >&5 +echo $ECHO_N "checking size of unsigned... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_unsigned+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef unsigned ac__type_sizeof_; +#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 () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [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 + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef unsigned ac__type_sizeof_; +#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 () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [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 + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef unsigned ac__type_sizeof_; +#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 () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [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 + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef unsigned ac__type_sizeof_; +#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 () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [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 + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef unsigned ac__type_sizeof_; +#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 () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [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 + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_unsigned=$ac_lo;; +'') if test "$ac_cv_type_unsigned" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (unsigned) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_unsigned=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef unsigned ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +#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 () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +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_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (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_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_unsigned=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_unsigned" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (unsigned) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_unsigned=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_unsigned" >&5 +echo "${ECHO_T}$ac_cv_sizeof_unsigned" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UNSIGNED $ac_cv_sizeof_unsigned +_ACEOF + + { echo "$as_me:$LINENO: checking for long" >&5 echo $ECHO_N "checking for long... $ECHO_C" >&6; } if test "${ac_cv_type_long+set}" = set; then @@ -51236,6 +51699,30 @@ echo "${ECHO_T}no" >&6; } esac +{ echo "$as_me:$LINENO: checking Whether to have library information embedded in the executables" >&5 +echo $ECHO_N "checking Whether to have library information embedded in the executables... $ECHO_C" >&6; } +# Check whether --enable-embedded-libinfo was given. +if test "${enable_embedded_libinfo+set}" = set; then + enableval=$enable_embedded_libinfo; enable_embedded_libinfo=$enableval +else + enable_embedded_libinfo=yes +fi + + + if test "${enable_embedded_libinfo}" = "yes"; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_EMBEDDED_LIBINFO 1 +_ACEOF + + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + fi + + { echo "$as_me:$LINENO: checking if alignment restrictions are strictly enforced" >&5 echo $ECHO_N "checking if alignment restrictions are strictly enforced... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then @@ -51926,7 +52413,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by HDF5 $as_me 1.9.36, which was +This file was extended by HDF5 $as_me 1.9.39, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -51979,7 +52466,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -HDF5 config.status 1.9.36 +HDF5 config.status 1.9.39 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" @@ -53413,7 +53900,16 @@ echo "$as_me: executing $ac_file commands" >&6;} cp libhdf5.settings.TMP src/libhdf5.settings rm -f libhdf5.settings.TMP ;; - "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + "depfiles":C) test x"$AMDEP_TRUE" != x"" || # Autoconf 2.62 quotes --file arguments for eval, but not when files +# are listed without --file. Let's play safe and only enable the eval +# if we detect the quoting. +case $CONFIG_FILES in +*\'*) eval set x "$CONFIG_FILES" ;; +*) set x $CONFIG_FILES ;; +esac +shift +for mf +do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. diff --git a/configure.in b/configure.in index 0fa7a1a..47d167f 100644 --- a/configure.in +++ b/configure.in @@ -26,7 +26,7 @@ dnl dnl NOTE: Don't forget to change the version number here when we do a dnl release!!! dnl -AC_INIT([HDF5], [1.9.36], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.9.39], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AM_CONFIG_HEADER([src/H5config.h]) @@ -1306,6 +1306,7 @@ AC_C_BIGENDIAN AC_CHECK_SIZEOF([char], [1]) AC_CHECK_SIZEOF([short], [2]) AC_CHECK_SIZEOF([int], [4]) +AC_CHECK_SIZEOF([unsigned], [4]) AC_CHECK_SIZEOF([long], [4]) AC_CHECK_SIZEOF([long long], [8]) AC_CHECK_SIZEOF([__int64], [8]) @@ -3796,6 +3797,25 @@ esac dnl ---------------------------------------------------------------------- +dnl Enable embedded library information +dnl +AC_MSG_CHECKING([Whether to have library information embedded in the executables]) +AC_ARG_ENABLE([embedded-libinfo], + [AC_HELP_STRING([--enable-embedded-libinfo], + [Enable embedded library information [default=yes]])], + [enable_embedded_libinfo=$enableval], + [enable_embedded_libinfo=yes]) + + if test "${enable_embedded_libinfo}" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_EMBEDDED_LIBINFO], [1], + [Define if library information should be embedded in the executables]) + else + AC_MSG_RESULT([no]) + fi + + +dnl ---------------------------------------------------------------------- dnl Check if pointer alignments are enforced dnl AC_MSG_CHECKING([if alignment restrictions are strictly enforced]) diff --git a/examples/Makefile.in b/examples/Makefile.in index fa4bf0e..57c7208 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -374,8 +374,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ diff --git a/examples/h5_shared_mesg.c b/examples/h5_shared_mesg.c index a2edb38..0c7f2f0 100644 --- a/examples/h5_shared_mesg.c +++ b/examples/h5_shared_mesg.c @@ -261,9 +261,9 @@ create_standard_file(const char *filename, hid_t fcpl_id) * disk, so this type will be an array type rather than an atomic type. * However, any type can be shared. */ - temp_type_id = H5Tarray_create2(H5T_NATIVE_INT, 10, dims); + temp_type_id = H5Tarray_create2(H5T_NATIVE_INT, 2, dims); if(temp_type_id < 0) goto error; - type_id = H5Tarray_create2(temp_type_id, 10, dims); + type_id = H5Tarray_create2(temp_type_id, 2, dims); if(type_id < 0) goto error; ret = H5Tclose(temp_type_id); if(ret < 0) goto error; diff --git a/examples/testh5cc.sh.in b/examples/testh5cc.sh.in index cf70c18..07c84ef 100755 --- a/examples/testh5cc.sh.in +++ b/examples/testh5cc.sh.in @@ -25,8 +25,8 @@ # Where the tool is installed. prefix="${prefix:-@prefix@}" PARALLEL=@PARALLEL@ # Am I in parallel mode? -AR=@AR@ -RANLIB=@RANLIB@ +AR="@AR@" +RANLIB="@RANLIB@" if [ "$PARALLEL" = no ]; then H5TOOL="h5cc" # The tool name else diff --git a/fortran/Makefile.in b/fortran/Makefile.in index b9678f5..adf9381 100644 --- a/fortran/Makefile.in +++ b/fortran/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -356,8 +356,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -463,7 +463,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/fortran/examples/Makefile.in b/fortran/examples/Makefile.in index 8702ab3..4baa6d4 100644 --- a/fortran/examples/Makefile.in +++ b/fortran/examples/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -375,8 +375,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ diff --git a/fortran/examples/testh5fc.sh.in b/fortran/examples/testh5fc.sh.in index 9f2d9bf..a25abbe 100755 --- a/fortran/examples/testh5fc.sh.in +++ b/fortran/examples/testh5fc.sh.in @@ -23,8 +23,8 @@ # Where the tool is installed. prefix="${prefix:-@prefix@}" PARALLEL=@PARALLEL@ # Am I in parallel mode? -AR=@AR@ -RANLIB=@RANLIB@ +AR="@AR@" +RANLIB="@RANLIB@" if [ "$PARALLEL" = no ]; then H5TOOL="h5fc" # The tool name else diff --git a/fortran/src/H5Df.c b/fortran/src/H5Df.c index 58f3ce2..a7c6e75 100644 --- a/fortran/src/H5Df.c +++ b/fortran/src/H5Df.c @@ -1992,4 +1992,32 @@ nh5dcreate_anon_c (hid_t_f *loc_id, hid_t_f *type_id, hid_t_f *space_id, return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5dget_access_plist_c + * Purpose: Call H5Dget_access_plist + * Inputs: + * dset_id - dataset identifier + * Outputs: + * plist_id - the dataset access property list identifier. + * + * Returns: 0 on success, -1 on failure + * Programmer: M.S. Breitenfeld + * April 13, 2009 + *---------------------------------------------------------------------------*/ +int_f +nh5dget_access_plist_c (hid_t_f *dset_id, hid_t_f *plist_id) +{ + int ret_value = -1; + /* + * Call H5Dget_access_plist function. + */ + if((*plist_id = (hid_t_f)H5Dget_access_plist((hid_t)*dset_id)) < 0) + goto DONE; + + ret_value = 0; + + DONE: + return ret_value; +} + diff --git a/fortran/src/H5Dff.f90 b/fortran/src/H5Dff.f90 index b170408..f06f5a5 100644 --- a/fortran/src/H5Dff.f90 +++ b/fortran/src/H5Dff.f90 @@ -220,7 +220,7 @@ CONTAINS ! port). February 28, 2001 ! ! -Added 1.8 (optional) parameter dapl_id -! February, 2008, M.S. Breitenfeld +! February, 2008, M. Scot Breitenfeld ! ! Comment: !---------------------------------------------------------------------- @@ -4276,7 +4276,7 @@ CONTAINS ! dcpl_id - Dataset creation property list identifier. ! dapl_id - Dataset access property list identifier. ! -! Programmer: M.S. Breitenfeld +! Programmer: M. Scot Breitenfeld ! February 11, 2008 ! ! Modifications: @@ -4325,6 +4325,48 @@ CONTAINS END SUBROUTINE h5dcreate_anon_f +!---------------------------------------------------------------------- +! Name: h5dget_access_plist_f +! +! Purpose: Returns a copy of the dataset creation property list. +! +! Inputs: +! dset_id - dataset identifier. +! Outputs: +! plist_id - the dataset access property list identifier. +! hdferr: - error code +! Success: 0 +! Failure: -1 +! +! Programmer: M. Scot Breitenfeld +! April 13, 2009 +! +! Modifications: +! +! Comment: +!---------------------------------------------------------------------- + + SUBROUTINE h5dget_access_plist_f(dset_id, plist_id, hdferr) + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN) :: dset_id + INTEGER(HID_T), INTENT(OUT) :: plist_id + INTEGER, INTENT(OUT) :: hdferr ! Error code. + + INTERFACE + INTEGER FUNCTION h5dget_access_plist_c(dset_id, plist_id) + USE H5GLOBAL + !DEC$IF DEFINED(HDF5F90_WINDOWS) + !DEC$ATTRIBUTES C,reference,decorate,alias:'H5DGET_ACCESS_PLIST_C'::h5dget_access_plist_c + !DEC$ENDIF + INTEGER(HID_T), INTENT(IN) :: dset_id + INTEGER(HID_T), INTENT(OUT) :: plist_id + END FUNCTION h5dget_access_plist_c + END INTERFACE + + hdferr = h5dget_access_plist_c(dset_id, plist_id) + + END SUBROUTINE h5dget_access_plist_f + END MODULE H5D diff --git a/fortran/src/H5If.c b/fortran/src/H5If.c index 5368861..e8b54f0 100644 --- a/fortran/src/H5If.c +++ b/fortran/src/H5If.c @@ -211,3 +211,33 @@ nh5iget_file_id_c(hid_t_f *obj_id, hid_t_f *file_id) done: return ret_value; } + +/*---------------------------------------------------------------------------- + * Name: h5iis_valid_c + * Purpose: Calls H5Iis_valid + * Inputs: obj_id - object identifier + * Outputs: 0 = false, 1 = true + * Returns: 0 on success, -1 on failure + * Programmer: Elena Pourmal + * Tuesday, August 24, 2004 + * Modifications: + *---------------------------------------------------------------------------*/ +int_f +nh5iis_valid_c(hid_t_f *obj_id, int_f *c_valid) +{ + int ret_value; + htri_t c_ret_value; + + /* + * Call H5Iis_valid + */ + if ((c_ret_value = H5Iis_valid(*obj_id)) < 0) + HGOTO_DONE(FAIL); + + /* Set output & return values */ + *c_valid = (int_f)c_ret_value; + ret_value=0; + +done: + return ret_value; +} diff --git a/fortran/src/H5Iff.f90 b/fortran/src/H5Iff.f90 index 0b70f8b..83587ce 100644 --- a/fortran/src/H5Iff.f90 +++ b/fortran/src/H5Iff.f90 @@ -306,5 +306,47 @@ hdferr = h5iget_file_id_c(obj_id, file_id) END SUBROUTINE h5iget_file_id_f +!---------------------------------------------------------------------- +! Name: H5Iis_valid_f +! +! Purpose: Check if an ID is valid without producing an error message +! +! Inputs: id - identifier +! Outputs: +! valid - status of id as a valid identifier +! hdferr: - error code +! Success: 0 +! Failure: -1 +! Programmer: M. Scot Breitenfeld +! April 13, 2009 +! +! Comment: +!---------------------------------------------------------------------- + SUBROUTINE h5iis_valid_f(id, valid, hdferr) + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN) :: id ! Identifier + LOGICAL, INTENT(OUT) :: valid ! Status of id as a valid identifier + INTEGER, INTENT(OUT) :: hdferr ! Error code + INTEGER :: c_valid ! 0 = .false, 1 = .true. + + INTERFACE + INTEGER FUNCTION h5iis_valid_c(id, c_valid) + USE H5GLOBAL + !DEC$IF DEFINED(HDF5F90_WINDOWS) + !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IIS_VALID_C':: h5iis_valid_c + !DEC$ENDIF + INTEGER(HID_T), INTENT(IN) :: id ! Identifier + INTEGER :: c_valid + END FUNCTION h5iis_valid_c + END INTERFACE + + hdferr = h5iis_valid_c(id, c_valid) + + valid = .FALSE. ! Default + IF(c_valid.EQ.1) valid = .TRUE. + + END SUBROUTINE h5iis_valid_f + + END MODULE H5I diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index ef38b31..95616db 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -4439,3 +4439,70 @@ nh5pget_create_inter_group_c(hid_t_f *lcpl_id, int_f *crt_intermed_group) ret_value = 0; return ret_value; } + +/*---------------------------------------------------------------------------- + * Name: h5pset_chunk_cache_c + * Purpose: Calls H5Pset_chunk_cache + * + * Inputs: dapl_id - Link creation property list identifier + * rdcc_nslots - + * rdcc_nbytes - + * rdcc_w0 - + * + * Returns: 0 on success, -1 on failure + * Programmer: M.S. Breitenfeld + * April 13, 2009 + * Modifications: + *---------------------------------------------------------------------------*/ + +int_f +nh5pset_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, size_t_f *rdcc_nbytes, real_f *rdcc_w0) +{ + int ret_value = -1; + + /* + * Call H5Pset_chunk_cache function. + */ + if( (H5Pset_chunk_cache((hid_t)*dapl_id, (size_t)*rdcc_nslots, (size_t)*rdcc_nbytes, (double)*rdcc_w0)) <0 ) + return ret_value; /* error occurred */ + + ret_value = 0; + return ret_value; +} + +/*---------------------------------------------------------------------------- + * Name: h5pget_chunk_cache_c + * Purpose: Calls H5Pget_chunk_cache + * + * Inputs: dapl_id - Link creation property list identifier + * Outputs: + * rdcc_nslots - + * rdcc_nbytes - + * rdcc_w0 - + * + * Returns: 0 on success, -1 on failure + * Programmer: M.S. Breitenfeld + * April 13, 2009 + * Modifications: + *---------------------------------------------------------------------------*/ + +int_f +nh5pget_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, size_t_f *rdcc_nbytes, real_f *rdcc_w0) +{ + int ret_value = -1; + size_t c_rdcc_nslots; + size_t c_rdcc_nbytes; + double c_rdcc_w0; + /* + * Call H5Pget_chunk_cache function. + */ + if( (H5Pget_chunk_cache((hid_t)*dapl_id, &c_rdcc_nslots, &c_rdcc_nbytes, &c_rdcc_w0)) <0 ) + return ret_value; /* error occurred */ + + *rdcc_nslots=(size_t_f)c_rdcc_nslots; + *rdcc_nbytes=(size_t_f)c_rdcc_nbytes; + *rdcc_w0=(real_f)c_rdcc_w0; + + ret_value = 0; + return ret_value; +} diff --git a/fortran/src/H5Pff.f90 b/fortran/src/H5Pff.f90 index 9d4ef67..c35c383 100644 --- a/fortran/src/H5Pff.f90 +++ b/fortran/src/H5Pff.f90 @@ -7034,6 +7034,124 @@ END SUBROUTINE h5pget_create_inter_group_f +!---------------------------------------------------------------------- +! Name: H5Pset_chunk_cache_f +! +! Purpose: Set the number of objects in the meta data cache and the +! maximum number of chunks and bytes in the raw data chunk cache. +! Once set, these values will override the values in the file access +! property list. Each of these values can be individually unset +! (or not set at all) by passing the macros: +! H5D_CHUNK_CACHE_NSLOTS_DFLT_F, +! H5D_CHUNK_CACHE_NBYTES_DFLT_F, and/or +! H5D_CHUNK_CACHE_W0_DFLT_F +! as appropriate. +! +! The RDCC_W0 value should be between 0 and 1 inclusive and +! indicates how much chunks that have been fully read or fully +! written are favored for preemption. A value of zero means +! fully read or written chunks are treated no differently than +! other chunks (the preemption is strictly LRU) while a value +! of one means fully read chunks are always preempted before +! other chunks. +! +! Inputs: +! dapl_id - Link creation property list identifier +! rdcc_nslots - +! rdcc_nbytes - +! rdcc_w0 - +! Outputs: +! hdferr: - error code +! Success: 0 +! Failure: -1 +! Optional parameters: +! NONE +! +! Programmer: M.S. Breitenfeld +! April 13, 2009 +! +! Modifications: +!-------------------------------------------------------------------------------------- + + SUBROUTINE h5pset_chunk_cache_f(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0, hdferr) + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN) :: dapl_id + INTEGER(SIZE_T), INTENT(IN) :: rdcc_nslots + INTEGER(SIZE_T), INTENT(IN) :: rdcc_nbytes + REAL, INTENT(IN) :: rdcc_w0 + INTEGER, INTENT(OUT) :: hdferr + + + INTERFACE + INTEGER FUNCTION h5pset_chunk_cache_c(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0) + USE H5GLOBAL + !DEC$IF DEFINED(HDF5F90_WINDOWS) + !DEC$ATTRIBUTES C,reference,decorate,alias:'H5PSET_CHUNK_CACHE_C'::h5pset_chunk_cache_c + !DEC$ENDIF + INTEGER(HID_T), INTENT(IN) :: dapl_id + INTEGER(SIZE_T), INTENT(IN) :: rdcc_nslots + INTEGER(SIZE_T), INTENT(IN) :: rdcc_nbytes + REAL, INTENT(IN) :: rdcc_w0 + END FUNCTION h5pset_chunk_cache_c + END INTERFACE + + hdferr = h5pset_chunk_cache_c(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0) + + END SUBROUTINE h5pset_chunk_cache_f + +!---------------------------------------------------------------------- +! Name: H5Pget_chunk_cache_f +! +! Purpose: Retrieves the maximum possible number of elements in the meta +! data cache and the maximum possible number of elements and +! bytes and the RDCC_W0 value in the raw data chunk cache. Any +! (or all) arguments may be null pointers in which case the +! corresponding datum is not returned. If these properties have +! not been set on this property list, the default values for a +! file access property list are returned. +! +! Inputs: +! dapl_id - Link creation property list identifier +! rdcc_nslots - +! rdcc_nbytes - +! rdcc_w0 - +! Outputs: +! hdferr: - error code +! Success: 0 +! Failure: -1 +! Optional parameters: +! NONE +! +! Programmer: M.S. Breitenfeld +! April 13, 2009 +! +! Modifications: +!-------------------------------------------------------------------------------------- + + SUBROUTINE h5pget_chunk_cache_f(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0, hdferr) + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN) :: dapl_id + INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nslots + INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nbytes + REAL, INTENT(OUT) :: rdcc_w0 + INTEGER, INTENT(OUT) :: hdferr + + INTERFACE + INTEGER FUNCTION h5pget_chunk_cache_c(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0) + USE H5GLOBAL + !DEC$IF DEFINED(HDF5F90_WINDOWS) + !DEC$ATTRIBUTES C,reference,decorate,alias:'H5PGET_CHUNK_CACHE_C'::h5pget_chunk_cache_c + !DEC$ENDIF + INTEGER(HID_T), INTENT(IN) :: dapl_id + INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nslots + INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nbytes + REAL, INTENT(OUT) :: rdcc_w0 + END FUNCTION h5pget_chunk_cache_c + END INTERFACE + + hdferr = h5pget_chunk_cache_c(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0) + + END SUBROUTINE h5pget_chunk_cache_f END MODULE H5P diff --git a/fortran/src/H5Sff.f90 b/fortran/src/H5Sff.f90 index 35b18a6..7cabb00 100644 --- a/fortran/src/H5Sff.f90 +++ b/fortran/src/H5Sff.f90 @@ -570,7 +570,7 @@ ! coord(rank, num_elements) INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HSIZE_T), ALLOCATABLE, DIMENSION(:,:) :: c_coord - INTEGER :: error, i,j + INTEGER :: error, i INTERFACE INTEGER FUNCTION h5sselect_elements_c(space_id, OPERATOR,& diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index d7bb3d8..a8b2d95 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -338,6 +338,9 @@ nh5init_flags_c( int_f *h5d_flags, int_f *h5f_flags, h5d_flags[16] = (int_f)H5D_FILL_VALUE_UNDEFINED; h5d_flags[17] = (int_f)H5D_FILL_VALUE_DEFAULT; h5d_flags[18] = (int_f)H5D_FILL_VALUE_USER_DEFINED; + h5d_flags[19] = (int_f)H5D_CHUNK_CACHE_NSLOTS_DEFAULT; + h5d_flags[20] = (int_f)H5D_CHUNK_CACHE_NBYTES_DEFAULT; + h5d_flags[21] = (int_f)H5D_CHUNK_CACHE_W0_DEFAULT; /* * H5F flags diff --git a/fortran/src/H5f90global.f90 b/fortran/src/H5f90global.f90 index 2d50f4f..e037d12 100644 --- a/fortran/src/H5f90global.f90 +++ b/fortran/src/H5f90global.f90 @@ -317,7 +317,7 @@ MODULE H5GLOBAL ! H5D flags declaration ! - INTEGER, PARAMETER :: H5D_FLAGS_LEN = 19 + INTEGER, PARAMETER :: H5D_FLAGS_LEN = 22 INTEGER H5D_flags(H5D_FLAGS_LEN) !DEC$if defined(BUILD_HDF5_DLL) !DEC$ATTRIBUTES DLLEXPORT :: /H5D_FLAGS/ @@ -348,6 +348,13 @@ MODULE H5GLOBAL INTEGER :: H5D_FILL_VALUE_DEFAULT_F INTEGER :: H5D_FILL_VALUE_USER_DEFINED_F +! shortened "_DEFAULT" to "_DFLT" to satisfy the limit of 31 +! characters for variable names in Fortran. + + INTEGER :: H5D_CHUNK_CACHE_NSLOTS_DFLT_F + INTEGER :: H5D_CHUNK_CACHE_NBYTES_DFLT_F + INTEGER :: H5D_CHUNK_CACHE_W0_DFLT_F + EQUIVALENCE(H5D_flags(1), H5D_COMPACT_F) EQUIVALENCE(H5D_flags(2), H5D_CONTIGUOUS_F) EQUIVALENCE(H5D_flags(3), H5D_CHUNKED_F) @@ -370,7 +377,11 @@ MODULE H5GLOBAL EQUIVALENCE(H5D_flags(16), H5D_FILL_VALUE_ERROR_F) EQUIVALENCE(H5D_flags(17), H5D_FILL_VALUE_UNDEFINED_F) EQUIVALENCE(H5D_flags(18), H5D_FILL_VALUE_DEFAULT_F) - EQUIVALENCE(H5D_flags(19), H5D_FILL_VALUE_USER_DEFINED_F) + EQUIVALENCE(H5D_flags(19), H5D_FILL_VALUE_USER_DEFINED_F) + + EQUIVALENCE(H5D_flags(20), H5D_CHUNK_CACHE_NSLOTS_DFLT_F) + EQUIVALENCE(H5D_flags(21), H5D_CHUNK_CACHE_NBYTES_DFLT_F) + EQUIVALENCE(H5D_flags(22), H5D_CHUNK_CACHE_W0_DFLT_F) ! ! H5FD flags declaration diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index b29af89..15dc41d 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -229,6 +229,7 @@ H5_FCDLL int_f nh5sextent_equal_c ( hid_t_f * space1_id, hid_t_f *space2_id, hid # define nh5dfill_double_c H5_FC_FUNC_(h5dfill_double_c, H5DFILL_DOUBLE_C) # define nh5dget_space_status_c H5_FC_FUNC_(h5dget_space_status_c, H5DGET_SPACE_STATUS_C) # define nh5dcreate_anon_c H5_FC_FUNC_(h5dcreate_anon_c, H5DCREATE_ANON_C) +# define nh5dget_access_plist_c H5_FC_FUNC_(h5dget_access_plist_c, H5DGET_ACCESS_PLIST_C) H5_FCDLL int_f nh5dcreate_c (hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *type_id, hid_t_f *space_id, @@ -325,6 +326,8 @@ H5_FCDLL int_f nh5dreadc_4_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *m H5_FCDLL int_f nh5dreadc_5_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims); H5_FCDLL int_f nh5dreadc_6_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims); H5_FCDLL int_f nh5dreadc_7_c (hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims); +H5_FCDLL int_f nh5dget_access_plist_c (hid_t_f *dset_id, hid_t_f *plist_id); + H5_FCDLL int_f nh5dget_space_c ( hid_t_f *dset_id , hid_t_f *space_id); H5_FCDLL int_f nh5dget_type_c ( hid_t_f *dset_id , hid_t_f *type_id); @@ -900,6 +903,8 @@ H5_FCDLL int_f nh5olink_c (hid_t_f *object_id, hid_t_f *new_loc_id, _fcd name, s # define nh5pset_scaleoffset_c H5_FC_FUNC_(h5pset_scaleoffset_c, H5PSET_SCALEOFFSET_C) # define nh5pset_nlinks_c H5_FC_FUNC_(h5pset_nlinks_c, H5PSET_NLINKS_C) # define nh5pget_nlinks_c H5_FC_FUNC_(h5pget_nlinks_c, H5PGET_NLINKS_C) +# define nh5pset_chunk_cache_c H5_FC_FUNC_(h5pset_chunk_cache_c, H5PSET_CHUNK_CACHE_C) +# define nh5pget_chunk_cache_c H5_FC_FUNC_(h5pget_chunk_cache_c, H5PGET_CHUNK_CACHE_C) H5_FCDLL int_f nh5pcreate_c ( hid_t_f *class, hid_t_f *prp_id ); H5_FCDLL int_f nh5pclose_c ( hid_t_f *prp_id ); @@ -1056,6 +1061,8 @@ H5_FCDLL int_f nh5pset_nbit_c(hid_t_f *plist_id ); H5_FCDLL int_f nh5pset_scaleoffset_c(hid_t_f *plist_id, int_f *scale_type, int_f *scale_factor ); H5_FCDLL int_f nh5pset_nlinks_c(hid_t_f *lapl_id, size_t_f *nlinks); H5_FCDLL int_f nh5pget_nlinks_c(hid_t_f *lapl_id, size_t_f *nlinks); +H5_FCDLL int_f nh5pset_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, size_t_f *rdcc_nbytes, real_f *rdcc_w0); +H5_FCDLL int_f nh5pget_chunk_cache_c(hid_t_f *dapl_id, size_t_f *rdcc_nslots, size_t_f *rdcc_nbytes, real_f *rdcc_w0); /* * Functions frome H5Rf.c */ @@ -1086,6 +1093,7 @@ H5_FCDLL int_f nh5rget_name_region_c (hid_t_f *loc_id, int_f *ref, _fcd name, si # define nh5idec_ref_c H5_FC_FUNC_(h5idec_ref_c, H5IDEC_REF_C) # define nh5iget_ref_c H5_FC_FUNC_(h5iget_ref_c, H5IGET_REF_C) # define nh5iget_file_id_c H5_FC_FUNC_(h5iget_file_id_c, H5IGET_FILE_ID_C) +# define nh5iis_valid_c H5_FC_FUNC_(h5iis_valid_c, H5IIS_VALID_C) H5_FCDLL int_f nh5iget_type_c(hid_t_f *obj_id, int_f *type); H5_FCDLL int_f nh5iget_name_c(hid_t_f *obj_id, _fcd buf, size_t_f *buf_size, size_t_f *name_size); @@ -1093,6 +1101,7 @@ H5_FCDLL int_f nh5iinc_ref_c(hid_t_f *obj_id, int_f *ref_count); H5_FCDLL int_f nh5idec_ref_c(hid_t_f *obj_id, int_f *ref_count); H5_FCDLL int_f nh5iget_ref_c(hid_t_f *obj_id, int_f *ref_count); H5_FCDLL int_f nh5iget_file_id_c(hid_t_f *obj_id, hid_t_f *file_id); +H5_FCDLL int_f nh5iis_valid_c(hid_t_f *obj_id, int_f *c_valid); /* * Functions from H5Ef.c diff --git a/fortran/src/Makefile.am b/fortran/src/Makefile.am index 6275545..3a9c3f2 100644 --- a/fortran/src/Makefile.am +++ b/fortran/src/Makefile.am @@ -19,6 +19,7 @@ # include $(top_srcdir)/config/commence.am +include $(top_srcdir)/config/lt_vers.am # Include src directory in both Fortran and C flags (C compiler is used # for linking). @@ -30,6 +31,9 @@ AM_FCLIBS=$(LIBHDF5) # This is our main target, the fortran library lib_LTLIBRARIES=libhdf5_fortran.la +# Add libtool numbers to the HDF5 Fortran library (from config/lt_vers.am) +libhdf5_fortran_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Some Fortran compilers can't build shared libraries, so sometimes we # want to build a shared C library and a static Fortran library. If so, # pass the -static flag to the library linker. diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in index a61d929..5b80fa0 100644 --- a/fortran/src/Makefile.in +++ b/fortran/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -52,7 +52,8 @@ build_triplet = @build@ host_triplet = @host@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/h5fc.in $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am + $(top_srcdir)/config/conclude.am \ + $(top_srcdir)/config/lt_vers.am noinst_PROGRAMS = H5match_types$(EXEEXT) H5fortran_detect$(EXEEXT) \ H5test_kind$(EXEEXT) TESTS = @@ -91,6 +92,9 @@ am_libhdf5_fortran_la_OBJECTS = H5f90global.lo H5fortran_types.lo \ H5Df.lo H5Ef.lo H5Ff.lo H5Gf.lo H5If.lo H5Lf.lo H5Of.lo \ H5Pf.lo H5Rf.lo H5Sf.lo H5Tf.lo H5Zf.lo $(am__objects_1) libhdf5_fortran_la_OBJECTS = $(am_libhdf5_fortran_la_OBJECTS) +libhdf5_fortran_la_LINK = $(LIBTOOL) $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(FCLD) $(AM_FCFLAGS) $(FCFLAGS) \ + $(libhdf5_fortran_la_LDFLAGS) $(LDFLAGS) -o $@ PROGRAMS = $(noinst_PROGRAMS) am_H5fortran_detect_OBJECTS = H5fortran_detect.$(OBJEXT) H5fortran_detect_OBJECTS = $(am_H5fortran_detect_OBJECTS) @@ -382,6 +386,12 @@ TRACE = perl $(top_srcdir)/bin/trace # *.clog are from the MPE option. CHECK_CLEANFILES = *.chkexe *.chklog *.clog +# Add libtool shared library version numbers to the HDF5 library +# See libtool versioning documentation online. +LT_VERS_INTERFACE = 6 +LT_VERS_REVISION = 29 +LT_VERS_AGE = 0 + # Include src directory in both Fortran and C flags (C compiler is used # for linking). INCLUDES = -I$(top_srcdir)/src @@ -391,6 +401,9 @@ AM_FCLIBS = $(LIBHDF5) # This is our main target, the fortran library lib_LTLIBRARIES = libhdf5_fortran.la +# Add libtool numbers to the HDF5 Fortran library (from config/lt_vers.am) +libhdf5_fortran_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Some Fortran compilers can't build shared libraries, so sometimes we # want to build a shared C library and a static Fortran library. If so, # pass the -static flag to the library linker. @@ -472,12 +485,12 @@ all: $(BUILT_SOURCES) .SUFFIXES: .SUFFIXES: .c .f90 .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/lt_vers.am $(top_srcdir)/config/conclude.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -531,7 +544,7 @@ clean-libLTLIBRARIES: rm -f "$${dir}/so_locations"; \ done libhdf5_fortran.la: $(libhdf5_fortran_la_OBJECTS) $(libhdf5_fortran_la_DEPENDENCIES) - $(FCLINK) -rpath $(libdir) $(libhdf5_fortran_la_OBJECTS) $(libhdf5_fortran_la_LIBADD) $(LIBS) + $(libhdf5_fortran_la_LINK) -rpath $(libdir) $(libhdf5_fortran_la_OBJECTS) $(libhdf5_fortran_la_LIBADD) $(LIBS) clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; for p in $$list; do \ @@ -626,7 +639,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -822,6 +835,19 @@ uninstall-am: uninstall-libLTLIBRARIES uninstall-local help: @$(top_srcdir)/bin/makehelp +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. + # Fortran module files can have different extensions and different names # (e.g., different capitalizations) on different platforms. Write rules # for them explicitly rather than trying to teach automake about them. diff --git a/fortran/src/hdf5_fortrandll.def b/fortran/src/hdf5_fortrandll.def index 501570b..057dc13 100644 --- a/fortran/src/hdf5_fortrandll.def +++ b/fortran/src/hdf5_fortrandll.def @@ -199,6 +199,7 @@ H5D_mp_H5DSET_EXTENT_F H5D_mp_H5DGET_CREATE_PLIST_F H5D_mp_H5DGET_STORAGE_SIZE_F H5D_mp_H5DVLEN_GET_MAX_LEN_F +H5D_mp_H5DGET_ACCESS_PLIST_F ; H5E H5E_mp_H5ECLEAR_F H5E_mp_H5EPRINT_F @@ -268,6 +269,7 @@ H5I_mp_H5IINC_REF_F H5I_mp_H5IDEC_REF_F H5I_mp_H5IGET_REF_F H5I_mp_H5IGET_FILE_ID_F +H5I_mp_H5IIS_VALID_F ; H5L H5L_mp_H5LCOPY_F H5L_mp_H5LDELETE_F @@ -418,6 +420,8 @@ H5P_mp_H5PSET_SCALEOFFSET_F H5P_mp_H5PSET_NLINKS_F H5P_mp_H5PGET_NLINKS_F H5P_mp_H5PGET_CREATE_INTER_GROUP_F +H5P_mp_H5PSET_CHUNK_CACHE_F +H5P_mp_H5PGET_CHUNK_CACHE_F ; H5R H5R_mp_H5RCREATE_OBJECT_F H5R_mp_H5RCREATE_REGION_F diff --git a/fortran/test/Makefile.in b/fortran/test/Makefile.in index 185db9b..f23efc4 100644 --- a/fortran/test/Makefile.in +++ b/fortran/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -442,8 +442,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -631,7 +631,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/fortran/test/fortranlib_test.f90 b/fortran/test/fortranlib_test.f90 index bbc6a25..742e98b 100644 --- a/fortran/test/fortranlib_test.f90 +++ b/fortran/test/fortranlib_test.f90 @@ -176,6 +176,9 @@ PROGRAM fortranlibtest CALL multi_file_test(cleanup, ret_total_error) CALL write_test_status(ret_total_error, ' Multi file driver test', total_error) + CALL test_chunk_cache (cleanup, ret_total_error) + CALL write_test_status(ret_total_error, ' Dataset chunk cache configuration', total_error) + ! write(*,*) ! write(*,*) '=========================================' ! write(*,*) 'Testing ATTRIBUTE interface ' @@ -240,5 +243,3 @@ PROGRAM fortranlibtest IF (total_error .NE. 0) CALL h5_exit_f (1) END PROGRAM fortranlibtest - - diff --git a/fortran/test/fortranlib_test_1_8.f90 b/fortran/test/fortranlib_test_1_8.f90 index 49835b0..6158c16 100644 --- a/fortran/test/fortranlib_test_1_8.f90 +++ b/fortran/test/fortranlib_test_1_8.f90 @@ -92,6 +92,8 @@ PROGRAM fortranlibtest ' Testing dataspace encoding and decoding', & total_error) + + ! CALL test_hard_query(group_total_error) WRITE(*,*) diff --git a/fortran/test/tH5I.f90 b/fortran/test/tH5I.f90 index 1ef7ba2..c34bd09 100644 --- a/fortran/test/tH5I.f90 +++ b/fortran/test/tH5I.f90 @@ -60,6 +60,30 @@ INTEGER :: ref_count ! Reference count for IDs + INTEGER(hid_t) :: dtype ! datatype id + LOGICAL :: tri_ret ! value + + ! + ! Tests the function H5Iis_valid_f + ! + ! check that the ID is not valid + dtype = -1 + CALL H5Iis_valid_f(dtype, tri_ret, error) + CALL check("H5Iis_valid_f", error, total_error) + CALL VerifyLogical("H5Iis_valid_f", tri_ret, .FALSE., total_error) + + ! Create a datatype id + CALL H5Tcopy_f(H5T_NATIVE_INTEGER,dtype,error) + CALL check("H5Tcopy_f", error, total_error) + + ! Check that the ID is valid + CALL H5Iis_valid_f(dtype, tri_ret, error) + CALL check("H5Iis_valid_f", error, total_error) + CALL VerifyLogical("H5Tequal_f", tri_ret, .TRUE., total_error) + + CALL H5Tclose_f(dtype, error) + CALL check("H5Tclose_f", error, total_error) + ! ! Create a new file using default properties. ! diff --git a/fortran/test/tH5P.f90 b/fortran/test/tH5P.f90 index 7e6c8de..3063842 100644 --- a/fortran/test/tH5P.f90 +++ b/fortran/test/tH5P.f90 @@ -49,8 +49,6 @@ buf_size = 4*1024*1024 - - ! !Create file "external.h5" using default properties. ! @@ -395,3 +393,276 @@ RETURN END SUBROUTINE multi_file_test + +!------------------------------------------------------------------------- +! Function: test_chunk_cache +! +! Purpose: Tests APIs: +! H5P_H5PSET_CHUNK_CACHE_F +! H5P_H5PGET_CHUNK_CACHE_F +! H5D_H5DGET_ACCESS_PLIST_F +! +! Return: Success: 0 +! Failure: -1 +! +! C Programmer: Neil Fortner +! Wednesday, October 29, 2008 +! +! FORTRAN Programmer: M. Scot Breitenfeld +! April 16, 2009 +!------------------------------------------------------------------------- +! +SUBROUTINE test_chunk_cache(cleanup, total_error) + + USE HDF5 ! This module contains all necessary modules + + IMPLICIT NONE + LOGICAL, INTENT(IN) :: cleanup + INTEGER, INTENT(OUT) :: total_error + + CHARACTER(LEN=14), PARAMETER :: filename="chunk_cache" + CHARACTER(LEN=80) :: fix_filename + INTEGER(hid_t) :: fid = -1 ! /* File ID */ + INTEGER(hid_t) :: file + INTEGER(hid_t) :: fapl_local = -1 ! /* Local fapl */ + INTEGER(hid_t) :: fapl_def = -1 ! /* Default fapl */ + INTEGER(hid_t) :: dcpl = -1 !/* Dataset creation property list ID */ + INTEGER(hid_t) :: dapl1 = -1 !/* Dataset access property list ID */ + INTEGER(hid_t) :: dapl2 = -1 !/* Dataset access property list ID */ + INTEGER(hid_t) :: sid = -1 !/* Dataspace ID */ + INTEGER(hid_t) :: dsid = -1 !/* Dataset ID */ + INTEGER(hsize_t), DIMENSION(1:1) :: chunk_dim, NDIM = (/100/) !/* Dataset and chunk dimensions */ + INTEGER(size_t) :: nslots_1, nslots_2, nslots_3, nslots_4 !/* rdcc number of elements */ + INTEGER(size_t) :: nbytes_1, nbytes_2, nbytes_3, nbytes_4 !/* rdcc number of bytes */ + INTEGER :: mdc_nelmts + INTEGER(size_t) ::nlinks !/* Number of link traversals */ + REAL :: w0_1, w0_2, w0_3, w0_4; !/* rdcc preemption policy */ + INTEGER :: error + INTEGER(size_t) rdcc_nelmts + INTEGER(size_t) rdcc_nbytes + REAL :: rdcc_w0 + + + CALL h5_fixname_f(filename, fix_filename, H5P_DEFAULT_F, error) + IF (error .NE. 0) THEN + WRITE(*,*) "Cannot modify filename" + STOP + ENDIF + + !/* Create a default fapl and dapl */ + CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl_def, error) + CALL check("H5Pcreate_f", error, total_error) + CALL H5Pcreate_f(H5P_DATASET_ACCESS_F, dapl1, error) + CALL check("H5Pcreate_f", error, total_error) + + ! Verify that H5Pget_chunk_cache(dapl) returns the same values as are in + ! the default fapl. + ! + CALL H5Pget_cache_f(fapl_def, mdc_nelmts, nslots_1, nbytes_1, w0_1, error) + CALL check("H5Pget_cache_f", error, total_error) + CALL H5Pget_chunk_cache_f(dapl1, nslots_4, nbytes_4, w0_4, error) + CALL check("H5Pget_chunk_cache_f", error, total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nslots_1), INT(nslots_4), total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nbytes_1), INT(nbytes_4), total_error) + IF(w0_1.NE.w0_4)THEN + CALL VERIFYlogical("H5Pget_chunk_cache_f", .TRUE., .FALSE., total_error) + ENDIF + + ! /* Set a lapl property on dapl1 (to verify inheritance) */ + CALL H5Pset_nlinks_f(dapl1, 134_size_t , error) + CALL check("H5Pset_nlinks_f", error, total_error) + CALL H5Pget_nlinks_f(dapl1, nlinks, error) + CALL check("H5Pget_nlinks_f", error, total_error) + CALL VERIFY("H5Pget_nlinks_f", INT(nlinks), 134, total_error) + + + CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl_local, error) + CALL check("h5pcreate_f", error, total_error) + ! Turn off the chunk cache, so all the chunks are immediately written to disk + CALL H5Pget_cache_f(fapl_local, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0, error) + CALL check("H5Pget_cache_f", error, total_error) + rdcc_nbytes = 0; + CALL H5Pset_cache_f(fapl_local, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0, error) + CALL check("H5Pset_cache_f", error, total_error) + + ! Set new rdcc settings on fapl! + nslots_2 = nslots_1 * 2 + nbytes_2 = nbytes_1 * 2 + w0_2 = w0_1 / 2. + + CALL H5Pset_cache_f(fapl_local, 0, nslots_2, nbytes_2, w0_2, error) + CALL check("H5Pset_cache_f", error, total_error) + + !/* Create file */ + CALL H5Fcreate_f(fix_filename, H5F_ACC_TRUNC_F, fid, error, H5P_DEFAULT_F, fapl_local) + CALL check("H5Fcreate_f", error, total_error) + + !/* Create dataset creation property list */ + CALL H5Pcreate_f(H5P_DATASET_CREATE_F, dcpl, error) + CALL check("H5Pcreate_f", error, total_error) + + !/* Set chunking */ + chunk_dim(1) = 10; + CALL H5Pset_chunk_f(dcpl, 1, chunk_dim, error) + CALL check("H5Pset_chunk_f", error, total_error) + + !/* Create 1-D dataspace */ + ndim(1) = 100 + CALL H5Screate_simple_f(1, ndim, sid, error) + CALL check("H5Pcreate_f", error, total_error) + + ! /* Create dataset with default dapl */ + CALL H5Dcreate_f(fid, "dset", H5T_NATIVE_INTEGER, sid, dsid, error, dcpl, H5P_DEFAULT_F, dapl1) + CALL check("H5Pcreate_f", error, total_error) + + ! /* Retrieve dapl from dataset, verify cache values are the same as on fapl_local */ + CALL H5Dget_access_plist_f(dsid, dapl2, error) + CALL check("H5Dget_access_plist_f", error, total_error) + CALL H5Pget_chunk_cache_f(dapl2, nslots_4, nbytes_4, w0_4, error) + CALL check("H5Pget_chunk_cache_f", error, total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nslots_2), INT(nslots_4), total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nbytes_2), INT(nbytes_4), total_error) + IF(w0_2.NE.w0_4)THEN + CALL VERIFYlogical("H5Pget_chunk_cache_f", .TRUE., .FALSE., total_error) + ENDIF + CALL H5Pclose_f(dapl2,error); CALL check("H5Pclose_f", error, total_error) + + ! Set new values on dapl1. nbytes will be set to default, so the file + ! property will override this setting + + nslots_3 = nslots_2 * 2 + nbytes_3 = H5D_CHUNK_CACHE_NBYTES_DFLT_F + w0_3 = w0_2 / 2 + + CALL H5Pset_chunk_cache_f(dapl1, nslots_3, nbytes_3, w0_3, error) + CALL check("H5Pset_chunk_cache_f", error, total_error) + + ! Close dataset, reopen with dapl1. Note the use of a dapl with H5Oopen */ + CALL H5Dclose_f(dsid, error) + CALL H5Oopen_f(fid, "dset", dsid, error, dapl1) + + ! Retrieve dapl from dataset, verfiy cache values are the same as on dapl1 + ! + ! Note we rely on the knowledge that H5Pget_chunk_cache retrieves these + ! values directly from the dataset structure, and not from a copy of the + ! dapl used to open the dataset (which is not preserved). + ! + CALL H5Dget_access_plist_f(dsid, dapl2, error) + CALL check("H5Dget_access_plist_f", error, total_error) + CALL H5Pget_chunk_cache_f(dapl2, nslots_4, nbytes_4, w0_4, error) + CALL check("H5Pget_chunk_cache_f", error, total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nslots_3), INT(nslots_4), total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nbytes_2), INT(nbytes_4), total_error) + IF(w0_3.NE.w0_4)THEN + CALL VERIFYlogical("H5Pget_chunk_cache_f4", .TRUE., .FALSE., total_error) + ENDIF + CALL H5Pclose_f(dapl2,error); CALL check("H5Pclose_f", error, total_error) + + ! Close dataset, reopen with H5P_DEFAULT as dapl + CALL H5Dclose_f(dsid, error); CALL check("H5Dclose_f", error, total_error) + CALL H5Oopen_f(fid, "dset", dsid, error) + CALL check("H5Oopen_f", error, total_error) + + ! Retrieve dapl from dataset, verfiy cache values are the same as on fapl_local + + CALL H5Dget_access_plist_f(dsid, dapl2, error) + CALL check("H5Dget_access_plist_f", error, total_error) + CALL H5Pget_chunk_cache_f(dapl2, nslots_4, nbytes_4, w0_4, error) + CALL check("H5Pget_chunk_cache_f", error, total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nslots_2), INT(nslots_4), total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nbytes_2), INT(nbytes_4), total_error) + IF(w0_2.NE.w0_4)THEN + CALL VERIFYlogical("H5Pget_chunk_cache_f", .TRUE., .FALSE., total_error) + ENDIF + CALL H5Pclose_f(dapl2,error); CALL check("H5Pclose_f", error, total_error) + + ! Similary, test use of H5Dcreate2 with H5P_DEFAULT + CALL H5Dclose_f(dsid, error); CALL check("H5Dclose_f", error, total_error) + + CALL H5Dcreate_f(fid, "dset2", H5T_NATIVE_INTEGER, sid, dsid, error, dcpl, H5P_DEFAULT_F, H5P_DEFAULT_F) + CALL check("H5Pcreate_f", error, total_error) + + CALL H5Dget_access_plist_f(dsid, dapl2, error) + CALL check("H5Dget_access_plist_f", error, total_error) + + CALL H5Pget_chunk_cache_f(dapl2, nslots_4, nbytes_4, w0_4, error) + CALL check("H5Pget_chunk_cache_f", error, total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nslots_2), INT(nslots_4), total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nbytes_2), INT(nbytes_4), total_error) + IF(w0_2.NE.w0_4)THEN + CALL VERIFYlogical("H5Pget_chunk_cache_f", .TRUE., .FALSE., total_error) + ENDIF + ! Don't close dapl2, we will use it in the next section + + ! Modify cache values on fapl_local + nbytes_3 = nbytes_2 * 2 + + CALL H5Pset_cache_f(fapl_local, 0, nslots_3, nbytes_3, w0_3, error) + CALL check("H5Pset_cache_f", error, total_error) + + ! Close and reopen file with new fapl_local + + CALL H5Dclose_f(dsid, error); CALL check("H5Dclose_f", error, total_error) + CALL H5Fclose_f(fid,error); CALL check("h5fclose_f", error, total_error) + + CALL H5Fopen_f (fix_filename, H5F_ACC_RDWR_F, fid, error, fapl_local) + CALL check("h5fopen_f", error, total_error) + + ! Verify that dapl2 retrieved earlier (using values from the old fapl) + ! sets its values in the new file (test use of H5Dopen2 with a dapl) + ! + + CALL h5dopen_f (fid, "dset", dsid, error, dapl2) + CALL check("h5dopen_f", error, total_error) + + CALL H5Pclose_f(dapl2,error); CALL check("H5Pclose_f", error, total_error) ! Close dapl2, to avoid id leak + + CALL H5Dget_access_plist_f(dsid, dapl2, error) + CALL check("H5Dget_access_plist_f", error, total_error) + CALL H5Pget_chunk_cache_f(dapl2, nslots_4, nbytes_4, w0_4, error) + CALL check("H5Pget_chunk_cache_f", error, total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nslots_2), INT(nslots_4), total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nbytes_2), INT(nbytes_4), total_error) + IF(w0_2.NE.w0_4)THEN + CALL VERIFYlogical("H5Pget_chunk_cache_f", .TRUE., .FALSE., total_error) + ENDIF + + ! Test H5D_CHUNK_CACHE_NSLOTS_DEFAULT and H5D_CHUNK_CACHE_W0_DEFAULT + nslots_2 = H5D_CHUNK_CACHE_NSLOTS_DFLT_F + w0_2 = H5D_CHUNK_CACHE_W0_DFLT_F + + CALL H5Pset_chunk_cache_f(dapl2, nslots_2, nbytes_2, w0_2, error) + CALL check("H5Pset_chunk_cache_f", error, total_error) + + CALL H5Dclose_f(dsid, error); CALL check("H5Dclose_f", error, total_error) + CALL h5dopen_f (fid, "dset", dsid, error, dapl2) + CALL check("h5dopen_f", error, total_error) + + CALL H5Pclose_f(dapl2,error); CALL check("H5Pclose_f", error, total_error) + + CALL H5Dget_access_plist_f(dsid, dapl2, error) + CALL check("H5Dget_access_plist_f", error, total_error) + CALL H5Pget_chunk_cache_f(dapl2, nslots_4, nbytes_4, w0_4, error) + CALL check("H5Pget_chunk_cache_f", error, total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nslots_3), INT(nslots_4), total_error) + CALL VERIFY("H5Pget_chunk_cache_f", INT(nbytes_2), INT(nbytes_4), total_error) + IF(w0_3.NE.w0_4)THEN + CALL VERIFYlogical("H5Pget_chunk_cache_f", .TRUE., .FALSE., total_error) + ENDIF + +! Close + + CALL H5Dclose_f(dsid, error); CALL check("H5Dclose_f", error, total_error) + CALL H5Sclose_f(sid,error); CALL check("H5Sclose_f", error, total_error) + CALL H5Pclose_f(fapl_local,error); CALL check("H5Pclose_f", error, total_error) + CALL H5Pclose_f(fapl_def,error); CALL check("H5Pclose_f", error, total_error) + CALL H5Pclose_f(dapl1,error); CALL check("H5Pclose_f", error, total_error) + CALL H5Pclose_f(dapl2,error); CALL check("H5Pclose_f", error, total_error) + CALL H5Pclose_f(dcpl,error); CALL check("H5Pclose_f", error, total_error) + CALL H5Fclose_f(fid,error); CALL check("H5Fclose_f", error, total_error) + + IF(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) + CALL check("h5_cleanup_f", error, total_error) + +END SUBROUTINE test_chunk_cache + diff --git a/fortran/testpar/Makefile.in b/fortran/testpar/Makefile.in index 14f4e7b..c0c475b 100644 --- a/fortran/testpar/Makefile.in +++ b/fortran/testpar/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -377,8 +377,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -439,7 +439,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/hl/Makefile.in b/hl/Makefile.in index 16a4a64..932ad0a 100755 --- a/hl/Makefile.in +++ b/hl/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -353,8 +353,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -460,7 +460,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/hl/c++/Makefile.in b/hl/c++/Makefile.in index 9ce31d4..bd53be5 100644 --- a/hl/c++/Makefile.in +++ b/hl/c++/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -347,8 +347,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -454,7 +454,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/hl/c++/examples/Makefile.in b/hl/c++/examples/Makefile.in index fa94108..07b8749 100644 --- a/hl/c++/examples/Makefile.in +++ b/hl/c++/examples/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -361,8 +361,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ diff --git a/hl/c++/src/Makefile.am b/hl/c++/src/Makefile.am index 8d2e869..1ff24be 100644 --- a/hl/c++/src/Makefile.am +++ b/hl/c++/src/Makefile.am @@ -19,6 +19,7 @@ # include $(top_srcdir)/config/commence.am +include $(top_srcdir)/config/lt_vers.am # Include src directory INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/hl/src @@ -26,6 +27,9 @@ INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/hl/src # This is our main target lib_LTLIBRARIES=libhdf5_hl_cpp.la +# Add libtool numbers to the HDF5 HL C++ library (from config/lt_vers.am) +libhdf5_hl_cpp_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Shared C++ libraries aren't universally supported. if CXX_SHARED_CONDITIONAL else diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in index 4e168ad..4e1cf8d 100644 --- a/hl/c++/src/Makefile.in +++ b/hl/c++/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -52,7 +52,8 @@ build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am + $(top_srcdir)/config/conclude.am \ + $(top_srcdir)/config/lt_vers.am TESTS = subdir = hl/c++/src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -74,6 +75,9 @@ LTLIBRARIES = $(lib_LTLIBRARIES) libhdf5_hl_cpp_la_LIBADD = am_libhdf5_hl_cpp_la_OBJECTS = H5PacketTable.lo libhdf5_hl_cpp_la_OBJECTS = $(am_libhdf5_hl_cpp_la_OBJECTS) +libhdf5_hl_cpp_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(libhdf5_hl_cpp_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/bin/depcomp am__depfiles_maybe = depfiles @@ -342,12 +346,21 @@ TRACE = perl $(top_srcdir)/bin/trace # *.clog are from the MPE option. CHECK_CLEANFILES = *.chkexe *.chklog *.clog +# Add libtool shared library version numbers to the HDF5 library +# See libtool versioning documentation online. +LT_VERS_INTERFACE = 6 +LT_VERS_REVISION = 29 +LT_VERS_AGE = 0 + # Include src directory INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src # This is our main target lib_LTLIBRARIES = libhdf5_hl_cpp.la +# Add libtool numbers to the HDF5 HL C++ library (from config/lt_vers.am) +libhdf5_hl_cpp_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Shared C++ libraries aren't universally supported. @CXX_SHARED_CONDITIONAL_FALSE@AM_LDFLAGS = -static @@ -377,12 +390,12 @@ all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/lt_vers.am $(top_srcdir)/config/conclude.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -434,7 +447,7 @@ clean-libLTLIBRARIES: rm -f "$${dir}/so_locations"; \ done libhdf5_hl_cpp.la: $(libhdf5_hl_cpp_la_OBJECTS) $(libhdf5_hl_cpp_la_DEPENDENCIES) - $(CXXLINK) -rpath $(libdir) $(libhdf5_hl_cpp_la_OBJECTS) $(libhdf5_hl_cpp_la_LIBADD) $(LIBS) + $(libhdf5_hl_cpp_la_LINK) -rpath $(libdir) $(libhdf5_hl_cpp_la_OBJECTS) $(libhdf5_hl_cpp_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -493,7 +506,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -682,6 +695,19 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES help: @$(top_srcdir)/bin/makehelp +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. + # lib/progs/tests targets recurse into subdirectories. build-* targets # build files in this directory. build-lib: $(LIB) diff --git a/hl/c++/test/Makefile.in b/hl/c++/test/Makefile.in index 285d2e0..dd02c2a 100644 --- a/hl/c++/test/Makefile.in +++ b/hl/c++/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -373,8 +373,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -449,7 +449,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/hl/examples/Makefile.in b/hl/examples/Makefile.in index 3c90dd8..20b6197 100644 --- a/hl/examples/Makefile.in +++ b/hl/examples/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -368,8 +368,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ diff --git a/hl/fortran/Makefile.in b/hl/fortran/Makefile.in index af080bb..c04a423 100644 --- a/hl/fortran/Makefile.in +++ b/hl/fortran/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -351,8 +351,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -458,7 +458,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/hl/fortran/examples/Makefile.in b/hl/fortran/examples/Makefile.in index 1de9302..3d9ba65 100644 --- a/hl/fortran/examples/Makefile.in +++ b/hl/fortran/examples/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -368,8 +368,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ diff --git a/hl/fortran/src/Makefile.am b/hl/fortran/src/Makefile.am index 6bf010b..fbc3908 100644 --- a/hl/fortran/src/Makefile.am +++ b/hl/fortran/src/Makefile.am @@ -20,6 +20,7 @@ # HDF5 High-Level Fortran Makefile(.in) include $(top_srcdir)/config/commence.am +include $(top_srcdir)/config/lt_vers.am INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src @@ -28,6 +29,9 @@ AM_FCFLAGS=-I$(top_builddir)/fortran/src $(F9XMODFLAG)$(top_builddir)/fortran/sr # Our main target, the high-level fortran library lib_LTLIBRARIES=libhdf5hl_fortran.la +# Add libtool numbers to the HDF5 HL Fortran library (from config/lt_vers.am) +libhdf5hl_fortran_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Some Fortran compilers can't build shared libraries, so sometimes we # want to build a shared C library and a static Fortran library. If so, # pass the -static flag to the library linker. diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index 4d4b6fc..8387e66 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -51,7 +51,8 @@ build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am + $(top_srcdir)/config/conclude.am \ + $(top_srcdir)/config/lt_vers.am TESTS = subdir = hl/fortran/src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -74,6 +75,9 @@ libhdf5hl_fortran_la_LIBADD = am_libhdf5hl_fortran_la_OBJECTS = H5LTfc.lo H5IMfc.lo H5IMcc.lo \ H5TBfc.lo H5LTff.lo H5IMff.lo H5TBff.lo libhdf5hl_fortran_la_OBJECTS = $(am_libhdf5hl_fortran_la_OBJECTS) +libhdf5hl_fortran_la_LINK = $(LIBTOOL) $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(FCLD) $(AM_FCFLAGS) $(FCFLAGS) \ + $(libhdf5hl_fortran_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/bin/depcomp am__depfiles_maybe = depfiles @@ -346,6 +350,12 @@ TRACE = perl $(top_srcdir)/bin/trace # .chklog files are output from those tests. # *.clog are from the MPE option. CHECK_CLEANFILES = *.chkexe *.chklog *.clog + +# Add libtool shared library version numbers to the HDF5 library +# See libtool versioning documentation online. +LT_VERS_INTERFACE = 6 +LT_VERS_REVISION = 29 +LT_VERS_AGE = 0 INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src @@ -354,6 +364,9 @@ AM_FCFLAGS = -I$(top_builddir)/fortran/src $(F9XMODFLAG)$(top_builddir)/fortran/ # Our main target, the high-level fortran library lib_LTLIBRARIES = libhdf5hl_fortran.la +# Add libtool numbers to the HDF5 HL Fortran library (from config/lt_vers.am) +libhdf5hl_fortran_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Some Fortran compilers can't build shared libraries, so sometimes we # want to build a shared C library and a static Fortran library. If so, # pass the -static flag to the library linker. @@ -386,12 +399,12 @@ all: all-am .SUFFIXES: .SUFFIXES: .c .f90 .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/lt_vers.am $(top_srcdir)/config/conclude.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -443,7 +456,7 @@ clean-libLTLIBRARIES: rm -f "$${dir}/so_locations"; \ done libhdf5hl_fortran.la: $(libhdf5hl_fortran_la_OBJECTS) $(libhdf5hl_fortran_la_DEPENDENCIES) - $(FCLINK) -rpath $(libdir) $(libhdf5hl_fortran_la_OBJECTS) $(libhdf5hl_fortran_la_LIBADD) $(LIBS) + $(libhdf5hl_fortran_la_LINK) -rpath $(libdir) $(libhdf5hl_fortran_la_OBJECTS) $(libhdf5hl_fortran_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -497,7 +510,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -687,6 +700,19 @@ uninstall-am: uninstall-libLTLIBRARIES uninstall-local help: @$(top_srcdir)/bin/makehelp +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. + # Fortran module files can have different extensions and different names # (e.g., different capitalizations) on different platforms. Write rules # for them explicitly rather than trying to teach automake about them. diff --git a/hl/fortran/test/Makefile.in b/hl/fortran/test/Makefile.in index 6958f34..0abae85 100644 --- a/hl/fortran/test/Makefile.in +++ b/hl/fortran/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -383,8 +383,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -451,7 +451,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 83bb1ed..9efa95e 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -142,13 +142,18 @@ herr_t H5DSattach_scale(hid_t did, H5I_type_t it1, it2; int i, len; int found_ds=0; + htri_t is_scale; /*------------------------------------------------------------------------- * parameter checking *------------------------------------------------------------------------- */ + + if ((is_scale = H5DSis_scale(did)) < 0) + return FAIL; + /* the dataset cannot be a DS dataset */ - if ((H5DSis_scale(did))==1) + if ( is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ @@ -477,7 +482,7 @@ herr_t H5DSattach_scale(hid_t did, nelmts++; - dsbuf = malloc((size_t)nelmts * sizeof(ds_list_t)); + dsbuf = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t)); if (dsbuf == NULL) goto out; @@ -637,13 +642,18 @@ herr_t H5DSdetach_scale(hid_t did, H5O_info_t oi1, oi2, oi3, oi4; int found_dset = 0, found_ds = 0; H5I_type_t it1, it2; + htri_t is_scale; /*------------------------------------------------------------------------- * parameter checking *------------------------------------------------------------------------- */ + + if ((is_scale = H5DSis_scale(did)) < 0) + return FAIL; + /* the dataset cannot be a DS dataset */ - if ((H5DSis_scale(did))==1) + if ( is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ @@ -691,6 +701,9 @@ herr_t H5DSdetach_scale(hid_t did, if (H5Sclose(sid) < 0) return FAIL; + /* parameter range checking */ + if (idx>(unsigned)rank-1) + return FAIL; /*------------------------------------------------------------------------- * find "REFERENCE_LIST" @@ -749,13 +762,21 @@ herr_t H5DSdetach_scale(hid_t did, goto out; /* same object, reset */ - if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) { + if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) + { + size_t len; + for(jj=j; jj ((unsigned)rank - 1)) - goto out; + return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) @@ -1169,7 +1195,7 @@ htri_t H5DSis_attached(hid_t did, if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = malloc((size_t)nelmts * sizeof(ds_list_t)); + dsbuf = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t)); if (dsbuf == NULL) goto out; @@ -1266,11 +1292,12 @@ out: * Parameters: * * hid_t DID; IN: the dataset -* unsigned int dim; IN: the dimension of the dataset -* int *idx; IN/OUT: input the index to start iterating, output the -* next index to visit. If NULL, start at the first position. -* H5DS_iterate_t visitor; IN: the visitor function -* void *visitor_data; IN: arbitrary data to pass to the visitor function. +* unsigned int DIM; IN: the dimension of the dataset +* int *DS_IDX; IN/OUT: on input the dimension scale index to start iterating, +* on output the next index to visit. If NULL, start at +* the first position. +* H5DS_iterate_t VISITOR; IN: the visitor function +* void *VISITOR_DATA; IN: arbitrary data to pass to the visitor function. * * Iterate over all scales of DIM, calling an application callback * with the item, key and any operator data. @@ -1298,7 +1325,7 @@ out: herr_t H5DSiterate_scales(hid_t did, unsigned int dim, - int *idx, + int *ds_idx, H5DS_iterate_t visitor, void *visitor_data ) { @@ -1331,6 +1358,13 @@ herr_t H5DSiterate_scales(hid_t did, if ((nscales = H5DSget_num_scales(did,dim)) < 0) return FAIL; + /* parameter range checking */ + if (ds_idx!=NULL) + { + if (*ds_idx>=nscales) + return FAIL; + } + /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; @@ -1343,6 +1377,9 @@ herr_t H5DSiterate_scales(hid_t did, if(H5Sclose(sid) < 0) goto out; + if ( dim >= (unsigned)rank ) + return FAIL; + /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; @@ -1371,8 +1408,8 @@ herr_t H5DSiterate_scales(hid_t did, if ( buf[dim].len > 0 ) { - if (idx!=NULL) - j_idx = *idx; + if (ds_idx!=NULL) + j_idx = *ds_idx; else j_idx=0; @@ -1389,14 +1426,16 @@ herr_t H5DSiterate_scales(hid_t did, goto out; } H5E_END_TRY; - if((ret_value=(visitor)(did,dim,scale_id,visitor_data))!=0) + /* set the return IDX OUT value at current scale index */ + if (ds_idx!=NULL) { - /* set the return IDX OUT value at current scale index and break */ - if (idx!=NULL) - { - *idx = i; - } + *ds_idx = i; + } + if((ret_value=(visitor)(did,dim,scale_id,visitor_data))!=0) + { + /* break */ + /* close the DS id */ if (H5Dclose(scale_id) < 0) goto out; @@ -1462,16 +1501,17 @@ out: *------------------------------------------------------------------------- */ -herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { - int has_labels; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - hsize_t dims[1]; /* dimensions of dataset */ - const char **buf = NULL; /* buffer to store in the attribute */ - H5I_type_t it; /* ID type */ - unsigned int i; +herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) +{ + int has_labels; + hid_t sid = -1; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + hsize_t dims[1]; /* dimensions of dataset */ + const char **buf = NULL; /* buffer to store in the attribute */ + H5I_type_t it; /* ID type */ + unsigned int i; /*------------------------------------------------------------------------- * parameter checking @@ -1484,16 +1524,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { if (H5I_DATASET != it) return FAIL; - /*------------------------------------------------------------------------- - * attribute "DIMENSION_LABELS" - *------------------------------------------------------------------------- - */ - - /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */ - if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0) - return FAIL; - - /* get dataset space */ + /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; @@ -1505,12 +1536,25 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { if (H5Sclose(sid) < 0) goto out; + if ( idx >= (unsigned)rank ) + return FAIL; + + /*------------------------------------------------------------------------- + * attribute "DIMENSION_LABELS" + *------------------------------------------------------------------------- + */ + + /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */ + if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0) + return FAIL; + /*------------------------------------------------------------------------- * make the attribute and insert label *------------------------------------------------------------------------- */ - if (has_labels == 0) { + if (has_labels == 0) + { dims[0] = rank; /* space for the attribute */ @@ -1524,8 +1568,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { goto out; /* create the attribute */ - if ((aid = H5Acreate2(did, DIMENSION_LABELS, tid, sid, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, DIMENSION_LABELS, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* allocate and initialize */ @@ -1553,7 +1596,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { goto out; if (buf) { - free((void *) buf); + free(buf); buf = NULL; } } @@ -1563,7 +1606,8 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { *------------------------------------------------------------------------- */ - else { + else + { if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0) goto out; @@ -1595,7 +1639,8 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { buf[idx] = NULL; /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) { + for (i = 0; i < (unsigned int) rank; i++) + { if (buf[i]) free(buf[i]); } @@ -1607,7 +1652,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { goto out; if (buf) { - free((void *) buf); + free(buf); buf = NULL; } } @@ -1616,11 +1661,13 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { /* error zone */ out: - if (buf) { + if (buf) + { if (buf[idx]) /* check if we errored during H5Awrite */ buf[idx] = NULL; /* don't free label */ /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) { + for (i = 0; i < (unsigned int) rank; i++) + { if (buf[i]) free(buf[i]); } @@ -1656,17 +1703,18 @@ out: * *------------------------------------------------------------------------- */ -ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { - int has_labels; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - char **buf = NULL; /* buffer to store in the attribute */ - H5I_type_t it; /* ID type */ - size_t nbytes; - size_t copy_len; - int i; +ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) +{ + int has_labels; + hid_t sid = -1; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + char **buf = NULL; /* buffer to store in the attribute */ + H5I_type_t it; /* ID type */ + size_t nbytes; + size_t copy_len; + int i; /*------------------------------------------------------------------------- * parameter checking @@ -1679,6 +1727,21 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { if (H5I_DATASET != it) return FAIL; + /* get dataset space */ + if ((sid = H5Dget_space(did)) < 0) + return FAIL; + + /* get rank */ + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) + goto out; + + /* close dataset space */ + if (H5Sclose(sid) < 0) + goto out; + + if ( idx >= (unsigned)rank ) + return FAIL; + /*------------------------------------------------------------------------- * attribute "DIMENSION_LABELS" *------------------------------------------------------------------------- @@ -1694,19 +1757,7 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { if (label) label[0] = 0; return 0; - } - - /* get dataset space */ - if ((sid = H5Dget_space(did)) < 0) - return FAIL; - - /* get rank */ - if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) - goto out; - - /* close dataset space */ - if (H5Sclose(sid) < 0) - goto out; + } /*------------------------------------------------------------------------- * open the attribute and read label @@ -1737,7 +1788,8 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { copy_len = MIN(size-1, nbytes); /* copy all/some of the name */ - if (label) { + if (label) + { memcpy(label, buf[idx], copy_len); /* terminate the string */ @@ -1745,7 +1797,8 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { } /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) { + for (i = 0; i < rank; i++) + { if (buf[i]) free(buf[i]); } @@ -1765,9 +1818,11 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { /* error zone */ out: - if (buf) { + if (buf) + { /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) { + for (i = 0; i < rank; i++) + { if (buf[i]) free(buf[i]); } @@ -2186,7 +2241,8 @@ herr_t H5DS_is_reserved(hid_t did) /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid); H5Aclose(aid); } H5E_END_TRY; diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index 479b572..361a65b 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5IMprivate.h" #include "H5LTprivate.h" @@ -19,155 +19,156 @@ #include /*------------------------------------------------------------------------- - * Function: H5IMmake_image_8bit - * - * Purpose: Creates and writes an image an 8 bit image - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: June 13, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMmake_image_8bit +* +* Purpose: Creates and writes an image an 8 bit image +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: June 13, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMmake_image_8bit( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const unsigned char *buffer ) + const char *dset_name, + hsize_t width, + hsize_t height, + const unsigned char *buf ) { - hsize_t dims[IMAGE8_RANK]; + hsize_t dims[IMAGE8_RANK]; - /* Initialize the image dimensions */ - dims[0] = height; - dims[1] = width; + /* Initialize the image dimensions */ + dims[0] = height; + dims[1] = width; - /* Make the dataset */ - if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buffer ) < 0) - return -1; + /* Make the dataset */ + if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0) + return -1; - /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) - return -1; + /* Attach the CLASS attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) + return -1; - /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) - return -1; + /* Attach the VERSION attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) + return -1; - /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0) - return -1; + /* Attach the IMAGE_SUBCLASS attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5IMmake_image_24bit - * - * Purpose: - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: June 13, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Interlace Mode Dimensions in the Dataspace - * INTERLACE_PIXEL [height][width][pixel components] - * INTERLACE_PLANE [pixel components][height][width] - * - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMmake_image_24bit +* +* Purpose: +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: June 13, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Interlace Mode Dimensions in the Dataspace +* INTERLACE_PIXEL [height][width][pixel components] +* INTERLACE_PLANE [pixel components][height][width] +* +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMmake_image_24bit( hid_t loc_id, - const char *dset_name, - hsize_t width, - hsize_t height, - const char *interlace, - const unsigned char *buffer ) + const char *dset_name, + hsize_t width, + hsize_t height, + const char *interlace, + const unsigned char *buf ) { - hsize_t dims[IMAGE24_RANK]; - - /* Initialize the image dimensions */ - - if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) - { - /* Number of color planes is defined as the third dimension */ - dims[0] = height; - dims[1] = width; - dims[2] = IMAGE24_RANK; - } - else - if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) - { - /* Number of color planes is defined as the first dimension */ - dims[0] = IMAGE24_RANK; - dims[1] = height; - dims[2] = width; - } - else return -1; - - /* Make the dataset */ - if ( H5LTmake_dataset( loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buffer ) < 0) - return -1; - - /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) - return -1; - - /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) - return -1; - - /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0) - return -1; - - /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ - if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0) - return -1; - - return 0; + hsize_t dims[IMAGE24_RANK]; + + /* Initialize the image dimensions */ + + if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) + { + /* Number of color planes is defined as the third dimension */ + dims[0] = height; + dims[1] = width; + dims[2] = IMAGE24_RANK; + } + else + if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) + { + /* Number of color planes is defined as the first dimension */ + dims[0] = IMAGE24_RANK; + dims[1] = height; + dims[2] = width; + } + else return -1; + + /* Make the dataset */ + if ( H5LTmake_dataset( loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0) + return -1; + + /* Attach the CLASS attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) + return -1; + + /* Attach the VERSION attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) + return -1; + + /* Attach the IMAGE_SUBCLASS attribute */ + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0) + return -1; + + /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ + if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0) + return -1; + + return 0; } /*------------------------------------------------------------------------- - * Function: find_palette - * - * Purpose: operator function used by H5LT_find_palette - * - * Return: - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 28, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo, - void *op_data) +* Function: find_palette +* +* Purpose: operator function used by H5LT_find_palette +* +* Return: +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: May 28, 2001 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ +static herr_t find_palette(hid_t loc_id, + const char *name, + const H5A_info_t *ainfo, + void *op_data) { int ret = H5_ITER_CONT; @@ -175,9 +176,9 @@ find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo, loc_id = loc_id; ainfo = ainfo; op_data = op_data; /* Define a positive value for return value if the attribute was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ if(strcmp(name, "PALETTE") == 0) ret = H5_ITER_STOP; @@ -186,23 +187,23 @@ find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo, /*------------------------------------------------------------------------- - * Function: H5IM_find_palette - * - * Purpose: Private function. Find the attribute "PALETTE" in the image dataset - * - * Return: Success: 1, Failure: 0 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 11, 2001 - * - * Comments: - * The function uses H5Aiterate2 with the operator function find_palette - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IM_find_palette +* +* Purpose: Private function. Find the attribute "PALETTE" in the image dataset +* +* Return: Success: 1, Failure: 0 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: May 11, 2001 +* +* Comments: +* The function uses H5Aiterate2 with the operator function find_palette +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IM_find_palette( hid_t loc_id ) { @@ -211,1007 +212,1011 @@ herr_t H5IM_find_palette( hid_t loc_id ) /*------------------------------------------------------------------------- - * Function: H5IMget_image_info - * - * Purpose: Gets information about an image dataset (dimensions, interlace mode - * and number of associated palettes). - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: July 25, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMget_image_info +* +* Purpose: Gets information about an image dataset (dimensions, interlace mode +* and number of associated palettes). +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: July 25, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMget_image_info( hid_t loc_id, - const char *dset_name, - hsize_t *width, - hsize_t *height, - hsize_t *planes, - char *interlace, - hssize_t *npals ) + const char *dset_name, + hsize_t *width, + hsize_t *height, + hsize_t *planes, + char *interlace, + hssize_t *npals ) { - hid_t did, sid; - hsize_t dims[IMAGE24_RANK]; - hid_t attr_id; - hid_t attr_type; - int has_attr; - hid_t attr_space_id; - hid_t attr_class; - int has_pal; + hid_t did; + hid_t sid; + hsize_t dims[IMAGE24_RANK]; + hid_t aid; + hid_t asid; + hid_t atid; + H5T_class_t aclass; + int has_pal; + int has_attr; - /*assume initially we have no palettes attached*/ - *npals = 0; + /*assume initially we have no palettes attached*/ + *npals = 0; - /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the dataset. */ + if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + return -1; - /* Try to find the attribute "INTERLACE_MODE" on the >>image<< dataset */ - has_attr = H5LT_find_attribute(did, "INTERLACE_MODE"); + /* Try to find the attribute "INTERLACE_MODE" on the >>image<< dataset */ + has_attr = H5LT_find_attribute(did, "INTERLACE_MODE"); - /* It exists, get it */ - if(has_attr == 1) - { + /* It exists, get it */ + if(has_attr == 1) + { - if((attr_id = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0) - goto out; + if((aid = H5Aopen(did, "INTERLACE_MODE", H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((atid = H5Aget_type(aid)) < 0) + goto out; - if(H5Aread(attr_id, attr_type, interlace) < 0) - goto out; + if(H5Aread(aid, atid, interlace) < 0) + goto out; - if(H5Tclose(attr_type) < 0) - goto out; + if(H5Tclose(atid) < 0) + goto out; - if(H5Aclose(attr_id) < 0) - goto out; - } + if(H5Aclose(aid) < 0) + goto out; + } - /* Get the dataspace handle */ - if ( (sid = H5Dget_space( did )) < 0) - goto out; + /* Get the dataspace handle */ + if ( (sid = H5Dget_space( did )) < 0) + goto out; - /* Get dimensions */ - if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0) - goto out; + /* Get dimensions */ + if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0) + goto out; - /* Initialize the image dimensions */ + /* Initialize the image dimensions */ - if ( has_attr == 1 ) - /* This is a 24 bit image */ - { + if ( has_attr == 1 ) + /* This is a 24 bit image */ + { - if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) - { - /* Number of color planes is defined as the third dimension */ - *height = dims[0]; - *width = dims[1]; - *planes = dims[2]; - } - else - if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) - { - /* Number of color planes is defined as the first dimension */ - *planes = dims[0]; - *height = dims[1]; - *width = dims[2]; - } - else return -1; - } - else - /* This is a 8 bit image */ - { - *height = dims[0]; - *width = dims[1]; - *planes = 1; - } + if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) + { + /* Number of color planes is defined as the third dimension */ + *height = dims[0]; + *width = dims[1]; + *planes = dims[2]; + } + else + if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) + { + /* Number of color planes is defined as the first dimension */ + *planes = dims[0]; + *height = dims[1]; + *width = dims[2]; + } + else return -1; + } + else + /* This is a 8 bit image */ + { + *height = dims[0]; + *width = dims[1]; + *planes = 1; + } - /* Close */ - if ( H5Sclose( sid ) < 0) - goto out; + /* Close */ + if ( H5Sclose( sid ) < 0) + goto out; - /* Get number of palettes */ + /* Get number of palettes */ - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - has_pal = H5IM_find_palette(did); + /* Try to find the attribute "PALETTE" on the >>image<< dataset */ + has_pal = H5IM_find_palette(did); - if(has_pal == 1) - { + if(has_pal == 1) + { - if((attr_id = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) - goto out; + if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((atid = H5Aget_type(aid)) < 0) + goto out; - if((attr_class = H5Tget_class(attr_type)) < 0) - goto out; + if((aclass = H5Tget_class(atid)) < 0) + goto out; - /* Check if it is really a reference */ + /* Check if it is really a reference */ - if(attr_class == H5T_REFERENCE) - { + if(aclass == H5T_REFERENCE) + { - /* Get the reference(s) */ + /* Get the reference(s) */ - if ( (attr_space_id = H5Aget_space( attr_id )) < 0) - goto out; + if ( (asid = H5Aget_space( aid )) < 0) + goto out; - *npals = H5Sget_simple_extent_npoints( attr_space_id ); + *npals = H5Sget_simple_extent_npoints( asid ); - if ( H5Sclose( attr_space_id ) < 0) - goto out; + if ( H5Sclose( asid ) < 0) + goto out; - } /* H5T_REFERENCE */ + } /* H5T_REFERENCE */ - if ( H5Tclose( attr_type ) < 0) - goto out; + if ( H5Tclose( atid ) < 0) + goto out; - /* Close the attribute. */ - if ( H5Aclose( attr_id ) < 0) - goto out; + /* Close the attribute. */ + if ( H5Aclose( aid ) < 0) + goto out; - } + } - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0) - goto out; + /* End access to the dataset and release resources used by it. */ + if ( H5Dclose( did ) < 0) + goto out; - return 0; + return 0; out: - H5Dclose( did ); - return -1; + H5Dclose( did ); + H5Aclose( aid ); + H5Sclose( asid ); + H5Tclose( atid ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5IMread_image - * - * Purpose: Reads image data from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: June 13, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMread_image +* +* Purpose: Reads image data from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: June 13, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMread_image( hid_t loc_id, const char *dset_name, - unsigned char *buffer ) + unsigned char *buf ) { - hid_t did; + hid_t did; - /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the dataset. */ + if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + return -1; - /* Read */ - if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer ) < 0) - goto out; + /* Read */ + if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0) + goto out; - /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) ) - return -1; + /* End access to the dataset and release resources used by it. */ + if ( H5Dclose( did ) ) + return -1; - return 0; + return 0; out: - H5Dclose( did ); - return -1; + H5Dclose( did ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5IMmake_palette - * - * Purpose: Creates and writes a palette. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 01, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMmake_palette +* +* Purpose: Creates and writes a palette. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: May 01, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMmake_palette( hid_t loc_id, - const char *pal_name, - const hsize_t *pal_dims, - const unsigned char *pal_data ) + const char *pal_name, + const hsize_t *pal_dims, + const unsigned char *pal_data ) { - int has_pal; + int has_pal; - /* Check if the dataset already exists */ - has_pal = H5LTfind_dataset( loc_id, pal_name ); + /* Check if the dataset already exists */ + has_pal = H5LTfind_dataset( loc_id, pal_name ); - /* It exists. Return */ - if ( has_pal == 1 ) - return 0; + /* It exists. Return */ + if ( has_pal == 1 ) + return 0; - /* Make the palette dataset. */ - if ( H5LTmake_dataset( loc_id, pal_name, 2, pal_dims, H5T_NATIVE_UCHAR, pal_data ) < 0 ) - return -1; + /* Make the palette dataset. */ + if ( H5LTmake_dataset( loc_id, pal_name, 2, pal_dims, H5T_NATIVE_UCHAR, pal_data ) < 0 ) + return -1; - /* Attach the attribute "CLASS" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0) - return -1; + /* Attach the attribute "CLASS" to the >>palette<< dataset*/ + if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0) + return -1; - /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0) - return -1; + /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ + if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5IMlink_palette - * - * Purpose: This function attaches a palette to an existing image dataset - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: May 01, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * An image (dataset) within an HDF5 file may optionally specify an array of - * palettes to be viewed with. The dataset will have an attribute - * which contains an array of object reference pointers which refer to palettes in the file. - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMlink_palette +* +* Purpose: This function attaches a palette to an existing image dataset +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: May 01, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* An image (dataset) within an HDF5 file may optionally specify an array of +* palettes to be viewed with. The dataset will have an attribute +* which contains an array of object reference pointers which refer to palettes in the file. +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ) + const char *image_name, + const char *pal_name ) { - hid_t image_id; - hid_t attr_type=-1; - hid_t attr_id=-1; - hid_t attr_space_id=-1; - hobj_ref_t ref; /* write a new reference */ - hobj_ref_t *refbuf; /* buffer to read references */ - hssize_t n_refs; - hsize_t dim_ref; - int ok_pal; - - /* The image dataset may or may not have the attribute "PALETTE" - * First we try to open to see if it is already there; if not, it is created. - * If it exists, the array of references is extended to hold the reference - * to the new palette - */ - - /* First we get the image id */ - if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) - return -1; - - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - ok_pal = H5LT_find_attribute( image_id, "PALETTE" ); + hid_t did; + hid_t atid=-1; + hid_t aid=-1; + hid_t asid=-1; + hobj_ref_t ref; /* write a new reference */ + hobj_ref_t *refbuf; /* buffer to read references */ + hssize_t n_refs; + hsize_t dim_ref; + int ok_pal; + + /* The image dataset may or may not have the attribute "PALETTE" + * First we try to open to see if it is already there; if not, it is created. + * If it exists, the array of references is extended to hold the reference + * to the new palette + */ + + /* First we get the image id */ + if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + return -1; + + /* Try to find the attribute "PALETTE" on the >>image<< dataset */ + ok_pal = H5LT_find_attribute( did, "PALETTE" ); + + /*------------------------------------------------------------------------- + * It does not exist. We create the attribute and one reference + *------------------------------------------------------------------------- + */ + if(ok_pal == 0 ) + { + if((asid = H5Screate(H5S_SCALAR)) < 0) + goto out; -/*------------------------------------------------------------------------- - * It does not exist. We create the attribute and one reference - *------------------------------------------------------------------------- - */ - if(ok_pal == 0 ) - { - if((attr_space_id = H5Screate(H5S_SCALAR)) < 0) - goto out; - - /* Create the attribute type for the reference */ - if((attr_type = H5Tcopy(H5T_STD_REF_OBJ)) < 0) - goto out; - - /* Create the attribute "PALETTE" to be attached to the image*/ - if((attr_id = H5Acreate2(image_id, "PALETTE", attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* Create a reference. The reference is created on the local id. */ - if(H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, -1) < 0) - goto out; - - /* Write the attribute with the reference */ - if(H5Awrite(attr_id, attr_type, &ref) < 0) - goto out; - - /* close */ - if(H5Sclose(attr_space_id) < 0) - goto out; - if ( H5Tclose( attr_type ) < 0) - goto out; - if(H5Aclose(attr_id) < 0) - goto out; - - } + /* Create the attribute type for the reference */ + if((atid = H5Tcopy(H5T_STD_REF_OBJ)) < 0) + goto out; -/*------------------------------------------------------------------------- - * The attribute already exists, open it - *------------------------------------------------------------------------- - */ - else if(ok_pal == 1) - { - if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0) - goto out; + /* Create the attribute "PALETTE" to be attached to the image*/ + if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + /* Create a reference. The reference is created on the local id. */ + if(H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, -1) < 0) + goto out; - if(H5Tget_class(attr_type) < 0) - goto out; + /* Write the attribute with the reference */ + if(H5Awrite(aid, atid, &ref) < 0) + goto out; - /* Get and save the old reference(s) */ - if((attr_space_id = H5Aget_space(attr_id)) < 0) - goto out; + /* close */ + if(H5Sclose(asid) < 0) + goto out; + if ( H5Tclose( atid ) < 0) + goto out; + if(H5Aclose(aid) < 0) + goto out; - n_refs = H5Sget_simple_extent_npoints(attr_space_id); + } - dim_ref = n_refs + 1; + /*------------------------------------------------------------------------- + * The attribute already exists, open it + *------------------------------------------------------------------------- + */ + else if(ok_pal == 1) + { + if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + goto out; - refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref ); + if((atid = H5Aget_type(aid)) < 0) + goto out; - if ( H5Aread( attr_id, attr_type, refbuf ) < 0) - goto out; + if(H5Tget_class(atid) < 0) + goto out; - /* The attribute must be deleted, in order to the new one can reflect the changes*/ - if(H5Adelete(image_id, "PALETTE") < 0) - goto out; + /* Get and save the old reference(s) */ + if((asid = H5Aget_space(aid)) < 0) + goto out; - /* Create a new reference for this palette. */ - if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, -1 ) < 0) - goto out; + n_refs = H5Sget_simple_extent_npoints(asid); - refbuf[n_refs] = ref; + dim_ref = n_refs + 1; - /* Create the data space for the new references */ - if(H5Sclose(attr_space_id) < 0) - goto out; + refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref ); - if((attr_space_id = H5Screate_simple(1, &dim_ref, NULL)) < 0) - goto out; + if ( H5Aread( aid, atid, refbuf ) < 0) + goto out; - /* Create the attribute again with the changes of space */ - if(H5Aclose(attr_id) < 0) - goto out; + /* The attribute must be deleted, in order to the new one can reflect the changes*/ + if(H5Adelete(did, "PALETTE") < 0) + goto out; - if((attr_id = H5Acreate2(image_id, "PALETTE", attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; + /* Create a new reference for this palette. */ + if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, -1 ) < 0) + goto out; - /* Write the attribute with the new references */ - if(H5Awrite(attr_id, attr_type, refbuf) < 0) - goto out; + refbuf[n_refs] = ref; - /* close */ - if(H5Sclose(attr_space_id) < 0) - goto out; - if(H5Aclose(attr_id) < 0) - goto out; + /* Create the data space for the new references */ + if(H5Sclose(asid) < 0) + goto out; - free( refbuf ); + if((asid = H5Screate_simple(1, &dim_ref, NULL)) < 0) + goto out; - } /* ok_pal == 1 */ + /* Create the attribute again with the changes of space */ + if(H5Aclose(aid) < 0) + goto out; - /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0) - return -1; + if((aid = H5Acreate2(did, "PALETTE", atid, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - return 0; + /* Write the attribute with the new references */ + if(H5Awrite(aid, atid, refbuf) < 0) + goto out; + + /* close */ + if(H5Sclose(asid) < 0) + goto out; + if(H5Aclose(aid) < 0) + goto out; + + free( refbuf ); + + } /* ok_pal == 1 */ + + /* Close the image dataset. */ + if ( H5Dclose( did ) < 0) + return -1; + + return 0; out: - H5Dclose( image_id ); - H5Sclose( attr_space_id ); - H5Tclose( attr_type ); - H5Aclose( attr_id ); - return -1; + H5Dclose( did ); + H5Sclose( asid ); + H5Tclose( atid ); + H5Aclose( aid ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5IMunlink_palette - * - * Purpose: This function dettaches a palette from an existing image dataset - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: September 10, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMunlink_palette +* +* Purpose: This function dettaches a palette from an existing image dataset +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: September 10, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMunlink_palette( hid_t loc_id, - const char *image_name, - const char *pal_name ) + const char *image_name, + const char *pal_name ) { - hid_t image_id; - hid_t attr_type; - hid_t attr_id; - hid_t attr_class; - int ok_pal, has_pal; + hid_t did; + hid_t atid; + hid_t aid; + H5T_class_t aclass; + int ok_pal, has_pal; - /* Try to find the palette dataset */ - has_pal = H5LTfind_dataset( loc_id, pal_name ); + /* Try to find the palette dataset */ + has_pal = H5LTfind_dataset( loc_id, pal_name ); - /* It does not exist. Return */ - if ( has_pal == 0 ) - return -1; + /* It does not exist. Return */ + if ( has_pal == 0 ) + return -1; - /* The image dataset may or not have the attribute "PALETTE" - * First we try to open to see if it is already there; if not, it is created. - * If it exists, the array of references is extended to hold the reference - * to the new palette - */ + /* The image dataset may or not have the attribute "PALETTE" + * First we try to open to see if it is already there; if not, it is created. + * If it exists, the array of references is extended to hold the reference + * to the new palette + */ - /* First we get the image id */ - if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) - return -1; + /* First we get the image id */ + if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + return -1; - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - ok_pal = H5LT_find_attribute(image_id, "PALETTE"); + /* Try to find the attribute "PALETTE" on the >>image<< dataset */ + ok_pal = H5LT_find_attribute(did, "PALETTE"); - /* It does not exist. Nothing to do */ - if(ok_pal == 0) - return -1; + /* It does not exist. Nothing to do */ + if(ok_pal == 0) + return -1; - /* The attribute exists, open it */ - else if(ok_pal == 1) - { - if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0) - goto out; + /* The attribute exists, open it */ + else if(ok_pal == 1) + { + if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((atid = H5Aget_type(aid)) < 0) + goto out; - if((attr_class = H5Tget_class(attr_type)) < 0) - goto out; + if((aclass = H5Tget_class(atid)) < 0) + goto out; - /* Check if it is really a reference */ - if(attr_class == H5T_REFERENCE) - { - /* Delete the attribute */ - if(H5Adelete(image_id, "PALETTE") < 0) - goto out; + /* Check if it is really a reference */ + if(aclass == H5T_REFERENCE) + { + /* Delete the attribute */ + if(H5Adelete(did, "PALETTE") < 0) + goto out; - } /* H5T_REFERENCE */ + } /* H5T_REFERENCE */ - if(H5Tclose(attr_type) < 0) - goto out; + if(H5Tclose(atid) < 0) + goto out; - /* Close the attribute. */ - if(H5Aclose(attr_id) < 0) - goto out; + /* Close the attribute. */ + if(H5Aclose(aid) < 0) + goto out; - } /* ok_pal */ + } /* ok_pal */ - /* Close the image dataset. */ - if(H5Dclose(image_id) < 0) - return -1; + /* Close the image dataset. */ + if(H5Dclose(did) < 0) + return -1; - return 0; + return 0; out: - H5Dclose( image_id ); - return -1; + H5Dclose( did ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5IMget_npalettes - * - * Purpose: Gets the number of palettes associated to an image - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: July 22, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMget_npalettes +* +* Purpose: Gets the number of palettes associated to an image +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: July 22, 2001 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMget_npalettes( hid_t loc_id, - const char *image_name, - hssize_t *npals ) + const char *image_name, + hssize_t *npals ) { - hid_t image_id; - hid_t attr_type; - hid_t attr_id; - hid_t attr_space_id; - hid_t attr_class; - int has_pal; + hid_t did; + hid_t atid; + hid_t aid; + hid_t asid; + H5T_class_t aclass; + int has_pal; - /*assume initially we have no palettes attached*/ - *npals = 0; + /*assume initially we have no palettes attached*/ + *npals = 0; - /* Open the dataset. */ - if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the dataset. */ + if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + return -1; - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - has_pal = H5IM_find_palette(image_id); + /* Try to find the attribute "PALETTE" on the >>image<< dataset */ + has_pal = H5IM_find_palette(did); - if(has_pal == 1 ) - { + if(has_pal == 1 ) + { - if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0) - goto out; + if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((atid = H5Aget_type(aid)) < 0) + goto out; - if((attr_class = H5Tget_class(attr_type)) < 0) - goto out; + if((aclass = H5Tget_class(atid)) < 0) + goto out; - /* Check if it is really a reference */ + /* Check if it is really a reference */ - if(attr_class == H5T_REFERENCE) - { - if((attr_space_id = H5Aget_space(attr_id)) < 0) - goto out; + if(aclass == H5T_REFERENCE) + { + if((asid = H5Aget_space(aid)) < 0) + goto out; - *npals = H5Sget_simple_extent_npoints( attr_space_id ); + *npals = H5Sget_simple_extent_npoints( asid ); - if ( H5Sclose( attr_space_id ) < 0) - goto out; + if ( H5Sclose( asid ) < 0) + goto out; - } /* H5T_REFERENCE */ + } /* H5T_REFERENCE */ - if ( H5Tclose( attr_type ) < 0) - goto out; + if ( H5Tclose( atid ) < 0) + goto out; - /* Close the attribute. */ - if ( H5Aclose( attr_id ) < 0) - goto out; + /* Close the attribute. */ + if ( H5Aclose( aid ) < 0) + goto out; - } + } - /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0) - return -1; + /* Close the image dataset. */ + if ( H5Dclose( did ) < 0) + return -1; - return 0; + return 0; out: - H5Dclose( image_id ); - return -1; + H5Dclose( did ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5IMget_palette_info - * - * Purpose: Get palette information - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: July 22, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMget_palette_info +* +* Purpose: Get palette information +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: July 22, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMget_palette_info( hid_t loc_id, - const char *image_name, - int pal_number, - hsize_t *pal_dims ) + const char *image_name, + int pal_number, + hsize_t *pal_dims ) { - hid_t image_id; - int has_pal; - hid_t attr_type=-1; - hid_t attr_id; - hid_t attr_space_id=-1; - hssize_t n_refs; - hsize_t dim_ref; - hobj_ref_t *refbuf; /* buffer to read references */ - hid_t pal_id; - hid_t pal_space_id; - hsize_t pal_maxdims[2]; + hid_t did; + int has_pal; + hid_t atid=-1; + hid_t aid; + hid_t asid=-1; + hssize_t n_refs; + hsize_t dim_ref; + hobj_ref_t *refbuf; /* buffer to read references */ + hid_t pal_id; + hid_t pal_space_id; + hsize_t pal_maxdims[2]; - /* Open the dataset. */ - if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the dataset. */ + if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + return -1; - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - has_pal = H5IM_find_palette(image_id); + /* Try to find the attribute "PALETTE" on the >>image<< dataset */ + has_pal = H5IM_find_palette(did); - if(has_pal == 1) - { - if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0) - goto out; + if(has_pal == 1) + { + if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((atid = H5Aget_type(aid)) < 0) + goto out; - if(H5Tget_class(attr_type) < 0) - goto out; + if(H5Tget_class(atid) < 0) + goto out; - /* Get the reference(s) */ - if((attr_space_id = H5Aget_space(attr_id)) < 0) - goto out; + /* Get the reference(s) */ + if((asid = H5Aget_space(aid)) < 0) + goto out; - n_refs = H5Sget_simple_extent_npoints(attr_space_id); + n_refs = H5Sget_simple_extent_npoints(asid); - dim_ref = n_refs; + dim_ref = n_refs; - refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref ); + refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref ); - if ( H5Aread( attr_id, attr_type, refbuf ) < 0) - goto out; + if ( H5Aread( aid, atid, refbuf ) < 0) + goto out; - /* Get the actual palette */ - if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0) - goto out; + /* Get the actual palette */ + if ( (pal_id = H5Rdereference( did, H5R_OBJECT, &refbuf[pal_number] )) < 0) + goto out; - if ( (pal_space_id = H5Dget_space( pal_id )) < 0) - goto out; + if ( (pal_space_id = H5Dget_space( pal_id )) < 0) + goto out; - if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0) - goto out; + if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0) + goto out; - if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0) - goto out; + if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0) + goto out; - /* close */ - if (H5Dclose(pal_id)<0) - goto out; - if ( H5Sclose( pal_space_id ) < 0) - goto out; - if ( H5Sclose( attr_space_id ) < 0) - goto out; - if ( H5Tclose( attr_type ) < 0) - goto out; - if ( H5Aclose( attr_id ) < 0) - goto out; - free( refbuf ); + /* close */ + if (H5Dclose(pal_id)<0) + goto out; + if ( H5Sclose( pal_space_id ) < 0) + goto out; + if ( H5Sclose( asid ) < 0) + goto out; + if ( H5Tclose( atid ) < 0) + goto out; + if ( H5Aclose( aid ) < 0) + goto out; + free( refbuf ); - } + } - /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0) - return -1; + /* Close the image dataset. */ + if ( H5Dclose( did ) < 0) + return -1; - return 0; + return 0; out: - H5Dclose( image_id ); - H5Sclose( attr_space_id ); - H5Tclose( attr_type ); - H5Aclose( attr_id ); - return -1; + H5Dclose( did ); + H5Sclose( asid ); + H5Tclose( atid ); + H5Aclose( aid ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5IMget_palette - * - * Purpose: Read palette - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: August 30, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMget_palette +* +* Purpose: Read palette +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: August 30, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMget_palette( hid_t loc_id, - const char *image_name, - int pal_number, - unsigned char *pal_data ) + const char *image_name, + int pal_number, + unsigned char *pal_data ) { - hid_t image_id; - int has_pal; - hid_t attr_type=-1; - hid_t attr_id; - hid_t attr_space_id=-1; - hssize_t n_refs; - hsize_t dim_ref; - hobj_ref_t *refbuf; /* buffer to read references */ - hid_t pal_id; + hid_t did; + int has_pal; + hid_t atid=-1; + hid_t aid; + hid_t asid=-1; + hssize_t n_refs; + hsize_t dim_ref; + hobj_ref_t *refbuf; /* buffer to read references */ + hid_t pal_id; - /* Open the dataset. */ - if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the dataset. */ + if((did = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0) + return -1; - /* Try to find the attribute "PALETTE" on the >>image<< dataset */ - has_pal = H5IM_find_palette(image_id); + /* Try to find the attribute "PALETTE" on the >>image<< dataset */ + has_pal = H5IM_find_palette(did); - if(has_pal == 1 ) - { - if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0) - goto out; + if(has_pal == 1 ) + { + if((aid = H5Aopen(did, "PALETTE", H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((atid = H5Aget_type(aid)) < 0) + goto out; - if(H5Tget_class(attr_type) < 0) - goto out; + if(H5Tget_class(atid) < 0) + goto out; - /* Get the reference(s) */ - if((attr_space_id = H5Aget_space(attr_id)) < 0) - goto out; + /* Get the reference(s) */ + if((asid = H5Aget_space(aid)) < 0) + goto out; - n_refs = H5Sget_simple_extent_npoints(attr_space_id); + n_refs = H5Sget_simple_extent_npoints(asid); - dim_ref = n_refs; + dim_ref = n_refs; - refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref ); + refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref ); - if ( H5Aread( attr_id, attr_type, refbuf ) < 0) - goto out; + if ( H5Aread( aid, atid, refbuf ) < 0) + goto out; - /* Get the palette id */ - if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0) - goto out; + /* Get the palette id */ + if ( (pal_id = H5Rdereference( did, H5R_OBJECT, &refbuf[pal_number] )) < 0) + goto out; - /* Read the palette dataset */ - if ( H5Dread( pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0) - goto out; + /* Read the palette dataset */ + if ( H5Dread( pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0) + goto out; - /* close */ - if (H5Dclose(pal_id)<0) - goto out; - if ( H5Sclose( attr_space_id ) < 0) - goto out; - if ( H5Tclose( attr_type ) < 0) - goto out; - if ( H5Aclose( attr_id ) < 0) - goto out; - free( refbuf ); - } + /* close */ + if (H5Dclose(pal_id)<0) + goto out; + if ( H5Sclose( asid ) < 0) + goto out; + if ( H5Tclose( atid ) < 0) + goto out; + if ( H5Aclose( aid ) < 0) + goto out; + free( refbuf ); + } - /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0) - return -1; + /* Close the image dataset. */ + if ( H5Dclose( did ) < 0) + return -1; - return 0; + return 0; out: - H5Dclose( image_id ); - H5Sclose( attr_space_id ); - H5Tclose( attr_type ); - H5Aclose( attr_id ); - return -1; + H5Dclose( did ); + H5Sclose( asid ); + H5Tclose( atid ); + H5Aclose( aid ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5IMis_image - * - * Purpose: - * - * Return: true, false, fail - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: August 30, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMis_image +* +* Purpose: +* +* Return: true, false, fail +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: August 30, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMis_image( hid_t loc_id, - const char *dset_name ) + const char *dset_name ) { - hid_t did; - int has_class; - hid_t attr_type; - hid_t attr_id; - char attr_data[20]; - herr_t ret; + hid_t did; + int has_class; + hid_t atid; + hid_t aid; + char attr_data[20]; + herr_t ret; - /* Assume initially fail condition */ - ret = -1; + /* Assume initially fail condition */ + ret = -1; - /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the dataset. */ + if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + return -1; - /* Try to find the attribute "CLASS" on the dataset */ - has_class = H5LT_find_attribute(did, "CLASS"); + /* Try to find the attribute "CLASS" on the dataset */ + has_class = H5LT_find_attribute(did, "CLASS"); - if(has_class == 0) - { - H5Dclose(did); - return 0; - } - else if(has_class == 1) - { + if(has_class == 0) + { + H5Dclose(did); + return 0; + } + else if(has_class == 1) + { - if((attr_id = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) - goto out; + if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((atid = H5Aget_type(aid)) < 0) + goto out; - if(H5Tget_class(attr_type) < 0) - goto out; + if(H5Tget_class(atid) < 0) + goto out; - if(H5Aread(attr_id, attr_type, attr_data) < 0) - goto out; + if(H5Aread(aid, atid, attr_data) < 0) + goto out; - if(strcmp(attr_data, IMAGE_CLASS) == 0) - ret = 1; - else - ret = 0; + if(strcmp(attr_data, IMAGE_CLASS) == 0) + ret = 1; + else + ret = 0; - if ( H5Tclose( attr_type ) < 0) - goto out; + if ( H5Tclose( atid ) < 0) + goto out; - if ( H5Aclose( attr_id ) < 0) - goto out; + if ( H5Aclose( aid ) < 0) + goto out; - } + } - /* Close the dataset. */ - if ( H5Dclose( did ) < 0) - return -1; + /* Close the dataset. */ + if ( H5Dclose( did ) < 0) + return -1; - return ret; + return ret; out: - H5Dclose( did ); - return -1; + H5Dclose( did ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5IMis_palette - * - * Purpose: - * - * Return: true, false, fail - * - * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu - * - * Date: August 30, 2001 - * - * Comments: - * based on HDF5 Image and Palette Specification - * http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5IMis_palette +* +* Purpose: +* +* Return: true, false, fail +* +* Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu +* +* Date: August 30, 2001 +* +* Comments: +* based on HDF5 Image and Palette Specification +* http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5IMis_palette( hid_t loc_id, - const char *dset_name ) + const char *dset_name ) { - hid_t did; - int has_class; - hid_t attr_type; - hid_t attr_id; - char attr_data[20]; - herr_t ret; + hid_t did; + int has_class; + hid_t atid; + hid_t aid; + char attr_data[20]; + herr_t ret; - /* Assume initially fail condition */ - ret = -1; + /* Assume initially fail condition */ + ret = -1; - /* Open the dataset. */ - if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the dataset. */ + if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) + return -1; - /* Try to find the attribute "CLASS" on the dataset */ - has_class = H5LT_find_attribute(did, "CLASS"); + /* Try to find the attribute "CLASS" on the dataset */ + has_class = H5LT_find_attribute(did, "CLASS"); - if(has_class == 0) - { - H5Dclose( did ); - return 0; - } - else if(has_class == 1) - { + if(has_class == 0) + { + H5Dclose( did ); + return 0; + } + else if(has_class == 1) + { - if((attr_id = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) - goto out; + if((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0) + goto out; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((atid = H5Aget_type(aid)) < 0) + goto out; - if(H5Tget_class(attr_type) < 0) - goto out; + if(H5Tget_class(atid) < 0) + goto out; - if(H5Aread(attr_id, attr_type, attr_data) < 0) - goto out; + if(H5Aread(aid, atid, attr_data) < 0) + goto out; - if(strcmp(attr_data, PALETTE_CLASS) == 0) - ret = 1; - else - ret = 0; + if(strcmp(attr_data, PALETTE_CLASS) == 0) + ret = 1; + else + ret = 0; - if ( H5Tclose( attr_type ) < 0) - goto out; + if ( H5Tclose( atid ) < 0) + goto out; - if ( H5Aclose( attr_id ) < 0) - goto out; + if ( H5Aclose( aid ) < 0) + goto out; - } + } - /* Close the dataset. */ - if ( H5Dclose( did ) < 0) - return -1; + /* Close the dataset. */ + if ( H5Dclose( did ) < 0) + return -1; - return ret; + return ret; out: - H5Dclose( did ); - return -1; + H5Dclose( did ); + return -1; } diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 33209ad..607eaca 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -33,38 +33,38 @@ int indent = 0; /*------------------------------------------------------------------------- - * - * internal functions - * - *------------------------------------------------------------------------- - */ +* +* internal functions +* +*------------------------------------------------------------------------- +*/ static herr_t H5LT_get_attribute_mem(hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data); - -/*------------------------------------------------------------------------- - * Function: H5LT_make_dataset - * - * Purpose: Creates and writes a dataset of a type tid - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: October 10, 2007 - * - *------------------------------------------------------------------------- - */ + const char *obj_name, + const char *attr_name, + hid_t mem_type_id, + void *data); + +/*------------------------------------------------------------------------- +* Function: H5LT_make_dataset +* +* Purpose: Creates and writes a dataset of a type tid +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Quincey Koziol, koziol@hdfgroup.org +* +* Date: October 10, 2007 +* +*------------------------------------------------------------------------- +*/ static herr_t H5LT_make_dataset_numerical( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - hid_t tid, - const void *data ) + const char *dset_name, + int rank, + const hsize_t *dims, + hid_t tid, + const void *data ) { hid_t did = -1, sid = -1; @@ -100,124 +100,124 @@ out: } /*------------------------------------------------------------------------- - * - * Public functions - * - *------------------------------------------------------------------------- - */ - -/*------------------------------------------------------------------------- - * Function: H5LTmake_dataset - * - * Purpose: Creates and writes a dataset of a type tid - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 19, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* +* Public functions +* +*------------------------------------------------------------------------- +*/ + +/*------------------------------------------------------------------------- +* Function: H5LTmake_dataset +* +* Purpose: Creates and writes a dataset of a type tid +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 19, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5LTmake_dataset( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - hid_t tid, - const void *data ) + const char *dset_name, + int rank, + const hsize_t *dims, + hid_t tid, + const void *data ) { return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, tid, data)); } /*------------------------------------------------------------------------- - * Function: H5LTmake_dataset_char - * - * Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 14, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5LTmake_dataset_char +* +* Purpose: Creates and writes a dataset of H5T_NATIVE_CHAR type +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 14, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5LTmake_dataset_char( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const char *data ) + const char *dset_name, + int rank, + const hsize_t *dims, + const char *data ) { return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_CHAR, data)); } /*------------------------------------------------------------------------- - * Function: H5LTmake_dataset_short - * - * Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 14, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5LTmake_dataset_short +* +* Purpose: Creates and writes a dataset of H5T_NATIVE_SHORT type +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 14, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5LTmake_dataset_short( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const short *data ) + const char *dset_name, + int rank, + const hsize_t *dims, + const short *data ) { return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- - * Function: H5LTmake_dataset_int - * - * Purpose: Creates and writes a dataset of H5T_NATIVE_INT type - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 14, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5LTmake_dataset_int +* +* Purpose: Creates and writes a dataset of H5T_NATIVE_INT type +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 14, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5LTmake_dataset_int( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const int *data ) + const char *dset_name, + int rank, + const hsize_t *dims, + const int *data ) { return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_INT, data)); } @@ -225,59 +225,59 @@ herr_t H5LTmake_dataset_int( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTmake_dataset_long - * - * Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 14, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5LTmake_dataset_long +* +* Purpose: Creates and writes a dataset of H5T_NATIVE_LONG type +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 14, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5LTmake_dataset_long( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const long *data ) + const char *dset_name, + int rank, + const hsize_t *dims, + const long *data ) { return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- - * Function: H5LTmake_dataset_float - * - * Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 14, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5LTmake_dataset_float +* +* Purpose: Creates and writes a dataset of H5T_NATIVE_FLOAT type +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 14, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5LTmake_dataset_float( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const float *data ) + const char *dset_name, + int rank, + const hsize_t *dims, + const float *data ) { return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, data)); } @@ -285,53 +285,53 @@ herr_t H5LTmake_dataset_float( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTmake_dataset_double - * - * Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 14, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5LTmake_dataset_double +* +* Purpose: Creates and writes a dataset of H5T_NATIVE_DOUBLE type +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 14, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5LTmake_dataset_double( hid_t loc_id, - const char *dset_name, - int rank, - const hsize_t *dims, - const double *data ) + const char *dset_name, + int rank, + const hsize_t *dims, + const double *data ) { return(H5LT_make_dataset_numerical(loc_id, dset_name, rank, dims, H5T_NATIVE_DOUBLE, data)); } /*------------------------------------------------------------------------- - * Function: H5LTmake_dataset_string - * - * Purpose: Creates and writes a dataset of H5T_C_S1 type - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October 05, 2004 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5LTmake_dataset_string +* +* Purpose: Creates and writes a dataset of H5T_C_S1 type +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: October 05, 2004 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5LTmake_dataset_string(hid_t loc_id, @@ -389,18 +389,18 @@ out: /*------------------------------------------------------------------------- - * Function: H5LT_read_dataset - * - * Purpose: Reads a dataset from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: October 8, 2007 - * - *------------------------------------------------------------------------- - */ +* Function: H5LT_read_dataset +* +* Purpose: Reads a dataset from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Quincey Koziol, koziol@hdfgroup.org +* +* Date: October 8, 2007 +* +*------------------------------------------------------------------------- +*/ static herr_t H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void *data) @@ -427,18 +427,18 @@ out: } /*------------------------------------------------------------------------- - * Function: H5LTread_dataset - * - * Purpose: Reads a dataset from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: June 13, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTread_dataset +* +* Purpose: Reads a dataset from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: June 13, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTread_dataset(hid_t loc_id, const char *dset_name, @@ -450,150 +450,150 @@ herr_t H5LTread_dataset(hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTread_dataset_char - * - * Purpose: Reads a dataset from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 5, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTread_dataset_char +* +* Purpose: Reads a dataset from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 5, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTread_dataset_char( hid_t loc_id, - const char *dset_name, - char *data ) + const char *dset_name, + char *data ) { return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_CHAR, data)); } /*------------------------------------------------------------------------- - * Function: H5LTread_dataset_short - * - * Purpose: Reads a dataset from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 5, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTread_dataset_short +* +* Purpose: Reads a dataset from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 5, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTread_dataset_short( hid_t loc_id, - const char *dset_name, - short *data ) + const char *dset_name, + short *data ) { return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_SHORT, data)); } /*------------------------------------------------------------------------- - * Function: H5LTread_dataset_int - * - * Purpose: Reads a dataset from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 5, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTread_dataset_int +* +* Purpose: Reads a dataset from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 5, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTread_dataset_int( hid_t loc_id, - const char *dset_name, - int *data ) + const char *dset_name, + int *data ) { return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_INT, data)); } /*------------------------------------------------------------------------- - * Function: H5LTread_dataset_long - * - * Purpose: Reads a dataset from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 5, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTread_dataset_long +* +* Purpose: Reads a dataset from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 5, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTread_dataset_long( hid_t loc_id, - const char *dset_name, - long *data ) + const char *dset_name, + long *data ) { return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_LONG, data)); } /*------------------------------------------------------------------------- - * Function: H5LTread_dataset_float - * - * Purpose: Reads a dataset from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 5, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTread_dataset_float +* +* Purpose: Reads a dataset from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 5, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTread_dataset_float( hid_t loc_id, - const char *dset_name, - float *data ) + const char *dset_name, + float *data ) { return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_FLOAT, data)); } /*------------------------------------------------------------------------- - * Function: H5LTread_dataset_double - * - * Purpose: Reads a dataset from disk. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 5, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTread_dataset_double +* +* Purpose: Reads a dataset from disk. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 5, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTread_dataset_double( hid_t loc_id, - const char *dset_name, - double *data ) + const char *dset_name, + double *data ) { return(H5LT_read_dataset_numerical(loc_id, dset_name, H5T_NATIVE_DOUBLE, data)); } /*------------------------------------------------------------------------- - * Function: H5LTread_dataset_string - * - * Purpose: Reads a dataset - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October 05, 2004 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTread_dataset_string +* +* Purpose: Reads a dataset +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: October 05, 2004 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTread_dataset_string( hid_t loc_id, - const char *dset_name, - char *buf ) + const char *dset_name, + char *buf ) { hid_t did = -1; hid_t tid = -1; @@ -627,22 +627,22 @@ out: /*------------------------------------------------------------------------- - * Function: H5LTget_dataset_ndims - * - * Purpose: Gets the dimensionality of a dataset. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 4, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_dataset_ndims +* +* Purpose: Gets the dimensionality of a dataset. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 4, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_dataset_ndims( hid_t loc_id, - const char *dset_name, - int *rank ) + const char *dset_name, + int *rank ) { hid_t did = -1; hid_t sid = -1; @@ -679,25 +679,25 @@ out: /*------------------------------------------------------------------------- - * Function: H5LTget_dataset_info - * - * Purpose: Gets information about a dataset. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 4, 2001 - * Modified: February 28, 2006: checked for NULL parameters - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_dataset_info +* +* Purpose: Gets information about a dataset. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 4, 2001 +* Modified: February 28, 2006: checked for NULL parameters +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_dataset_info( hid_t loc_id, - const char *dset_name, - hsize_t *dims, - H5T_class_t *type_class, - size_t *type_size ) + const char *dset_name, + hsize_t *dims, + H5T_class_t *type_class, + size_t *type_size ) { hid_t did = -1; hid_t tid = -1; @@ -753,27 +753,27 @@ out: } /*------------------------------------------------------------------------- - * Function: find_dataset - * - * Purpose: operator function used by H5LTfind_dataset - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: June 21, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: find_dataset +* +* Purpose: operator function used by H5LTfind_dataset +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: June 21, 2001 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ static herr_t find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_data) { /* Define a default zero value for return. This will cause the iterator to continue if - * the dataset is not found yet. - */ + * the dataset is not found yet. + */ int ret = 0; /* Shut the compiler up */ @@ -781,9 +781,9 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d linfo = linfo; /* Define a positive value for return value if the dataset was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ if(strcmp(name, (char *)op_data) == 0) ret = 1; @@ -792,26 +792,26 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d /*------------------------------------------------------------------------- - * Function: H5LTfind_dataset - * - * Purpose: Inquires if a dataset named dset_name exists attached - * to the object loc_id. - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: July 15, 2001 - * - * Return: - * Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. - * - * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. - * - *------------------------------------------------------------------------- - */ +* Function: H5LTfind_dataset +* +* Purpose: Inquires if a dataset named dset_name exists attached +* to the object loc_id. +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: July 15, 2001 +* +* Return: +* Success: The return value of the first operator that +* returns non-zero, or zero if all members were +* processed with no operator returning non-zero. +* +* Failure: Negative if something goes wrong within the +* library, or the negative value returned by one +* of the operators. +* +*------------------------------------------------------------------------- +*/ herr_t H5LTfind_dataset( hid_t loc_id, const char *dset_name ) @@ -821,98 +821,98 @@ H5LTfind_dataset( hid_t loc_id, const char *dset_name ) /*------------------------------------------------------------------------- - * - * Set attribute functions - * - *------------------------------------------------------------------------- - */ +* +* Set attribute functions +* +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_string - * - * Purpose: Creates and writes a string attribute named attr_name and attaches - * it to the object specified by the name obj_name. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: July 23, 2001 - * - * Comments: If the attribute already exists, it is overwritten - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_string +* +* Purpose: Creates and writes a string attribute named attr_name and attaches +* it to the object specified by the name obj_name. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: July 23, 2001 +* +* Comments: If the attribute already exists, it is overwritten +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *attr_data ) + const char *obj_name, + const char *attr_name, + const char *attr_data ) { - hid_t attr_type; - hid_t attr_space_id; - hid_t attr_id; - hid_t obj_id; - int has_attr; - size_t attr_size; + hid_t attr_type; + hid_t attr_space_id; + hid_t attr_id; + hid_t obj_id; + int has_attr; + size_t attr_size; - /* Open the object */ - if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the object */ + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; - /* Create the attribute */ - if ( (attr_type = H5Tcopy( H5T_C_S1 )) < 0 ) - goto out; + /* Create the attribute */ + if ( (attr_type = H5Tcopy( H5T_C_S1 )) < 0 ) + goto out; - attr_size = strlen( attr_data ) + 1; /* extra null term */ + attr_size = strlen( attr_data ) + 1; /* extra null term */ - if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 ) - goto out; + if ( H5Tset_size( attr_type, (size_t)attr_size) < 0 ) + goto out; - if ( H5Tset_strpad( attr_type, H5T_STR_NULLTERM ) < 0 ) - goto out; + if ( H5Tset_strpad( attr_type, H5T_STR_NULLTERM ) < 0 ) + goto out; - if ( (attr_space_id = H5Screate( H5S_SCALAR )) < 0 ) - goto out; + if ( (attr_space_id = H5Screate( H5S_SCALAR )) < 0 ) + goto out; - /* Verify if the attribute already exists */ - has_attr = H5LT_find_attribute(obj_id, attr_name); + /* Verify if the attribute already exists */ + has_attr = H5LT_find_attribute(obj_id, attr_name); - /* The attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(obj_id, attr_name) < 0) - goto out; + /* The attribute already exists, delete it */ + if(has_attr == 1) + if(H5Adelete(obj_id, attr_name) < 0) + goto out; - /* Create and write the attribute */ + /* Create and write the attribute */ - if((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; + if((attr_id = H5Acreate2(obj_id, attr_name, attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - if(H5Awrite(attr_id, attr_type, attr_data) < 0) - goto out; + if(H5Awrite(attr_id, attr_type, attr_data) < 0) + goto out; - if(H5Aclose(attr_id) < 0) - goto out; + if(H5Aclose(attr_id) < 0) + goto out; - if(H5Sclose(attr_space_id) < 0) - goto out; + if(H5Sclose(attr_space_id) < 0) + goto out; - if(H5Tclose(attr_type) < 0) - goto out; + if(H5Tclose(attr_type) < 0) + goto out; - /* Close the object */ - if(H5Oclose(obj_id) < 0) - return -1; + /* Close the object */ + if(H5Oclose(obj_id) < 0) + return -1; - return 0; + return 0; out: - H5Oclose(obj_id); - return -1; + H5Oclose(obj_id); + return -1; } @@ -920,185 +920,185 @@ out: /*------------------------------------------------------------------------- - * Function: H5LT_set_attribute_numerical - * - * Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: July 25, 2001 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LT_set_attribute_numerical +* +* Purpose: Private function used by H5LTset_attribute_int and H5LTset_attribute_float +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: July 25, 2001 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LT_set_attribute_numerical( hid_t loc_id, - const char *obj_name, - const char *attr_name, - size_t size, - hid_t tid, - const void *data ) + const char *obj_name, + const char *attr_name, + size_t size, + hid_t tid, + const void *data ) { - hid_t obj_id, sid, attr_id; - hsize_t dim_size=size; - int has_attr; + hid_t obj_id, sid, attr_id; + hsize_t dim_size=size; + int has_attr; - /* Open the object */ - if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the object */ + if ((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; - /* Create the data space for the attribute. */ - if ( (sid = H5Screate_simple( 1, &dim_size, NULL )) < 0 ) - goto out; + /* Create the data space for the attribute. */ + if ( (sid = H5Screate_simple( 1, &dim_size, NULL )) < 0 ) + goto out; - /* Verify if the attribute already exists */ - has_attr = H5LT_find_attribute(obj_id, attr_name); + /* Verify if the attribute already exists */ + has_attr = H5LT_find_attribute(obj_id, attr_name); - /* The attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(obj_id, attr_name) < 0) - goto out; + /* The attribute already exists, delete it */ + if(has_attr == 1) + if(H5Adelete(obj_id, attr_name) < 0) + goto out; - /* Create the attribute. */ - if((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; + /* Create the attribute. */ + if((attr_id = H5Acreate2(obj_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - /* Write the attribute data. */ - if(H5Awrite(attr_id, tid, data) < 0) - goto out; + /* Write the attribute data. */ + if(H5Awrite(attr_id, tid, data) < 0) + goto out; - /* Close the attribute. */ - if(H5Aclose(attr_id) < 0) - goto out; + /* Close the attribute. */ + if(H5Aclose(attr_id) < 0) + goto out; - /* Close the dataspace. */ - if(H5Sclose(sid) < 0) - goto out; + /* Close the dataspace. */ + if(H5Sclose(sid) < 0) + goto out; - /* Close the object */ - if(H5Oclose(obj_id) < 0) - return -1; + /* Close the object */ + if(H5Oclose(obj_id) < 0) + return -1; - return 0; + return 0; out: - H5Oclose(obj_id); - return -1; + H5Oclose(obj_id); + return -1; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_char - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 7, 2001 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_char +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 7, 2001 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const char *data, - size_t size ) + const char *obj_name, + const char *attr_name, + const char *data, + size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_CHAR, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_CHAR, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_uchar - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 8, 2004 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_uchar +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 8, 2004 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const unsigned char *data, - size_t size ) + const char *obj_name, + const char *attr_name, + const unsigned char *data, + size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_UCHAR, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_UCHAR, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_short - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 7, 2001 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_short +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 7, 2001 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const short *data, - size_t size ) + const char *obj_name, + const char *attr_name, + const short *data, + size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_SHORT, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_SHORT, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_ushort - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 8, 2004 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_ushort +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 8, 2004 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_ushort( hid_t loc_id, const char *obj_name, @@ -1107,60 +1107,60 @@ herr_t H5LTset_attribute_ushort( hid_t loc_id, size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_USHORT, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_USHORT, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_int - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 7, 2001 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_int +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 7, 2001 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const int *data, - size_t size ) + const char *obj_name, + const char *attr_name, + const int *data, + size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_INT, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_INT, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_uint - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 8, 2004 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_uint +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 8, 2004 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_uint( hid_t loc_id, const char *obj_name, @@ -1169,92 +1169,92 @@ herr_t H5LTset_attribute_uint( hid_t loc_id, size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_UINT, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_UINT, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_long - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 7, 2001 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_long +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 7, 2001 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const long *data, - size_t size ) + const char *obj_name, + const char *attr_name, + const long *data, + size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_LONG, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_LONG, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_long_long - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu - * - * Date: June 17, 2005 - * - * Comments: This function was added to support attributes of type long long - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_long_long +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu +* +* Date: June 17, 2005 +* +* Comments: This function was added to support attributes of type long long +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const long long *data, - size_t size ) + const char *obj_name, + const char *attr_name, + const long long *data, + size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_LLONG, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_LLONG, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_ulong - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 8, 2004 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_ulong +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 8, 2004 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_ulong( hid_t loc_id, const char *obj_name, @@ -1263,99 +1263,99 @@ herr_t H5LTset_attribute_ulong( hid_t loc_id, size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_ULONG, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_ULONG, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_float - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: July 25, 2001 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_float +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: July 25, 2001 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const float *data, - size_t size ) + const char *obj_name, + const char *attr_name, + const float *data, + size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_FLOAT, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_FLOAT, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_double - * - * Purpose: Create and write an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 7, 2001 - * - * Comments: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTset_attribute_double +* +* Purpose: Create and write an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 7, 2001 +* +* Comments: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTset_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - const double *data, - size_t size ) + const char *obj_name, + const char *attr_name, + const double *data, + size_t size ) { - if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, - H5T_NATIVE_DOUBLE, data ) < 0 ) - return -1; + if ( H5LT_set_attribute_numerical( loc_id, obj_name, attr_name, size, + H5T_NATIVE_DOUBLE, data ) < 0 ) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: find_attr - * - * Purpose: operator function used by H5LT_find_attribute - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: June 21, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: find_attr +* +* Purpose: operator function used by H5LT_find_attribute +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: June 21, 2001 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ static herr_t find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, - void *op_data) + void *op_data) { int ret = H5_ITER_CONT; @@ -1363,9 +1363,9 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, loc_id = loc_id; ainfo = ainfo; /* Define a positive value for return value if the attribute was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ + * cause the iterator to immediately return that positive value, + * indicating short-circuit success + */ if(strcmp(name, (char *)op_data) == 0) ret = H5_ITER_STOP; @@ -1374,51 +1374,51 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, /*------------------------------------------------------------------------- - * Function: H5LTfind_attribute - * - * Purpose: Inquires if an attribute named attr_name exists attached to - * the object loc_id. - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: May 17, 2006 - * - * Comments: - * Calls the private version of the function - * - *------------------------------------------------------------------------- - */ +* Function: H5LTfind_attribute +* +* Purpose: Inquires if an attribute named attr_name exists attached to +* the object loc_id. +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: May 17, 2006 +* +* Comments: +* Calls the private version of the function +* +*------------------------------------------------------------------------- +*/ herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name ) { - return H5LT_find_attribute(loc_id,attr_name); + return H5LT_find_attribute(loc_id,attr_name); } /*------------------------------------------------------------------------- - * Function: H5LT_find_attribute - * - * Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id. - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: June 21, 2001 - * - * Comments: - * The function uses H5Aiterate2 with the operator function find_attr - * - * Return: - * Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. - * - * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. - * - *------------------------------------------------------------------------- - */ +* Function: H5LT_find_attribute +* +* Purpose: Inquires if an attribute named attr_name exists attached to the object loc_id. +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: June 21, 2001 +* +* Comments: +* The function uses H5Aiterate2 with the operator function find_attr +* +* Return: +* Success: The return value of the first operator that +* returns non-zero, or zero if all members were +* processed with no operator returning non-zero. +* +* Failure: Negative if something goes wrong within the +* library, or the negative value returned by one +* of the operators. +* +*------------------------------------------------------------------------- +*/ herr_t H5LT_find_attribute( hid_t loc_id, const char* attr_name ) @@ -1429,210 +1429,210 @@ H5LT_find_attribute( hid_t loc_id, const char* attr_name ) /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_ndims - * - * Purpose: Gets the dimensionality of an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 4, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_ndims +* +* Purpose: Gets the dimensionality of an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 4, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_ndims( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *rank ) + const char *obj_name, + const char *attr_name, + int *rank ) { - hid_t attr_id; - hid_t sid; - hid_t obj_id; + hid_t attr_id; + hid_t sid; + hid_t obj_id; - /* Open the object */ - if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the object */ + if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; - /* Open the attribute. */ - if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) - { - H5Oclose(obj_id); - return -1; - } + /* Open the attribute. */ + if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) + { + H5Oclose(obj_id); + return -1; + } - /* Get the dataspace handle */ - if((sid = H5Aget_space(attr_id)) < 0) - goto out; + /* Get the dataspace handle */ + if((sid = H5Aget_space(attr_id)) < 0) + goto out; - /* Get rank */ - if((*rank = H5Sget_simple_extent_ndims(sid)) < 0) - goto out; + /* Get rank */ + if((*rank = H5Sget_simple_extent_ndims(sid)) < 0) + goto out; - /* Terminate access to the attribute */ - if ( H5Sclose( sid ) < 0 ) - goto out; + /* Terminate access to the attribute */ + if ( H5Sclose( sid ) < 0 ) + goto out; - /* End access to the attribute */ - if ( H5Aclose( attr_id ) ) - goto out;; + /* End access to the attribute */ + if ( H5Aclose( attr_id ) ) + goto out;; - /* Close the object */ - if(H5Oclose(obj_id) < 0 ) - return -1; + /* Close the object */ + if(H5Oclose(obj_id) < 0 ) + return -1; - return 0; + return 0; out: - H5Aclose( attr_id ); - H5Oclose(obj_id); - return -1; + H5Aclose( attr_id ); + H5Oclose(obj_id); + return -1; } /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_info - * - * Purpose: Gets information about an attribute. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 4, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_info +* +* Purpose: Gets information about an attribute. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 4, 2001 +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_info( hid_t loc_id, - const char *obj_name, - const char *attr_name, - hsize_t *dims, - H5T_class_t *type_class, - size_t *type_size ) + const char *obj_name, + const char *attr_name, + hsize_t *dims, + H5T_class_t *type_class, + size_t *type_size ) { - hid_t attr_id; - hid_t tid; - hid_t sid; - hid_t obj_id; + hid_t attr_id; + hid_t tid; + hid_t sid; + hid_t obj_id; - /* Open the object */ - if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the object */ + if((obj_id = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; - /* Open the attribute. */ - if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) - { - H5Oclose(obj_id); - return -1; - } + /* Open the attribute. */ + if((attr_id = H5Aopen(obj_id, attr_name, H5P_DEFAULT)) < 0) + { + H5Oclose(obj_id); + return -1; + } - /* Get an identifier for the datatype. */ - tid = H5Aget_type(attr_id); + /* Get an identifier for the datatype. */ + tid = H5Aget_type(attr_id); - /* Get the class. */ - *type_class = H5Tget_class(tid); + /* Get the class. */ + *type_class = H5Tget_class(tid); - /* Get the size. */ - *type_size = H5Tget_size( tid ); + /* Get the size. */ + *type_size = H5Tget_size( tid ); - /* Get the dataspace handle */ - if ( (sid = H5Aget_space( attr_id )) < 0 ) - goto out; + /* Get the dataspace handle */ + if ( (sid = H5Aget_space( attr_id )) < 0 ) + goto out; - /* Get dimensions */ - if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 ) - goto out; + /* Get dimensions */ + if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 ) + goto out; - /* Terminate access to the dataspace */ - if ( H5Sclose( sid ) < 0 ) - goto out; + /* Terminate access to the dataspace */ + if ( H5Sclose( sid ) < 0 ) + goto out; - /* Release the datatype. */ - if ( H5Tclose( tid ) ) - goto out; + /* Release the datatype. */ + if ( H5Tclose( tid ) ) + goto out; - /* End access to the attribute */ - if ( H5Aclose( attr_id ) ) - goto out; + /* End access to the attribute */ + if ( H5Aclose( attr_id ) ) + goto out; - /* Close the object */ - if(H5Oclose(obj_id) < 0 ) - return -1; + /* Close the object */ + if(H5Oclose(obj_id) < 0 ) + return -1; - return 0; + return 0; out: - H5Tclose(tid); - H5Aclose(attr_id); - H5Oclose(obj_id); - return -1; + H5Tclose(tid); + H5Aclose(attr_id); + H5Oclose(obj_id); + return -1; } /*------------------------------------------------------------------------- - * Function: H5LTtext_to_dtype - * - * Purpose: Convert DDL description to HDF5 data type. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Raymond Lu, slu@ncsa.uiuc.edu - * - * Date: October 6, 2004 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTtext_to_dtype +* +* Purpose: Convert DDL description to HDF5 data type. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Raymond Lu, slu@ncsa.uiuc.edu +* +* Date: October 6, 2004 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) { - extern int H5LTyyparse(void); - hid_t type_id; + extern int H5LTyyparse(void); + hid_t type_id; - if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) - goto out; + if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) + goto out; - if(lang_type != H5LT_DDL) { - fprintf(stderr, "only DDL is supported for now.\n"); - goto out; - } + if(lang_type != H5LT_DDL) { + fprintf(stderr, "only DDL is supported for now.\n"); + goto out; + } - input_len = strlen(text); - myinput = strdup(text); + input_len = strlen(text); + myinput = strdup(text); - if((type_id = H5LTyyparse()) < 0) - goto out; + if((type_id = H5LTyyparse()) < 0) + goto out; - free(myinput); - input_len = 0; + free(myinput); + input_len = 0; - return type_id; + return type_id; out: - return -1; + return -1; } /*------------------------------------------------------------------------- - * Function: indentation - * - * Purpose: Print spaces for indentation - * - * Return: void - * - * Programmer: Raymond Lu, slu@ncsa.uiuc.edu - * - * Date: December 6, 2005 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: indentation +* +* Purpose: Print spaces for indentation +* +* Return: void +* +* Programmer: Raymond Lu, slu@ncsa.uiuc.edu +* +* Date: December 6, 2005 +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ static void indentation(int x, char* str) { @@ -1646,17 +1646,17 @@ indentation(int x, char* str) } /*------------------------------------------------------------------------- - * Function: print_enum - * - * Purpose: prints the enum data - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Raymond Lu - * - * Modifications: - * - *-----------------------------------------------------------------------*/ +* Function: print_enum +* +* Purpose: prints the enum data +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Raymond Lu +* +* Modifications: +* +*-----------------------------------------------------------------------*/ static herr_t print_enum(hid_t type, char* str, int indt) { @@ -1680,9 +1680,9 @@ print_enum(hid_t type, char* str, int indt) goto out; /* Use buffer of INT or UNSIGNED INT to print enum values because - * we don't expect these values to be so big that INT or UNSIGNED - * INT can't hold. - */ + * we don't expect these values to be so big that INT or UNSIGNED + * INT can't hold. + */ if (H5T_SGN_NONE == H5Tget_sign(super)) { native = H5T_NATIVE_UINT; } else { @@ -1697,9 +1697,9 @@ print_enum(hid_t type, char* str, int indt) value = (unsigned char*)calloc((size_t)nmembs, MAX(dst_size, super_size)); for (i = 0; i < nmembs; i++) { - if((name[i] = H5Tget_member_name(type, (unsigned)i))==NULL) + if((name[i] = H5Tget_member_name(type, (unsigned)i))==NULL) goto out; - if(H5Tget_member_value(type, (unsigned)i, value + i * super_size) < 0) + if(H5Tget_member_value(type, (unsigned)i, value + i * super_size) < 0) goto out; } @@ -1710,45 +1710,45 @@ print_enum(hid_t type, char* str, int indt) } /* - * Sort members by increasing value - * ***not implemented yet*** - */ + * Sort members by increasing value + * ***not implemented yet*** + */ /* Print members */ for (i = 0; i < nmembs; i++) { - indentation(indt + COL, str); - nchars = sprintf(tmp_str, "\"%s\"", name[i]); + indentation(indt + COL, str); + nchars = sprintf(tmp_str, "\"%s\"", name[i]); strcat(str, tmp_str); - sprintf(tmp_str, "%*s ", MAX(0, 16 - nchars), ""); + sprintf(tmp_str, "%*s ", MAX(0, 16 - nchars), ""); strcat(str, tmp_str); - if (H5T_SGN_NONE == H5Tget_sign(native)) { - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value+i*dst_size; - sprintf(tmp_str,"%u", *((unsigned int*)((void *)copy))); + if (H5T_SGN_NONE == H5Tget_sign(native)) { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value+i*dst_size; + sprintf(tmp_str,"%u", *((unsigned int*)((void *)copy))); strcat(str, tmp_str); - } else { - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value+i*dst_size; - sprintf(tmp_str,"%d", *((int*)((void *)copy))); + } else { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value+i*dst_size; + sprintf(tmp_str,"%d", *((int*)((void *)copy))); strcat(str, tmp_str); - } + } - strcat(str, ";\n"); + strcat(str, ";\n"); } /* Release resources */ for (i = 0; i < nmembs; i++) - free(name[i]); + free(name[i]); free(name); free(value); H5Tclose(super); if (0 == nmembs) { - sprintf(tmp_str, "\n%*s ", indt + 4, ""); + sprintf(tmp_str, "\n%*s ", indt + 4, ""); strcat(str, tmp_str); } @@ -1759,22 +1759,22 @@ out: } /*------------------------------------------------------------------------- - * Function: H5LTdtype_to_text - * - * Purpose: Convert HDF5 data type to DDL description. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Raymond Lu, slu@ncsa.uiuc.edu - * - * Date: December 6, 2005 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTdtype_to_text +* +* Purpose: Convert HDF5 data type to DDL description. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Raymond Lu, slu@ncsa.uiuc.edu +* +* Date: December 6, 2005 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) { size_t str_len = INCREMENT; @@ -1790,6 +1790,7 @@ herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t * if((ret = H5LT_dtype_to_text(dtype, &text_str, lang_type, &str_len, 1)) < 0) goto out; *len = strlen(text_str) + 1; + free(text_str); } else if(len && str) { if((ret = H5LT_dtype_to_text(dtype, &str, lang_type, len, 0)) < 0) goto out; @@ -1803,24 +1804,24 @@ out: } /*------------------------------------------------------------------------- - * Function: H5LT_dtype_to_text - * - * Purpose: Private function to convert HDF5 data type to DDL description. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Raymond Lu, slu@ncsa.uiuc.edu - * - * Date: December 20, 2005 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LT_dtype_to_text +* +* Purpose: Private function to convert HDF5 data type to DDL description. +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Raymond Lu, slu@ncsa.uiuc.edu +* +* Date: December 20, 2005 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LT_dtype_to_text(hid_t dtype, char **dt_str, H5LT_lang_t lang, size_t *slen, - hbool_t no_user_buf) + hbool_t no_user_buf) { H5T_class_t tcls; char tmp_str[256]; @@ -1832,8 +1833,8 @@ herr_t H5LT_dtype_to_text(hid_t dtype, char **dt_str, H5LT_lang_t lang, size_t * *slen += INCREMENT; tmp = (char*)realloc(*dt_str, *slen); if(tmp != *dt_str) { - free(*dt_str); - *dt_str = tmp; + free(*dt_str); + *dt_str = tmp; } } @@ -1928,152 +1929,155 @@ herr_t H5LT_dtype_to_text(hid_t dtype, char **dt_str, H5LT_lang_t lang, size_t * break; case H5T_STRING: { - /* Make a copy of type in memory in case when DTYPE is on disk, the size - * will be bigger than in memory. This makes it easier to compare - * types in memory. */ - hid_t str_type; - H5T_order_t order; - hid_t tmp_type; - size_t size; - H5T_str_t str_pad; - H5T_cset_t cset; - htri_t is_vlstr; - - if((tmp_type = H5Tcopy(dtype)) < 0) - goto out; - if((size = H5Tget_size(tmp_type))==0) - goto out; - if((str_pad = H5Tget_strpad(tmp_type)) < 0) - goto out; - if((cset = H5Tget_cset(tmp_type)) < 0) - goto out; - if((is_vlstr = H5Tis_variable_str(tmp_type)) < 0) - goto out; + /* Make a copy of type in memory in case when DTYPE is on disk, the size + * will be bigger than in memory. This makes it easier to compare + * types in memory. */ + hid_t str_type; + H5T_order_t order; + hid_t tmp_type; + size_t size; + H5T_str_t str_pad; + H5T_cset_t cset; + htri_t is_vlstr; + + if((tmp_type = H5Tcopy(dtype)) < 0) + goto out; + if((size = H5Tget_size(tmp_type))==0) + goto out; + if((str_pad = H5Tget_strpad(tmp_type)) < 0) + goto out; + if((cset = H5Tget_cset(tmp_type)) < 0) + goto out; + if((is_vlstr = H5Tis_variable_str(tmp_type)) < 0) + goto out; - /* Print lead-in */ - sprintf(*dt_str, "H5T_STRING {\n"); - indent += COL; + /* Print lead-in */ + sprintf(*dt_str, "H5T_STRING {\n"); + indent += COL; - indentation(indent + COL, *dt_str); + indentation(indent + COL, *dt_str); - if(is_vlstr) - strcat(*dt_str, "STRSIZE H5T_VARIABLE;\n"); - else { - sprintf(tmp_str, "STRSIZE %d;\n", (int)size); - strcat(*dt_str, tmp_str); - } + if(is_vlstr) + strcat(*dt_str, "STRSIZE H5T_VARIABLE;\n"); + else { + sprintf(tmp_str, "STRSIZE %d;\n", (int)size); + strcat(*dt_str, tmp_str); + } - indentation(indent + COL, *dt_str); + indentation(indent + COL, *dt_str); - if (str_pad == H5T_STR_NULLTERM) - strcat(*dt_str, "STRPAD H5T_STR_NULLTERM;\n"); - else if (str_pad == H5T_STR_NULLPAD) - strcat(*dt_str, "STRPAD H5T_STR_NULLPAD;\n"); - else if (str_pad == H5T_STR_SPACEPAD) - strcat(*dt_str, "STRPAD H5T_STR_SPACEPAD;\n"); - else - strcat(*dt_str, "STRPAD H5T_STR_ERROR;\n"); + if (str_pad == H5T_STR_NULLTERM) + strcat(*dt_str, "STRPAD H5T_STR_NULLTERM;\n"); + else if (str_pad == H5T_STR_NULLPAD) + strcat(*dt_str, "STRPAD H5T_STR_NULLPAD;\n"); + else if (str_pad == H5T_STR_SPACEPAD) + strcat(*dt_str, "STRPAD H5T_STR_SPACEPAD;\n"); + else + strcat(*dt_str, "STRPAD H5T_STR_ERROR;\n"); - indentation(indent + COL, *dt_str); + indentation(indent + COL, *dt_str); - if (cset == H5T_CSET_ASCII) - strcat(*dt_str, "CSET H5T_CSET_ASCII;\n"); - else if (cset == H5T_CSET_UTF8) - strcat(*dt_str, "CSET H5T_CSET_UTF8;\n"); - else - strcat(*dt_str, "CSET unknown;\n"); + if (cset == H5T_CSET_ASCII) + strcat(*dt_str, "CSET H5T_CSET_ASCII;\n"); + else if (cset == H5T_CSET_UTF8) + strcat(*dt_str, "CSET H5T_CSET_UTF8;\n"); + else + strcat(*dt_str, "CSET unknown;\n"); - /* Reproduce a C type string */ - if((str_type = H5Tcopy(H5T_C_S1)) < 0) - goto out; - if(is_vlstr) { - if(H5Tset_size(str_type, H5T_VARIABLE) < 0) + /* Reproduce a C type string */ + if((str_type = H5Tcopy(H5T_C_S1)) < 0) goto out; - } else { - if(H5Tset_size(str_type, size) < 0) + if(is_vlstr) { + if(H5Tset_size(str_type, H5T_VARIABLE) < 0) + goto out; + } else { + if(H5Tset_size(str_type, size) < 0) + goto out; + } + if(H5Tset_cset(str_type, cset) < 0) + goto out; + if(H5Tset_strpad(str_type, str_pad) < 0) goto out; - } - if(H5Tset_cset(str_type, cset) < 0) - goto out; - if(H5Tset_strpad(str_type, str_pad) < 0) - goto out; - indentation(indent + COL, *dt_str); + indentation(indent + COL, *dt_str); - /* Check C variable-length string first. Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - strcat(*dt_str, "CTYPE H5T_C_S1;\n"); - goto next; - } + /* Check C variable-length string first. Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + strcat(*dt_str, "CTYPE H5T_C_S1;\n"); + goto next; + } - /* Change the endianness and see if they're equal. */ - if((order = H5Tget_order(tmp_type)) < 0) - goto out; - if(order==H5T_ORDER_LE) { - if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) + /* Change the endianness and see if they're equal. */ + if((order = H5Tget_order(tmp_type)) < 0) goto out; - } else if(order==H5T_ORDER_BE) { - if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) + if(order==H5T_ORDER_LE) { + if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) + goto out; + } else if(order==H5T_ORDER_BE) { + if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) + goto out; + } + + if (H5Tequal(tmp_type, str_type)) { + strcat(*dt_str, "H5T_C_S1;\n"); + goto next; + } + + /* If not equal to C variable-length string, check Fortran type. + * Actually H5Tequal can't tell difference between H5T_C_S1 and H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + if(H5Tclose(str_type) < 0) goto out; - } - - if (H5Tequal(tmp_type, str_type)) { - strcat(*dt_str, "H5T_C_S1;\n"); - goto next; - } - - /* If not equal to C variable-length string, check Fortran type. - * Actually H5Tequal can't tell difference between H5T_C_S1 and H5T_FORTRAN_S1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - if(H5Tclose(str_type) < 0) - goto out; - if((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0) - goto out; - if(H5Tset_cset(str_type, cset) < 0) - goto out; - if(H5Tset_size(str_type, size) < 0) - goto out; - if(H5Tset_strpad(str_type, str_pad) < 0) - goto out; - - /* Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - strcat(*dt_str, "CTYPE H5T_FORTRAN_S1;\n"); - goto next; - } - - /* Change the endianness and see if they're equal. */ - if((order = H5Tget_order(tmp_type)) < 0) - goto out; - if(order==H5T_ORDER_LE) { - if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) + if((str_type = H5Tcopy(H5T_FORTRAN_S1)) < 0) goto out; - } else if(order==H5T_ORDER_BE) { - if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) + if(H5Tset_cset(str_type, cset) < 0) + goto out; + if(H5Tset_size(str_type, size) < 0) + goto out; + if(H5Tset_strpad(str_type, str_pad) < 0) goto out; - } - /* Are the two types equal? */ - if (H5Tequal(tmp_type, str_type)) { - strcat(*dt_str, "CTYPE H5T_FORTRAN_S1;\n"); - goto next; - } + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + strcat(*dt_str, "CTYPE H5T_FORTRAN_S1;\n"); + goto next; + } - /* Type doesn't match any of above. */ - strcat(*dt_str, "CTYPE unknown_one_character_type;\n "); + /* Change the endianness and see if they're equal. */ + if((order = H5Tget_order(tmp_type)) < 0) + goto out; + if(order==H5T_ORDER_LE) { + if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) + goto out; + } else if(order==H5T_ORDER_BE) { + if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) + goto out; + } + + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + strcat(*dt_str, "CTYPE H5T_FORTRAN_S1;\n"); + goto next; + } + + /* Type doesn't match any of above. */ + strcat(*dt_str, "CTYPE unknown_one_character_type;\n "); next: - H5Tclose(str_type); - H5Tclose(tmp_type); + H5Tclose(str_type); + H5Tclose(tmp_type); - /* Print closing */ - indent -= COL; - indentation(indent + COL, *dt_str); - strcat(*dt_str, "}"); + /* Print closing */ + indent -= COL; + indentation(indent + COL, *dt_str); + strcat(*dt_str, "}"); - break; + break; } case H5T_OPAQUE: + { + char *tag; + /* Print lead-in */ sprintf(*dt_str, "H5T_OPAQUE {\n"); indent += COL; @@ -2083,7 +2087,12 @@ next: strcat(*dt_str, tmp_str); indentation(indent + COL, *dt_str); - sprintf(tmp_str, "OPQ_TAG \"%s\";\n", H5Tget_tag(dtype)); + tag = H5Tget_tag(dtype); + if(tag) { + sprintf(tmp_str, "OPQ_TAG \"%s\";\n", tag); + free(tag); + } else + sprintf(tmp_str, "OPQ_TAG \"\";\n"); strcat(*dt_str, tmp_str); /* Print closing */ @@ -2092,168 +2101,169 @@ next: strcat(*dt_str, "}"); break; + } case H5T_ENUM: { - hid_t super; - size_t super_len; - char* stmp; + hid_t super; + size_t super_len; + char* stmp; - /* Print lead-in */ - sprintf(*dt_str, "H5T_ENUM {\n"); - indent += COL; - indentation(indent + COL, *dt_str); + /* Print lead-in */ + sprintf(*dt_str, "H5T_ENUM {\n"); + indent += COL; + indentation(indent + COL, *dt_str); - if((super = H5Tget_super(dtype)) < 0) - goto out; - if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) - goto out; - stmp = (char*)calloc(super_len, sizeof(char)); - if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) - goto out; - strcat(*dt_str, stmp); - free(stmp); - strcat(*dt_str, ";\n"); - H5Tclose(super); - - if(print_enum(dtype, *dt_str, indent) < 0) - goto out; + if((super = H5Tget_super(dtype)) < 0) + goto out; + if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + goto out; + stmp = (char*)calloc(super_len, sizeof(char)); + if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + goto out; + strcat(*dt_str, stmp); + free(stmp); + strcat(*dt_str, ";\n"); + H5Tclose(super); - /* Print closing */ - indent -= COL; - indentation(indent + COL, *dt_str); - strcat(*dt_str, "}"); + if(print_enum(dtype, *dt_str, indent) < 0) + goto out; - break; + /* Print closing */ + indent -= COL; + indentation(indent + COL, *dt_str); + strcat(*dt_str, "}"); + + break; } case H5T_VLEN: { - hid_t super; - size_t super_len; - char* stmp; + hid_t super; + size_t super_len; + char* stmp; - /* Print lead-in */ - sprintf(*dt_str, "H5T_VLEN {\n"); - indent += COL; - indentation(indent + COL, *dt_str); + /* Print lead-in */ + sprintf(*dt_str, "H5T_VLEN {\n"); + indent += COL; + indentation(indent + COL, *dt_str); - if((super = H5Tget_super(dtype)) < 0) - goto out; - if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) - goto out; - stmp = (char*)calloc(super_len, sizeof(char)); - if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) - goto out; - strcat(*dt_str, stmp); - free(stmp); - strcat(*dt_str, "\n"); - H5Tclose(super); + if((super = H5Tget_super(dtype)) < 0) + goto out; + if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) + goto out; + stmp = (char*)calloc(super_len, sizeof(char)); + if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + goto out; + strcat(*dt_str, stmp); + free(stmp); + strcat(*dt_str, "\n"); + H5Tclose(super); - /* Print closing */ - indent -= COL; - indentation(indent + COL, *dt_str); - strcat(*dt_str, "}"); + /* Print closing */ + indent -= COL; + indentation(indent + COL, *dt_str); + strcat(*dt_str, "}"); - break; + break; } case H5T_ARRAY: { - hid_t super; - size_t super_len; - char* stmp; - hsize_t dims[H5S_MAX_RANK]; - int ndims; - - /* Print lead-in */ - sprintf(*dt_str, "H5T_ARRAY {\n"); - indent += COL; - indentation(indent + COL, *dt_str); - - /* Get array information */ - if((ndims = H5Tget_array_ndims(dtype)) < 0) - goto out; - if(H5Tget_array_dims2(dtype, dims) < 0) - goto out; - - /* Print array dimensions */ - for (i = 0; i < ndims; i++) { - sprintf(tmp_str, "[%d]", (int) dims[i]); - strcat(*dt_str, tmp_str); - } - strcat(*dt_str, " "); - - if((super = H5Tget_super(dtype)) < 0) - goto out; - if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) - goto out; - stmp = (char*)calloc(super_len, sizeof(char)); - if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) - goto out; - strcat(*dt_str, stmp); - free(stmp); - strcat(*dt_str, "\n"); - H5Tclose(super); - - /* Print closing */ - indent -= COL; - indentation(indent + COL, *dt_str); - strcat(*dt_str, "}"); - - break; - } - case H5T_COMPOUND: - { - char *mname; - hid_t mtype; - size_t moffset; - H5T_class_t mclass; - size_t mlen; - char* mtmp; - int nmembs; - - if((nmembs = H5Tget_nmembers(dtype)) < 0) - goto out; - - sprintf(*dt_str, "H5T_COMPOUND {\n"); - indent += COL; + hid_t super; + size_t super_len; + char* stmp; + hsize_t dims[H5S_MAX_RANK]; + int ndims; + + /* Print lead-in */ + sprintf(*dt_str, "H5T_ARRAY {\n"); + indent += COL; + indentation(indent + COL, *dt_str); - for (i = 0; i < nmembs; i++) { - if((mname = H5Tget_member_name(dtype, (unsigned)i))==NULL) + /* Get array information */ + if((ndims = H5Tget_array_ndims(dtype)) < 0) goto out; - if((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0) + if(H5Tget_array_dims2(dtype, dims) < 0) goto out; - moffset = H5Tget_member_offset(dtype, (unsigned)i); - indentation(indent + COL, *dt_str); - if((mclass = H5Tget_class(mtype)) < 0) - goto out; - if (H5T_COMPOUND == mclass) - indent += COL; + /* Print array dimensions */ + for (i = 0; i < ndims; i++) { + sprintf(tmp_str, "[%d]", (int) dims[i]); + strcat(*dt_str, tmp_str); + } + strcat(*dt_str, " "); - if(H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) + if((super = H5Tget_super(dtype)) < 0) goto out; - mtmp = (char*)calloc(mlen, sizeof(char)); - if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) + if(H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; - strcat(*dt_str, mtmp); - free(mtmp); - - if (H5T_COMPOUND == mclass) - indent -= COL; + stmp = (char*)calloc(super_len, sizeof(char)); + if(H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + goto out; + strcat(*dt_str, stmp); + free(stmp); + strcat(*dt_str, "\n"); + H5Tclose(super); - sprintf(tmp_str, " \"%s\"", mname); - strcat(*dt_str, tmp_str); - free(mname); + /* Print closing */ + indent -= COL; + indentation(indent + COL, *dt_str); + strcat(*dt_str, "}"); - sprintf(tmp_str, " : %lu;\n", (unsigned long)moffset); - strcat(*dt_str, tmp_str); + break; } + case H5T_COMPOUND: + { + char *mname; + hid_t mtype; + size_t moffset; + H5T_class_t mclass; + size_t mlen; + char* mtmp; + int nmembs; + + if((nmembs = H5Tget_nmembers(dtype)) < 0) + goto out; - /* Print closing */ - indent -= COL; - indentation(indent + COL, *dt_str); - strcat(*dt_str, "}"); + sprintf(*dt_str, "H5T_COMPOUND {\n"); + indent += COL; + + for (i = 0; i < nmembs; i++) { + if((mname = H5Tget_member_name(dtype, (unsigned)i))==NULL) + goto out; + if((mtype = H5Tget_member_type(dtype, (unsigned)i)) < 0) + goto out; + moffset = H5Tget_member_offset(dtype, (unsigned)i); + indentation(indent + COL, *dt_str); + + if((mclass = H5Tget_class(mtype)) < 0) + goto out; + if (H5T_COMPOUND == mclass) + indent += COL; + + if(H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) + goto out; + mtmp = (char*)calloc(mlen, sizeof(char)); + if(H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) + goto out; + strcat(*dt_str, mtmp); + free(mtmp); + + if (H5T_COMPOUND == mclass) + indent -= COL; + + sprintf(tmp_str, " \"%s\"", mname); + strcat(*dt_str, tmp_str); + free(mname); + + sprintf(tmp_str, " : %lu;\n", (unsigned long)moffset); + strcat(*dt_str, tmp_str); + } + + /* Print closing */ + indent -= COL; + indentation(indent + COL, *dt_str); + strcat(*dt_str, "}"); - break; + break; } case H5T_TIME: sprintf(*dt_str, "H5T_TIME: not yet implemented"); @@ -2272,81 +2282,81 @@ out: } - - - -/*------------------------------------------------------------------------- - * - * Get attribute functions - * - *------------------------------------------------------------------------- - */ - - -/*------------------------------------------------------------------------- - * Function: H5LTget_attribute_string - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - - + + + +/*------------------------------------------------------------------------- +* +* Get attribute functions +* +*------------------------------------------------------------------------- +*/ + + +/*------------------------------------------------------------------------- +* Function: H5LTget_attribute_string +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ + + herr_t H5LTget_attribute_string( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ) + const char *obj_name, + const char *attr_name, + char *data ) { - /* identifiers */ - hid_t obj_id; + /* identifiers */ + hid_t obj_id; - /* Open the object */ - if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0) - return -1; + /* Open the object */ + if ((obj_id = H5Oopen( loc_id, obj_name, H5P_DEFAULT)) < 0) + return -1; - /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) + return -1; - /* Close the object */ - if(H5Oclose(obj_id) < 0) - return -1; + /* Close the object */ + if(H5Oclose(obj_id) < 0) + return -1; - return 0; + return 0; } /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_char - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_char +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_char( hid_t loc_id, - const char *obj_name, - const char *attr_name, - char *data ) + const char *obj_name, + const char *attr_name, + char *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_CHAR, data) < 0) @@ -2356,26 +2366,26 @@ herr_t H5LTget_attribute_char( hid_t loc_id, } /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_uchar - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 8, 2004 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_uchar +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 8, 2004 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_uchar( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned char *data ) + const char *obj_name, + const char *attr_name, + unsigned char *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_UCHAR, data) < 0) @@ -2387,26 +2397,26 @@ herr_t H5LTget_attribute_uchar( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_short - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_short +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_short( hid_t loc_id, - const char *obj_name, - const char *attr_name, - short *data ) + const char *obj_name, + const char *attr_name, + short *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_SHORT, data) < 0) @@ -2416,22 +2426,22 @@ herr_t H5LTget_attribute_short( hid_t loc_id, } /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_ushort - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 8, 2004 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_ushort +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 8, 2004 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_ushort( hid_t loc_id, const char *obj_name, const char *attr_name, @@ -2447,26 +2457,26 @@ herr_t H5LTget_attribute_ushort( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_int - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_int +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_int( hid_t loc_id, - const char *obj_name, - const char *attr_name, - int *data ) + const char *obj_name, + const char *attr_name, + int *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_INT, data) < 0) @@ -2476,22 +2486,22 @@ herr_t H5LTget_attribute_int( hid_t loc_id, } /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_uint - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 8, 2004 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_uint +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 8, 2004 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_uint( hid_t loc_id, const char *obj_name, const char *attr_name, @@ -2507,22 +2517,22 @@ herr_t H5LTget_attribute_uint( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_long - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_long +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_long( hid_t loc_id, const char *obj_name, const char *attr_name, @@ -2536,26 +2546,26 @@ herr_t H5LTget_attribute_long( hid_t loc_id, } /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_long_long - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu - * - * Date: June 17, 2005 - * - * Comments: This funstion was added to suuport INTEGER*8 Fortran types - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_long_long +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Elena Pourmal, epourmal@ncsa.uiuc.edu +* +* Date: June 17, 2005 +* +* Comments: This funstion was added to suuport INTEGER*8 Fortran types +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_long_long( hid_t loc_id, - const char *obj_name, - const char *attr_name, - long long *data ) + const char *obj_name, + const char *attr_name, + long long *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_LLONG, data) < 0) @@ -2566,26 +2576,26 @@ herr_t H5LTget_attribute_long_long( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_ulong - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 8, 2004 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_ulong +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 8, 2004 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_ulong( hid_t loc_id, - const char *obj_name, - const char *attr_name, - unsigned long *data ) + const char *obj_name, + const char *attr_name, + unsigned long *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULONG, data) < 0) @@ -2596,28 +2606,28 @@ herr_t H5LTget_attribute_ulong( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_float - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_float +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_float( hid_t loc_id, - const char *obj_name, - const char *attr_name, - float *data ) + const char *obj_name, + const char *attr_name, + float *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_FLOAT, data) < 0) @@ -2628,28 +2638,28 @@ herr_t H5LTget_attribute_float( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTget_attribute_double - * - * Purpose: Reads an attribute named attr_name - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute_double +* +* Purpose: Reads an attribute named attr_name +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute_double( hid_t loc_id, - const char *obj_name, - const char *attr_name, - double *data ) + const char *obj_name, + const char *attr_name, + double *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_DOUBLE, data) < 0) @@ -2660,29 +2670,29 @@ herr_t H5LTget_attribute_double( hid_t loc_id, /*------------------------------------------------------------------------- - * Function: H5LTget_attribute - * - * Purpose: Reads an attribute named attr_name with the memory type mem_type_id - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: Private function - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LTget_attribute +* +* Purpose: Reads an attribute named attr_name with the memory type mem_type_id +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: Private function +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LTget_attribute( hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data ) + const char *obj_name, + const char *attr_name, + hid_t mem_type_id, + void *data ) { /* Get the attribute */ if(H5LT_get_attribute_mem(loc_id, obj_name, attr_name, mem_type_id, data) < 0) @@ -2693,35 +2703,35 @@ herr_t H5LTget_attribute( hid_t loc_id, /*------------------------------------------------------------------------- - * private functions - *------------------------------------------------------------------------- - */ +* private functions +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5LT_get_attribute_mem - * - * Purpose: Reads an attribute named attr_name with the memory type mem_type_id - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: Private function - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LT_get_attribute_mem +* +* Purpose: Reads an attribute named attr_name with the memory type mem_type_id +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: Private function +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ static herr_t H5LT_get_attribute_mem(hid_t loc_id, - const char *obj_name, - const char *attr_name, - hid_t mem_type_id, - void *data) + const char *obj_name, + const char *attr_name, + hid_t mem_type_id, + void *data) { /* identifiers */ hid_t obj_id = -1; @@ -2743,7 +2753,7 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, /* Close the object */ if(H5Oclose(obj_id) < 0) - goto out; + goto out; obj_id = -1; return 0; @@ -2755,138 +2765,138 @@ out: } /*------------------------------------------------------------------------- - * Function: H5LT_get_attribute_disk - * - * Purpose: Reads an attribute named attr_name with the datatype stored on disk - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September 19, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LT_get_attribute_disk +* +* Purpose: Reads an attribute named attr_name with the datatype stored on disk +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September 19, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LT_get_attribute_disk( hid_t loc_id, - const char *attr_name, - void *attr_out ) + const char *attr_name, + void *attr_out ) { - /* identifiers */ - hid_t attr_id; - hid_t attr_type; + /* identifiers */ + hid_t attr_id; + hid_t attr_type; - if(( attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0) - return -1; + if(( attr_id = H5Aopen(loc_id, attr_name, H5P_DEFAULT)) < 0) + return -1; - if((attr_type = H5Aget_type(attr_id)) < 0) - goto out; + if((attr_type = H5Aget_type(attr_id)) < 0) + goto out; - if(H5Aread(attr_id, attr_type, attr_out) < 0) - goto out; + if(H5Aread(attr_id, attr_type, attr_out) < 0) + goto out; - if(H5Tclose(attr_type) < 0) - goto out; + if(H5Tclose(attr_type) < 0) + goto out; - if ( H5Aclose( attr_id ) < 0 ) - return -1;; + if ( H5Aclose( attr_id ) < 0 ) + return -1;; - return 0; + return 0; out: - H5Tclose( attr_type ); - H5Aclose( attr_id ); - return -1; + H5Tclose( attr_type ); + H5Aclose( attr_id ); + return -1; } /*------------------------------------------------------------------------- - * Function: H5LT_set_attribute_string - * - * Purpose: creates and writes an attribute named NAME to the dataset DSET_ID - * - * Return: FAIL on error, SUCCESS on success - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: January 04, 2005 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5LT_set_attribute_string +* +* Purpose: creates and writes an attribute named NAME to the dataset DSET_ID +* +* Return: FAIL on error, SUCCESS on success +* +* Programmer: pvn@ncsa.uiuc.edu +* +* Date: January 04, 2005 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf ) { - hid_t tid; - hid_t sid = -1; - hid_t aid = -1; - int has_attr; - size_t size; + hid_t tid; + hid_t sid = -1; + hid_t aid = -1; + int has_attr; + size_t size; - /* verify if the attribute already exists */ - has_attr = H5LT_find_attribute(dset_id,name); + /* verify if the attribute already exists */ + has_attr = H5LT_find_attribute(dset_id,name); - /* the attribute already exists, delete it */ - if(has_attr == 1) - if(H5Adelete(dset_id, name) < 0) - return FAIL; + /* the attribute already exists, delete it */ + if(has_attr == 1) + if(H5Adelete(dset_id, name) < 0) + return FAIL; -/*------------------------------------------------------------------------- - * create the attribute type - *------------------------------------------------------------------------- - */ - if((tid = H5Tcopy(H5T_C_S1)) < 0) - return FAIL; + /*------------------------------------------------------------------------- + * create the attribute type + *------------------------------------------------------------------------- + */ + if((tid = H5Tcopy(H5T_C_S1)) < 0) + return FAIL; - size = strlen(buf) + 1; /* extra null term */ + size = strlen(buf) + 1; /* extra null term */ - if(H5Tset_size(tid,(size_t)size) < 0) - goto out; + if(H5Tset_size(tid,(size_t)size) < 0) + goto out; - if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) - goto out; + if(H5Tset_strpad(tid, H5T_STR_NULLTERM) < 0) + goto out; - if((sid = H5Screate(H5S_SCALAR)) < 0) - goto out; + if((sid = H5Screate(H5S_SCALAR)) < 0) + goto out; -/*------------------------------------------------------------------------- - * create and write the attribute - *------------------------------------------------------------------------- - */ - if((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; + /*------------------------------------------------------------------------- + * create and write the attribute + *------------------------------------------------------------------------- + */ + if((aid = H5Acreate2(dset_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - if(H5Awrite(aid, tid, buf) < 0) - goto out; + if(H5Awrite(aid, tid, buf) < 0) + goto out; - if(H5Aclose(aid) < 0) - goto out; + if(H5Aclose(aid) < 0) + goto out; - if(H5Sclose(sid) < 0) - goto out; + if(H5Sclose(sid) < 0) + goto out; - if(H5Tclose(tid) < 0) - goto out; + if(H5Tclose(tid) < 0) + goto out; - return SUCCEED; + return SUCCEED; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { - H5Aclose(aid); - H5Tclose(tid); - H5Sclose(sid); - } H5E_END_TRY; - return FAIL; + H5E_BEGIN_TRY { + H5Aclose(aid); + H5Tclose(tid); + H5Sclose(sid); + } H5E_END_TRY; + return FAIL; } diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 30a8490..a035319 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -20,11 +20,11 @@ /*------------------------------------------------------------------------- - * - * internal functions - * - *------------------------------------------------------------------------- - */ +* +* internal functions +* +*------------------------------------------------------------------------- +*/ static int H5TB_find_field(const char *field, const char *field_list); @@ -43,47 +43,47 @@ static hid_t H5TB_create_type(hid_t loc_id, hid_t ftype_id); /*------------------------------------------------------------------------- - * - * Create functions - * - *------------------------------------------------------------------------- - */ +* +* Create functions +* +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5TBmake_table - * - * Purpose: Make a table - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * Quincey Koziol - * - * Date: January 17, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5TBmake_table +* +* Purpose: Make a table +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* Quincey Koziol +* +* Date: January 17, 2001 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5TBmake_table( const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hsize_t nrecords, - size_t type_size, - const char *field_names[], - const size_t *field_offset, - const hid_t *field_types, - hsize_t chunk_size, - void *fill_data, - int compress, - const void *buf ) + hid_t loc_id, + const char *dset_name, + hsize_t nfields, + hsize_t nrecords, + size_t type_size, + const char *field_names[], + const size_t *field_offset, + const hid_t *field_types, + hsize_t chunk_size, + void *fill_data, + int compress, + const void *buf ) { - + hid_t did; hid_t sid; hid_t mem_type_id; @@ -97,37 +97,37 @@ herr_t H5TBmake_table( const char *table_title, char aux[255]; hsize_t i; unsigned char *tmp_buf; - + dims[0] = nrecords; dims_chunk[0] = chunk_size; - + /* create the memory data type. */ if ((mem_type_id = H5Tcreate (H5T_COMPOUND, type_size )) < 0) return -1; - + /* insert fields. */ for ( i = 0; i < nfields; i++) { if(H5Tinsert(mem_type_id, field_names[i], field_offset[i], field_types[i] ) < 0) return -1; } - + /* create a simple data space with unlimited size */ if ((sid = H5Screate_simple( 1, dims, maxdims )) < 0) return -1; - + /* modify dataset creation properties, i.e. enable chunking */ plist_id = H5Pcreate(H5P_DATASET_CREATE); if (H5Pset_chunk(plist_id, 1, dims_chunk) < 0) return -1; - + /* set the fill value using a struct as the data type. */ if (fill_data) { if(H5Pset_fill_value(plist_id, mem_type_id, fill_data) < 0) return -1; } - + /* dataset creation property list is modified to use GZIP compression with the compression effort set to 6. @@ -137,11 +137,11 @@ herr_t H5TBmake_table( const char *table_title, if(H5Pset_deflate(plist_id, 6) < 0) return -1; } - + /* create the dataset. */ if ((did = H5Dcreate2(loc_id, dset_name, mem_type_id, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) goto out; - + /* only write if there is something to write */ if (buf) { @@ -149,108 +149,108 @@ herr_t H5TBmake_table( const char *table_title, if (H5Dwrite( did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0) goto out; } - + /* terminate access to the data space. */ if (H5Sclose(sid) < 0) goto out; - + /* end access to the dataset */ if (H5Dclose(did) < 0) goto out; - + /* end access to the property list */ if (H5Pclose(plist_id) < 0) goto out; - + /*------------------------------------------------------------------------- * set the conforming table attributes *------------------------------------------------------------------------- */ - + /* attach the CLASS attribute */ if (H5LTset_attribute_string( loc_id, dset_name, "CLASS", TABLE_CLASS ) < 0) goto out; - + /* attach the VERSION attribute */ if (H5LTset_attribute_string( loc_id, dset_name, "VERSION", TABLE_VERSION ) < 0) goto out; - + /* attach the TITLE attribute */ if (H5LTset_attribute_string( loc_id, dset_name, "TITLE", table_title ) < 0) goto out; - + /* attach the FIELD_ name attribute */ for ( i = 0; i < nfields; i++) { /* get the member name */ member_name = H5Tget_member_name( mem_type_id,(unsigned) i ); - + strcpy( attr_name, "FIELD_" ); sprintf( aux, "%d", (int)i ); strcat( attr_name, aux ); sprintf( aux, "%s", "_NAME" ); strcat( attr_name, aux ); - + /* attach the attribute */ if (H5LTset_attribute_string( loc_id, dset_name, attr_name, member_name ) < 0) goto out; - + free( member_name ); - + } - + /* attach the FIELD_ fill value attribute */ if (fill_data ) { - - tmp_buf = fill_data; - + + tmp_buf = (unsigned char *) fill_data; + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + if (( sid = H5Screate(H5S_SCALAR)) < 0) goto out; - + for ( i = 0; i < nfields; i++) { - + /* get the member name */ member_name = H5Tget_member_name(mem_type_id, (unsigned)i); - + strcpy(attr_name, "FIELD_"); sprintf(aux, "%d", (int)i); strcat(attr_name, aux); sprintf(aux, "%s", "_FILL"); strcat(attr_name, aux); - + if ((attr_id = H5Acreate2(did, attr_name, field_types[i], sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - + if (H5Awrite(attr_id, field_types[i], tmp_buf+field_offset[i]) < 0) goto out; - + if (H5Aclose(attr_id) < 0) goto out; - + free(member_name); } - + /* terminate access to the data space. */ if (H5Sclose(sid) < 0) goto out; - + /* end access to the dataset */ if (H5Dclose(did) < 0) goto out; } - + /* release the datatype. */ if (H5Tclose( mem_type_id ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY { @@ -260,45 +260,45 @@ out: H5Tclose(mem_type_id); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * - * Write functions - * - *------------------------------------------------------------------------- - */ +* +* Write functions +* +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5TBappend_records - * - * Purpose: Appends records to a table - * - * Return: Success: 0, Failure: -1 - * - * Programmers: - * Pedro Vicente, pvn@ncsa.uiuc.edu - * Quincey Koziol - * - * Date: November 19, 2001 - * - * Comments: Uses memory offsets - * - * Modifications: April 1, 2004 - * the FIELD_SIZES parameter is used to define the memory type ID - * returned by H5TB_create_type - * - *------------------------------------------------------------------------- - */ +* Function: H5TBappend_records +* +* Purpose: Appends records to a table +* +* Return: Success: 0, Failure: -1 +* +* Programmers: +* Pedro Vicente, pvn@ncsa.uiuc.edu +* Quincey Koziol +* +* Date: November 19, 2001 +* +* Comments: Uses memory offsets +* +* Modifications: April 1, 2004 +* the FIELD_SIZES parameter is used to define the memory type ID +* returned by H5TB_create_type +* +*------------------------------------------------------------------------- +*/ herr_t H5TBappend_records( hid_t loc_id, - const char *dset_name, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf ) + const char *dset_name, + hsize_t nrecords, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + const void *buf ) { hid_t did; hid_t tid=-1; @@ -307,26 +307,26 @@ herr_t H5TBappend_records( hid_t loc_id, hid_t m_sid=-1; hsize_t nrecords_orig; hsize_t nfields; - + /* get the original number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords_orig ) < 0) return -1; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - + /* get the datatypes */ if ((tid = H5Dget_type( did )) < 0) goto out; - + if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,tid)) < 0) goto out; - + /* append the records */ if ((H5TB_common_append_records(did, mem_type_id, (size_t)nrecords, nrecords_orig, buf)) < 0) goto out; - + /* close */ if (H5Tclose( tid ) < 0) return -1; @@ -334,9 +334,9 @@ herr_t H5TBappend_records( hid_t loc_id, goto out; if (H5Dclose( did ) < 0) goto out; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -351,36 +351,36 @@ out: } /*------------------------------------------------------------------------- - * Function: H5TBwrite_records - * - * Purpose: Writes records - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 19, 2001 - * - * Comments: Uses memory offsets - * - * Modifications: April 1, 2004 - * the FIELD_SIZES parameter is used to define the memory type ID - * returned by H5TB_create_type - * - *------------------------------------------------------------------------- - */ +* Function: H5TBwrite_records +* +* Purpose: Writes records +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 19, 2001 +* +* Comments: Uses memory offsets +* +* Modifications: April 1, 2004 +* the FIELD_SIZES parameter is used to define the memory type ID +* returned by H5TB_create_type +* +*------------------------------------------------------------------------- +*/ herr_t H5TBwrite_records( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf ) + const char *dset_name, + hsize_t start, + hsize_t nrecords, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + const void *buf ) { - + hid_t did; hid_t tid; hsize_t count[1]; @@ -390,43 +390,43 @@ herr_t H5TBwrite_records( hid_t loc_id, hsize_t mem_size[1]; hsize_t dims[1]; hid_t mem_type_id=-1; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /* get the datatype */ if ((tid = H5Dget_type( did )) < 0) goto out; - + if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,tid)) < 0) goto out; - + /* get the dataspace handle */ if ((sid = H5Dget_space( did )) < 0) goto out; - + /* get records */ if (H5Sget_simple_extent_dims( sid, dims, NULL) < 0) goto out; - + if (start + nrecords > dims[0] ) goto out; - + /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = nrecords; if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - + if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0) goto out; - + /* close */ if (H5Sclose( m_sid ) < 0) goto out; @@ -438,9 +438,9 @@ herr_t H5TBwrite_records( hid_t loc_id, return -1; if (H5Dclose( did ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -455,32 +455,32 @@ out: } /*------------------------------------------------------------------------- - * Function: H5TBwrite_fields_name - * - * Purpose: Writes fields - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 21, 2001 - * - * Comments: - * - * Modifications: April 1, 2004 - * the FIELD_SIZES parameter is used to define a memory type ID - * - *------------------------------------------------------------------------- - */ +* Function: H5TBwrite_fields_name +* +* Purpose: Writes fields +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 21, 2001 +* +* Comments: +* +* Modifications: April 1, 2004 +* the FIELD_SIZES parameter is used to define a memory type ID +* +*------------------------------------------------------------------------- +*/ herr_t H5TBwrite_fields_name( hid_t loc_id, - const char *dset_name, - const char *field_names, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf ) + const char *dset_name, + const char *field_names, + hsize_t start, + hsize_t nrecords, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + const void *buf ) { hid_t did; hid_t tid=-1; @@ -496,57 +496,57 @@ herr_t H5TBwrite_fields_name( hid_t loc_id, hssize_t i, j; hid_t preserve_id; size_t size_native; - + /* create xfer properties to preserve initialized data */ if ((preserve_id = H5Pcreate (H5P_DATASET_XFER)) < 0) return -1; if (H5Pset_preserve (preserve_id, 1) < 0) return -1; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - + /* get the datatype */ if ((tid = H5Dget_type( did )) < 0) goto out; - + /* get the number of fields */ if (( nfields = H5Tget_nmembers( tid )) < 0) goto out; - + /* create a write id */ if (( write_type_id = H5Tcreate( H5T_COMPOUND, type_size )) < 0) goto out; - + j = 0; - + /* iterate tru the members */ for ( i = 0; i < nfields; i++) { /* get the member name */ member_name = H5Tget_member_name( tid, (unsigned)i ); - + if(H5TB_find_field( member_name, field_names ) > 0 ) { - + /* get the member type */ if(( member_type_id = H5Tget_member_type( tid,(unsigned) i )) < 0) goto out; - + /* convert to native type */ if ((nmtype_id=H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0) goto out; - + size_native=H5Tget_size(nmtype_id); - + /* adjust, if necessary */ if (field_sizes[j]!=size_native) { if (H5Tset_size(nmtype_id, field_sizes[j]) < 0) goto out; } - + /* the field in the file is found by its name */ if (field_offset ) { @@ -559,36 +559,36 @@ herr_t H5TBwrite_fields_name( hid_t loc_id, if (H5Tinsert( write_type_id, member_name, (size_t)0, nmtype_id ) < 0) goto out; } - + j++; - + /* close */ if(H5Tclose( member_type_id ) < 0) goto out; if(H5Tclose( nmtype_id ) < 0) goto out; } - + free( member_name ); - + } - + /* get the dataspace handle */ if ((file_space_id = H5Dget_space( did )) < 0) goto out; if ((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) goto out; - + /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; if (H5Sselect_hyperslab( file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* write */ if (H5Dwrite( did, write_type_id, m_sid, file_space_id, preserve_id, buf ) < 0) goto out; - + /* close */ if(H5Tclose( write_type_id ) ) goto out; @@ -602,9 +602,9 @@ herr_t H5TBwrite_fields_name( hid_t loc_id, return -1; if(H5Sclose( m_sid ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -617,41 +617,41 @@ out: H5Tclose(tid); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TBwrite_fields_index - * - * Purpose: Writes fields - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 21, 2001 - * - * Comments: Uses memory offsets - * - * Modifications: April 1, 2004 - * the FIELD_SIZES parameter is used to define a memory type ID - * - *------------------------------------------------------------------------- - */ +* Function: H5TBwrite_fields_index +* +* Purpose: Writes fields +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 21, 2001 +* +* Comments: Uses memory offsets +* +* Modifications: April 1, 2004 +* the FIELD_SIZES parameter is used to define a memory type ID +* +*------------------------------------------------------------------------- +*/ herr_t H5TBwrite_fields_index( hid_t loc_id, - const char *dset_name, - hsize_t nfields, - const int *field_index, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - const void *buf ) + const char *dset_name, + hsize_t nfields, + const int *field_index, + hsize_t start, + hsize_t nrecords, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + const void *buf ) { hid_t did; hid_t tid=-1; @@ -666,50 +666,50 @@ herr_t H5TBwrite_fields_index( hid_t loc_id, hsize_t i, j; hid_t preserve_id; size_t size_native; - + /* create xfer properties to preserve initialized data */ if ((preserve_id = H5Pcreate (H5P_DATASET_XFER)) < 0) return -1; if (H5Pset_preserve (preserve_id, 1) < 0) return -1; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - + /* get the datatype */ if ((tid = H5Dget_type( did )) < 0) goto out; - + /* create a write id */ if (( write_type_id = H5Tcreate( H5T_COMPOUND, type_size )) < 0) goto out; - + /* iterate tru the members */ for ( i = 0; i < nfields; i++) { - + j = field_index[i]; - + /* get the member name */ member_name = H5Tget_member_name( tid, (unsigned) j ); - + /* get the member type */ if (( member_type_id = H5Tget_member_type( tid, (unsigned) j )) < 0) goto out; - + /* convert to native type */ if ((nmtype_id = H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0) goto out; - + size_native = H5Tget_size(nmtype_id); - + if (field_sizes[i]!=size_native) { if (H5Tset_size(nmtype_id, field_sizes[i]) < 0) goto out; } - + /* the field in the file is found by its name */ if ( field_offset ) { @@ -727,27 +727,27 @@ herr_t H5TBwrite_fields_index( hid_t loc_id, goto out; if(H5Tclose( nmtype_id ) < 0) goto out; - + free( member_name ); - + } - + /* get the dataspace handles */ if ((file_space_id = H5Dget_space( did )) < 0) goto out; if ((m_sid = H5Screate_simple(1, &nrecords, NULL)) < 0) goto out; - + /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; if (H5Sselect_hyperslab( file_space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* write */ if (H5Dwrite( did, write_type_id, m_sid, file_space_id, preserve_id, buf ) < 0) goto out; - + /* close */ if (H5Tclose( write_type_id ) ) goto out; @@ -761,9 +761,9 @@ herr_t H5TBwrite_fields_index( hid_t loc_id, return -1; if (H5Sclose( m_sid ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -780,68 +780,68 @@ out: /*------------------------------------------------------------------------- - * - * Read functions - * - *------------------------------------------------------------------------- - */ +* +* Read functions +* +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5TBread_table - * - * Purpose: Reads a table - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 20, 2001 - * - * Comments: - * - * Modifications: April 1, 2004 - * used a memory type ID returned by H5TB_create_type - * - *------------------------------------------------------------------------- - */ +* Function: H5TBread_table +* +* Purpose: Reads a table +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 20, 2001 +* +* Comments: +* +* Modifications: April 1, 2004 +* used a memory type ID returned by H5TB_create_type +* +*------------------------------------------------------------------------- +*/ herr_t H5TBread_table( hid_t loc_id, - const char *dset_name, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *dst_buf ) + const char *dset_name, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + void *dst_buf ) { hid_t did; hid_t ftype_id=-1; hid_t mem_type_id=-1; hid_t sid; hsize_t dims[1]; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /* get the dataspace handle */ if ((sid = H5Dget_space( did )) < 0) goto out; - + /* get dimensions */ if (H5Sget_simple_extent_dims( sid, dims, NULL) < 0) goto out; - + /* get the datatypes */ if ((ftype_id=H5Dget_type (did)) < 0) goto out; - + if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,ftype_id)) < 0) goto out; - + /* read */ if (H5Dread( did, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, dst_buf) < 0) goto out; - + /* close */ if (H5Tclose( ftype_id ) < 0) goto out; @@ -851,9 +851,9 @@ herr_t H5TBread_table( hid_t loc_id, goto out; if (H5Dclose( did ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -867,36 +867,36 @@ out: } /*------------------------------------------------------------------------- - * Function: H5TBread_records - * - * Purpose: Reads records - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 19, 2001 - * - * Comments: - * - * Modifications: April 1, 2004 - * the FIELD_SIZES parameter is used to define the memory type ID - * returned by H5TB_create_type - * - *------------------------------------------------------------------------- - */ +* Function: H5TBread_records +* +* Purpose: Reads records +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 19, 2001 +* +* Comments: +* +* Modifications: April 1, 2004 +* the FIELD_SIZES parameter is used to define the memory type ID +* returned by H5TB_create_type +* +*------------------------------------------------------------------------- +*/ herr_t H5TBread_records( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf ) + const char *dset_name, + hsize_t start, + hsize_t nrecords, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + void *buf ) { - + hid_t did; hid_t ftype_id; hid_t mem_type_id=-1; @@ -904,22 +904,22 @@ herr_t H5TBread_records( hid_t loc_id, hid_t m_sid=-1; hsize_t nrecords_orig; hsize_t nfields; - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords_orig ) < 0) return -1; - + /* open the dataset */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /* get the datatypes */ if ((ftype_id = H5Dget_type( did )) < 0) goto out; - + if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,ftype_id)) < 0) goto out; - + /* read the records */ if ((H5TB_common_read_records(did, mem_type_id, start, (size_t)nrecords, nrecords_orig, buf)) < 0) goto out; @@ -931,9 +931,9 @@ herr_t H5TBread_records( hid_t loc_id, return -1; if (H5Dclose( did ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY { @@ -944,40 +944,40 @@ out: H5Sclose(sid); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TBread_fields_name - * - * Purpose: Reads fields - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 19, 2001 - * - * Comments: - * - * Modifications: April 1, 2004 - * the FIELD_SIZES parameter is used to define the memory type ID - * returned by H5TB_create_type - * - *------------------------------------------------------------------------- - */ +* Function: H5TBread_fields_name +* +* Purpose: Reads fields +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 19, 2001 +* +* Comments: +* +* Modifications: April 1, 2004 +* the FIELD_SIZES parameter is used to define the memory type ID +* returned by H5TB_create_type +* +*------------------------------------------------------------------------- +*/ herr_t H5TBread_fields_name( hid_t loc_id, - const char *dset_name, - const char *field_names, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf ) + const char *dset_name, + const char *field_names, + hsize_t start, + hsize_t nrecords, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + void *buf ) { hid_t did; @@ -994,41 +994,41 @@ herr_t H5TBread_fields_name( hid_t loc_id, hsize_t mem_size[1]; size_t size_native; hssize_t i, j; - + /* open the dataset */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - + /* get the datatype */ if ((ftype_id = H5Dget_type( did )) < 0) goto out; - + /* get the number of fields */ if (( nfields = H5Tget_nmembers( ftype_id )) < 0) goto out; - + /* create a memory read id */ if (( mem_type_id = H5Tcreate( H5T_COMPOUND, type_size )) < 0) goto out; - + /* iterate tru the members */ for ( i=0,j=0; i 0 ) { /* get the member type */ if (( mtype_id = H5Tget_member_type( ftype_id, (unsigned) i )) < 0) goto out; - + /* convert to native type */ if ((nmtype_id=H5Tget_native_type(mtype_id,H5T_DIR_DEFAULT)) < 0) goto out; - + size_native=H5Tget_size(nmtype_id); - + if (field_sizes[j]!=size_native) { if (H5Tset_size(nmtype_id, field_sizes[j]) < 0) @@ -1045,7 +1045,7 @@ herr_t H5TBread_fields_name( hid_t loc_id, if(H5Tinsert( mem_type_id, member_name, (size_t)0, nmtype_id ) < 0) goto out; } - + /* close */ if(H5Tclose( mtype_id ) < 0) goto out; @@ -1055,26 +1055,26 @@ herr_t H5TBread_fields_name( hid_t loc_id, } free( member_name ); } - + /* get the dataspace handle */ if ((sid = H5Dget_space( did )) < 0) goto out; - + /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - + /* read */ if (H5Dread( did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0) goto out; - + /* close */ if (H5Tclose( mem_type_id ) ) goto out; @@ -1086,9 +1086,9 @@ herr_t H5TBread_fields_name( hid_t loc_id, goto out; if (H5Dclose( did ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -1100,43 +1100,43 @@ out: H5Sclose(sid); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TBread_fields_index - * - * Purpose: Reads fields - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 19, 2001 - * - * Comments: - * - * Modifications: April 1, 2004 - * the FIELD_SIZES parameter is used to define the memory type ID - * returned by H5TB_create_type - * - *------------------------------------------------------------------------- - */ +* Function: H5TBread_fields_index +* +* Purpose: Reads fields +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 19, 2001 +* +* Comments: +* +* Modifications: April 1, 2004 +* the FIELD_SIZES parameter is used to define the memory type ID +* returned by H5TB_create_type +* +*------------------------------------------------------------------------- +*/ herr_t H5TBread_fields_index( hid_t loc_id, - const char *dset_name, - hsize_t nfields, - const int *field_index, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf ) + const char *dset_name, + hsize_t nfields, + const int *field_index, + hsize_t start, + hsize_t nrecords, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + void *buf ) { - + hid_t did; hid_t tid=-1; hid_t read_type_id=-1; @@ -1150,47 +1150,47 @@ herr_t H5TBread_fields_index( hid_t loc_id, hsize_t mem_size[1]; size_t size_native; hsize_t i, j; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - + /* get the datatype */ if ((tid = H5Dget_type( did )) < 0) goto out; - + /* create a read id */ if (( read_type_id = H5Tcreate( H5T_COMPOUND, type_size )) < 0) goto out; - + /* iterate tru the members */ for ( i = 0; i < nfields; i++) { j = field_index[i]; - + /* get the member name */ member_name = H5Tget_member_name( tid, (unsigned) j ); - + /* get the member type */ if (( member_type_id = H5Tget_member_type( tid, (unsigned) j )) < 0) goto out; - + /* get the member size */ if (H5Tget_size( member_type_id ) == 0 ) goto out; - + /* convert to native type */ if ((nmtype_id=H5Tget_native_type(member_type_id,H5T_DIR_DEFAULT)) < 0) goto out; - + size_native=H5Tget_size(nmtype_id); - + if (field_sizes[i]!=size_native) { if (H5Tset_size(nmtype_id, field_sizes[i]) < 0) goto out; } - + /* the field in the file is found by its name */ if (field_offset ) { @@ -1202,35 +1202,35 @@ herr_t H5TBread_fields_index( hid_t loc_id, if(H5Tinsert( read_type_id, member_name, (size_t)0, nmtype_id ) < 0) goto out; } - + /* close the member type */ if (H5Tclose( member_type_id ) < 0) goto out; if (H5Tclose( nmtype_id ) < 0) goto out; - + free( member_name ); } - + /* get the dataspace handle */ if ((sid = H5Dget_space( did )) < 0) goto out; - + /* define a hyperslab in the dataset */ offset[0] = start; count[0] = nrecords; if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - + /* read */ if (H5Dread( did, read_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0) goto out; - + /* close */ if (H5Sclose( sid ) < 0) goto out; @@ -1242,9 +1242,9 @@ herr_t H5TBread_fields_index( hid_t loc_id, return -1; if (H5Dclose( did ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -1256,40 +1256,40 @@ out: H5Sclose(sid); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * - * Manipulation functions - * - *------------------------------------------------------------------------- - */ +* +* Manipulation functions +* +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5TBdelete_record - * - * Purpose: Delete records from middle of table ("pulling up" all the records after it) - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 26, 2001 - * - * Modifications: April 29, 2003 - * - * - *------------------------------------------------------------------------- - */ +* Function: H5TBdelete_record +* +* Purpose: Delete records from middle of table ("pulling up" all the records after it) +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 26, 2001 +* +* Modifications: April 29, 2003 +* +* +*------------------------------------------------------------------------- +*/ herr_t H5TBdelete_record( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords ) + const char *dset_name, + hsize_t start, + hsize_t nrecords ) { - + hsize_t nfields; hsize_t ntotal_records; hsize_t read_start; @@ -1306,24 +1306,24 @@ herr_t H5TBdelete_record( hid_t loc_id, size_t *src_offset; size_t *src_sizes; hsize_t dims[1]; - + /*------------------------------------------------------------------------- * first we get information about type size and offsets on disk *------------------------------------------------------------------------- */ - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &ntotal_records ) < 0) return -1; - + src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t)); src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t)); - + if (src_offset == NULL ) return -1; if (src_sizes == NULL ) return -1; - + /* get field info */ if (H5TBget_field_info( loc_id, dset_name, NULL, src_sizes, src_offset, &src_size ) < 0) return -1; @@ -1331,53 +1331,53 @@ herr_t H5TBdelete_record( hid_t loc_id, /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /*------------------------------------------------------------------------- * read the records after the deleted one(s) *------------------------------------------------------------------------- */ - + read_start = start + nrecords; read_nrecords = ntotal_records - read_start; if ( read_nrecords ) { tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, src_size ); - + if (tmp_buf == NULL ) return -1; - + /* read the records after the deleted one(s) */ if (H5TBread_records( loc_id, dset_name, read_start, read_nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0) return -1; - + /*------------------------------------------------------------------------- * write the records in another position *------------------------------------------------------------------------- */ - + /* get the datatype */ if ((tid = H5Dget_type( did )) < 0) goto out; - + /* get the dataspace handle */ if ((sid = H5Dget_space( did )) < 0) goto out; - + /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = read_nrecords; if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - + if (H5Dwrite( did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0) goto out; - + /* close */ if (H5Sclose( m_sid ) < 0) goto out; @@ -1385,10 +1385,10 @@ herr_t H5TBdelete_record( hid_t loc_id, goto out; if (H5Tclose( tid ) < 0) goto out; - + } /* read_nrecords */ - - + + /*------------------------------------------------------------------------- * change the dataset dimension *------------------------------------------------------------------------- @@ -1396,20 +1396,20 @@ herr_t H5TBdelete_record( hid_t loc_id, dims[0] = ntotal_records - nrecords; if (H5Dset_extent( did, dims ) < 0) goto out; - + /* close dataset */ if (H5Dclose( did ) < 0) return -1; - + if (tmp_buf !=NULL) free( tmp_buf ); free( src_offset ); free( src_sizes ); - - + + return 0; - /* error zone */ + /* error zone */ out: if (tmp_buf !=NULL ) @@ -1421,41 +1421,41 @@ out: H5Sclose(sid); } H5E_END_TRY; return -1; - - + + } /*------------------------------------------------------------------------- - * Function: H5TBinsert_record - * - * Purpose: Inserts records into middle of table ("pushing down" all the records after it) - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 26, 2001 - * - * Comments: Uses memory offsets - * - * Modifications: April 1, 2004 - * the FIELD_SIZES parameter is used to define the memory type ID - * returned by H5TB_create_type - * - *------------------------------------------------------------------------- - */ +* Function: H5TBinsert_record +* +* Purpose: Inserts records into middle of table ("pushing down" all the records after it) +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 26, 2001 +* +* Comments: Uses memory offsets +* +* Modifications: April 1, 2004 +* the FIELD_SIZES parameter is used to define the memory type ID +* returned by H5TB_create_type +* +*------------------------------------------------------------------------- +*/ herr_t H5TBinsert_record( hid_t loc_id, - const char *dset_name, - hsize_t start, - hsize_t nrecords, - size_t type_size, - const size_t *field_offset, - const size_t *field_sizes, - void *buf ) + const char *dset_name, + hsize_t start, + hsize_t nrecords, + size_t type_size, + const size_t *field_offset, + const size_t *field_sizes, + void *buf ) { - + hsize_t nfields; hsize_t ntotal_records; hsize_t read_nrecords; @@ -1469,93 +1469,93 @@ herr_t H5TBinsert_record( hid_t loc_id, hsize_t dims[1]; hsize_t mem_dims[1]; unsigned char *tmp_buf; - + /*------------------------------------------------------------------------- * read the records after the inserted one(s) *------------------------------------------------------------------------- */ - + /* get the dimensions */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &ntotal_records ) < 0) return -1; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - + /* get the datatype */ if ((tid = H5Dget_type( did )) < 0) goto out; - + /* create the memory data type. */ if ((mem_type_id=H5TB_create_type(loc_id,dset_name,type_size,field_offset,field_sizes,tid)) < 0) goto out; - + read_nrecords = ntotal_records - start; tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, type_size); - + /* read the records after the inserted one(s) */ if (H5TBread_records( loc_id, dset_name, start, read_nrecords, type_size, field_offset, field_sizes, tmp_buf ) < 0) return -1; - + /* extend the dataset */ dims[0] = ntotal_records + nrecords; - + if (H5Dset_extent(did, dims) < 0) goto out; - + /*------------------------------------------------------------------------- * write the inserted records *------------------------------------------------------------------------- */ - + /* create a simple memory data space */ mem_dims[0] = nrecords; if ((m_sid = H5Screate_simple(1, mem_dims, NULL)) < 0) return -1; - + /* get the file data space */ if ((sid = H5Dget_space( did )) < 0) return -1; - + /* define a hyperslab in the dataset to write the new data */ offset[0] = start; count[0] = nrecords; if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, buf ) < 0) goto out; - + /* terminate access to the dataspace */ if (H5Sclose( m_sid ) < 0) goto out; if (H5Sclose( sid ) < 0) goto out; - + /*------------------------------------------------------------------------- * write the "pushed down" records *------------------------------------------------------------------------- */ - + /* create a simple memory data space */ mem_dims[0]=read_nrecords; if ((m_sid = H5Screate_simple( 1, mem_dims, NULL )) < 0) return -1; - + /* get the file data space */ if ((sid = H5Dget_space( did )) < 0) return -1; - + /* define a hyperslab in the dataset to write the new data */ offset[0] = start + nrecords; count[0] = read_nrecords; if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0) goto out; - + /* close */ if (H5Sclose( m_sid ) < 0) goto out; @@ -1567,11 +1567,11 @@ herr_t H5TBinsert_record( hid_t loc_id, return -1; if (H5Dclose( did ) < 0) return -1; - + free( tmp_buf ); - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -1586,30 +1586,30 @@ out: } /*------------------------------------------------------------------------- - * Function: H5TBadd_records_from - * - * Purpose: Add records from first table to second table - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 5, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5TBadd_records_from +* +* Purpose: Add records from first table to second table +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: December 5, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5TBadd_records_from( hid_t loc_id, - const char *dset_name1, - hsize_t start1, - hsize_t nrecords, - const char *dset_name2, - hsize_t start2 ) + const char *dset_name1, + hsize_t start1, + hsize_t nrecords, + const char *dset_name2, + hsize_t start2 ) { hid_t did_1; hid_t tid_1; @@ -1625,75 +1625,75 @@ herr_t H5TBadd_records_from( hid_t loc_id, size_t src_size; size_t *src_offset; size_t *src_sizes; - + /*------------------------------------------------------------------------- * first we get information about type size and offsets on disk *------------------------------------------------------------------------- */ - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name1, &nfields, &ntotal_records ) < 0) return -1; - + src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t)); src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t)); - + if (src_offset == NULL ) return -1; - + /* get field info */ if (H5TBget_field_info( loc_id, dset_name1, NULL, src_sizes, src_offset, &src_size ) < 0) return -1; - + /*------------------------------------------------------------------------- * Get information about the first table and read it *------------------------------------------------------------------------- */ - + /* open the 1st dataset. */ if ((did_1 = H5Dopen2(loc_id, dset_name1, H5P_DEFAULT)) < 0) return -1; - + /* get the datatype */ if ((tid_1 = H5Dget_type( did_1 )) < 0) goto out; - + /* get the dataspace handle */ if ((sid_1 = H5Dget_space( did_1 )) < 0) goto out; - + /* get the size of the datatype */ if (( type_size1 = H5Tget_size( tid_1 )) == 0 ) goto out; - + tmp_buf = (unsigned char *)calloc((size_t)nrecords, type_size1 ); - + /* define a hyperslab in the dataset of the size of the records */ offset[0] = start1; count[0] = nrecords; if (H5Sselect_hyperslab( sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((msid_1 = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - + if (H5Dread( did_1, tid_1, msid_1, sid_1, H5P_DEFAULT, tmp_buf ) < 0) goto out; - + /*------------------------------------------------------------------------- * add to the second table *------------------------------------------------------------------------- */ if (H5TBinsert_record(loc_id,dset_name2,start2,nrecords,src_size,src_offset,src_sizes,tmp_buf ) < 0) goto out; - + /*------------------------------------------------------------------------- * close resources for table 1 *------------------------------------------------------------------------- */ - + if (H5Sclose( msid_1 ) < 0) goto out; if (H5Sclose( sid_1 ) < 0) @@ -1702,13 +1702,13 @@ herr_t H5TBadd_records_from( hid_t loc_id, return -1; if (H5Dclose( did_1 ) < 0) return -1; - + free( tmp_buf ); free( src_offset ); free( src_sizes ); - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -1719,34 +1719,34 @@ out: H5Tclose(tid_1); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TBcombine_tables - * - * Purpose: Combine records from two tables into a third - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 10, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5TBcombine_tables +* +* Purpose: Combine records from two tables into a third +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: December 10, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5TBcombine_tables( hid_t loc_id1, - const char *dset_name1, - hid_t loc_id2, - const char *dset_name2, - const char *dset_name3 ) + const char *dset_name1, + hid_t loc_id2, + const char *dset_name2, + const char *dset_name3 ) { - + /* identifiers for the 1st dataset. */ hid_t did_1=-1; hid_t tid_1=-1; @@ -1784,178 +1784,178 @@ herr_t H5TBcombine_tables( hid_t loc_id1, size_t *src_offset; size_t *src_sizes; int has_fill=0; - + /*------------------------------------------------------------------------- * first we get information about type size and offsets on disk *------------------------------------------------------------------------- */ - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id1, dset_name1, &nfields, &nrecords ) < 0) return -1; - + src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t)); src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t)); - + if (src_offset == NULL ) return -1; - + /* get field info */ if (H5TBget_field_info( loc_id1, dset_name1, NULL, src_sizes, src_offset, &src_size ) < 0) return -1; - + /*------------------------------------------------------------------------- * get information about the first table *------------------------------------------------------------------------- */ - + /* open the 1st dataset. */ if ((did_1 = H5Dopen2(loc_id1, dset_name1, H5P_DEFAULT)) < 0) goto out; - + /* get the datatype */ if ((tid_1 = H5Dget_type( did_1 )) < 0) goto out; - + /* get the dataspace handle */ if ((sid_1 = H5Dget_space( did_1 )) < 0) goto out; - + /* get creation properties list */ if ((pid_1 = H5Dget_create_plist( did_1 )) < 0) goto out; - + /* get the dimensions */ if (H5TBget_table_info ( loc_id1, dset_name1, &nfields, &nrecords ) < 0) return -1; - + /*------------------------------------------------------------------------- * make the merged table with no data originally *------------------------------------------------------------------------- */ - + /* clone the property list */ if ((pid_3 = H5Pcopy(pid_1)) < 0) goto out; - + /* clone the type id */ if ((tid_3 = H5Tcopy(tid_1)) < 0) goto out; - + /*------------------------------------------------------------------------- * here we do not clone the file space from the 1st dataset, because we want to create * an empty table. Instead we create a new dataspace with zero records and expandable. *------------------------------------------------------------------------- */ dims[0] = 0; - + /* create a simple data space with unlimited size */ if ((sid_3 = H5Screate_simple(1, dims, maxdims)) < 0) return -1; - + /* create the dataset */ if ((did_3 = H5Dcreate2(loc_id1, dset_name3, tid_3, sid_3, H5P_DEFAULT, pid_3, H5P_DEFAULT)) < 0) goto out; - + /*------------------------------------------------------------------------- * attach the conforming table attributes *------------------------------------------------------------------------- */ if (H5TB_attach_attributes("Merge table", loc_id1, dset_name3, nfields, tid_3) < 0) goto out; - + /*------------------------------------------------------------------------- * get attributes *------------------------------------------------------------------------- */ - + type_size = H5Tget_size(tid_3); - + /* alloc fill value attribute buffer */ tmp_fill_buf = (unsigned char *)malloc(type_size); - + /* get the fill value attributes */ has_fill = H5TBAget_fill(loc_id1, dset_name1, did_1, tmp_fill_buf); - + /*------------------------------------------------------------------------- * attach the fill attributes from previous table *------------------------------------------------------------------------- */ if (has_fill == 1 ) { - + if (( sid = H5Screate(H5S_SCALAR)) < 0) goto out; - + for ( i = 0; i < nfields; i++) { - + /* get the member type */ if (( member_type_id = H5Tget_member_type( tid_3, (unsigned) i )) < 0) goto out; - + /* get the member offset */ member_offset = H5Tget_member_offset(tid_3, (unsigned)i); - + strcpy(attr_name, "FIELD_"); sprintf(aux, "%d", (int)i); strcat(attr_name, aux); sprintf(aux, "%s", "_FILL"); strcat(attr_name, aux); - + if ((attr_id = H5Acreate2(did_3, attr_name, member_type_id, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf+member_offset) < 0) goto out; - + if (H5Aclose(attr_id) < 0) goto out; - + if (H5Tclose(member_type_id) < 0) goto out; } - + /* close data space. */ if (H5Sclose( sid ) < 0) goto out; } - + /*------------------------------------------------------------------------- * read data from 1st table *------------------------------------------------------------------------- */ - + tmp_buf = (unsigned char *)calloc((size_t) nrecords, type_size ); - + /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; if (H5Sselect_hyperslab( sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - + if (H5Dread( did_1, tid_1, m_sid, sid_1, H5P_DEFAULT, tmp_buf ) < 0) goto out; - + /*------------------------------------------------------------------------- * save data from 1st table into new table *------------------------------------------------------------------------- */ - + /* append the records to the new table */ if (H5TBappend_records( loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0) goto out; - + /*------------------------------------------------------------------------- * release resources from 1st table *------------------------------------------------------------------------- */ - + if (H5Sclose( m_sid ) < 0) goto out; if(H5Sclose( sid_1 ) < 0) @@ -1966,70 +1966,70 @@ herr_t H5TBcombine_tables( hid_t loc_id1, goto out; if(H5Dclose( did_1 ) < 0) goto out; - + /* Release resources. */ free( tmp_buf ); - + /*------------------------------------------------------------------------- * get information about the 2nd table *------------------------------------------------------------------------- */ - + /* open the dataset. */ if ((did_2 = H5Dopen2(loc_id2, dset_name2, H5P_DEFAULT)) < 0) goto out; - + /* get the datatype */ if ((tid_2 = H5Dget_type( did_2 )) < 0) goto out; - + /* get the dataspace handle */ if ((sid_2 = H5Dget_space( did_2 )) < 0) goto out; - + /* get the property list handle */ if ((pid_2 = H5Dget_create_plist( did_2 )) < 0) goto out; - + /* get the dimensions */ if (H5TBget_table_info ( loc_id2, dset_name2, &nfields, &nrecords ) < 0) return -1; - + /*------------------------------------------------------------------------- * read data from 2nd table *------------------------------------------------------------------------- */ - + tmp_buf = (unsigned char *)calloc((size_t) nrecords, type_size ); - + /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; if (H5Sselect_hyperslab( sid_2, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - + if (H5Dread( did_2, tid_2, m_sid, sid_2, H5P_DEFAULT, tmp_buf ) < 0) goto out; - + /*------------------------------------------------------------------------- * save data from 2nd table into new table *------------------------------------------------------------------------- */ - + /* append the records to the new table */ if (H5TBappend_records( loc_id1, dset_name3, nrecords, src_size, src_offset, src_sizes, tmp_buf ) < 0) goto out; - + /*------------------------------------------------------------------------- * release resources from 2nd table *------------------------------------------------------------------------- */ - + if (H5Sclose( m_sid ) < 0) goto out; if (H5Sclose( sid_2 ) < 0) @@ -2040,12 +2040,12 @@ herr_t H5TBcombine_tables( hid_t loc_id1, goto out; if (H5Dclose( did_2 ) < 0) return -1; - + /*------------------------------------------------------------------------- * release resources from 3rd table *------------------------------------------------------------------------- */ - + if (H5Sclose( sid_3 ) < 0) return -1; if (H5Tclose( tid_3 ) < 0) @@ -2054,16 +2054,16 @@ herr_t H5TBcombine_tables( hid_t loc_id1, return -1; if (H5Dclose( did_3 ) < 0) return -1; - + /* Release resources. */ free( tmp_buf ); free( tmp_fill_buf ); free( src_offset ); free( src_sizes ); - + return 0; - - /* error zone */ + + /* error zone */ out: H5E_BEGIN_TRY { @@ -2081,34 +2081,34 @@ out: H5Pclose(pid_3); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TBinsert_field - * - * Purpose: Inserts a field - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: January 30, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5TBinsert_field +* +* Purpose: Inserts a field +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: January 30, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5TBinsert_field( hid_t loc_id, - const char *dset_name, - const char *field_name, - hid_t field_type, - hsize_t position, - const void *fill_data, - const void *buf ) + const char *dset_name, + const char *field_name, + hid_t field_type, + hsize_t position, + const void *fill_data, + const void *buf ) { /* identifiers for the 1st, original dataset */ hid_t did_1; @@ -2148,214 +2148,214 @@ herr_t H5TBinsert_field( hid_t loc_id, unsigned char *tmp_buf; unsigned char *tmp_fill_buf; hsize_t i; - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0) return -1; - + /*------------------------------------------------------------------------- * get information about the old data type *------------------------------------------------------------------------- */ - + /* open the dataset. */ if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /* get creation properties list */ if ((pid_1 = H5Dget_create_plist( did_1 )) < 0) goto out; - + /* get the datatype */ if ((tid_1 = H5Dget_type( did_1 )) < 0) goto out; - + /* get the size of the datatype */ if (( total_size = H5Tget_size( tid_1 )) == 0 ) goto out; - + /* get the dataspace handle */ if ((sid_1 = H5Dget_space( did_1 )) < 0) goto out; - + /* get dimension */ if (H5Sget_simple_extent_dims( sid_1, dims, NULL) < 0) goto out; - + /*------------------------------------------------------------------------- * get attributes *------------------------------------------------------------------------- */ - + /* get the table title */ if ((H5TBAget_title( did_1, table_title )) < 0) goto out; - + /* alloc fill value attribute buffer */ tmp_fill_buf = (unsigned char *)malloc(total_size ); - + /* get the fill value attributes */ if ((H5TBAget_fill( loc_id, dset_name, did_1, tmp_fill_buf )) < 0) goto out; - + /*------------------------------------------------------------------------- * create a new data type *------------------------------------------------------------------------- */ - + /* get the new member size */ member_size = H5Tget_size( field_type ); - + /* create the data type. */ if (( tid_2 = H5Tcreate (H5T_COMPOUND,(size_t)(total_size + member_size) )) < 0) goto out; - + curr_offset = 0; inserted = 0; - + /* insert the old fields, counting with the new one */ for ( i = 0; i < nfields + 1; i++) { idx = i; if (inserted ) idx = i - 1; - + if (i == position ) { /* get the new member size */ new_member_size = H5Tget_size( field_type ); - + /* insert the new field type */ if (H5Tinsert( tid_2, field_name, curr_offset, field_type ) < 0) goto out; - + curr_offset += new_member_size; - + inserted = 1; - + continue; } - + /* get the member name */ member_name = H5Tget_member_name( tid_1, (unsigned)idx ); - + /* get the member type */ if (( member_type_id = H5Tget_member_type( tid_1,(unsigned)idx )) < 0) goto out; - + /* get the member size */ member_size = H5Tget_size( member_type_id ); - + /* insert it into the new type */ if (H5Tinsert( tid_2, member_name, curr_offset, member_type_id ) < 0) goto out; - + curr_offset += member_size; - + free( member_name ); - + /* close the member type */ if(H5Tclose( member_type_id ) < 0) goto out; } /* i */ - + /*------------------------------------------------------------------------- * create a new temporary dataset *------------------------------------------------------------------------- */ - + /* retrieve the size of chunk */ if (H5Pget_chunk(pid_1, 1, dims_chunk) < 0) goto out; - + /* create a new simple data space with unlimited size, using the dimension */ if ((sid_2 = H5Screate_simple( 1, dims, maxdims)) < 0) return -1; - + /* modify dataset creation properties, i.e. enable chunking */ pid_2 = H5Pcreate(H5P_DATASET_CREATE); if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0) return -1; - + /* create the dataset. */ if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) goto out; - + /*------------------------------------------------------------------------- * read data from 1st table *------------------------------------------------------------------------- */ - + tmp_buf = (unsigned char *)calloc((size_t)nrecords, (size_t)total_size); - + /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; count[0] = nrecords; if (H5Sselect_hyperslab(sid_1, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((msid_1 = H5Screate_simple(1, mem_size, NULL)) < 0) goto out; - + if (H5Dread(did_1, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf) < 0) goto out; - + /*------------------------------------------------------------------------- * save data from 1st table into new table, using the 1st type id *------------------------------------------------------------------------- */ - + /* write */ if (H5Dwrite( did_2, tid_1, msid_1, H5S_ALL, H5P_DEFAULT, tmp_buf ) < 0) goto out; - + /*------------------------------------------------------------------------- * save the function supplied data of the new field *------------------------------------------------------------------------- */ - + /* create a write id */ if (( write_type_id = H5Tcreate( H5T_COMPOUND, (size_t)new_member_size )) < 0) goto out; - + /* the field in the file is found by its name */ if (H5Tinsert( write_type_id, field_name, (size_t)0, field_type ) < 0) goto out; - + /* create xfer properties to preserve initialized data */ if ((preserve_id = H5Pcreate (H5P_DATASET_XFER)) < 0) goto out; if (H5Pset_preserve (preserve_id, 1) < 0) goto out; - + /* only write if there is something to write */ if ( buf ) { /* create a memory dataspace handle */ if ((msid_2 = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - + /* write */ if (H5Dwrite( did_2, write_type_id, msid_2, sid_2, preserve_id, buf ) < 0) goto out; - + /* terminate access to the memory dataspace */ if (H5Sclose( msid_2 ) < 0) goto out; } - + /* end access to the property list */ if (H5Pclose( preserve_id ) < 0) goto out; - + /*------------------------------------------------------------------------- * release resources from 1st table *------------------------------------------------------------------------- */ - + if (H5Sclose( msid_1 ) < 0) goto out; if (H5Tclose( tid_1 ) < 0) @@ -2366,13 +2366,13 @@ herr_t H5TBinsert_field( hid_t loc_id, goto out; if (H5Dclose( did_1 ) < 0) goto out; - - + + /*------------------------------------------------------------------------- * release resources from 2nd table *------------------------------------------------------------------------- */ - + if (H5Sclose( sid_2 ) < 0) goto out; if (H5Tclose( tid_2 ) < 0) @@ -2380,112 +2380,112 @@ herr_t H5TBinsert_field( hid_t loc_id, if (H5Pclose( pid_2 ) < 0) goto out; if (H5Dclose( did_2 ) < 0) - goto out; - + goto out; + /*------------------------------------------------------------------------- * delete 1st table *------------------------------------------------------------------------- */ if (H5Ldelete( loc_id, dset_name, H5P_DEFAULT ) < 0) return -1; - + /*------------------------------------------------------------------------- * rename 2nd table *------------------------------------------------------------------------- */ - + if (H5Lmove( loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT ) < 0) return -1; - + /*------------------------------------------------------------------------- * attach the conforming table attributes *------------------------------------------------------------------------- */ - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0) return -1; - + /* open the dataset. */ if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /* get the datatype */ if ((tid_1 = H5Dget_type( did_1 )) < 0) goto out; - + /* set the attributes */ if (H5TB_attach_attributes( table_title, loc_id, dset_name,(hsize_t) nfields, tid_1 ) < 0) return -1; - + /*------------------------------------------------------------------------- * attach the fill attributes from previous table *------------------------------------------------------------------------- */ - + if (( sid_1 = H5Screate(H5S_SCALAR)) < 0) goto out; - + for ( i = 0; i < nfields-1; i++) { /* get the member type */ if(( member_type_id = H5Tget_member_type( tid_1, (unsigned) i )) < 0) goto out; - + /* get the member offset */ member_offset = H5Tget_member_offset(tid_1, (unsigned)i); - + strcpy(attr_name, "FIELD_"); sprintf(aux, "%d", (int)i); strcat(attr_name, aux); sprintf(aux, "%s", "_FILL"); strcat(attr_name, aux); - + if ((attr_id = H5Acreate2(did_1, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf+member_offset) < 0) goto out; - + if (H5Aclose(attr_id) < 0) goto out; - + /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; } - + /*------------------------------------------------------------------------- * attach the fill attribute from the new field, if present *------------------------------------------------------------------------- */ if (fill_data) { - + strcpy(attr_name, "FIELD_"); sprintf(aux, "%d",(int)(nfields - 1)); strcat(attr_name, aux); sprintf(aux, "%s", "_FILL"); strcat(attr_name, aux); - + /* get the member type */ if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)nfields - 1)) < 0) goto out; - + if ((attr_id = H5Acreate2(did_1, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - + if (H5Awrite(attr_id, member_type_id, fill_data) < 0) goto out; - + if (H5Aclose(attr_id) < 0) goto out; - + if (H5Tclose(member_type_id) < 0) goto out; - + } - + /* close */ if (H5Sclose( sid_1 ) < 0) goto out; @@ -2493,13 +2493,13 @@ herr_t H5TBinsert_field( hid_t loc_id, goto out; if (H5Dclose( did_1 ) < 0) goto out; - + /* release resources. */ free ( tmp_buf ); free ( tmp_fill_buf ); - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -2512,33 +2512,33 @@ out: H5Sclose(sid_2); H5Tclose(tid_2); H5Pclose(pid_2); - + } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TBdelete_field - * - * Purpose: Deletes a field - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: January 30, 2002 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5TBdelete_field +* +* Purpose: Deletes a field +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: January 30, 2002 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5TBdelete_field( hid_t loc_id, - const char *dset_name, - const char *field_name ) + const char *dset_name, + const char *field_name ) { /* identifiers for the 1st original dataset */ hid_t did_1; @@ -2574,179 +2574,179 @@ herr_t H5TBdelete_field( hid_t loc_id, hid_t attr_id; hsize_t i; int has_fill=0; - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0) return -1; - + /*------------------------------------------------------------------------- * get information about the old data type *------------------------------------------------------------------------- */ - + /* open the dataset. */ if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /* get creation properties list */ if ((pid_1 = H5Dget_create_plist( did_1 )) < 0) goto out; - + /* get the datatype */ if ((tid_1 = H5Dget_type( did_1 )) < 0) goto out; - + /* get the size of the datatype */ type_size1 = H5Tget_size( tid_1 ); - + /* get the dataspace handle */ if ((sid_1 = H5Dget_space( did_1 )) < 0) goto out; - + /* get dimension */ if (H5Sget_simple_extent_dims( sid_1, dims, NULL) < 0) goto out; - + /*------------------------------------------------------------------------- * create a new data type; first we find the size of the datatype to delete *------------------------------------------------------------------------- */ - + /* check out the field */ for ( i = 0; i < nfields; i++) { /* get the member name */ member_name = H5Tget_member_name( tid_1,(unsigned) i ); - + /* we want to find the field to delete */ if (H5TB_find_field( member_name, field_name ) > 0 ) { /* get the member type */ if (( member_type_id = H5Tget_member_type( tid_1,(unsigned) i )) < 0) goto out; - + /* get the member size */ delete_member_size = H5Tget_size( member_type_id ); - + /* close the member type */ if (H5Tclose( member_type_id ) < 0) goto out; - + free( member_name ); - + break; - + } - + free( member_name ); - + } /* i */ - + /* no field to delete was found */ if (delete_member_size == 0 ) goto out; - + /*------------------------------------------------------------------------- * create a new data type; we now insert all the fields into the new type *------------------------------------------------------------------------- */ - + type_size2 = type_size1 - delete_member_size; - + /* create the data type. */ if (( tid_2 = H5Tcreate (H5T_COMPOUND, type_size2 )) < 0) goto out; - + curr_offset = 0; - + /* alloc fill value attribute buffer */ tmp_fill_buf = (unsigned char *)malloc((size_t) type_size2 ); - + /*------------------------------------------------------------------------- * get attributes from previous table in the process *------------------------------------------------------------------------- */ - + /* get the table title */ if ((H5TBAget_title( did_1, table_title )) < 0) goto out; - + /* insert the old fields except the one to delete */ for ( i = 0; i < nfields; i++) { /* get the member name */ member_name = H5Tget_member_name( tid_1, (unsigned) i ); - + /* we want to skip the field to delete */ if (H5TB_find_field( member_name, field_name ) > 0 ) { free( member_name ); continue; } - + /* get the member type */ if (( member_type_id = H5Tget_member_type( tid_1, (unsigned)i )) < 0) goto out; - + /* get the member size */ member_size = H5Tget_size( member_type_id ); - + /* insert it into the new type */ if (H5Tinsert( tid_2, member_name, curr_offset, member_type_id ) < 0) goto out; - + /*------------------------------------------------------------------------- * get the fill value information *------------------------------------------------------------------------- */ - + strcpy( attr_name, "FIELD_" ); sprintf( aux, "%d", (int)i ); strcat( attr_name, aux ); sprintf( aux, "%s", "_FILL" ); strcat( attr_name, aux ); - + /* check if we have the _FILL attribute */ has_fill = H5LT_find_attribute( did_1, attr_name ); - + /* get it */ if (has_fill == 1 ) { if(H5LT_get_attribute_disk( did_1, attr_name, tmp_fill_buf+curr_offset ) < 0) goto out; } - + curr_offset += member_size; - + free(member_name); - + /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; } /* i */ - + /*------------------------------------------------------------------------- * create a new temporary dataset *------------------------------------------------------------------------- */ - + /* retrieve the size of chunk */ if (H5Pget_chunk(pid_1, 1, dims_chunk) < 0) goto out; - + /* create a new simple data space with unlimited size, using the dimension */ if ((sid_2 = H5Screate_simple(1, dims, maxdims)) < 0) return -1; - + /* modify dataset creation properties, i.e. enable chunking */ pid_2 = H5Pcreate(H5P_DATASET_CREATE); if (H5Pset_chunk(pid_2, 1, dims_chunk) < 0) return -1; - + /* create the dataset. */ if ((did_2 = H5Dcreate2(loc_id, "new", tid_2, sid_2, H5P_DEFAULT, pid_2, H5P_DEFAULT)) < 0) goto out; - + /*------------------------------------------------------------------------- * we have to read field by field of the old dataset and save it into the new one *------------------------------------------------------------------------- @@ -2755,80 +2755,80 @@ herr_t H5TBdelete_field( hid_t loc_id, { /* get the member name */ member_name = H5Tget_member_name(tid_1, (unsigned)i); - + /* skip the field to delete */ if (H5TB_find_field(member_name, field_name) > 0) { free(member_name); continue; } - + /* get the member type */ if ((member_type_id = H5Tget_member_type(tid_1, (unsigned)i)) < 0) goto out; - + /* get the member size */ member_size = H5Tget_size(member_type_id); - + /* create a read id */ if ((read_type_id = H5Tcreate(H5T_COMPOUND, member_size)) < 0) goto out; - + /* insert it into the new type */ if (H5Tinsert( read_type_id, member_name, (size_t)0, member_type_id ) < 0) goto out; - + tmp_buf = (unsigned char *)calloc((size_t) nrecords, member_size ); - + /* read */ if (H5Dread( did_1, read_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp_buf ) < 0) goto out; - + /* create a write id */ if (( write_type_id = H5Tcreate( H5T_COMPOUND, member_size )) < 0) goto out; - + /* the field in the file is found by its name */ if (H5Tinsert( write_type_id, member_name, (size_t)0, member_type_id ) < 0) goto out; - + /* create xfer properties to preserve initialized data */ if ((preserve_id = H5Pcreate (H5P_DATASET_XFER)) < 0) goto out; if (H5Pset_preserve (preserve_id, 1) < 0) goto out; - + /* write */ if(H5Dwrite( did_2, write_type_id, H5S_ALL, H5S_ALL, preserve_id, tmp_buf ) < 0) goto out; - + /* end access to the property list */ if (H5Pclose( preserve_id ) < 0) goto out; - + /* close the member type */ if (H5Tclose( member_type_id ) < 0) goto out; - + /* close the read type */ if (H5Tclose( read_type_id ) < 0) goto out; - + /* close the write type */ if (H5Tclose( write_type_id ) < 0) goto out; - + /* release resources. */ free( member_name ); free ( tmp_buf ); - + } /* i */ - + /*------------------------------------------------------------------------- * release resources from 1st table *------------------------------------------------------------------------- */ - + if (H5Tclose( tid_1 ) < 0) goto out; if (H5Pclose( pid_1 ) < 0) @@ -2837,13 +2837,13 @@ herr_t H5TBdelete_field( hid_t loc_id, goto out; if (H5Dclose( did_1 ) < 0) goto out; - - + + /*------------------------------------------------------------------------- * release resources from 2nd table *------------------------------------------------------------------------- */ - + if (H5Sclose( sid_2 ) < 0) goto out; if (H5Tclose( tid_2 ) < 0) @@ -2852,104 +2852,104 @@ herr_t H5TBdelete_field( hid_t loc_id, goto out; if (H5Dclose( did_2 ) < 0) goto out; - + /*------------------------------------------------------------------------- * delete 1st table *------------------------------------------------------------------------- */ - + if (H5Ldelete( loc_id, dset_name, H5P_DEFAULT ) < 0) return -1; - + /*------------------------------------------------------------------------- * rename 2nd table *------------------------------------------------------------------------- */ - + if (H5Lmove( loc_id, "new", H5L_SAME_LOC, dset_name, H5P_DEFAULT, H5P_DEFAULT ) < 0) return -1; - + /*------------------------------------------------------------------------- * attach the conforming table attributes *------------------------------------------------------------------------- */ - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0) return -1; - + /* open the dataset. */ if ((did_1 = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /* get the datatype */ if ((tid_1 = H5Dget_type( did_1 )) < 0) goto out; - + /* set the attributes */ if (H5TB_attach_attributes( table_title, loc_id, dset_name, nfields, tid_1 ) < 0) return -1; - + /*------------------------------------------------------------------------- * attach the fill attributes from previous table *------------------------------------------------------------------------- */ - + if (has_fill == 1) { if((sid_1 = H5Screate(H5S_SCALAR)) < 0) goto out; - + for(i = 0; i < nfields; i++) { - + /* get the member type */ if (( member_type_id = H5Tget_member_type( tid_1, (unsigned)i )) < 0) goto out; - + /* get the member offset */ member_offset = H5Tget_member_offset(tid_1, (unsigned)i); - + strcpy(attr_name, "FIELD_"); sprintf(aux, "%d", (int)i); strcat(attr_name, aux); sprintf(aux, "%s", "_FILL"); strcat(attr_name, aux); - + if ((attr_id = H5Acreate2(did_1, attr_name, member_type_id, sid_1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - + if (H5Awrite(attr_id, member_type_id, tmp_fill_buf+member_offset) < 0) goto out; - + if (H5Aclose(attr_id) < 0) goto out; - + /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; } - + /* close data space. */ if (H5Sclose(sid_1) < 0) goto out; - + } /*has_fill*/ - + /* release the datatype. */ if (H5Tclose( tid_1 ) < 0) goto out; - + /* end access to the dataset */ if (H5Dclose( did_1 ) < 0) goto out; - + /* Release resources. */ free ( tmp_fill_buf ); - + return 0; - -/* error zone */ + + /* error zone */ out: H5E_BEGIN_TRY { @@ -2961,74 +2961,74 @@ out: H5Sclose(sid_2); H5Tclose(tid_2); H5Pclose(pid_2); - + } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * - * Table attribute functions - * - *------------------------------------------------------------------------- - */ +* +* Table attribute functions +* +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5TBAget_title - * - * Purpose: Read the table title - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: January 30, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5TBAget_title +* +* Purpose: Read the table title +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: January 30, 2001 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5TBAget_title( hid_t loc_id, - char *table_title ) + char *table_title ) { - + /* Get the TITLE attribute */ if(H5LT_get_attribute_disk( loc_id, "TITLE", table_title ) < 0) return -1; - - + + return 0; - + } /*------------------------------------------------------------------------- - * Function: H5TBAget_fill - * - * Purpose: Read the table attribute fill values - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: January 30, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5TBAget_fill +* +* Purpose: Read the table attribute fill values +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: January 30, 2002 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ herr_t H5TBAget_fill( hid_t loc_id, - const char *dset_name, - hid_t dset_id, - unsigned char *dst_buf ) + const char *dset_name, + hid_t dset_id, + unsigned char *dst_buf ) { - + hsize_t nfields; hsize_t nrecords; char attr_name[255]; @@ -3036,20 +3036,20 @@ herr_t H5TBAget_fill( hid_t loc_id, hsize_t i; size_t *src_offset; int has_fill=0; - + /* get the number of records and fields */ if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0) return -1; - + src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t)); - + if (src_offset == NULL ) return -1; - + /* get field info */ if (H5TBget_field_info( loc_id, dset_name, NULL, NULL, src_offset, NULL ) < 0) goto out; - + for ( i = 0; i < nfields; i++) { strcpy( attr_name, "FIELD_" ); @@ -3057,125 +3057,125 @@ herr_t H5TBAget_fill( hid_t loc_id, strcat( attr_name, aux ); sprintf( aux, "%s", "_FILL" ); strcat( attr_name, aux ); - + /* check if we have the _FILL attribute */ has_fill = H5LT_find_attribute( dset_id, attr_name ); - + /* get it */ if (has_fill == 1 ) { if(H5LT_get_attribute_disk( dset_id, attr_name, dst_buf+src_offset[i] ) < 0) goto out; } - + } - + free( src_offset ); - + return has_fill; - + out: free( src_offset ); return -1; - + } /*------------------------------------------------------------------------- - * - * Inquiry functions - * - *------------------------------------------------------------------------- - */ +* +* Inquiry functions +* +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5TBget_table_info - * - * Purpose: Gets the number of records and fields of a table - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 19, 2001 - * - * Comments: - * - * Modifications: - * May 08, 2003 - * In version 2.0 of Table, the number of records is stored as an - * attribute "NROWS" - * November 24, 2008 - * In version 3.0 of Table, "NROWS" was deprecated - * - * - *------------------------------------------------------------------------- - */ +* Function: H5TBget_table_info +* +* Purpose: Gets the number of records and fields of a table +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 19, 2001 +* +* Comments: +* +* Modifications: +* May 08, 2003 +* In version 2.0 of Table, the number of records is stored as an +* attribute "NROWS" +* November 24, 2008 +* In version 3.0 of Table, "NROWS" was deprecated +* +* +*------------------------------------------------------------------------- +*/ herr_t H5TBget_table_info ( hid_t loc_id, - const char *dset_name, - hsize_t *nfields, - hsize_t *nrecords ) + const char *dset_name, + hsize_t *nfields, + hsize_t *nrecords ) { hid_t tid=-1; hid_t sid=-1; hid_t did=-1; int num_members; hsize_t dims[1]; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) return -1; - + /* get the datatype */ if ((tid = H5Dget_type( did )) < 0) goto out; - + /* get the number of members */ if ((num_members = H5Tget_nmembers( tid )) < 0) goto out; - + /*------------------------------------------------------------------------- * get number of nfields *------------------------------------------------------------------------- */ - + if (nfields) { *nfields = num_members; } - - + + /*------------------------------------------------------------------------- * get number of records *------------------------------------------------------------------------- */ - + if (nrecords) { /* get the dataspace handle */ if ((sid = H5Dget_space( did )) < 0) goto out; - + /* get dimension */ if (H5Sget_simple_extent_dims( sid, dims, NULL) < 0) goto out; - + /* terminate access to the dataspace */ if (H5Sclose( sid ) < 0) goto out; - + *nrecords = dims[0]; } - + /* close */ if (H5Tclose( tid ) < 0) goto out; if (H5Dclose( did ) < 0) return -1; - + return 0; - + /* error zone */ out: H5E_BEGIN_TRY @@ -3185,33 +3185,33 @@ out: H5Tclose(tid); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TBget_field_info - * - * Purpose: Get information about fields - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 19, 2001 - * - * Comments: - * - * Modifications: - * - * - *------------------------------------------------------------------------- - */ +* Function: H5TBget_field_info +* +* Purpose: Get information about fields +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 19, 2001 +* +* Comments: +* +* Modifications: +* +* +*------------------------------------------------------------------------- +*/ herr_t H5TBget_field_info( hid_t loc_id, - const char *dset_name, - char *field_names[], - size_t *field_sizes, - size_t *field_offsets, - size_t *type_size ) + const char *dset_name, + char *field_names[], + size_t *field_sizes, + size_t *field_offsets, + size_t *type_size ) { hid_t did; /* dataset ID */ hid_t tid; /* file type ID */ @@ -3224,73 +3224,73 @@ herr_t H5TBget_field_info( hid_t loc_id, size_t member_offset; size_t size; hssize_t i; - + /* open the dataset. */ if ((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0) goto out; - + /* get the datatype */ if (( tid = H5Dget_type( did )) < 0) goto out; - + if ((n_tid = H5Tget_native_type(tid,H5T_DIR_DEFAULT)) < 0) goto out; - + /* get the type size */ size = H5Tget_size( n_tid ); - + if ( type_size ) { *type_size = size; } - + /* get the number of members */ if (( nfields = H5Tget_nmembers( tid )) < 0) goto out; - + /* iterate tru the members */ for ( i = 0; i < nfields; i++) { /* get the member name */ member_name = H5Tget_member_name( tid, (unsigned)i ); - + if (field_names ) { strcpy( field_names[i], member_name ); } - + /* get the member type */ if (( m_tid = H5Tget_member_type( tid,(unsigned) i )) < 0) goto out; if ((nm_tid = H5Tget_native_type(m_tid,H5T_DIR_DEFAULT)) < 0) goto out; - + /* get the member size */ member_size = H5Tget_size( nm_tid ); - + if(field_sizes ) { field_sizes[i] = member_size; } - + /* get the member offset */ member_offset = H5Tget_member_offset( n_tid,(unsigned) i ); - + if(field_offsets ) { field_offsets[i] = member_offset; } - + /* close the member types */ if (H5Tclose( m_tid ) < 0) goto out; if (H5Tclose( nm_tid ) < 0) goto out; - + free( member_name ); - + } /* i */ - + /* close */ if (H5Tclose( tid ) < 0) goto out; @@ -3298,10 +3298,10 @@ herr_t H5TBget_field_info( hid_t loc_id, goto out; if (H5Dclose( did ) < 0) return -1; - + return 0; - - /* error zone */ + + /* error zone */ out: H5E_BEGIN_TRY { @@ -3310,36 +3310,36 @@ out: H5Tclose(n_tid); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * - * internal functions - * - *------------------------------------------------------------------------- - */ +* +* internal functions +* +*------------------------------------------------------------------------- +*/ /*------------------------------------------------------------------------- - * Function: H5TB_find_field - * - * Purpose: Find a string field - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 19, 2001 - * - *------------------------------------------------------------------------- - */ +* Function: H5TB_find_field +* +* Purpose: Find a string field +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 19, 2001 +* +*------------------------------------------------------------------------- +*/ static int H5TB_find_field( const char *field, const char *field_list ) { const char *start = field_list; const char *end; - + while ( (end = strstr( start, "," )) != 0 ) { size_t count = end - start; @@ -3347,105 +3347,105 @@ int H5TB_find_field( const char *field, const char *field_list ) return 1; start = end + 1; } - + if(strcmp( start, field ) == 0 ) return 1; - + return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TB_attach_attributes - * - * Purpose: Private function that creates the conforming table attributes; - * Used by H5TBcombine_tables; not used by H5TBmake_table, which does not read - * the fill value attributes from an existing table - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 6, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5TB_attach_attributes +* +* Purpose: Private function that creates the conforming table attributes; +* Used by H5TBcombine_tables; not used by H5TBmake_table, which does not read +* the fill value attributes from an existing table +* +* Return: Success: 0, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: December 6, 2001 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ static herr_t H5TB_attach_attributes( const char *table_title, - hid_t loc_id, - const char *dset_name, - hsize_t nfields, - hid_t tid ) + hid_t loc_id, + const char *dset_name, + hsize_t nfields, + hid_t tid ) { - + char attr_name[255]; char *member_name; char aux[255]; hsize_t i; - + /* attach the CLASS attribute */ if (H5LTset_attribute_string( loc_id, dset_name, "CLASS", TABLE_CLASS ) < 0) goto out; - + /* attach the VERSION attribute */ if (H5LTset_attribute_string( loc_id, dset_name, "VERSION", TABLE_VERSION ) < 0) goto out; - + /* attach the TITLE attribute */ if (H5LTset_attribute_string( loc_id, dset_name, "TITLE", table_title ) < 0) goto out; - + /* attach the FIELD_ name attribute */ for ( i = 0; i < nfields; i++) { - + /* get the member name */ member_name = H5Tget_member_name( tid, (unsigned)i ); - + strcpy( attr_name, "FIELD_" ); sprintf( aux, "%d", (int)i ); strcat( attr_name, aux ); sprintf( aux, "%s", "_NAME" ); strcat( attr_name, aux ); - + /* attach the attribute */ if (H5LTset_attribute_string( loc_id, dset_name, attr_name, member_name ) < 0) goto out; - + free( member_name ); - + } - + return 0; - + out: return -1; - + } /*------------------------------------------------------------------------- - * Function: H5TB_create_type - * - * Purpose: Private function that creates a memory type ID - * - * Return: Success: the memory type ID, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 31, 2004 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ +* Function: H5TB_create_type +* +* Purpose: Private function that creates a memory type ID +* +* Return: Success: the memory type ID, Failure: -1 +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: March 31, 2004 +* +* Comments: +* +* Modifications: +* +*------------------------------------------------------------------------- +*/ static hid_t H5TB_create_type(hid_t loc_id, @@ -3462,31 +3462,31 @@ hid_t H5TB_create_type(hid_t loc_id, hsize_t nfields; char **fnames; unsigned i; - + /* get the number of fields */ if (H5TBget_table_info(loc_id,dset_name,&nfields,NULL) < 0) return -1; - - if ((fnames=malloc(sizeof(char*)*(size_t)nfields))==NULL) + + if ((fnames = (char**) malloc(sizeof(char*)*(size_t)nfields))==NULL) return -1; - + for ( i = 0; i < nfields; i++) { - if ((fnames[i]=malloc(sizeof(char)*HLTB_MAX_FIELD_LEN))==NULL) + if ((fnames[i] = (char*) malloc(sizeof(char)*HLTB_MAX_FIELD_LEN))==NULL) { free(fnames); return -1; } } - + /* get field info */ if (H5TBget_field_info(loc_id,dset_name,fnames,NULL,NULL,NULL) < 0) goto out; - + /* create the memory data type */ if ((mem_type_id=H5Tcreate(H5T_COMPOUND,type_size)) < 0) goto out; - + /* get each field ID and adjust its size, if necessary */ for ( i = 0; i < nfields; i++) { @@ -3507,15 +3507,15 @@ hid_t H5TB_create_type(hid_t loc_id, if (H5Tclose(nmtype_id) < 0) goto out; } - + for ( i=0; i table_size ) goto out; - + /* get the dataspace handle */ if ((sid = H5Dget_space( dataset_id )) < 0) goto out; - + /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = nrecords; if (H5Sselect_hyperslab( sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0) goto out; - + /* create a memory dataspace handle */ mem_size[0] = count[0]; if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; if ((H5Dread( dataset_id, mem_type_id, m_sid, sid, H5P_DEFAULT, buf)) < 0) goto out; - + /* close */ if (H5Sclose( m_sid ) < 0) goto out; if (H5Sclose( sid ) < 0) goto out; - + return 0; - + out: H5E_BEGIN_TRY { diff --git a/hl/src/Makefile.am b/hl/src/Makefile.am index 5beb64f..b1860c1 100644 --- a/hl/src/Makefile.am +++ b/hl/src/Makefile.am @@ -19,6 +19,7 @@ # include $(top_srcdir)/config/commence.am +include $(top_srcdir)/config/lt_vers.am # Add include directories to the C preprocessor flags AM_CPPFLAGS=-I$(top_srcdir)/src @@ -26,6 +27,8 @@ AM_CPPFLAGS=-I$(top_srcdir)/src # This library is our main target. lib_LTLIBRARIES=libhdf5_hl.la +# Add libtool numbers to the HDF5 hl library (from config/lt_vers.am) +libhdf5_hl_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) libhdf5_hl_la_SOURCES=H5DS.c H5HLerror.c H5HLint.c H5IM.c H5LT.c H5LTanalyze.c H5LTparse.c H5PT.c H5TB.c H5LR.c # Public header files (to be installed) diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index a2b88fc..71ed29b 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -52,7 +52,8 @@ build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am COPYING + $(top_srcdir)/config/conclude.am \ + $(top_srcdir)/config/lt_vers.am COPYING TESTS = subdir = hl/src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -75,6 +76,9 @@ libhdf5_hl_la_LIBADD = am_libhdf5_hl_la_OBJECTS = H5DS.lo H5HLerror.lo H5HLint.lo H5IM.lo \ H5LT.lo H5LTanalyze.lo H5LTparse.lo H5PT.lo H5TB.lo H5LR.lo libhdf5_hl_la_OBJECTS = $(am_libhdf5_hl_la_OBJECTS) +libhdf5_hl_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libhdf5_hl_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/bin/depcomp am__depfiles_maybe = depfiles @@ -343,11 +347,20 @@ TRACE = perl $(top_srcdir)/bin/trace # *.clog are from the MPE option. CHECK_CLEANFILES = *.chkexe *.chklog *.clog +# Add libtool shared library version numbers to the HDF5 library +# See libtool versioning documentation online. +LT_VERS_INTERFACE = 6 +LT_VERS_REVISION = 29 +LT_VERS_AGE = 0 + # Add include directories to the C preprocessor flags AM_CPPFLAGS = -I$(top_srcdir)/src # This library is our main target. lib_LTLIBRARIES = libhdf5_hl.la + +# Add libtool numbers to the HDF5 hl library (from config/lt_vers.am) +libhdf5_hl_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) libhdf5_hl_la_SOURCES = H5DS.c H5HLerror.c H5HLint.c H5IM.c H5LT.c H5LTanalyze.c H5LTparse.c H5PT.c H5TB.c H5LR.c # Public header files (to be installed) @@ -372,12 +385,12 @@ all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/lt_vers.am $(top_srcdir)/config/conclude.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -429,7 +442,7 @@ clean-libLTLIBRARIES: rm -f "$${dir}/so_locations"; \ done libhdf5_hl.la: $(libhdf5_hl_la_OBJECTS) $(libhdf5_hl_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libhdf5_hl_la_OBJECTS) $(libhdf5_hl_la_LIBADD) $(LIBS) + $(libhdf5_hl_la_LINK) -rpath $(libdir) $(libhdf5_hl_la_OBJECTS) $(libhdf5_hl_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -497,7 +510,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -686,6 +699,19 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES help: @$(top_srcdir)/bin/makehelp +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. + # lib/progs/tests targets recurse into subdirectories. build-* targets # build files in this directory. build-lib: $(LIB) diff --git a/hl/test/Makefile.am b/hl/test/Makefile.am index 52d58fa..431f7c2 100644 --- a/hl/test/Makefile.am +++ b/hl/test/Makefile.am @@ -33,7 +33,7 @@ TEST_PROG=test_lite test_image test_table test_ds test_packet test_regref_hyper check_PROGRAMS=$(TEST_PROG) # Temporary files. These files are the ones created by running `make test'. -CHECK_CLEANFILES+=combine_tables[1-2].h5 test_ds[1-6].h5 test_image[1-3].h5 \ +CHECK_CLEANFILES+=combine_tables[1-2].h5 test_ds[1-7].h5 test_image[1-3].h5 \ test_lite[1-2].h5 test_table.h5 test_packet_table.h5 \ test_packet_compress.h5 FileA.h5 NPOESS_EDR.h5 diff --git a/hl/test/Makefile.in b/hl/test/Makefile.in index cb4bb52..f9dfe3b 100644 --- a/hl/test/Makefile.in +++ b/hl/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -363,7 +363,7 @@ TRACE = perl $(top_srcdir)/bin/trace # Temporary files. These files are the ones created by running `make test'. CHECK_CLEANFILES = *.chkexe *.chklog *.clog combine_tables[1-2].h5 \ - test_ds[1-6].h5 test_image[1-3].h5 test_lite[1-2].h5 \ + test_ds[1-7].h5 test_image[1-3].h5 test_lite[1-2].h5 \ test_table.h5 test_packet_table.h5 test_packet_compress.h5 \ FileA.h5 NPOESS_EDR.h5 @@ -400,8 +400,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -500,7 +500,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index e4d4260..6951619 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -24,11 +24,13 @@ static herr_t verify_scale(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); -static herr_t op_bogus(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); +static herr_t op_continue(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); +static herr_t op_stop(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); /* prototypes */ static int test_simple(void); static int test_errors(void); +static int test_errors2(void); static int test_rank(void); static int test_types(void); static int test_iterators(void); @@ -43,14 +45,12 @@ static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf ) #define DIM3_SIZE 2 #define DIM0 0 #define DIM1 1 -#define DIM2 2 #define DS_1_NAME "ds_a_1" #define DS_11_NAME "ds_a_11" #define DS_2_NAME "ds_a_2" #define DS_21_NAME "ds_a_21" #define DS_22_NAME "ds_a_22" -#define DS_3_NAME "ds_a_3" #define SCALE_1_NAME "Latitude set 0" #define SCALE_11_NAME "Latitude set 1" @@ -67,8 +67,7 @@ static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf ) #define FILE4 "test_ds4.h5" #define FILE5 "test_ds5.h5" #define FILE6 "test_ds6.h5" - - +#define FILE7 "test_ds7.h5" /*------------------------------------------------------------------------- * the main program @@ -80,10 +79,12 @@ int main(void) nerrors += test_simple() < 0 ?1:0; nerrors += test_errors() < 0 ?1:0; + nerrors += test_errors2() < 0 ?1:0; nerrors += test_rank() < 0 ?1:0; nerrors += test_iterators() < 0 ?1:0; nerrors += test_types() < 0 ?1:0; nerrors += test_data() < 0 ?1:0; + if(nerrors) goto error; printf("All dimension scales tests passed.\n"); @@ -101,6 +102,7 @@ error: * Functions tested: * * H5DSattach_scale + * H5DSget_num_scales * H5DSdetach_scale * H5DSset_label * H5DSget_label @@ -108,7 +110,6 @@ error: * H5DSget_scale_name * H5DSis_scale * H5DSiterate_scales - * H5DSget_num_scales * *------------------------------------------------------------------------- */ @@ -116,13 +117,13 @@ error: static int test_simple(void) { - hid_t fid; /* file ID */ + hid_t fid = -1; /* file ID */ hid_t did = -1; /* dataset ID */ - hid_t dsid; /* DS dataset ID */ - hid_t sid; /* space ID */ - hid_t gid; /* group ID */ - int rank = RANK; /* rank of data dataset */ - int rankds = 1; /* rank of DS dataset */ + hid_t dsid = -1; /* DS dataset ID */ + hid_t sid = -1; /* space ID */ + hid_t gid = -1; /* group ID */ + int rank = RANK; /* rank of data dataset */ + int rankds = 1; /* rank of DS dataset */ hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12}; /* data of data dataset */ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */ @@ -191,9 +192,9 @@ static int test_simple(void) if(H5LTmake_dataset_int(fid,DS_22_NAME,rankds,s2_dim,s22_wbuf) < 0) goto out; - + /*------------------------------------------------------------------------- - * test 1: attach scale + * H5DSattach_scale *------------------------------------------------------------------------- */ @@ -333,10 +334,11 @@ static int test_simple(void) /*------------------------------------------------------------------------- - * test 2: get number of scales + * H5DSget_num_scales *------------------------------------------------------------------------- */ + TESTING2("get number of scales"); /*------------------------------------------------------------------------- @@ -423,7 +425,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- - * test 3: detach scales + * H5DSdetach_scale *------------------------------------------------------------------------- */ @@ -952,16 +954,12 @@ static int test_simple(void) goto out; - PASSED(); - /*------------------------------------------------------------------------- * create a dataset and attach only to 1 dimension *------------------------------------------------------------------------- */ - TESTING2("attach only to 1 dimension"); - /* make a dataset */ if(H5LTmake_dataset_int(fid,"dset_e",rank,dims,NULL) < 0) goto out; @@ -1004,8 +1002,9 @@ static int test_simple(void) PASSED(); + /*------------------------------------------------------------------------- - * test 4: set/get label + * H5DSset_label, H5DSget_label *------------------------------------------------------------------------- */ @@ -1100,9 +1099,11 @@ static int test_simple(void) PASSED(); /*------------------------------------------------------------------------- - * test 5: set scale/get scale name + * H5DSget_scale_name, H5DSget_scale_name *------------------------------------------------------------------------- */ + + TESTING2("set scale/get scale name"); if((dsid = H5Dopen2(fid,DS_1_NAME, H5P_DEFAULT)) < 0) @@ -1206,10 +1207,18 @@ static int test_simple(void) PASSED(); /*------------------------------------------------------------------------- + * H5DSiterate_scales + *------------------------------------------------------------------------- + */ + + + TESTING2("iterate scales"); + + + /*------------------------------------------------------------------------- * test 6: test iterate scales with a function verify_scale *------------------------------------------------------------------------- */ - TESTING2("iterate scales (verify scale)"); /* get the dataset id for "dset_a" */ if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) @@ -1233,14 +1242,11 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; - PASSED(); - /*------------------------------------------------------------------------- - * test 7: test iterate scales with a function read_scale + * test iterate scales with a function read_scale *------------------------------------------------------------------------- */ - TESTING2("iterate scales (read scale values)"); /* get the dataset id for "dset_a" */ @@ -1265,13 +1271,11 @@ static int test_simple(void) if(H5Dclose(did) < 0) goto out; - PASSED(); /*------------------------------------------------------------------------- - * test 8: test iterate scales with a function match_dim_scale + * test iterate scales with a function match_dim_scale *------------------------------------------------------------------------- */ - TESTING2("iterate scales (verify the scale sizes match)"); /* get the dataset id for "dset_a" */ if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) @@ -1316,13 +1320,11 @@ static int test_simple(void) if(H5Sclose(sid) < 0) goto out; - PASSED(); /*------------------------------------------------------------------------- - * test 9: test iterate scales with a function match_dim_scale + * test iterate scales with a function match_dim_scale *------------------------------------------------------------------------- */ - TESTING2("iterate scales (verify the scale sizes do not match)"); /*------------------------------------------------------------------------- * create 3 datasets: 1 "data" dataset and dimension scales (some are empty) @@ -1411,6 +1413,10 @@ static int test_simple(void) case 1: /* for DIM 1, we get no valid scales */ if(match_size!=0 && idx!=0) goto out; + break; + default: + assert(0); + break; }/*switch*/ }/*for*/ } @@ -1434,11 +1440,15 @@ static int test_simple(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); + H5Dclose(dsid); H5Fclose(fid); + H5Sclose(sid); + H5Gclose(gid); } H5E_END_TRY; H5_FAILED(); return FAIL; @@ -1508,14 +1518,14 @@ static herr_t verify_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visit static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) { int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */ - hid_t sid; /* space ID */ + hid_t sid = -1; /* space ID */ hid_t tid = -1; /* file type ID */ hid_t mtid = -1; /* memory type ID */ hssize_t nelmts; /* number of data elements */ char *buf=NULL; /* data buffer */ size_t size; int i; - char *data=visitor_data; + char *data = (char*) visitor_data; /* unused */ dset=dset; @@ -1568,14 +1578,17 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor return ret; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Tclose(tid); H5Tclose(mtid); if(buf) + { free(buf); + } } H5E_END_TRY; return FAIL; @@ -1657,7 +1670,8 @@ static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor return ret; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); } H5E_END_TRY; return FAIL; @@ -1665,9 +1679,10 @@ out: /*------------------------------------------------------------------------- - * Function: op_bogus + * Function: op_continue * - * Purpose: example operator function used by H5DSiterate_scales, that does nothing + * Purpose: example operator function used by H5DSiterate_scales that continues + * iteration and increments visitor_data (Note: int*) * * Return: * The return values from an operator are: @@ -1680,19 +1695,58 @@ out: *------------------------------------------------------------------------- */ -static herr_t op_bogus(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) +static herr_t op_continue(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) { /* Stop compiler from whining about "unused parameters" */ dset = dset; dim = dim; scale_id = scale_id; - visitor_data = visitor_data; + + if ( visitor_data != NULL ) + { + (*(int *)visitor_data)++; + } /* define a default zero value for return. This will cause the iterator to continue */ return 0; } +/*------------------------------------------------------------------------- + * Function: op_stop + * + * Purpose: example operator function used by H5DSiterate_scales that stops + * iteration and increments visitor_data (Note: int*) + * + * Return: + * The return values from an operator are: + * Zero causes the iterator to continue, returning zero when all group members have been processed. + * Positive causes the iterator to immediately return that positive value, indicating + * short-circuit success. The iterator can be restarted at the next group member. + * Negative causes the iterator to immediately return that value, indicating failure. + * The iterator can be restarted at the next group member. + * + *------------------------------------------------------------------------- + */ + +static herr_t op_stop(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) +{ + /* Stop compiler from whining about "unused parameters" */ + dset = dset; + dim = dim; + scale_id = scale_id; + + if ( visitor_data != NULL ) + { + (*(int *)visitor_data)++; + } + + /* define a default 1 value for return. This will cause the iterator to stop */ + return 1; +} + + + /*------------------------------------------------------------------------- * test error conditions @@ -2057,9 +2111,10 @@ static int test_errors(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Sclose(sidds); H5Dclose(did); @@ -2086,8 +2141,8 @@ static int test_iterators(void) hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */ hid_t gid = -1; /* group ID */ - hid_t did; /* dataset ID */ - hid_t dsid; /* scale ID */ + hid_t did = -1; /* dataset ID */ + hid_t dsid = -1; /* scale ID */ char dname[30]; /* dataset name */ int i; @@ -2186,7 +2241,7 @@ static int test_iterators(void) } /* iterate trough the 1st dimension of "dset_a" */ - if(H5DSiterate_scales(did,0,NULL,op_bogus,NULL) < 0) + if(H5DSiterate_scales(did,0,NULL,op_continue,NULL) < 0) goto out; /* close */ @@ -2232,7 +2287,7 @@ static int test_iterators(void) goto out; /* iterate */ - if(H5DSiterate_scales(did, 0, NULL, op_bogus, NULL) == SUCCEED) + if(H5DSiterate_scales(did, 0, NULL, op_continue, NULL) == SUCCEED) goto out; /* close */ @@ -2248,10 +2303,12 @@ static int test_iterators(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); + H5Dclose(did); H5Fclose(fid); } H5E_END_TRY; H5_FAILED(); @@ -2269,8 +2326,8 @@ static int test_rank(void) hid_t fid; /* file ID */ hid_t did = -1; /* dataset ID */ hid_t dsid = -1; /* scale ID */ - hid_t sid; /* space ID */ - hid_t sidds; /* space ID */ + hid_t sid = -1; /* space ID */ + hid_t sidds = -1; /* space ID */ hsize_t dims1[1] = {DIM1_SIZE}; /* size of data dataset */ hsize_t dims2[2] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ hsize_t dims3[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; /* size of data dataset */ @@ -2455,11 +2512,14 @@ static int test_rank(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Dclose(dsid); + H5Sclose(sidds); + H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; H5_FAILED(); @@ -2632,9 +2692,10 @@ static int test_types(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Dclose(dsid); H5Fclose(fid); @@ -2790,9 +2851,10 @@ static int test_data(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Dclose(dsid); H5Fclose(fid); @@ -2882,3 +2944,200 @@ static int read_data( const char* fname, } +/*------------------------------------------------------------------------- + * test parameter errors + *------------------------------------------------------------------------- + */ + +static int test_errors2(void) +{ + hid_t fid; /* file ID */ + hid_t did = -1; /* dataset ID */ + hid_t dsid = -1; /* scale ID */ + hsize_t dimd[2] = {3,3}; /* size of data dataset */ + hsize_t dims[1] = {3}; /* size of scale dataset */ + char lbuf[255]; /* label buffer */ + ssize_t label_len; /* label lenght */ + int scale_idx; /* scale index */ + int nscales; /* number of scales in DIM */ + int count; /* visitor data */ + + printf("Testing parameter errors\n"); + + /*------------------------------------------------------------------------- + * create a file, a dataset, scales + *------------------------------------------------------------------------- + */ + + /* create a file using default properties */ + if ((fid=H5Fcreate(FILE7,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + goto out; + + /* make a dataset */ + if (H5LTmake_dataset_int(fid,"dset",2,dimd,NULL) < 0) + goto out; + + /* make a scale dataset */ + if(H5LTmake_dataset_int(fid,"ds1",1,dims,NULL) < 0) + goto out; + + /* make a scale dataset */ + if(H5LTmake_dataset_int(fid,"ds2",1,dims,NULL) < 0) + goto out; + + + TESTING2("attach scales"); + + + /*------------------------------------------------------------------------- + * attach with invalid indices + *------------------------------------------------------------------------- + */ + + if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0) + goto out; + if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0) + goto out; + if (H5DSattach_scale(did,dsid,2) == SUCCEED) + goto out; + if (H5DSattach_scale(did,dsid,0) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + + PASSED(); + + TESTING2("detach scales"); + + /*------------------------------------------------------------------------- + * detach with invalid indices + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0) + goto out; + if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0) + goto out; + if (H5DSdetach_scale(did,dsid,2) == SUCCEED) + goto out; + if (H5DSdetach_scale(did,dsid,0) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + + PASSED(); + + TESTING2("set/get label"); + + /*------------------------------------------------------------------------- + * set/get label invalid indices + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0) + goto out; + if (H5DSset_label(did,2,"label")== SUCCEED) + goto out; + if (H5DSset_label(did,0,"label") < 0) + goto out; + if (H5DSget_label(did,2,lbuf,sizeof(lbuf)) == SUCCEED) + goto out; + if ((label_len=H5DSget_label(did,0,NULL,0)) < 0) + goto out; + if ( label_len != strlen("label") ) + goto out; + if (H5DSget_label(did,0,lbuf,sizeof(lbuf)) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + + PASSED(); + + TESTING2("iterate scales"); + + + /*------------------------------------------------------------------------- + * iterate_scales invalid indices and return DS_IDX and visitor data + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0) + goto out; + + if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0) + goto out; + if (H5DSattach_scale(did,dsid,0) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; + + if ((dsid = H5Dopen2(fid,"ds2", H5P_DEFAULT)) < 0) + goto out; + if (H5DSattach_scale(did,dsid,0) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; + + if((nscales = H5DSget_num_scales(did,0)) < 0) + goto out; + if(nscales!=2) + goto out; + + /* invalid DIM */ + if (H5DSiterate_scales(did,2,NULL,op_continue,NULL)== SUCCEED) + goto out; + /* invalid DS_IDX */ + scale_idx = 2; + if (H5DSiterate_scales(did,0,&scale_idx,op_continue,NULL)== SUCCEED) + goto out; + + /* continue iteration */ + scale_idx = 0; + count = 0; + if (H5DSiterate_scales(did,0,&scale_idx,op_continue,(void *)&count) < 0) + goto out; + + if ( scale_idx != 1 && count != nscales ) + { + goto out; + } + + /* stop iteration */ + scale_idx = 0; + count = 0; + if (H5DSiterate_scales(did,0,&scale_idx,op_stop,(void *)&count) < 0) + goto out; + + if ( scale_idx != 0 && count != 1 ) + { + goto out; + } + + + if (H5Dclose(did) < 0) + goto out; + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + if(H5Fclose(fid) < 0) + goto out; + + PASSED(); + + return 0; + + /* error zone */ +out: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Dclose(dsid); + H5Fclose(fid); + } H5E_END_TRY; + H5_FAILED(); + return FAIL; +} + diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 2a365e2..426ae1d 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -61,9 +61,9 @@ static int read_palette(const char* file_name, rgb_t *palette, size_t palette_si unsigned char *image_data = NULL; /*------------------------------------------------------------------------- - * the main program - *------------------------------------------------------------------------- - */ +* the main program +*------------------------------------------------------------------------- +*/ int main(void) { @@ -83,9 +83,9 @@ error: } /*------------------------------------------------------------------------- - * a simple test that generates images and palettes - *------------------------------------------------------------------------- - */ +* a simple test that generates images and palettes +*------------------------------------------------------------------------- +*/ static int test_simple(void) { @@ -94,6 +94,7 @@ static int test_simple(void) hsize_t planes; hid_t fid; int i, j, n, space; + hsize_t u; char interlace[20]; hssize_t npals; @@ -142,7 +143,7 @@ static int test_simple(void) } } - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * define a palette, blue to red tones *------------------------------------------------------------------------- */ @@ -156,7 +157,7 @@ static int test_simple(void) /* Create a new HDF5 file using default properties. */ fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * Indexed image test *------------------------------------------------------------------------- */ @@ -182,9 +183,9 @@ static int test_simple(void) if ( H5IMread_image( fid, IMAGE1_NAME, buf1_out ) < 0 ) goto out; - for (i = 0; i < height*width*planes; i++) + for (u = 0; u < height*width*planes; u++) { - if ( buf1[i] != buf1_out[i] ) + if ( buf1[u] != buf1_out[u] ) goto out; } @@ -192,7 +193,7 @@ static int test_simple(void) PASSED(); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * True color image test *------------------------------------------------------------------------- */ @@ -210,16 +211,16 @@ static int test_simple(void) if ( H5IMread_image( fid, IMAGE2_NAME, buf2_out ) < 0 ) goto out; - for (i = 0; i < height*width*planes; i++) + for (u = 0; u < height*width*planes; u++) { - if ( buf2[i] != buf2_out[i] ) + if ( buf2[u] != buf2_out[u] ) goto out; } PASSED(); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * H5IMget_npalettes test *------------------------------------------------------------------------- */ @@ -229,7 +230,7 @@ static int test_simple(void) if ( H5IMget_npalettes( fid, IMAGE1_NAME, &npals ) < 0 ) goto out; - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * H5IMget_palette_info test *------------------------------------------------------------------------- */ @@ -243,7 +244,7 @@ static int test_simple(void) goto out; } - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * H5IMget_palette test *------------------------------------------------------------------------- */ @@ -257,7 +258,7 @@ static int test_simple(void) goto out; } - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * H5IMis_image test *------------------------------------------------------------------------- */ @@ -268,7 +269,7 @@ static int test_simple(void) if ( H5IMis_image( fid, IMAGE2_NAME ) < 0 ) goto out; - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * H5IMis_palette test *------------------------------------------------------------------------- */ @@ -276,7 +277,7 @@ static int test_simple(void) if ( H5IMis_palette( fid, PAL_NAME ) < 0 ) goto out; - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * end tests *------------------------------------------------------------------------- */ @@ -301,9 +302,9 @@ out: /*------------------------------------------------------------------------- - * read sample realistic image data from ASCII files - *------------------------------------------------------------------------- - */ +* read sample realistic image data from ASCII files +*------------------------------------------------------------------------- +*/ static int test_data(void) { @@ -321,7 +322,7 @@ static int test_data(void) printf("Testing read ascii image data and generate images\n"); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * read 8bit image data *------------------------------------------------------------------------- */ @@ -341,7 +342,7 @@ static int test_data(void) TESTING2("attaching palettes"); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * palette #1. rainbow palette. data is contained in "pal_rgb.h" *------------------------------------------------------------------------- */ @@ -358,7 +359,7 @@ static int test_data(void) if (H5IMlink_palette(fid,IMAGE1_NAME,PAL1_NAME)<0) goto out; - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * palette #2. sepia palette. * read a PAL file and attach the palette to the HDF5 file *------------------------------------------------------------------------- @@ -384,7 +385,7 @@ static int test_data(void) if (H5IMlink_palette(fid,IMAGE1_NAME,PAL2_NAME)<0) goto out; - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * palette #3. earth palette. * read a PAL file and attach the palette to the HDF5 file *------------------------------------------------------------------------- @@ -413,7 +414,7 @@ static int test_data(void) PASSED(); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * palette #4. blue-red * make a palette whith blue to red colors *------------------------------------------------------------------------- @@ -434,7 +435,7 @@ static int test_data(void) goto out; - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * true color image example with pixel interlace *------------------------------------------------------------------------- */ @@ -469,7 +470,7 @@ static int test_data(void) PASSED(); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ @@ -488,16 +489,16 @@ out: } - /* - The following test provides an examples of how to generate HDF5 image data from - floating point data. In the example we use real life topographic data - (from the North American hemisphere). In the dataset sea values are represented - as negative numbers and land values are represented as positive numbers. - The example generates 3 HDF5 images, one that generates an image from all the values, - another that generates an image from the land values and another that generates an - image from the sea values. - For the example we used data from MODB, the Mediterranean Oceanic Data Base - http://modb.oce.ulg.ac.be/ +/* +The following test provides an examples of how to generate HDF5 image data from +floating point data. In the example we use real life topographic data +(from the North American hemisphere). In the dataset sea values are represented +as negative numbers and land values are represented as positive numbers. +The example generates 3 HDF5 images, one that generates an image from all the values, +another that generates an image from the land values and another that generates an +image from the sea values. +For the example we used data from MODB, the Mediterranean Oceanic Data Base +http://modb.oce.ulg.ac.be/ */ @@ -519,7 +520,7 @@ static int test_generate(void) printf("Testing read and process data and make indexed images\n"); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * compose the name of the file to open, using the srcdir, if appropriate *------------------------------------------------------------------------- */ @@ -543,40 +544,40 @@ static int test_generate(void) return -1; } -/* -!The first line of the ASCII file contains the dimension of the array : -! IMAX, JMAX, KMAX. The integers are stored with the FORTRAN format I5. -!The second line contains the exclusion value, the minimum and the maximum value of this -! file. These numbers are stored with the FORTRAN format E12.5. -! The remaining lines contains the data of the array, with 5 numbers per line -! (except the last line for each I-line). -! The array is stored in horizontal slices from sea surface to sea bottom and from -! north to south. So the indexes go from : -! -! DO K = KMAX to 1 -! DO J = JMAX to 1 -! DO I = 1 to IMAX -! read -! OD -! OD -! OD -! -! ____________________________ -! / /| (imax,jmax,kmax) -! / sea surface / | -! / / | -! /__________________________ / | -! | | | -! | | | (imax,jmax,1) n -! | | / / -! | | / / -! ^ j | | / w <-----o-----> e -! k | / |__________________________|/ / -! | / (imax,1,1) / -! |----------> s -! i -! -*/ + /* + !The first line of the ASCII file contains the dimension of the array : + ! IMAX, JMAX, KMAX. The integers are stored with the FORTRAN format I5. + !The second line contains the exclusion value, the minimum and the maximum value of this + ! file. These numbers are stored with the FORTRAN format E12.5. + ! The remaining lines contains the data of the array, with 5 numbers per line + ! (except the last line for each I-line). + ! The array is stored in horizontal slices from sea surface to sea bottom and from + ! north to south. So the indexes go from : + ! + ! DO K = KMAX to 1 + ! DO J = JMAX to 1 + ! DO I = 1 to IMAX + ! read + ! OD + ! OD + ! OD + ! + ! ____________________________ + ! / /| (imax,jmax,kmax) + ! / sea surface / | + ! / / | + ! /__________________________ / | + ! | | | + ! | | | (imax,jmax,1) n + ! | | / / + ! | | / / + ! ^ j | | / w <-----o-----> e + ! k | / |__________________________|/ / + ! | / (imax,1,1) / + ! |----------> s + ! i + ! + */ fscanf( f, "%d %d %d", &imax, &jmax, &kmax ); @@ -592,7 +593,7 @@ static int test_generate(void) } fclose( f ); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * transform the data from floating point to unsigned char * we are processing all the data here *------------------------------------------------------------------------- @@ -611,7 +612,7 @@ static int test_generate(void) PASSED(); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * transform the data from floating point to unsigned char * here we just process the land data *------------------------------------------------------------------------- @@ -633,7 +634,7 @@ static int test_generate(void) PASSED(); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * transform the data from floating point to unsigned char * here we just process the sea data *------------------------------------------------------------------------- @@ -655,7 +656,7 @@ static int test_generate(void) PASSED(); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * make a palette and attach it to the datasets *------------------------------------------------------------------------- */ @@ -677,7 +678,7 @@ static int test_generate(void) PASSED(); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ @@ -697,25 +698,25 @@ out: /*------------------------------------------------------------------------- - * read_data - * utility function to read ASCII image data - * the files have a header of the type - * - * components - * n - * height - * n - * width - * n - * - * followed by the image data - * - *------------------------------------------------------------------------- - */ +* read_data +* utility function to read ASCII image data +* the files have a header of the type +* +* components +* n +* height +* n +* width +* n +* +* followed by the image data +* +*------------------------------------------------------------------------- +*/ static int read_data( const char* fname, /*IN*/ - hsize_t *width, /*OUT*/ - hsize_t *height /*OUT*/ ) + hsize_t *width, /*OUT*/ + hsize_t *height /*OUT*/ ) { int i, n; int color_planes; @@ -725,7 +726,7 @@ static int read_data( const char* fname, /*IN*/ char *srcdir = getenv("srcdir"); /* the source directory */ char data_file[512]=""; /* buffer to hold name of existing data file */ - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * compose the name of the file to open, using "srcdir", if appropriate *------------------------------------------------------------------------- */ @@ -737,7 +738,7 @@ static int read_data( const char* fname, /*IN*/ } strcat(data_file,fname); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * read *------------------------------------------------------------------------- */ @@ -781,17 +782,17 @@ static int read_data( const char* fname, /*IN*/ /*------------------------------------------------------------------------- - * read_palette - * Read an ASCII palette file .PAL into an array - * the files have a header of the type - * - * Parameters: - * fname - name of file to read. - * palette - array of rgb_t to store the read palette. - * palette_size - number of elements in 'palette' array - * - *------------------------------------------------------------------------- - */ +* read_palette +* Read an ASCII palette file .PAL into an array +* the files have a header of the type +* +* Parameters: +* fname - name of file to read. +* palette - array of rgb_t to store the read palette. +* palette_size - number of elements in 'palette' array +* +*------------------------------------------------------------------------- +*/ #define STRING_JASC "JASC-PAL" @@ -803,118 +804,118 @@ static int read_palette(const char* fname, rgb_t *palette, size_t palette_size) { - FILE *file; - char buffer[80]; - unsigned u; - unsigned int red; - unsigned int green; - unsigned int blue; - unsigned nentries; - char *srcdir = getenv("srcdir"); /* the source directory */ - char data_file[512]; /* buffer to hold name of existing data file */ + FILE *file; + char buffer[80]; + unsigned u; + unsigned int red; + unsigned int green; + unsigned int blue; + unsigned nentries; + char *srcdir = getenv("srcdir"); /* the source directory */ + char data_file[512]; /* buffer to hold name of existing data file */ -/*------------------------------------------------------------------------- - * compose the name of the file to open, using "srcdir", if appropriate - *------------------------------------------------------------------------- - */ - strcpy(data_file, ""); - if (srcdir) - { - strcpy(data_file, srcdir); - strcat(data_file, "/"); - } - strcat(data_file,fname); - - /* ensure the given palette is valid */ - if (!palette) - return -1; - - /* open the input file */ - if (!(file = fopen(data_file, "r"))) - { - printf( "Could not open file %s. Try set $srcdir \n", data_file ); - return -1; - } - - /* read the file ident string */ - if (fgets(buffer, sizeof(buffer), file) == NULL) - { - fclose(file); - return -1; - } - - /* ensure it matches the palette file ident string */ - if ( strncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 && - strncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0 ) - { - fclose(file); - return -1; - } - - /* read the version string */ - if (fgets(buffer, sizeof(buffer), file) == NULL) - { - fclose(file); - return -1; - } - - /* ensure it matches the palette file version string */ - if ( strncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 && - strncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0 ) - { - fclose(file); - return -1; - } - - /* read the number of colors */ - if (fgets(buffer, sizeof(buffer), file) == NULL) - { - fclose(file); - return -1; - } - - - /* extract the number of colors. + /*------------------------------------------------------------------------- + * compose the name of the file to open, using "srcdir", if appropriate + *------------------------------------------------------------------------- + */ + strcpy(data_file, ""); + if (srcdir) + { + strcpy(data_file, srcdir); + strcat(data_file, "/"); + } + strcat(data_file,fname); + + /* ensure the given palette is valid */ + if (!palette) + return -1; + + /* open the input file */ + if (!(file = fopen(data_file, "r"))) + { + printf( "Could not open file %s. Try set $srcdir \n", data_file ); + return -1; + } + + /* read the file ident string */ + if (fgets(buffer, sizeof(buffer), file) == NULL) + { + fclose(file); + return -1; + } + + /* ensure it matches the palette file ident string */ + if ( strncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 && + strncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0 ) + { + fclose(file); + return -1; + } + + /* read the version string */ + if (fgets(buffer, sizeof(buffer), file) == NULL) + { + fclose(file); + return -1; + } + + /* ensure it matches the palette file version string */ + if ( strncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 && + strncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0 ) + { + fclose(file); + return -1; + } + + /* read the number of colors */ + if (fgets(buffer, sizeof(buffer), file) == NULL) + { + fclose(file); + return -1; + } + + + /* extract the number of colors. check for missing version or number of colors in this case it reads the first entry */ - if ( strlen( buffer ) > 4 ) - { - fclose(file); - return -1; - } - - if (sscanf(buffer, "%u", &nentries) != 1) - { - fclose(file); - return -1; - } - - /* ensure there are a sensible number of colors in the palette */ - if ((nentries > 256) || (nentries > palette_size)) - { - fclose(file); - return(-1); - } - - /* read the palette entries */ - for (u = 0; u < nentries; u++) - { - /* extract the red, green and blue color components. */ - if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3) - { - fclose(file); - return -1; - } - /* store this palette entry */ - palette[u].r = (unsigned char)red; - palette[u].g = (unsigned char)green; - palette[u].b = (unsigned char)blue; - } - - /* close file */ - fclose(file); - - return nentries; + if ( strlen( buffer ) > 4 ) + { + fclose(file); + return -1; + } + + if (sscanf(buffer, "%u", &nentries) != 1) + { + fclose(file); + return -1; + } + + /* ensure there are a sensible number of colors in the palette */ + if ((nentries > 256) || (nentries > palette_size)) + { + fclose(file); + return(-1); + } + + /* read the palette entries */ + for (u = 0; u < nentries; u++) + { + /* extract the red, green and blue color components. */ + if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3) + { + fclose(file); + return -1; + } + /* store this palette entry */ + palette[u].r = (unsigned char)red; + palette[u].g = (unsigned char)green; + palette[u].b = (unsigned char)blue; + } + + /* close file */ + fclose(file); + + return nentries; } diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index 239ad60..8c9fb30 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -45,358 +45,355 @@ #define ATTR10_NAME "attr float" #define ATTR11_NAME "attr double" -/*Initial input buffer size for testing H5LTtext_to_dtype()*/ -#define BUF_SIZE 1024 - static herr_t make_attributes( hid_t loc_id, const char* obj_name ); /*------------------------------------------------------------------------- - * test dataset functions - *------------------------------------------------------------------------- - */ +* test dataset functions +*------------------------------------------------------------------------- +*/ static int test_dsets( void ) { - int rank = 2; - hsize_t dims[2] = {2,3}; - hid_t file_id; - hid_t dataset_id; - char data_char_in[DIM] = {1,2,3,4,5,6}; - char data_char_out[DIM]; - short data_short_in[DIM] = {1,2,3,4,5,6}; - short data_short_out[DIM]; - int data_int_in[DIM] = {1,2,3,4,5,6}; - int data_int_out[DIM]; - long data_long_in[DIM] = {1,2,3,4,5,6}; - long data_long_out[DIM]; - float data_float_in[DIM] = {1,2,3,4,5,6}; - float data_float_out[DIM]; - double data_double_in[DIM] = {1,2,3,4,5,6}; - double data_double_out[DIM]; - const char *data_string_in = "This is a string"; - char data_string_out[20]; - int i; - - - /* Create a new file using default properties. */ - file_id = H5Fcreate( FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); + int rank = 2; + hsize_t dims[2] = {2,3}; + hid_t file_id; + hid_t dataset_id; + char data_char_in[DIM] = {1,2,3,4,5,6}; + char data_char_out[DIM]; + short data_short_in[DIM] = {1,2,3,4,5,6}; + short data_short_out[DIM]; + int data_int_in[DIM] = {1,2,3,4,5,6}; + int data_int_out[DIM]; + long data_long_in[DIM] = {1,2,3,4,5,6}; + long data_long_out[DIM]; + float data_float_in[DIM] = {1,2,3,4,5,6}; + float data_float_out[DIM]; + double data_double_in[DIM] = {1,2,3,4,5,6}; + double data_double_out[DIM]; + const char *data_string_in = "This is a string"; + char data_string_out[20]; + int i; -/*------------------------------------------------------------------------- - * H5LTmake_dataset test - *------------------------------------------------------------------------- - */ - TESTING("H5LTmake_dataset"); + /* Create a new file using default properties. */ + file_id = H5Fcreate( FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - /* Make dataset */ - if ( H5LTmake_dataset( file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in ) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * H5LTmake_dataset test + *------------------------------------------------------------------------- + */ - /* Read dataset using the basic HDF5 API */ + TESTING("H5LTmake_dataset"); - if ( ( dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT) ) < 0 ) - goto out; + /* Make dataset */ + if ( H5LTmake_dataset( file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in ) < 0 ) + goto out; - if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 ) - goto out; + /* Read dataset using the basic HDF5 API */ - if ( H5Dclose( dataset_id ) < 0 ) - goto out; + if ( ( dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT) ) < 0 ) + goto out; - for (i = 0; i < DIM; i++) - { - if ( data_int_in[i] != data_int_out[i] ) { - goto out; - } - } + if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 ) + goto out; - PASSED(); + if ( H5Dclose( dataset_id ) < 0 ) + goto out; -/*------------------------------------------------------------------------- - * read using the LT function H5LTread_dataset - *------------------------------------------------------------------------- - */ + for (i = 0; i < DIM; i++) + { + if ( data_int_in[i] != data_int_out[i] ) { + goto out; + } + } - TESTING("H5LTread_dataset"); + PASSED(); - if ( H5LTread_dataset( file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out ) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * read using the LT function H5LTread_dataset + *------------------------------------------------------------------------- + */ - for (i = 0; i < DIM; i++) - { - if ( data_int_in[i] != data_int_out[i] ) { - goto out; - } - } + TESTING("H5LTread_dataset"); - PASSED(); + if ( H5LTread_dataset( file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out ) < 0 ) + goto out; -/*------------------------------------------------------------------------- - * test the H5LTmake_dataset_ functions - *------------------------------------------------------------------------- - */ + for (i = 0; i < DIM; i++) + { + if ( data_int_in[i] != data_int_out[i] ) { + goto out; + } + } + PASSED(); -/*------------------------------------------------------------------------- - * H5LTmake_dataset_char - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * test the H5LTmake_dataset_ functions + *------------------------------------------------------------------------- + */ - TESTING("H5LTmake_dataset_char"); - /* Make dataset char */ - if ( H5LTmake_dataset_char( file_id, DSET1_NAME, rank, dims, data_char_in ) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * H5LTmake_dataset_char + *------------------------------------------------------------------------- + */ - /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out ) < 0 ) - goto out; + TESTING("H5LTmake_dataset_char"); - for (i = 0; i < DIM; i++) - { - if ( data_char_in[i] != data_char_out[i] ) { - goto out; - } - } + /* Make dataset char */ + if ( H5LTmake_dataset_char( file_id, DSET1_NAME, rank, dims, data_char_in ) < 0 ) + goto out; - /* Read dataset */ - if ( H5LTread_dataset_char( file_id, DSET1_NAME, data_char_out ) < 0 ) - goto out; + /* Read dataset */ + if ( H5LTread_dataset( file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out ) < 0 ) + goto out; - for (i = 0; i < DIM; i++) - { - if ( data_char_in[i] != data_char_out[i] ) { - goto out; - } - } + for (i = 0; i < DIM; i++) + { + if ( data_char_in[i] != data_char_out[i] ) { + goto out; + } + } - PASSED(); + /* Read dataset */ + if ( H5LTread_dataset_char( file_id, DSET1_NAME, data_char_out ) < 0 ) + goto out; + for (i = 0; i < DIM; i++) + { + if ( data_char_in[i] != data_char_out[i] ) { + goto out; + } + } -/*------------------------------------------------------------------------- - * H5LTmake_dataset_short - *------------------------------------------------------------------------- - */ + PASSED(); - TESTING("H5LTmake_dataset_short"); - /* Make dataset short */ - if ( H5LTmake_dataset_short( file_id, DSET2_NAME, rank, dims, data_short_in ) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * H5LTmake_dataset_short + *------------------------------------------------------------------------- + */ - /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out ) < 0 ) - goto out; + TESTING("H5LTmake_dataset_short"); - for (i = 0; i < DIM; i++) - { - if ( data_short_in[i] != data_short_out[i] ) { - goto out; - } - } + /* Make dataset short */ + if ( H5LTmake_dataset_short( file_id, DSET2_NAME, rank, dims, data_short_in ) < 0 ) + goto out; - /* Read dataset */ - if ( H5LTread_dataset_short( file_id, DSET2_NAME, data_short_out ) < 0 ) - goto out; + /* Read dataset */ + if ( H5LTread_dataset( file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out ) < 0 ) + goto out; - for (i = 0; i < DIM; i++) - { - if ( data_short_in[i] != data_short_out[i] ) { - goto out; - } - } + for (i = 0; i < DIM; i++) + { + if ( data_short_in[i] != data_short_out[i] ) { + goto out; + } + } - PASSED(); + /* Read dataset */ + if ( H5LTread_dataset_short( file_id, DSET2_NAME, data_short_out ) < 0 ) + goto out; -/*------------------------------------------------------------------------- - * H5LTmake_dataset_int - *------------------------------------------------------------------------- - */ + for (i = 0; i < DIM; i++) + { + if ( data_short_in[i] != data_short_out[i] ) { + goto out; + } + } - TESTING("H5LTmake_dataset_int"); + PASSED(); - /* Make dataset int */ - if ( H5LTmake_dataset_int( file_id, DSET3_NAME, rank, dims, data_int_in ) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * H5LTmake_dataset_int + *------------------------------------------------------------------------- + */ - /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out ) < 0 ) - goto out; + TESTING("H5LTmake_dataset_int"); - for (i = 0; i < DIM; i++) - { - if ( data_int_in[i] != data_int_out[i] ) { - goto out; - } - } + /* Make dataset int */ + if ( H5LTmake_dataset_int( file_id, DSET3_NAME, rank, dims, data_int_in ) < 0 ) + goto out; - /* Read dataset */ - if ( H5LTread_dataset_int( file_id, DSET3_NAME, data_int_out ) < 0 ) - goto out; + /* Read dataset */ + if ( H5LTread_dataset( file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out ) < 0 ) + goto out; - for (i = 0; i < DIM; i++) - { - if ( data_int_in[i] != data_int_out[i] ) { - goto out; - } - } + for (i = 0; i < DIM; i++) + { + if ( data_int_in[i] != data_int_out[i] ) { + goto out; + } + } - PASSED(); + /* Read dataset */ + if ( H5LTread_dataset_int( file_id, DSET3_NAME, data_int_out ) < 0 ) + goto out; + for (i = 0; i < DIM; i++) + { + if ( data_int_in[i] != data_int_out[i] ) { + goto out; + } + } -/*------------------------------------------------------------------------- - * H5LTmake_dataset_long - *------------------------------------------------------------------------- - */ + PASSED(); - TESTING("H5LTmake_dataset_long"); - /* Make dataset long */ - if ( H5LTmake_dataset_long( file_id, DSET4_NAME, rank, dims, data_long_in ) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * H5LTmake_dataset_long + *------------------------------------------------------------------------- + */ - /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out ) < 0 ) - goto out; + TESTING("H5LTmake_dataset_long"); - for (i = 0; i < DIM; i++) - { - if ( data_long_in[i] != data_long_out[i] ) { - goto out; - } - } + /* Make dataset long */ + if ( H5LTmake_dataset_long( file_id, DSET4_NAME, rank, dims, data_long_in ) < 0 ) + goto out; - /* Read dataset */ - if ( H5LTread_dataset_long( file_id, DSET4_NAME, data_long_out ) < 0 ) - goto out; + /* Read dataset */ + if ( H5LTread_dataset( file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out ) < 0 ) + goto out; - for (i = 0; i < DIM; i++) - { - if ( data_long_in[i] != data_long_out[i] ) { - goto out; - } - } + for (i = 0; i < DIM; i++) + { + if ( data_long_in[i] != data_long_out[i] ) { + goto out; + } + } - PASSED(); + /* Read dataset */ + if ( H5LTread_dataset_long( file_id, DSET4_NAME, data_long_out ) < 0 ) + goto out; + for (i = 0; i < DIM; i++) + { + if ( data_long_in[i] != data_long_out[i] ) { + goto out; + } + } -/*------------------------------------------------------------------------- - * H5LTmake_dataset_float - *------------------------------------------------------------------------- - */ + PASSED(); - TESTING("H5LTmake_dataset_float"); - /* Make dataset float */ - if ( H5LTmake_dataset_float( file_id, DSET5_NAME, rank, dims, data_float_in ) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * H5LTmake_dataset_float + *------------------------------------------------------------------------- + */ - /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out ) < 0 ) - goto out; + TESTING("H5LTmake_dataset_float"); - for (i = 0; i < DIM; i++) - { - if ( data_float_in[i] != data_float_out[i] ) { - goto out; - } - } + /* Make dataset float */ + if ( H5LTmake_dataset_float( file_id, DSET5_NAME, rank, dims, data_float_in ) < 0 ) + goto out; - /* Read dataset */ - if ( H5LTread_dataset_float( file_id, DSET5_NAME, data_float_out ) < 0 ) - goto out; + /* Read dataset */ + if ( H5LTread_dataset( file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out ) < 0 ) + goto out; - for (i = 0; i < DIM; i++) - { - if ( data_float_in[i] != data_float_out[i] ) { - goto out; - } - } + for (i = 0; i < DIM; i++) + { + if ( data_float_in[i] != data_float_out[i] ) { + goto out; + } + } - PASSED(); + /* Read dataset */ + if ( H5LTread_dataset_float( file_id, DSET5_NAME, data_float_out ) < 0 ) + goto out; + for (i = 0; i < DIM; i++) + { + if ( data_float_in[i] != data_float_out[i] ) { + goto out; + } + } -/*------------------------------------------------------------------------- - * H5LTmake_dataset_double - *------------------------------------------------------------------------- - */ + PASSED(); - TESTING("H5LTmake_dataset_double"); - /* Make dataset double */ - if ( H5LTmake_dataset_double( file_id, DSET6_NAME, rank, dims, data_double_in ) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * H5LTmake_dataset_double + *------------------------------------------------------------------------- + */ - /* Read dataset */ - if ( H5LTread_dataset( file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out ) < 0 ) - goto out; + TESTING("H5LTmake_dataset_double"); - for (i = 0; i < DIM; i++) - { - if ( data_double_in[i] != data_double_out[i] ) { - goto out; - } - } + /* Make dataset double */ + if ( H5LTmake_dataset_double( file_id, DSET6_NAME, rank, dims, data_double_in ) < 0 ) + goto out; - /* Read dataset */ - if ( H5LTread_dataset_double( file_id, DSET6_NAME, data_double_out ) < 0 ) - goto out; + /* Read dataset */ + if ( H5LTread_dataset( file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out ) < 0 ) + goto out; - for (i = 0; i < DIM; i++) - { - if ( data_double_in[i] != data_double_out[i] ) { - goto out; - } - } + for (i = 0; i < DIM; i++) + { + if ( data_double_in[i] != data_double_out[i] ) { + goto out; + } + } - PASSED(); + /* Read dataset */ + if ( H5LTread_dataset_double( file_id, DSET6_NAME, data_double_out ) < 0 ) + goto out; + for (i = 0; i < DIM; i++) + { + if ( data_double_in[i] != data_double_out[i] ) { + goto out; + } + } -/*------------------------------------------------------------------------- - * H5LTmake_dataset_string - *------------------------------------------------------------------------- - */ + PASSED(); - TESTING("H5LTmake_dataset_string"); - /* Make dataset string */ - if ( H5LTmake_dataset_string(file_id,DSET7_NAME,data_string_in) < 0 ) - goto out; + /*------------------------------------------------------------------------- + * H5LTmake_dataset_string + *------------------------------------------------------------------------- + */ + + TESTING("H5LTmake_dataset_string"); + + /* Make dataset string */ + if ( H5LTmake_dataset_string(file_id,DSET7_NAME,data_string_in) < 0 ) + goto out; - /* Read dataset */ - if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 ) - goto out; + /* Read dataset */ + if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 ) + goto out; - if ( strcmp(data_string_in,data_string_out) != 0 ) - goto out; + if ( strcmp(data_string_in,data_string_out) != 0 ) + goto out; -/*------------------------------------------------------------------------- - * end tests - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * end tests + *------------------------------------------------------------------------- + */ - /* Close the file. */ - H5Fclose( file_id ); + /* Close the file. */ + H5Fclose( file_id ); - PASSED(); + PASSED(); - return 0; + return 0; out: - /* Close the file. */ - H5_FAILED(); - return -1; + /* Close the file. */ + H5_FAILED(); + return -1; } /*------------------------------------------------------------------------- - * test attribute functions - *------------------------------------------------------------------------- - */ +* test attribute functions +*------------------------------------------------------------------------- +*/ static int test_attr(void) { @@ -477,575 +474,575 @@ out: } /*------------------------------------------------------------------------- - * make_attributes - *------------------------------------------------------------------------- - */ +* make_attributes +*------------------------------------------------------------------------- +*/ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) { - int rank_out; - hsize_t *dims_out = 0; - H5T_class_t type_class; - size_t type_size; - int i; - - char attr_str_in[] = {"My attribute"}; - char attr_str_out[20]; - char attr_char_in[5] = {1,2,3,4,5}; - char attr_char_out[5]; - short attr_short_in[5] = {1,2,3,4,5}; - short attr_short_out[5]; - int attr_int_in[5] = {1,2,3,4,5}; - int attr_int_out[5]; - long attr_long_in[5] = {1,2,3,4,5}; - long attr_long_out[5]; - float attr_float_in[5] = {1,2,3,4,5}; - float attr_float_out[5]; - double attr_double_in[5] = {1,2,3,4,5}; - double attr_double_out[5]; - unsigned char attr_uchar_in[5] = {1,2,3,4,5}; - unsigned char attr_uchar_out[5]; - unsigned short attr_ushort_in[5] = {1,2,3,4,5}; - unsigned short attr_ushort_out[5]; - unsigned int attr_uint_in[5] = {1,2,3,4,5}; - unsigned int attr_uint_out[5]; - unsigned long attr_ulong_in[5] = {1,2,3,4,5}; - unsigned long attr_ulong_out[5]; + int rank_out; + hsize_t *dims_out = 0; + H5T_class_t type_class; + size_t type_size; + int i; + + char attr_str_in[] = {"My attribute"}; + char attr_str_out[20]; + char attr_char_in[5] = {1,2,3,4,5}; + char attr_char_out[5]; + short attr_short_in[5] = {1,2,3,4,5}; + short attr_short_out[5]; + int attr_int_in[5] = {1,2,3,4,5}; + int attr_int_out[5]; + long attr_long_in[5] = {1,2,3,4,5}; + long attr_long_out[5]; + float attr_float_in[5] = {1,2,3,4,5}; + float attr_float_out[5]; + double attr_double_in[5] = {1,2,3,4,5}; + double attr_double_out[5]; + unsigned char attr_uchar_in[5] = {1,2,3,4,5}; + unsigned char attr_uchar_out[5]; + unsigned short attr_ushort_in[5] = {1,2,3,4,5}; + unsigned short attr_ushort_out[5]; + unsigned int attr_uint_in[5] = {1,2,3,4,5}; + unsigned int attr_uint_out[5]; + unsigned long attr_ulong_in[5] = {1,2,3,4,5}; + unsigned long attr_ulong_out[5]; -/*------------------------------------------------------------------------- - * H5LTset_attribute_string test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_string test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_string"); + TESTING("H5LTset_attribute_string"); - /* Set the attribute */ - if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_string test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_string test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_string"); + TESTING("H5LTget_attribute_string"); - /* Get the attribute */ - if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 ) + return -1; - if ( strcmp( attr_str_in, attr_str_out ) != 0 ) - { - return -1; - } + if ( strcmp( attr_str_in, attr_str_out ) != 0 ) + { + return -1; + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_char test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_char test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_char"); + TESTING("H5LTset_attribute_char"); - /* Set the attribute */ - if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_char test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_char test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_char"); + TESTING("H5LTget_attribute_char"); - /* Get the attribute */ - if ( H5LTget_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_char_in[i] != attr_char_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_char_in[i] != attr_char_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_char_in[i] != attr_char_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_char_in[i] != attr_char_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_short test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_short test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_short"); + TESTING("H5LTset_attribute_short"); - /* Set the attribute */ - if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_short test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_short test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_short"); + TESTING("H5LTget_attribute_short"); - /* Get the attribute */ - if ( H5LTget_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_short_in[i] != attr_short_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_short_in[i] != attr_short_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_short_in[i] != attr_short_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_short_in[i] != attr_short_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_int test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_int test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_int"); + TESTING("H5LTset_attribute_int"); - /* Set the attribute */ - if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_int test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_int test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_int"); + TESTING("H5LTget_attribute_int"); - /* Get the attribute */ - if ( H5LTget_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_int_in[i] != attr_int_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_int_in[i] != attr_int_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_int_in[i] != attr_int_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_int_in[i] != attr_int_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_long test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_long test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_long"); + TESTING("H5LTset_attribute_long"); - /* Set the attribute */ - if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_long test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_long test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_long"); + TESTING("H5LTget_attribute_long"); - /* Get the attribute */ - if ( H5LTget_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_long_in[i] != attr_long_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_long_in[i] != attr_long_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_long_in[i] != attr_long_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_long_in[i] != attr_long_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_uchar test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_uchar test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_uchar"); + TESTING("H5LTset_attribute_uchar"); - /* Set the attribute */ - if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_uchar test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_uchar test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_uchar"); + TESTING("H5LTget_attribute_uchar"); - /* Get the attribute */ - if ( H5LTget_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_uchar_in[i] != attr_uchar_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_uchar_in[i] != attr_uchar_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_uchar_in[i] != attr_uchar_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_uchar_in[i] != attr_uchar_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_ushort test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_ushort test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_ushort"); + TESTING("H5LTset_attribute_ushort"); - /* Set the attribute */ - if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_ushort test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_ushort test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_ushort"); + TESTING("H5LTget_attribute_ushort"); - /* Get the attribute */ - if ( H5LTget_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_ushort_in[i] != attr_ushort_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_ushort_in[i] != attr_ushort_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_ushort_in[i] != attr_ushort_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_ushort_in[i] != attr_ushort_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_int test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_int test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_uint"); + TESTING("H5LTset_attribute_uint"); - /* Set the attribute */ - if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_int test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_int test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_uint"); + TESTING("H5LTget_attribute_uint"); - /* Get the attribute */ - if ( H5LTget_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_uint_in[i] != attr_uint_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_uint_in[i] != attr_uint_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_uint_in[i] != attr_uint_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_uint_in[i] != attr_uint_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_ulong test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_ulong test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_ulong"); + TESTING("H5LTset_attribute_ulong"); - /* Set the attribute */ - if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_long test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_long test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_ulong"); + TESTING("H5LTget_attribute_ulong"); - /* Get the attribute */ - if ( H5LTget_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_ulong_in[i] != attr_ulong_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_ulong_in[i] != attr_ulong_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_ulong_in[i] != attr_ulong_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_ulong_in[i] != attr_ulong_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_float test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_float test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_float"); + TESTING("H5LTset_attribute_float"); - /* Set the attribute */ - if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_float test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_float test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_float"); + TESTING("H5LTget_attribute_float"); - /* Get the attribute */ - if ( H5LTget_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_float_in[i] != attr_float_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_float_in[i] != attr_float_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_float_in[i] != attr_float_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_float_in[i] != attr_float_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTset_attribute_double test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTset_attribute_double test + *------------------------------------------------------------------------- + */ - TESTING("H5LTset_attribute_double"); + TESTING("H5LTset_attribute_double"); - /* Set the attribute */ - if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 ) - return -1; + /* Set the attribute */ + if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 ) + return -1; - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_double test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_double test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_double"); + TESTING("H5LTget_attribute_double"); - /* Get the attribute */ - if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_double_in[i] != attr_double_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_double_in[i] != attr_double_out[i] ) { + return -1; + } + } - /* Get the attribute */ - if ( H5LTget_attribute( loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out ) < 0 ) - return -1; + /* Get the attribute */ + if ( H5LTget_attribute( loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out ) < 0 ) + return -1; - for (i = 0; i < 5; i++) - { - if ( attr_double_in[i] != attr_double_out[i] ) { - return -1; - } - } + for (i = 0; i < 5; i++) + { + if ( attr_double_in[i] != attr_double_out[i] ) { + return -1; + } + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_ndims test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_ndims test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_ndims"); + TESTING("H5LTget_attribute_ndims"); - if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 ) - return -1; + if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 ) + return -1; - if ( rank_out != 1 ) { - return -1; - } + if ( rank_out != 1 ) { + return -1; + } - PASSED(); + PASSED(); -/*------------------------------------------------------------------------- - * H5LTget_attribute_info test - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5LTget_attribute_info test + *------------------------------------------------------------------------- + */ - TESTING("H5LTget_attribute_info"); + TESTING("H5LTget_attribute_info"); - dims_out = malloc( sizeof(hsize_t) * rank_out ); + dims_out = (hsize_t*) malloc( sizeof(hsize_t) * rank_out ); - if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, - &type_size) < 0 ) - return -1; + if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, + &type_size) < 0 ) + return -1; - for (i = 0; i < rank_out; i++) - { - if ( dims_out[i] != 5 ) { - return -1; - } - } + for (i = 0; i < rank_out; i++) + { + if ( dims_out[i] != 5 ) { + return -1; + } + } - if ( type_class != H5T_INTEGER ) { - return -1; - } + if ( type_class != H5T_INTEGER ) { + return -1; + } - if ( dims_out ) - free( dims_out ); + if ( dims_out ) + free( dims_out ); - PASSED(); + PASSED(); - return 0; + return 0; } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_integers(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_integers(). +*------------------------------------------------------------------------- +*/ static int test_integers(void) { hid_t dtype; @@ -1094,9 +1091,9 @@ out: } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_fps(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_fps(). +*------------------------------------------------------------------------- +*/ static int test_fps(void) { hid_t dtype; @@ -1145,9 +1142,9 @@ out: } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_strings(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_strings(). +*------------------------------------------------------------------------- +*/ static int test_strings(void) { hid_t dtype; @@ -1231,9 +1228,9 @@ out: } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_opaques(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_opaques(). +*------------------------------------------------------------------------- +*/ static int test_opaques(void) { hid_t dtype; @@ -1280,9 +1277,9 @@ out: } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_enums(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_enums(). +*------------------------------------------------------------------------- +*/ static int test_enums(void) { hid_t dtype; @@ -1320,10 +1317,12 @@ static int test_enums(void) dt_str = (char*)calloc(str_len, sizeof(char)); if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) goto out; - /*if(strcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) { + if(strcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) { + printf("dt=\n%s\n", dt_str); goto out; - }*/ + } + free(dt_str); if(H5Tclose(dtype)<0) @@ -1338,9 +1337,9 @@ out: } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_variables(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_variables(). +*------------------------------------------------------------------------- +*/ static int test_variables(void) { hid_t dtype; @@ -1393,9 +1392,9 @@ out: } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_arrays(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_arrays(). +*------------------------------------------------------------------------- +*/ static int test_arrays(void) { hid_t dtype; @@ -1430,10 +1429,11 @@ static int test_arrays(void) dt_str = (char*)calloc(str_len, sizeof(char)); if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) goto out; - /*if(strcmp(dt_str, "H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }")) { + if(strcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE \"arr_compound_2\" : 1;\n }\n }\n }")) { printf("dt=\n%s\n", dt_str); goto out; - }*/ + } + free(dt_str); if(H5Tclose(dtype)<0) @@ -1448,9 +1448,9 @@ out: } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_compounds(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_compounds(). +*------------------------------------------------------------------------- +*/ static int test_compounds(void) { hid_t dtype; @@ -1513,9 +1513,9 @@ out: } /*------------------------------------------------------------------------- - * subroutine for test_text_dtype(): test_complicated_compound(). - *------------------------------------------------------------------------- - */ +* subroutine for test_text_dtype(): test_complicated_compound(). +*------------------------------------------------------------------------- +*/ static int test_complicated_compound(void) { hid_t dtype; @@ -1532,8 +1532,8 @@ static int test_complicated_compound(void) /* compose the name of the file to open, using the srcdir, if appropriate */ if(srcdir) { - strcpy(filename, srcdir); - strcat(filename, "/"); + strcpy(filename, srcdir); + strcat(filename, "/"); } strcat(filename, INPUT_FILE); @@ -1541,14 +1541,14 @@ static int test_complicated_compound(void) fp = fopen(filename, "r"); if(fp == NULL) { - printf( "Could not find file %s. Try set $srcdir \n", filename); - goto out; + printf( "Could not find file %s. Try set $srcdir \n", filename); + goto out; } /* This part reads in the input as a string in a slow manner. GNU C - * Library has convenient function getline() but isn't available on - * all machines. - */ + * Library has convenient function getline() but isn't available on + * all machines. + */ if((line = (char*)calloc(size, sizeof(char)))==NULL) goto out; if(fgets(line, (int)size, fp)==NULL) @@ -1593,9 +1593,9 @@ out: } /*------------------------------------------------------------------------- - * test H5LTtext_to_dtype function - *------------------------------------------------------------------------- - */ +* test H5LTtext_to_dtype function +*------------------------------------------------------------------------- +*/ static int test_text_dtype(void) { TESTING("H5LTtext_to_dtype"); @@ -1634,30 +1634,30 @@ out: } /*------------------------------------------------------------------------- - * the main program - *------------------------------------------------------------------------- - */ +* the main program +*------------------------------------------------------------------------- +*/ int main( void ) { - int nerrors=0; + int nerrors=0; - /* test dataset functions */ - nerrors += test_dsets(); + /* test dataset functions */ + nerrors += test_dsets(); - /* test attribute functions */ - nerrors += test_attr(); + /* test attribute functions */ + nerrors += test_attr(); - /* test text-dtype functions */ - nerrors += test_text_dtype(); + /* test text-dtype functions */ + nerrors += test_text_dtype(); - /* check for errors */ - if (nerrors) - goto error; + /* check for errors */ + if (nerrors) + goto error; - return 0; + return 0; error: - return 1; + return 1; } diff --git a/hl/test/test_table.c b/hl/test/test_table.c index bd8dd79..433d49f 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -24,28 +24,28 @@ /*------------------------------------------------------------------------- - * Table API test - * - * Functions tested: - * - * H5TBmake_table - * H5TBread_table - * H5TBwrite_records - * H5TBread_records - * H5TBappend_records - * H5TBinsert_record - * H5TBdelete_record - * H5TBcombine_tables - * H5TBwrite_fields_name - * H5TBread_fields_name - * H5TBwrite_fields_index - * H5TBinsert_field - * H5TBdelete_field - * H5TBget_table_info - * H5TBget_field_info - * - *------------------------------------------------------------------------- - */ +* Table API test +* +* Functions tested: +* +* H5TBmake_table +* H5TBread_table +* H5TBwrite_records +* H5TBread_records +* H5TBappend_records +* H5TBinsert_record +* H5TBdelete_record +* H5TBcombine_tables +* H5TBwrite_fields_name +* H5TBread_fields_name +* H5TBwrite_fields_index +* H5TBinsert_field +* H5TBdelete_field +* H5TBget_table_info +* H5TBget_field_info +* +*------------------------------------------------------------------------- +*/ #define TITLE "Title" #define NFIELDS 5 @@ -55,9 +55,9 @@ #define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);} /*------------------------------------------------------------------------- - * structure used for all tests, a particle with properties - *------------------------------------------------------------------------- - */ +* structure used for all tests, a particle with properties +*------------------------------------------------------------------------- +*/ typedef struct particle_t { char name[16]; @@ -68,19 +68,9 @@ typedef struct particle_t } particle_t; /*------------------------------------------------------------------------- - * local auxiliary functions - *------------------------------------------------------------------------- - */ - -static hid_t h5file_open(const char *fname, unsigned flags); -static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ); -static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, - particle_t *rbuf, particle_t *wbuf); - -/*------------------------------------------------------------------------- - * a subset of particle_t, with latitude and longitude fields - *------------------------------------------------------------------------- - */ +* a subset of particle_t, with latitude and longitude fields +*------------------------------------------------------------------------- +*/ typedef struct position_t { long longi; @@ -88,9 +78,9 @@ typedef struct position_t } position_t; /*------------------------------------------------------------------------- - * a subset of particle_t, with name and pressure fields - *------------------------------------------------------------------------- - */ +* a subset of particle_t, with name and pressure fields +*------------------------------------------------------------------------- +*/ typedef struct namepressure_t { char name[16]; @@ -98,9 +88,9 @@ typedef struct namepressure_t } namepressure_t; /*------------------------------------------------------------------------- - * an extended particle, used in the insert field test - *------------------------------------------------------------------------- - */ +* an extended particle, used in the insert field test +*------------------------------------------------------------------------- +*/ typedef struct particle2_t { char name[16]; @@ -112,9 +102,9 @@ typedef struct particle2_t } particle2_t; /*------------------------------------------------------------------------- - * a particle with one field less, used in the delete field test - *------------------------------------------------------------------------- - */ +* a particle with one field less, used in the delete field test +*------------------------------------------------------------------------- +*/ typedef struct particle3_t { char name[16]; @@ -126,16 +116,16 @@ typedef struct particle3_t /*------------------------------------------------------------------------- - * function to open an HDF5 file and return its file identifier - *------------------------------------------------------------------------- - */ +* function to open an HDF5 file and return its file identifier +*------------------------------------------------------------------------- +*/ static hid_t h5file_open(const char *fname, unsigned flags) { - + hid_t fid; /* identifier for the file */ char *srcdir = getenv("srcdir"); /* the source directory */ char data_file[512]=""; /* buffer to hold name of existing file */ - + /* compose the name of the file to open, using the srcdir, if appropriate */ if (srcdir) { @@ -143,21 +133,21 @@ static hid_t h5file_open(const char *fname, unsigned flags) strcat(data_file,"/"); } strcat(data_file,fname); - + /* open */ if ((fid = H5Fopen(data_file,flags,H5P_DEFAULT))<0) { fprintf(stderr,"Error: Cannot open file <%s>\n",data_file ); exit(1); } - + return fid; } /*------------------------------------------------------------------------- - * function that compares one particle - *------------------------------------------------------------------------- - */ +* function that compares one particle +*------------------------------------------------------------------------- +*/ static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ) { if ( ( strcmp( rbuf[i].name, wbuf[j].name ) != 0 ) || @@ -177,9 +167,9 @@ static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ) } /*------------------------------------------------------------------------- - * function to compare deleted records - *------------------------------------------------------------------------- - */ +* function to compare deleted records +*------------------------------------------------------------------------- +*/ static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, particle_t *rbuf, particle_t *wbuf) { @@ -204,11 +194,11 @@ static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, /*------------------------------------------------------------------------- - * the test program - *------------------------------------------------------------------------- - */ +* the test program +*------------------------------------------------------------------------- +*/ -int test_table(hid_t fid, int write) +static int test_table(hid_t fid, int do_write) { hid_t fid1; hid_t fid2; @@ -219,7 +209,7 @@ int test_table(hid_t fid, int write) int fill1_new[1] = { -100 }; hsize_t position; char tname[20]; - int i, j; + hsize_t i, j; /* write, read, append, delete, insert some records and fields */ hsize_t FIELDS = NFIELDS; hsize_t RECORDS = NRECORDS; @@ -277,39 +267,39 @@ int test_table(hid_t fid, int write) {"six", 6.0f}, {"seven", 7.0f}, }; - - + + /*------------------------------------------------------------------------- * initialize table parameters * field offsets and sizes used in the fields functions *------------------------------------------------------------------------- */ - + size_t field_offset_pos[2]= { HOFFSET( position_t, longi ), - HOFFSET( position_t, lati ) + HOFFSET( position_t, lati ) }; size_t field_offset_namepre[2]= { HOFFSET( namepressure_t, name ), - HOFFSET( namepressure_t, pressure ) + HOFFSET( namepressure_t, pressure ) }; size_t field_sizes_pos[2]= { sizeof(position_in[0].longi), - sizeof(position_in[0].lati) + sizeof(position_in[0].lati) }; size_t field_sizes_namepre[2]= { sizeof(namepre_in[0].name), - sizeof(namepre_in[0].pressure) + sizeof(namepre_in[0].pressure) }; size_t field_sizes_pre[1]= { sizeof(namepre_in[0].pressure) }; - + /*------------------------------------------------------------------------- * query table test *------------------------------------------------------------------------- @@ -318,7 +308,7 @@ int test_table(hid_t fid, int write) size_t sizes_out[NFIELDS]; size_t offset_out[NFIELDS]; size_t size_out; - + /*------------------------------------------------------------------------- * initialize table parameters * field indexes (zero based) used in the fields functions @@ -329,7 +319,7 @@ int test_table(hid_t fid, int write) int field_index_pos[2] = { 1,4 }; int field_index_namepre[2] = { 0,2 }; int field_index[NFIELDS] = { 0,1,2,3,4 }; - + /*------------------------------------------------------------------------- * initialize table parameters * size and the offsets of struct members in memory @@ -351,48 +341,48 @@ int test_table(hid_t fid, int write) sizeof( rbuf2[0].temperature), sizeof( rbuf2[0].lati), sizeof( rbuf2[0].new_field)}; - /*------------------------------------------------------------------------- - * initialize table parameters - * size and the offsets of struct members in memory - * these are used for the delete field test - *------------------------------------------------------------------------- + /*------------------------------------------------------------------------- + * initialize table parameters + * size and the offsets of struct members in memory + * these are used for the delete field test + *------------------------------------------------------------------------- */ size_t dst_size3 = sizeof( particle3_t ); size_t dst_offset3[NFIELDS-1] = { HOFFSET( particle3_t, name ), HOFFSET( particle3_t, longi ), HOFFSET( particle3_t, temperature ), HOFFSET( particle3_t, lati )}; - + size_t dst_sizes3[NFIELDS-1] = { sizeof( rbuf3[0].name), sizeof( rbuf3[0].longi), sizeof( rbuf3[0].temperature), sizeof( rbuf3[0].lati)}; - - - /*------------------------------------------------------------------------- - * initialize table parameters - * 1) size and the offsets of struct members in memory - * 2) field names - * 3) define a HDF5 type for the fields - *------------------------------------------------------------------------- + + + /*------------------------------------------------------------------------- + * initialize table parameters + * 1) size and the offsets of struct members in memory + * 2) field names + * 3) define a HDF5 type for the fields + *------------------------------------------------------------------------- */ - + size_t type_size_mem = sizeof( particle_t ); size_t field_offset[NFIELDS]= { HOFFSET( particle_t, name ), - HOFFSET( particle_t, longi ), - HOFFSET( particle_t, pressure ), - HOFFSET( particle_t, temperature ), - HOFFSET( particle_t, lati ) + HOFFSET( particle_t, longi ), + HOFFSET( particle_t, pressure ), + HOFFSET( particle_t, temperature ), + HOFFSET( particle_t, lati ) }; size_t field_size[NFIELDS] = { sizeof( rbuf[0].name), - sizeof( rbuf[0].longi), - sizeof( rbuf[0].pressure), - sizeof( rbuf[0].temperature), - sizeof( rbuf[0].lati) + sizeof( rbuf[0].longi), + sizeof( rbuf[0].pressure), + sizeof( rbuf[0].temperature), + sizeof( rbuf[0].lati) }; const char *field_names[NFIELDS] = { "Name","Longitude","Pressure","Temperature","Latitude" }; @@ -404,7 +394,7 @@ int test_table(hid_t fid, int write) field_type[2] = H5T_NATIVE_FLOAT; field_type[3] = H5T_NATIVE_DOUBLE; field_type[4] = H5T_NATIVE_INT; - + /*------------------------------------------------------------------------- * * Functions tested: @@ -414,37 +404,37 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - if (write) + if (do_write) { TESTING2("making table"); - + if (H5TBmake_table(TITLE,fid,"table1",FIELDS,RECORDS,type_size_mem, field_names,field_offset,field_type, chunk_size,fill,compress,wbuf)<0) goto out; PASSED(); } - + TESTING2("reading table"); - + /*------------------------------------------------------------------------- * read the table *------------------------------------------------------------------------- */ - + if (H5TBread_table(fid,"table1",type_size_mem,field_offset,field_size,rbuf)<0) goto out; - + /* compare the extracted table with the original array */ for( i = 0; i < NRECORDS; i++ ) { if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } - + PASSED(); - - + + /*------------------------------------------------------------------------- * * Functions tested: @@ -453,16 +443,16 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - if (write) + if (do_write) { TESTING2("writing records"); - + /* create an empty table */ if (H5TBmake_table(TITLE,fid,"table2",FIELDS,RECORDS,type_size_mem, field_names,field_offset,field_type, chunk_size,fill,compress,0)<0) goto out; - + /*------------------------------------------------------------------------- * write records, start at 0, write 8 * pos = 0 1 2 3 4 5 6 7 @@ -474,21 +464,21 @@ int test_table(hid_t fid, int write) if (H5TBwrite_records(fid,"table2",wstart,wrecords,type_size_mem,field_offset, field_size,wbuf)<0) goto out; - + /* read it back */ if (H5TBread_table(fid,"table2",type_size_mem,field_offset,field_size,rbuf)<0) goto out; - + /* compare */ for( i = 0; i < NRECORDS; i++ ) { if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } - + PASSED(); } - + /*------------------------------------------------------------------------- * * Functions tested: @@ -497,40 +487,40 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - + TESTING2("reading records"); - + /*------------------------------------------------------------------------- * read records, start at 0, read 8 * pos = 0 1 2 3 4 5 6 7 * data= 0 1 2 3 4 5 6 7 *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * for the read test we cannot use "table2" because it has been appended * we use the original "table1" instead *------------------------------------------------------------------------- */ - if(write) + if(do_write) strcpy(tname,"table2"); else strcpy(tname,"table1"); - + rstart=0; rrecords=8; if (H5TBread_records(fid,tname,rstart,rrecords,type_size_mem,field_offset, field_size,rbuf)<0) goto out; - + /* compare */ - for( i=(int)rstart; i<(int)rrecords; i++) + for( i = rstart; i < rrecords; i++) { if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } PASSED(); - + /*------------------------------------------------------------------------- * * Functions tested: @@ -540,10 +530,10 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - if (write) + if (do_write) { TESTING2("appending records"); - + /*------------------------------------------------------------------------- * append 2 records * pos = 0 1 2 3 4 5 6 7 8 9 @@ -553,30 +543,30 @@ int test_table(hid_t fid, int write) arecords=2; if (H5TBappend_records(fid,"table2",arecords,type_size_mem,field_offset,field_size,abuf)<0) return 1; - + if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0) return 1; - + rstart=0; rrecords=NRECORDS+arecords; if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset, field_size,rbuf)<0) return 1; - + /* compare */ wrecords=8; - for( i=(int)rstart; i<(int)wrecords; i++) + for( i = rstart; i< wrecords; i++) { if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } - for( i=(int)wrecords, j=0; i<(int)rrecords; i++,j++) + for( i = wrecords, j = 0; i < rrecords; i++,j++) { if (cmp_par(i,j,rbuf,abuf)<0) goto out; } PASSED(); } - + /*------------------------------------------------------------------------- * * Functions tested: @@ -586,10 +576,10 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - if (write) + if (do_write) { TESTING2("inserting records"); - + /*------------------------------------------------------------------------- * insert 2 records * pos = 0 1 2 3 4 5 6 7 8 9 10 11 @@ -599,44 +589,44 @@ int test_table(hid_t fid, int write) istart=1; irecords=2; if (H5TBinsert_record(fid,"table2",istart,irecords,type_size_mem,field_offset,field_size,ibuf)<0) return 1; - + if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0) return 1; - + if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset, field_size,rbuf)<0) return 1; - + /* compare */ - for( i=0; i<12; i++) + for( i = 0; i < 12; i++) { - if (i=(int)istart && i<(int)istart+(int)irecords) + else if (i >= istart && i < istart + irecords) { - j=i-(int)istart; + j = i - istart; if (cmp_par(i,j,rbuf,ibuf)<0) goto out; } - else if (i>=(int)istart+(int)irecords && i<10) + else if ( i >= istart + irecords && i < 10 ) { - j=i-(int)irecords; + j = i - irecords; if (cmp_par(i,j,rbuf,wbuf)<0) goto out; } else { - j=i-10; + j = i - 10; if (cmp_par(i,j,rbuf,abuf)<0) goto out; } } PASSED(); } - + /*------------------------------------------------------------------------- * * Functions tested: @@ -646,17 +636,17 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - if (write) + if (do_write) { TESTING2("deleting records"); - + /*------------------------------------------------------------------------- * Create a table * pos = 0 1 2 3 4 5 6 7 * data= 0 1 2 3 4 5 6 7 *------------------------------------------------------------------------- */ - + for( i=0; id_slist_ptr = - H5SL_create(H5SL_TYPE_HADDR,0.5,(size_t)16); + H5SL_create(H5SL_TYPE_HADDR); if ( aux_ptr->d_slist_ptr == NULL ) { @@ -598,7 +598,7 @@ H5AC_create(const H5F_t *f, } aux_ptr->c_slist_ptr = - H5SL_create(H5SL_TYPE_HADDR,0.5,(size_t)16); + H5SL_create(H5SL_TYPE_HADDR); if ( aux_ptr->c_slist_ptr == NULL ) { @@ -1154,6 +1154,8 @@ H5AC_get_entry_status(H5F_t * f, hbool_t is_dirty; hbool_t is_protected; hbool_t is_pinned; + hbool_t is_flush_dep_child; + hbool_t is_flush_dep_parent; size_t entry_size; unsigned status = 0; @@ -1168,7 +1170,8 @@ H5AC_get_entry_status(H5F_t * f, } result = H5C_get_entry_status(cache_ptr, addr, &entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, &is_flush_dep_parent, + &is_flush_dep_child); if ( result < 0 ) { @@ -1188,6 +1191,12 @@ H5AC_get_entry_status(H5F_t * f, if ( is_pinned ) status |= H5AC_ES__IS_PINNED; + + if ( is_flush_dep_parent ) + status |= H5AC_ES__IS_FLUSH_DEP_PARENT; + + if ( is_flush_dep_child ) + status |= H5AC_ES__IS_FLUSH_DEP_CHILD; } *status_ptr = status; @@ -1264,12 +1273,12 @@ done: */ herr_t -H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned int flags) +H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, + void *thing, unsigned int flags) { herr_t result; H5AC_info_t *info; H5AC_t *cache; - herr_t ret_value=SUCCEED; /* Return value */ #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ @@ -1278,6 +1287,7 @@ H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void * size_t trace_entry_size = 0; FILE * trace_file_ptr = NULL; #endif /* H5AC__TRACE_FILE_ENABLED */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_set, FAIL) @@ -1826,6 +1836,59 @@ done: /*------------------------------------------------------------------------- + * Function: H5AC_create_flush_dependency() + * + * Purpose: Create a flush dependency between two entries in the metadata + * cache. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * 3/24/09 + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_create_flush_dependency(H5F_t * f, void * parent_thing, void * child_thing) +{ + H5C_t *cache_ptr = f->shared->cache; +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5AC_create_flush_dependency, FAIL) + + /* Sanity check */ + HDassert(cache_ptr); + HDassert(parent_thing); + HDassert(child_thing); + +#if H5AC__TRACE_FILE_ENABLED + if ( ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + sprintf(trace, "%s %lx %lx", + FUNC, + (unsigned long)(((H5C_cache_entry_t *)parent_thing)->addr), + (unsigned long)(((H5C_cache_entry_t *)child_thing)->addr)); + } /* end if */ +#endif /* H5AC__TRACE_FILE_ENABLED */ + + if(H5C_create_flush_dependency(cache_ptr, parent_thing, child_thing) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "H5C_create_flush_dependency() failed.") + +done: +#if H5AC__TRACE_FILE_ENABLED + if(trace_file_ptr != NULL) + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); +#endif /* H5AC__TRACE_FILE_ENABLED */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_create_flush_dependency() */ + + +/*------------------------------------------------------------------------- * Function: H5AC_protect * * Purpose: If the target entry is not in the cache, load it. If @@ -2190,6 +2253,58 @@ done: /*------------------------------------------------------------------------- + * Function: H5AC_destroy_flush_dependency() + * + * Purpose: Destroy a flush dependency between two entries. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * 3/24/09 + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_destroy_flush_dependency(H5F_t * f, void * parent_thing, void * child_thing) +{ + H5C_t *cache_ptr = f->shared->cache; +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5AC_destroy_flush_dependency, FAIL) + + /* Sanity check */ + HDassert(cache_ptr); + HDassert(parent_thing); + HDassert(child_thing); + +#if H5AC__TRACE_FILE_ENABLED + if ( ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + sprintf(trace, "%s %lx", + FUNC, + (unsigned long)(((H5C_cache_entry_t *)parent_thing)->addr), + (unsigned long)(((H5C_cache_entry_t *)child_thing)->addr)); + } /* end if */ +#endif /* H5AC__TRACE_FILE_ENABLED */ + + if(H5C_destroy_flush_dependency(cache_ptr, parent_thing, child_thing) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "H5C_destroy_flush_dependency() failed.") + +done: +#if H5AC__TRACE_FILE_ENABLED + if( trace_file_ptr != NULL ) + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); +#endif /* H5AC__TRACE_FILE_ENABLED */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_destroy_flush_dependency() */ + + +/*------------------------------------------------------------------------- * Function: H5AC_unprotect * * Purpose: Undo an H5AC_protect() call -- specifically, mark the @@ -4316,7 +4431,7 @@ H5AC_log_renamed_entry(H5AC_t * cache_ptr, /* get entry status, size, etc here */ if ( H5C_get_entry_status(cache_ptr, old_addr, &entry_size, &entry_in_cache, - &entry_dirty, NULL, NULL) < 0 ) { + &entry_dirty, NULL, NULL, NULL, NULL) < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get entry status.") diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 66bdf2d..b5e0bda 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -118,6 +118,9 @@ typedef enum { * * CLEAR: Just marks object as non-dirty. * + * NOTIFY: Notify client that an action on an entry has taken/will take + * place + * * SIZE: Report the size (on disk) of the specified cache object. * Note that the space allocated on disk may not be contiguous. */ @@ -126,10 +129,16 @@ typedef enum { #define H5AC_CALLBACK__SIZE_CHANGED_FLAG H5C_CALLBACK__SIZE_CHANGED_FLAG #define H5AC_CALLBACK__RENAMED_FLAG H5C_CALLBACK__RENAMED_FLAG +/* Aliases for 'notify action' type & values */ +typedef H5C_notify_action_t H5AC_notify_action_t; +#define H5AC_NOTIFY_ACTION_AFTER_INSERT H5C_NOTIFY_ACTION_AFTER_INSERT +#define H5AC_NOTIFY_ACTION_BEFORE_EVICT H5C_NOTIFY_ACTION_BEFORE_EVICT + typedef H5C_load_func_t H5AC_load_func_t; typedef H5C_flush_func_t H5AC_flush_func_t; typedef H5C_dest_func_t H5AC_dest_func_t; typedef H5C_clear_func_t H5AC_clear_func_t; +typedef H5C_notify_func_t H5AC_notify_func_t; typedef H5C_size_func_t H5AC_size_func_t; typedef H5C_class_t H5AC_class_t; @@ -266,6 +275,8 @@ extern hid_t H5AC_ind_dxpl_id; #define H5AC_ES__IS_DIRTY 0x0002 #define H5AC_ES__IS_PROTECTED 0x0004 #define H5AC_ES__IS_PINNED 0x0008 +#define H5AC_ES__IS_FLUSH_DEP_PARENT 0x0010 +#define H5AC_ES__IS_FLUSH_DEP_CHILD 0x0020 /* external function declarations: */ @@ -275,8 +286,10 @@ H5_DLL herr_t H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr); H5_DLL herr_t H5AC_get_entry_status(H5F_t * f, haddr_t addr, unsigned * status_ptr); H5_DLL herr_t H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, - haddr_t addr, void *thing, unsigned int flags); + haddr_t addr, void *thing, unsigned int flags); H5_DLL herr_t H5AC_pin_protected_entry(H5F_t * f, void * thing); +H5_DLL herr_t H5AC_create_flush_dependency(H5F_t *f, void *parent_thing, + void *child_thing); H5_DLL void * H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, const void *udata1, void *udata2, H5AC_protect_t rw); @@ -285,6 +298,8 @@ H5_DLL herr_t H5AC_resize_pinned_entry(H5F_t * f, size_t new_size); H5_DLL herr_t H5AC_unpin_entry(H5F_t * f, void * thing); +H5_DLL herr_t H5AC_destroy_flush_dependency(H5F_t *f, void *parent_thing, + void *child_thing); H5_DLL herr_t H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags); diff --git a/src/H5Apkg.h b/src/H5Apkg.h index b166b06..3c62635 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -163,14 +163,16 @@ typedef struct { typedef herr_t (*H5A_lib_iterate_t)(const H5A_t *attr, void *op_data); /* Describe kind of callback to make for each attribute */ -struct H5A_attr_iter_op_t { - enum { +typedef enum H5A_attr_iter_op_type_t { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5A_ATTR_OP_APP, /* Application callback */ + H5A_ATTR_OP_APP, /* Application callback */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5A_ATTR_OP_APP2, /* Revised application callback */ - H5A_ATTR_OP_LIB /* Library internal callback */ - } op_type; + H5A_ATTR_OP_APP2, /* Revised application callback */ + H5A_ATTR_OP_LIB /* Library internal callback */ +} H5A_attr_iter_op_type_t; + +typedef struct H5A_attr_iter_op_t { + H5A_attr_iter_op_type_t op_type; union { #ifndef H5_NO_DEPRECATED_SYMBOLS H5A_operator1_t app_op; /* Application callback for each attribute */ @@ -178,7 +180,7 @@ struct H5A_attr_iter_op_t { H5A_operator2_t app_op2; /* Revised application callback for each attribute */ H5A_lib_iterate_t lib_op; /* Library internal callback for each attribute */ } u; -}; +} H5A_attr_iter_op_t; /*****************************/ diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h index d46e46b..0c0e519 100644 --- a/src/H5Aprivate.h +++ b/src/H5Aprivate.h @@ -37,7 +37,6 @@ /* Forward references of package typedefs */ typedef struct H5A_t H5A_t; -typedef struct H5A_attr_iter_op_t H5A_attr_iter_op_t; /*****************************/ diff --git a/src/H5B.c b/src/H5B.c index 254183f..aba62b0 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -257,7 +257,7 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, /* * Cache the new B-tree node. */ - if (H5AC_set(f, dxpl_id, H5AC_BT, *addr_p, bt, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_set(f, dxpl_id, H5AC_BT, *addr_p, bt, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache") #ifdef H5B_DEBUG H5B_assert(f, dxpl_id, *addr_p, shared->type, udata); @@ -713,7 +713,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, HDmemcpy(H5B_NKEY(new_bt,shared,2), rt_key, shared->type->sizeof_nkey); /* Insert the modified copy of the old root into the file again */ - if (H5AC_set(f, dxpl_id, H5AC_BT, addr, new_bt, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_set(f, dxpl_id, H5AC_BT, addr, new_bt, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to flush old B-tree root node") #ifdef H5B_DEBUG @@ -2057,7 +2057,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_get_info() */ -#ifndef H5_STRICT_FORMAT_CHECKS /*------------------------------------------------------------------------- * Function: H5B_valid @@ -2099,5 +2098,4 @@ H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_valid() */ -#endif /* H5_STRICT_FORMAT_CHECKS */ diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 903b4f3..5ca7ed8 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -94,6 +94,7 @@ const H5AC_class_t H5AC_BT2_HDR[1] = {{ (H5AC_flush_func_t)H5B2_cache_hdr_flush, (H5AC_dest_func_t)H5B2_cache_hdr_dest, (H5AC_clear_func_t)H5B2_cache_hdr_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5B2_cache_hdr_size, }}; @@ -104,6 +105,7 @@ const H5AC_class_t H5AC_BT2_INT[1] = {{ (H5AC_flush_func_t)H5B2_cache_internal_flush, (H5AC_dest_func_t)H5B2_cache_internal_dest, (H5AC_clear_func_t)H5B2_cache_internal_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5B2_cache_internal_size, }}; @@ -114,6 +116,7 @@ const H5AC_class_t H5AC_BT2_LEAF[1] = {{ (H5AC_flush_func_t)H5B2_cache_leaf_flush, (H5AC_dest_func_t)H5B2_cache_leaf_dest, (H5AC_clear_func_t)H5B2_cache_leaf_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5B2_cache_leaf_size, }}; @@ -272,7 +275,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_t *bt2, unsigned UNUSED * flags_ptr) +H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, + H5B2_t *bt2, unsigned UNUSED * flags_ptr) { H5WB_t *wb = NULL; /* Wrapped buffer for header data */ uint8_t hdr_buf[H5B2_HDR_BUF_SIZE]; /* Buffer for header */ diff --git a/src/H5B2int.c b/src/H5B2int.c index b5d4048..f0213ce 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -207,7 +207,7 @@ HDmemset(shared->page, 0, shared->node_size); /* Compute size to store # of records in each node */ /* (uses leaf # of records because its the largest) */ u_max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[0].max_nrec); - H5_ASSIGN_OVERFLOW(/* To: */ shared->max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ unsigned char) + H5_ASSIGN_OVERFLOW(/* To: */ shared->max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t) HDassert(shared->max_nrec_size <= H5B2_SIZEOF_RECORDS_PER_NODE); /* Initialize internal node info */ @@ -223,7 +223,7 @@ HDmemset(shared->page, 0, shared->node_size); shared->node_info[u].cum_max_nrec = ((shared->node_info[u].max_nrec + 1) * shared->node_info[u - 1].cum_max_nrec) + shared->node_info[u].max_nrec; u_max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[u].cum_max_nrec); - H5_ASSIGN_OVERFLOW(/* To: */ shared->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ unsigned char) + H5_ASSIGN_OVERFLOW(/* To: */ shared->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t) if((shared->node_info[u].nat_rec_fac = H5FL_fac_init(shared->type->nrec_size * shared->node_info[u].max_nrec)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") @@ -586,7 +586,7 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2, unsigned *bt2_flags_ptr) shared->node_info[shared->depth].cum_max_nrec = ((shared->node_info[shared->depth].max_nrec + 1) * shared->node_info[shared->depth - 1].cum_max_nrec) + shared->node_info[shared->depth].max_nrec; u_max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[shared->depth].cum_max_nrec); - H5_ASSIGN_OVERFLOW(/* To: */ shared->node_info[shared->depth].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ unsigned char) + H5_ASSIGN_OVERFLOW(/* To: */ shared->node_info[shared->depth].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t) if((shared->node_info[shared->depth].nat_rec_fac = H5FL_fac_init(shared->type->nrec_size * shared->node_info[shared->depth].max_nrec)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") if((shared->node_info[shared->depth].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (shared->node_info[shared->depth].max_nrec + 1))) == NULL) diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index d05220b..c5af54f 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -124,7 +124,7 @@ typedef struct { unsigned split_nrec; /* Number of records to split node at */ unsigned merge_nrec; /* Number of records to merge node at */ hsize_t cum_max_nrec; /* Cumulative max. # of records below this node's depth */ - unsigned char cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */ + uint8_t cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */ H5FL_fac_head_t *nat_rec_fac; /* Factory for native record blocks */ H5FL_fac_head_t *node_ptr_fac; /* Factory for node pointer blocks */ } H5B2_node_info_t; @@ -149,7 +149,7 @@ typedef struct H5B2_shared_t { unsigned depth; /* B-tree's overall depth */ /* Derived information from user's information */ - unsigned char max_nrec_size; /* Size to store max. # of records in any node (in bytes) */ + uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */ } H5B2_shared_t; /* The B-tree information */ diff --git a/src/H5B2test.c b/src/H5B2test.c index f2cf79d..46cd510 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -456,7 +456,7 @@ H5B2_get_node_depth_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, hadd HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "error looking up node info") /* Set return value */ - ret_value = ninfo.depth; + ret_value = (int)ninfo.depth; done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 9765552..99930e6 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -71,6 +71,7 @@ const H5AC_class_t H5AC_BT[1] = {{ (H5AC_flush_func_t)H5B_flush, (H5AC_dest_func_t)H5B_dest, (H5AC_clear_func_t)H5B_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5B_compute_size, }}; diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 2ec2c22..716b608 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -168,9 +168,7 @@ H5_DLL H5B_shared_t *H5B_shared_new(const H5F_t *f, const H5B_class_t *type, H5_DLL herr_t H5B_shared_free(void *_shared); H5_DLL herr_t H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, const H5B_class_t *type, void *udata); -#ifndef H5_STRICT_FORMAT_CHECKS H5_DLL htri_t H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr); -#endif /* H5_STRICT_FORMAT_CHECKS */ #endif /* _H5Bprivate_H */ diff --git a/src/H5C.c b/src/H5C.c index 27b98d0..8c67f10 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -2798,6 +2798,7 @@ static herr_t H5C_epoch_marker_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, unsigned *flags_ptr); static herr_t H5C_epoch_marker_dest(H5F_t *f, void *thing); static herr_t H5C_epoch_marker_clear(H5F_t *f, void *thing, hbool_t dest); +static herr_t H5C_epoch_marker_notify(H5C_notify_action_t action, void *thing); static herr_t H5C_epoch_marker_size(const H5F_t *f, const void *thing, size_t *size_ptr); const H5C_class_t epoch_marker_class = @@ -2807,6 +2808,7 @@ const H5C_class_t epoch_marker_class = /* flush = */ &H5C_epoch_marker_flush, /* dest = */ &H5C_epoch_marker_dest, /* clear = */ &H5C_epoch_marker_clear, + /* notify = */&H5C_epoch_marker_notify, /* size = */ &H5C_epoch_marker_size }; @@ -2888,6 +2890,20 @@ done: } static herr_t +H5C_epoch_marker_notify(H5C_notify_action_t UNUSED action, + void UNUSED * thing) +{ + herr_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5C_epoch_marker_notify) + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "called unreachable fcn.") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + +static herr_t H5C_epoch_marker_size(const H5F_t UNUSED * f, const void UNUSED * thing, size_t UNUSED * size_ptr) @@ -3029,8 +3045,7 @@ H5C_create(size_t max_cache_size, "memory allocation failed") } - if ( (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR,0.5,(size_t)16)) - == NULL ) { + if ( (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR)) == NULL ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, NULL, "can't create skip list.") } @@ -4535,10 +4550,12 @@ H5C_get_entry_status(H5C_t * cache_ptr, hbool_t * in_cache_ptr, hbool_t * is_dirty_ptr, hbool_t * is_protected_ptr, - hbool_t * is_pinned_ptr) + hbool_t * is_pinned_ptr, + hbool_t * is_flush_dep_parent_ptr, + hbool_t * is_flush_dep_child_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ H5C_cache_entry_t * entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C_get_entry_status, FAIL) @@ -4587,6 +4604,16 @@ H5C_get_entry_status(H5C_t * cache_ptr, *is_pinned_ptr = entry_ptr->is_pinned; } + + if ( is_flush_dep_parent_ptr != NULL ) { + + *is_flush_dep_parent_ptr = (entry_ptr->flush_dep_height > 0); + } + + if ( is_flush_dep_child_ptr != NULL ) { + + *is_flush_dep_child_ptr = (entry_ptr->flush_dep_parent != NULL); + } } done: @@ -4881,6 +4908,7 @@ H5C_insert_entry(H5F_t * f, entry_ptr->ro_ref_count = 0; entry_ptr->is_pinned = insert_pinned; + entry_ptr->pinned_from_client = insert_pinned; /* newly inserted entries are assumed to be dirty */ entry_ptr->is_dirty = TRUE; @@ -5056,6 +5084,13 @@ H5C_insert_entry(H5F_t * f, } #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + /* If the entry's type has a 'notify' callback send a 'after insertion' + * notice now that the entry is fully integrated into the cache. + */ + if(entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_INSERT, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry inserted into cache") + H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) done: @@ -5973,6 +6008,56 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_pin_entry_from_client() + * + * Purpose: Internal routine to pin a cache entry from a client action. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * 3/26/09 + * + *------------------------------------------------------------------------- + */ +#ifndef NDEBUG +static herr_t +H5C_pin_entry_from_client(H5C_t * cache_ptr, + H5C_cache_entry_t * entry_ptr) +#else +static herr_t +H5C_pin_entry_from_client(H5C_t UNUSED * cache_ptr, + H5C_cache_entry_t * entry_ptr) +#endif +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5C_pin_entry_from_client) + + /* Sanity checks */ + HDassert( cache_ptr ); + HDassert( entry_ptr ); + + /* Check if the entry is already pinned */ + if(entry_ptr->is_pinned) { + /* Check if the entry was pinned through an explicit pin from a client */ + if(entry_ptr->pinned_from_client) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Entry is already pinned") + } /* end if */ + else { + entry_ptr->is_pinned = TRUE; + + H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) + } /* end else */ + + /* Mark that the entry was pinned through an explicit pin from a client */ + entry_ptr->pinned_from_client = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_pin_entry_from_client() */ + + +/*------------------------------------------------------------------------- * Function: H5C_pin_protected_entry() * * Purpose: Pin a protected cache entry. The entry must be protected @@ -6000,47 +6085,32 @@ done: * *------------------------------------------------------------------------- */ -#ifndef NDEBUG herr_t H5C_pin_protected_entry(H5C_t * cache_ptr, void * thing) -#else -herr_t -H5C_pin_protected_entry(H5C_t UNUSED * cache_ptr, - void * thing) -#endif { + H5C_cache_entry_t * entry_ptr; /* Pointer to entry to pin */ herr_t ret_value = SUCCEED; /* Return value */ - H5C_cache_entry_t * entry_ptr; FUNC_ENTER_NOAPI(H5C_pin_protected_entry, FAIL) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( thing ); - entry_ptr = (H5C_cache_entry_t *)thing; - + HDassert( entry_ptr ); HDassert( H5F_addr_defined(entry_ptr->addr) ); - if ( ! ( entry_ptr->is_protected ) ) { - + /* Only protected entries can be pinned */ + if(!entry_ptr->is_protected) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Entry isn't protected") - } - - if ( entry_ptr->is_pinned ) { - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Entry is already pinned") - } - - entry_ptr->is_pinned = TRUE; - - H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) + /* Pin the entry from a client */ + if(H5C_pin_entry_from_client(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_pin_protected_entry() */ @@ -6360,6 +6430,13 @@ H5C_protect(H5F_t * f, * code. If we do this often enough, we may want to optimize this. */ H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, NULL) + + /* If the entry's type has a 'notify' callback send a 'after insertion' + * notice now that the entry is fully integrated into the cache. + */ + if(entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_INSERT, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, NULL, "can't notify client about entry inserted into cache") } HDassert( entry_ptr->addr == addr ); @@ -7671,6 +7748,58 @@ H5C_stats__reset(H5C_t UNUSED * cache_ptr) /*------------------------------------------------------------------------- + * Function: H5C_unpin_entry_from_client() + * + * Purpose: Internal routine to unpin a cache entry from a client action. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * 3/24/09 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C_unpin_entry_from_client(H5C_t * cache_ptr, + H5C_cache_entry_t * entry_ptr, + hbool_t update_rp) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5C_unpin_entry_from_client) + + /* Sanity checking */ + HDassert( cache_ptr ); + HDassert( entry_ptr ); + + /* Error checking (should be sanity checks?) */ + if(!entry_ptr->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Entry isn't pinned") + if(!entry_ptr->pinned_from_client) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Entry wasn't pinned by cache client") + + /* If requested, update the replacement policy if the entry is not protected */ + if(update_rp && !entry_ptr->is_protected) + H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, FAIL) + + /* Check if the entry is not pinned from a flush dependency */ + if(!entry_ptr->pinned_from_cache) { + /* Unpin the entry now */ + entry_ptr->is_pinned = FALSE; + + /* Update the stats for an unpin operation */ + H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) + } /* end if */ + + /* Mark the entry as explicitly unpinned by the client */ + entry_ptr->pinned_from_client = FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_unpin_entry_from_client() */ + + +/*------------------------------------------------------------------------- * Function: H5C_unpin_entry() * * Purpose: Unpin a cache entry. The entry can be either protected or @@ -7687,35 +7816,24 @@ herr_t H5C_unpin_entry(H5C_t * cache_ptr, void * thing) { + H5C_cache_entry_t * entry_ptr; /* Pointer to entry to unpin */ herr_t ret_value = SUCCEED; /* Return value */ - H5C_cache_entry_t * entry_ptr; FUNC_ENTER_NOAPI(H5C_unpin_entry, FAIL) + /* Sanity checking */ HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( thing ); - entry_ptr = (H5C_cache_entry_t *)thing; + HDassert( entry_ptr ); - if ( ! ( entry_ptr->is_pinned ) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Entry isn't pinned") - } - - if ( ! ( entry_ptr->is_protected ) ) { - - H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, FAIL) - } - - entry_ptr->is_pinned = FALSE; - - H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) + /* Unpin the entry */ + if(H5C_unpin_entry_from_client(cache_ptr, entry_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry from client") done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_unpin_entry() */ @@ -7846,7 +7964,6 @@ H5C_unprotect(H5F_t * f, unsigned int flags, size_t new_size) { - /* const char * fcn_name = "H5C_unprotect()"; */ hbool_t deleted; hbool_t dirtied; hbool_t set_flush_marker; @@ -7938,23 +8055,15 @@ H5C_unprotect(H5F_t * f, /* Pin or unpin the entry as requested. */ if ( pin_entry ) { - if ( entry_ptr->is_pinned ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, \ - "Entry already pinned???") - } - entry_ptr->is_pinned = TRUE; - H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) + /* Pin the entry from a client */ + if(H5C_pin_entry_from_client(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") } else if ( unpin_entry ) { - if ( ! ( entry_ptr->is_pinned ) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, \ - "Entry already unpinned???") - } - entry_ptr->is_pinned = FALSE; - H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) + /* Unpin the entry from a client */ + if(H5C_unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") } @@ -8071,23 +8180,15 @@ H5C_unprotect(H5F_t * f, /* Pin or unpin the entry as requested. */ if ( pin_entry ) { - if ( entry_ptr->is_pinned ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, \ - "Entry already pinned???") - } - entry_ptr->is_pinned = TRUE; - H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) + /* Pin the entry from a client */ + if(H5C_pin_entry_from_client(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") } else if ( unpin_entry ) { - if ( ! ( entry_ptr->is_pinned ) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, \ - "Entry already unpinned???") - } - entry_ptr->is_pinned = FALSE; - H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) + /* Unpin the entry from a client */ + if(H5C_unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") } @@ -8655,8 +8756,8 @@ H5C_create_flush_dependency(H5C_t UNUSED * cache_ptr, void * parent_thing, /* More sanity checks */ if(child_entry == parent_entry) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Child entry flush dependency parent can't be itself") - if(!parent_entry->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Parent entry isn't protected") + if(!(parent_entry->is_protected || parent_entry->is_pinned)) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Parent entry isn't pinned or protected") if(NULL != child_entry->flush_dep_parent) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Child entry already has flush dependency parent") { @@ -8675,21 +8776,21 @@ H5C_create_flush_dependency(H5C_t UNUSED * cache_ptr, void * parent_thing, HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Combined flush dependency height too large") } - /* Check for parent already pinned */ - if(parent_entry->is_pinned) { - /* Verify that the parent entry was pinned through a flush dependency relationship */ - if(0 == parent_entry->flush_dep_height) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Parent entry wasn't pinned through flush dependency") - } /* end if */ - else { + /* Check for parent not pinned */ + if(!parent_entry->is_pinned) { /* Sanity check */ HDassert(parent_entry->flush_dep_height == 0); + HDassert(!parent_entry->pinned_from_client); + HDassert(!parent_entry->pinned_from_cache); /* Pin the parent entry */ parent_entry->is_pinned = TRUE; H5C__UPDATE_STATS_FOR_PIN(cache_ptr, parent_entry) } /* end else */ + /* Mark the entry as pinned from the cache's action (possibly redundantly) */ + parent_entry->pinned_from_cache = TRUE; + /* Increment ref. count for parent's flush dependency children heights */ parent_entry->child_flush_dep_height_rc[child_entry->flush_dep_height]++; @@ -8811,12 +8912,24 @@ H5C_destroy_flush_dependency(H5C_t * cache_ptr, void *parent_thing, * parent of _any_ child flush dependencies). */ if(0 == parent_entry->flush_dep_height) { - if(!parent_entry->is_protected) - H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, parent_entry, FAIL) + /* Sanity check */ + HDassert(parent_entry->pinned_from_cache); + + /* Check if we should unpin parent entry now */ + if(!parent_entry->pinned_from_client) { + /* Update the replacement policy if the entry is not protected */ + if(!parent_entry->is_protected) + H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, parent_entry, FAIL) + + /* Unpin the entry now */ + parent_entry->is_pinned = FALSE; + + /* Update the stats for an unpin operation */ + H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, parent_entry) + } /* end if */ - /* Unpin parent entry */ - parent_entry->is_pinned = FALSE; - H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, parent_entry) + /* Mark the entry as unpinned from the cache's action */ + parent_entry->pinned_from_cache = FALSE; } /* end if */ } /* end if */ @@ -10986,6 +11099,16 @@ H5C_flush_single_entry(H5F_t * f, H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr) } + /* If the entry's type has a 'notify' callback and the entry is about + * to be removed from the cache, send a 'before eviction' notice while + * the entry is still fully integrated in the cache. + */ + if(destroy) { + if(entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") + } /* end if */ + /* Always remove the entry from the hash table on a destroy. On a * flush with destroy, it is cheaper to discard the skip list all at * once rather than remove the entries one by one, so we only delete diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 855c861..e252134 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -113,6 +113,9 @@ typedef struct H5C_t H5C_t; * * CLEAR: Just marks object as non-dirty. * + * NOTIFY: Notify client that an action on an entry has taken/will take + * place + * * SIZE: Report the size (on disk) of the specified cache object. * Note that the space allocated on disk may not be contiguous. */ @@ -121,6 +124,16 @@ typedef struct H5C_t H5C_t; #define H5C_CALLBACK__SIZE_CHANGED_FLAG 0x1 #define H5C_CALLBACK__RENAMED_FLAG 0x2 +/* Actions that can be reported to 'notify' client callback */ +typedef enum H5C_notify_action_t { + H5C_NOTIFY_ACTION_AFTER_INSERT, /* Entry has been added to the cache */ + /* (could be loaded from file with + * 'protect' call, or inserted + * with 'set' call) + */ + H5C_NOTIFY_ACTION_BEFORE_EVICT /* Entry is about to be evicted from cache */ +} H5C_notify_action_t; + typedef void *(*H5C_load_func_t)(H5F_t *f, hid_t dxpl_id, haddr_t addr, @@ -137,6 +150,8 @@ typedef herr_t (*H5C_dest_func_t)(H5F_t *f, typedef herr_t (*H5C_clear_func_t)(H5F_t *f, void *thing, hbool_t dest); +typedef herr_t (*H5C_notify_func_t)(H5C_notify_action_t action, + void *thing); typedef herr_t (*H5C_size_func_t)(const H5F_t *f, const void *thing, size_t *size_ptr); @@ -147,6 +162,7 @@ typedef struct H5C_class_t { H5C_flush_func_t flush; H5C_dest_func_t dest; H5C_clear_func_t clear; + H5C_notify_func_t notify; H5C_size_func_t size; } H5C_class_t; @@ -378,6 +394,37 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t * cache_ptr, * 'dest' callback routine. * * + * Fields supporting the 'flush dependency' feature: + * + * Entries in the cache may have a 'flush dependency' on another entry in the + * cache. A flush dependency requires that all dirty child entries be flushed + * to the file before a dirty parent entry (of those child entries) can be + * flushed to the file. This can be used by cache clients to create data + * structures that allow Single-Writer/Multiple-Reader (SWMR) access for the + * data structure. + * + * The leaf child entry will have a "height" of 0, with any parent entries + * having a height of 1 greater than the maximum height of any of their child + * entries (flush dependencies are allowed to create asymmetric trees of + * relationships). + * + * flush_dep_parent: Pointer to the parent entry for an entry in a flush + * dependency relationship. + * + * child_flush_dep_height_rc: An array of reference counts for child entries, + * where the number of children of each height is tracked. + * + * flush_dep_height: The height of the entry, which is one greater than the + * maximum height of any of its child entries.. + * + * pinned_from_client: Whether the entry was pinned by an explicit pin request + * from a cache client. + * + * pinned_from_cache: Whether the entry was pinned implicitly as a + * request of being a parent entry in a flush dependency + * relationship. + * + * * Fields supporting the hash table: * * Fields in the cache are indexed by a more or less conventional hash table. @@ -504,11 +551,13 @@ typedef struct H5C_cache_entry_t hbool_t destroy_in_progress; hbool_t free_file_space_on_destroy; - /* fields supporting the 'flush dependency height': */ + /* fields supporting the 'flush dependency' feature: */ struct H5C_cache_entry_t * flush_dep_parent; uint64_t child_flush_dep_height_rc[H5C__NUM_FLUSH_DEP_HEIGHTS]; unsigned flush_dep_height; + hbool_t pinned_from_client; + hbool_t pinned_from_cache; /* fields supporting the hash table: */ @@ -1014,7 +1063,9 @@ H5_DLL herr_t H5C_get_entry_status(H5C_t * cache_ptr, hbool_t * in_cache_ptr, hbool_t * is_dirty_ptr, hbool_t * is_protected_ptr, - hbool_t * is_pinned_ptr); + hbool_t * is_pinned_ptr, + hbool_t * is_flush_dep_parent_ptr, + hbool_t * is_flush_dep_child_ptr); H5_DLL herr_t H5C_get_evictions_enabled(H5C_t * cache_ptr, hbool_t * evictions_enabled_ptr); diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 2f35609..d972043 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -36,9 +36,6 @@ /* Local Macros */ /****************/ -/* Default skip list height for storing list of chunks */ -#define H5D_CHUNK_DEFAULT_SKIPLIST_HEIGHT 8 - /* Macros for iterating over chunks to operate on */ #define H5D_CHUNK_GET_FIRST_NODE(map) (map->use_single ? (H5SL_node_t *)(1) : H5SL_first(map->sel_chunks)) #define H5D_CHUNK_GET_NODE_INFO(map, node) (map->use_single ? map->single_chunk_info : (H5D_chunk_info_t *)H5SL_item(node)) @@ -149,7 +146,7 @@ typedef struct H5D_chunk_it_ud4_t { /********************/ /* Chunked layout operation callbacks */ -static herr_t H5D_chunk_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, +static herr_t H5D_chunk_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); static herr_t H5D_chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, @@ -192,7 +189,7 @@ static herr_t H5D_chunk_mem_cb(void *elem, hid_t type_id, unsigned ndims, /* Chunked storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {{ - H5D_chunk_new, + H5D_chunk_construct, H5D_chunk_is_space_alloc, H5D_chunk_io_init, H5D_chunk_read, @@ -245,7 +242,7 @@ H5FL_DEFINE_STATIC(H5D_chunk_prune_stack_t); /*------------------------------------------------------------------------- - * Function: H5D_chunk_new + * Function: H5D_chunk_construct * * Purpose: Constructs new chunked layout information for dataset * @@ -257,7 +254,7 @@ H5FL_DEFINE_STATIC(H5D_chunk_prune_stack_t); *------------------------------------------------------------------------- */ static herr_t -H5D_chunk_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, +H5D_chunk_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist) { const H5T_t *type = dset->shared->type; /* Convenience pointer to dataset's datatype */ @@ -267,7 +264,7 @@ H5D_chunk_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_new) + FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_construct) /* Sanity checks */ HDassert(f); @@ -323,7 +320,7 @@ H5D_chunk_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D_chunk_new() */ +} /* end H5D_chunk_construct() */ /*------------------------------------------------------------------------- @@ -495,7 +492,7 @@ H5D_chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info else { /* Initialize skip list for chunk selections */ if(NULL == dataset->shared->cache.chunk.sel_chunks) { - if(NULL == (dataset->shared->cache.chunk.sel_chunks = H5SL_create(H5SL_TYPE_HSIZE, 0.5, (size_t)H5D_CHUNK_DEFAULT_SKIPLIST_HEIGHT))) + if(NULL == (dataset->shared->cache.chunk.sel_chunks = H5SL_create(H5SL_TYPE_HSIZE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for chunk selections") } /* end if */ fm->sel_chunks = dataset->shared->cache.chunk.sel_chunks; @@ -2196,6 +2193,11 @@ H5D_chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * if(H5Z_pipeline(&(dset->shared->dcpl_cache.pline), 0, &(udata.filter_mask), dxpl_cache->err_detect, dxpl_cache->filter_cb, &nbytes, &alloc, &buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "output pipeline failed") +#if H5_SIZEOF_SIZE_T > 4 + /* Check for the chunk expanding too much to encode in a 32-bit value */ + if(nbytes > ((size_t)0xffffffff)) + HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") +#endif /* H5_SIZEOF_SIZE_T > 4 */ H5_ASSIGN_OVERFLOW(udata.nbytes, nbytes, size_t, uint32_t); /* Indicate that the chunk must go through 'insert' method */ @@ -3058,6 +3060,11 @@ H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite) /* Push the chunk through the filters */ if(H5Z_pipeline(pline, 0, &filter_mask, dxpl_cache->err_detect, dxpl_cache->filter_cb, &orig_chunk_size, &buf_size, &fb_info.fill_buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") +#if H5_SIZEOF_SIZE_T > 4 + /* Check for the chunk expanding too much to encode in a 32-bit value */ + if(orig_chunk_size > ((size_t)0xffffffff)) + HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") +#endif /* H5_SIZEOF_SIZE_T > 4 */ } /* end if */ } /* end if */ @@ -3122,6 +3129,12 @@ H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite) if(H5Z_pipeline(pline, 0, &filter_mask, dxpl_cache->err_detect, dxpl_cache->filter_cb, &nbytes, &buf_size, &fb_info.fill_buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "output pipeline failed") +#if H5_SIZEOF_SIZE_T > 4 + /* Check for the chunk expanding too much to encode in a 32-bit value */ + if(nbytes > ((size_t)0xffffffff)) + HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") +#endif /* H5_SIZEOF_SIZE_T > 4 */ + /* Keep the number of bytes the chunk turned in to */ chunk_size = nbytes; } /* end if */ @@ -3829,7 +3842,7 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout) idx_info.layout = layout; /* Delete the chunked storage information in the file */ - if((layout->u.chunk.ops->delete)(&idx_info) < 0) + if((layout->u.chunk.ops->idx_delete)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk index") done: @@ -4088,6 +4101,11 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) if(has_filters && (is_vlen || fix_ref) ) { if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, cb_struct, &nbytes, &buf_size, &buf) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed") +#if H5_SIZEOF_SIZE_T > 4 + /* Check for the chunk expanding too much to encode in a 32-bit value */ + if(nbytes > ((size_t)0xffffffff)) + HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") +#endif /* H5_SIZEOF_SIZE_T > 4 */ H5_ASSIGN_OVERFLOW(udata_dst.nbytes, nbytes, size_t, uint32_t); udata->buf = buf; udata->buf_size = buf_size; diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index ad95e18..f773f5f 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -57,7 +57,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_compact_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, +static herr_t H5D_compact_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); static hbool_t H5D_compact_is_space_alloc(const H5O_layout_t *layout); static herr_t H5D_compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, @@ -77,7 +77,7 @@ static ssize_t H5D_compact_writevv(const H5D_io_info_t *io_info, /* Compact storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{ - H5D_compact_new, + H5D_compact_construct, H5D_compact_is_space_alloc, H5D_compact_io_init, H5D_contig_read, @@ -154,7 +154,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_compact_new + * Function: H5D_compact_construct * * Purpose: Constructs new compact layout information for dataset * @@ -167,14 +167,14 @@ done: */ /* ARGSUSED */ static herr_t -H5D_compact_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, +H5D_compact_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, const H5P_genplist_t UNUSED *dc_plist) { hssize_t tmp_size; /* Temporary holder for raw data size */ hsize_t comp_data_size; /* Size of compact data */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_compact_new) + FUNC_ENTER_NOAPI_NOINIT(H5D_compact_construct) /* Sanity checks */ HDassert(f); @@ -197,7 +197,7 @@ H5D_compact_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dse done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D_compact_new() */ +} /* end H5D_compact_construct() */ /*------------------------------------------------------------------------- diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 112eea5..1275ee1 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -61,7 +61,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_contig_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, +static herr_t H5D_contig_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); static hbool_t H5D_contig_is_space_alloc(const H5O_layout_t *layout); static herr_t H5D_contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, @@ -79,7 +79,7 @@ static herr_t H5D_contig_write_one(H5D_io_info_t *io_info, hsize_t offset, /* Contiguous storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {{ - H5D_contig_new, + H5D_contig_construct, H5D_contig_is_space_alloc, H5D_contig_io_init, H5D_contig_read, @@ -360,7 +360,7 @@ H5D_contig_get_addr(const H5D_t *dset) /*------------------------------------------------------------------------- - * Function: H5D_contig_new + * Function: H5D_contig_construct * * Purpose: Constructs new contiguous layout information for dataset * @@ -373,17 +373,20 @@ H5D_contig_get_addr(const H5D_t *dset) */ /* ARGSUSED */ static herr_t -H5D_contig_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, +H5D_contig_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, const H5P_genplist_t UNUSED *dc_plist) { - hssize_t tmp_size; /* Temporary holder for raw data size */ + hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ + hsize_t nelmts; /* Number of elements in dataspace */ + size_t dt_size; /* Size of datatype */ + hsize_t tmp_size; /* Temporary holder for raw data size */ hsize_t dim[H5O_LAYOUT_NDIMS]; /* Current size of data in elements */ hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */ int ndims; /* Rank of dataspace */ int i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_contig_new) + FUNC_ENTER_NOAPI_NOINIT(H5D_contig_construct) /* Sanity checks */ HDassert(f); @@ -402,16 +405,31 @@ H5D_contig_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset if(max_dim[i] > dim[i]) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible contiguous non-external dataset") - /* Compute the total size of dataset */ - tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * H5T_get_size(dset->shared->type); - H5_ASSIGN_OVERFLOW(dset->shared->layout.u.contig.size, tmp_size, hssize_t, hsize_t); + /* Retrieve the number of elements in the dataspace */ + if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") + nelmts = (hsize_t)snelmts; + + /* Get the datatype's size */ + if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") + + /* Compute the size of the dataset's contiguous storage */ + tmp_size = nelmts * dt_size; + + /* Check for overflow during multiplication */ + if(nelmts != (tmp_size / dt_size)) + HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") + + /* Assign the dataset's contiguous storage size */ + dset->shared->layout.u.contig.size = tmp_size; /* Get the sieve buffer size for this dataset */ dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(f); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D_contig_new() */ +} /* end H5D_contig_construct() */ /*------------------------------------------------------------------------- diff --git a/src/H5Defl.c b/src/H5Defl.c index f3b346e..a22ca2d 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -49,7 +49,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_efl_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, +static herr_t H5D_efl_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); static hbool_t H5D_efl_is_space_alloc(const H5O_layout_t *layout); static herr_t H5D_efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, @@ -75,7 +75,7 @@ static herr_t H5D_efl_write(const H5O_efl_t *efl, haddr_t addr, size_t size, /* External File List (EFL) storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ - H5D_efl_new, + H5D_efl_construct, H5D_efl_is_space_alloc, H5D_efl_io_init, H5D_contig_read, @@ -97,7 +97,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ /*------------------------------------------------------------------------- - * Function: H5D_efl_new + * Function: H5D_efl_construct * * Purpose: Constructs new EFL layout information for dataset * @@ -109,7 +109,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5D_efl_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, +H5D_efl_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist) { size_t dt_size; /* Size of datatype */ @@ -122,7 +122,7 @@ H5D_efl_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, int i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_efl_new) + FUNC_ENTER_NOAPI_NOINIT(H5D_efl_construct) /* Sanity checks */ HDassert(f); @@ -167,7 +167,7 @@ H5D_efl_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D_efl_new() */ +} /* end H5D_efl_construct() */ /*------------------------------------------------------------------------- diff --git a/src/H5Dint.c b/src/H5Dint.c index 0e71ef8..00bc347 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -457,8 +457,9 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) { H5S_t *space; /* Dataset's dataspace */ hsize_t space_allocated; /* The number of bytes allocated for chunks */ - hssize_t total_elem; /* The total number of elements in dataspace */ - size_t type_size; /* The size of the datatype for the dataset */ + hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ + hsize_t nelmts; /* Number of elements in dataspace */ + size_t dt_size; /* Size of datatype */ hsize_t full_size; /* The number of bytes in the dataset when fully populated */ herr_t ret_value = SUCCEED; @@ -471,16 +472,20 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) HDassert(space); /* Get the total number of elements in dataset's dataspace */ - if((total_elem=H5S_GET_EXTENT_NPOINTS(space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get # of dataspace elements") + if((snelmts = H5S_GET_EXTENT_NPOINTS(space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") + nelmts = (hsize_t)snelmts; /* Get the size of the dataset's datatype */ - if((type_size = H5T_get_size(dset->shared->type)) == 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get size of datatype") + if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") /* Compute the maximum size of the dataset in bytes */ - H5_CHECK_OVERFLOW(total_elem,hssize_t,hsize_t); - full_size=((hsize_t)total_elem)*type_size; + full_size = nelmts * dt_size; + + /* Check for overflow during multiplication */ + if(nelmts != (full_size / dt_size)) + HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") /* Difficult to error check, since the error value is 0 and 0 is a valid value... :-/ */ space_allocated = H5D_get_storage_size(dset, dxpl_id); @@ -1132,7 +1137,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize I/O operations") /* Create the layout information for the new dataset */ - if((new_dset->shared->layout.ops->new)(file, dapl_id, dxpl_id, new_dset, dc_plist) < 0) + if((new_dset->shared->layout.ops->construct)(file, dapl_id, dxpl_id, new_dset, dc_plist) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize layout information") /* Indicate that the layout information was initialized */ @@ -1392,10 +1397,29 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ if(dataset->shared->layout.version < 3) { - hssize_t tmp_size; /* Temporary holder for raw data size */ + hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ + hsize_t nelmts; /* Number of elements in dataspace */ + size_t dt_size; /* Size of datatype */ + hsize_t tmp_size; /* Temporary holder for raw data size */ + + /* Retrieve the number of elements in the dataspace */ + if((snelmts = H5S_GET_EXTENT_NPOINTS(dataset->shared->space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") + nelmts = (hsize_t)snelmts; + + /* Get the datatype's size */ + if(0 == (dt_size = H5T_GET_SIZE(dataset->shared->type))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") + + /* Compute the size of the dataset's contiguous storage */ + tmp_size = nelmts * dt_size; + + /* Check for overflow during multiplication */ + if(nelmts != (tmp_size / dt_size)) + HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") - tmp_size = H5S_GET_EXTENT_NPOINTS(dataset->shared->space) * H5T_get_size(dataset->shared->type); - H5_ASSIGN_OVERFLOW(dataset->shared->layout.u.contig.size, tmp_size, hssize_t, hsize_t); + /* Assign the dataset's contiguous storage size */ + dataset->shared->layout.u.contig.size = tmp_size; } /* end if */ /* Get the sieve buffer size for this dataset */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 6693348..afa9201 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -956,7 +956,10 @@ if(H5DEBUG(D)) /* Chunk address relative to the first chunk */ chunk_addr_info_array[u].chunk_addr -= ctg_store.contig.dset_addr; - H5_ASSIGN_OVERFLOW(chunk_disp_array[u], chunk_addr_info_array[u].chunk_addr, haddr_t, MPI_Aint); + + /* Assign chunk address to MPI displacement */ + /* (assume MPI_Aint big enough to hold it) */ + chunk_disp_array[u] = (MPI_Aint)chunk_addr_info_array[u].chunk_addr; } /* end for */ /* Initialize the buffer with the constant value 1 */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 791e223..69126ee 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -100,7 +100,7 @@ struct H5D_io_info_t; struct H5D_chunk_map_t; /* Function pointers for I/O on particular types of dataset layouts */ -typedef herr_t (*H5D_layout_new_func_t)(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, +typedef herr_t (*H5D_layout_construct_func_t)(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); typedef hbool_t (*H5D_layout_is_space_alloc_func_t)(const H5O_layout_t *layout); typedef herr_t (*H5D_layout_io_init_func_t)(const struct H5D_io_info_t *io_info, @@ -123,7 +123,7 @@ typedef herr_t (*H5D_layout_io_term_func_t)(const struct H5D_chunk_map_t *cm); /* Typedef for grouping layout I/O routines */ typedef struct H5D_layout_ops_t { - H5D_layout_new_func_t new; /* Layout constructor for new datasets */ + H5D_layout_construct_func_t construct; /* Layout constructor for new datasets */ H5D_layout_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage is allocated */ H5D_layout_io_init_func_t io_init; /* I/O initialization routine */ H5D_layout_read_func_t ser_read; /* High-level I/O routine for reading data in serial */ @@ -177,6 +177,11 @@ typedef union H5D_storage_t { } H5D_storage_t; /* Typedef for raw data I/O operation info */ +typedef enum H5D_io_op_type_t { + H5D_IO_OP_READ, /* Read operation */ + H5D_IO_OP_WRITE /* Write operation */ +} H5D_io_op_type_t; + typedef struct H5D_io_info_t { H5D_t *dset; /* Pointer to dataset being operated on */ #ifndef H5_HAVE_PARALLEL @@ -196,10 +201,7 @@ typedef struct H5D_io_info_t { H5D_storage_t *store; /* Dataset storage info */ H5D_layout_ops_t layout_ops; /* Dataset layout I/O operation function pointers */ H5D_io_ops_t io_ops; /* I/O operation function pointers */ - enum { - H5D_IO_OP_READ, /* Read operation */ - H5D_IO_OP_WRITE /* Write operation */ - } op_type; + H5D_io_op_type_t op_type; union { void *rbuf; /* Pointer to buffer for read */ const void *wbuf; /* Pointer to buffer to write */ @@ -294,7 +296,7 @@ typedef struct H5D_chunk_ops_t { H5D_chunk_get_addr_func_t get_addr; /* Routine to retrieve address of chunk in file */ H5D_chunk_iterate_func_t iterate; /* Routine to iterate over chunks */ H5D_chunk_remove_func_t remove; /* Routine to remove a chunk from an index */ - H5D_chunk_delete_func_t delete; /* Routine to delete index & all chunks from file*/ + H5D_chunk_delete_func_t idx_delete; /* Routine to delete index & all chunks from file*/ H5D_chunk_copy_setup_func_t copy_setup; /* Routine to perform any necessary setup for copying chunks */ H5D_chunk_copy_shutdown_func_t copy_shutdown; /* Routine to perform any necessary shutdown for copying chunks */ H5D_chunk_size_func_t size; /* Routine to get size of indexing information */ diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index bb9f46b..ed73f3c 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -662,6 +662,12 @@ H5D_scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") } /* end if */ + /* Do the data transform before the type conversion (since + * transforms must be done in the memory type). */ + if(!type_info->is_xform_noop) + if(H5Z_xform_eval(dxpl_cache->data_xform_prop, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform") + /* * Perform datatype conversion. */ @@ -669,11 +675,6 @@ H5D_scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf, type_info->bkg_buf, io_info->dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") - - /* Do the data transform after the type conversion (since we're using dataset->shared->type). */ - if(!type_info->is_xform_noop) - if(H5Z_xform_eval(dxpl_cache->data_xform_prop, type_info->tconv_buf, smine_nelmts, type_info->dset_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Error performing data transform") } /* end else */ /* diff --git a/src/H5EA.c b/src/H5EA.c index f1ed71b..e35738d 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -110,7 +110,7 @@ H5FL_DEFINE_STATIC(H5EA_t); */ BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, -H5EA_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam)) +H5EA_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam, void *ctx_udata)) /* Local variables */ H5EA_t *ea = NULL; /* Pointer to new extensible array */ @@ -128,7 +128,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(cparam); /* Create extensible array header */ - if(HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, dxpl_id, cparam))) + if(HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, dxpl_id, cparam, ctx_udata))) H5E_THROW(H5E_CANTINIT, "can't create extensible array header") /* Allocate extensible array wrapper */ @@ -181,7 +181,8 @@ END_FUNC(PRIV) /* end H5EA_create() */ */ BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, -H5EA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, const H5EA_class_t *cls)) +H5EA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, const H5EA_class_t *cls, + void *ctx_udata)) /* Local variables */ H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ @@ -198,7 +199,7 @@ H5EA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, const H5EA_class_t *cls)) #ifdef QAK HDfprintf(stderr, "%s: ea_addr = %a\n", FUNC, ea_addr); #endif /* QAK */ - if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, ea_addr, cls, NULL, H5AC_READ))) + if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, ea_addr, cls, ctx_udata, H5AC_READ))) H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header, address = %llu", (unsigned long long)ea_addr) /* Check for pending array deletion */ @@ -265,7 +266,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(nelmts); /* Retrieve the max. index set */ - *nelmts = ea->hdr->stats.max_idx_set; + *nelmts = ea->hdr->stats.stored.max_idx_set; END_FUNC(PRIV) /* end H5EA_get_nelmts() */ @@ -333,7 +334,8 @@ H5EA_set(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, const void *elmt)) unsigned sblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting super block */ unsigned dblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting data block */ unsigned dblk_page_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting data block page */ - hbool_t hdr_dirty = FALSE; /* Whether header information changed */ + hbool_t stats_changed = FALSE; /* Whether array statistics changed */ + hbool_t hdr_dirty = FALSE; /* Whether the array header changed */ #ifdef QAK HDfprintf(stderr, "%s: Called\n", FUNC); @@ -355,9 +357,10 @@ HDfprintf(stderr, "%s: Index %Hu\n", FUNC, idx); HDfprintf(stderr, "%s: Index block address not defined!\n", FUNC, idx); #endif /* QAK */ /* Create the index block */ - hdr->idx_blk_addr = H5EA__iblock_create(hdr, dxpl_id, &hdr_dirty); + hdr->idx_blk_addr = H5EA__iblock_create(hdr, dxpl_id, &stats_changed); if(!H5F_addr_defined(hdr->idx_blk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create index block") + hdr_dirty = TRUE; } /* end if */ #ifdef QAK HDfprintf(stderr, "%s: Index block address is: %a\n", FUNC, hdr->idx_blk_addr); @@ -371,7 +374,7 @@ HDfprintf(stderr, "%s: Index block address is: %a\n", FUNC, hdr->idx_blk_addr); if(idx < hdr->cparam.idx_blk_elmts) { /* Set element in index block */ HDmemcpy(((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * idx), elmt, hdr->cparam.cls->nat_elmt_size); - iblock_cache_flags |= H5AC__DIRTIED_FLAG; + dblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else { unsigned sblk_idx; /* Which superblock does this index fall in? */ @@ -409,17 +412,17 @@ HDfprintf(stderr, "%s: dblk_idx = %u, iblock->ndblk_addrs = %Zu\n", FUNC, dblk_i /* Create data block */ dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); - dblk_addr = H5EA__dblock_create(hdr, dxpl_id, &hdr_dirty, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts); + dblk_addr = H5EA__dblock_create(hdr, dxpl_id, iblock, &stats_changed, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts); if(!H5F_addr_defined(dblk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") /* Set data block address in index block */ iblock->dblk_addrs[dblk_idx] = dblk_addr; - iblock_cache_flags |= H5AC__DIRTIED_FLAG; + dblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, iblock->dblk_addrs[dblk_idx], hdr->sblk_info[sblk_idx].dblk_nelmts, H5AC_WRITE))) + if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, iblock, iblock->dblk_addrs[dblk_idx], hdr->sblk_info[sblk_idx].dblk_nelmts, H5AC_WRITE))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)iblock->dblk_addrs[dblk_idx]) /* Adjust index to offset in data block */ @@ -441,7 +444,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u, iblock->ndblk_addrs = %Zu\n", FUNC, dblk_i haddr_t sblk_addr; /* Address of data block created */ /* Create super block */ - sblk_addr = H5EA__sblock_create(hdr, dxpl_id, &hdr_dirty, sblk_idx); + sblk_addr = H5EA__sblock_create(hdr, dxpl_id, iblock, &stats_changed, sblk_idx); #ifdef QAK HDfprintf(stderr, "%s: New super block address is: %a\n", FUNC, sblk_addr); #endif /* QAK */ @@ -450,11 +453,11 @@ HDfprintf(stderr, "%s: New super block address is: %a\n", FUNC, sblk_addr); /* Set super block address in index block */ iblock->sblk_addrs[sblk_off] = sblk_addr; - iblock_cache_flags |= H5AC__DIRTIED_FLAG; + dblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ /* Protect super block */ - if(NULL == (sblock = H5EA__sblock_protect(hdr, dxpl_id, iblock->sblk_addrs[sblk_off], sblk_idx, H5AC_WRITE))) + if(NULL == (sblock = H5EA__sblock_protect(hdr, dxpl_id, iblock, iblock->sblk_addrs[sblk_off], sblk_idx, H5AC_WRITE))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)iblock->sblk_addrs[sblk_off]) /* Compute the data block index in super block */ @@ -471,7 +474,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u, sblock->ndblks = %Zu\n", FUNC, dblk_idx, s /* Create data block */ dblk_off = hdr->sblk_info[sblk_idx].start_idx + (dblk_idx * hdr->sblk_info[sblk_idx].dblk_nelmts); - dblk_addr = H5EA__dblock_create(hdr, dxpl_id, &hdr_dirty, dblk_off, sblock->dblk_nelmts); + dblk_addr = H5EA__dblock_create(hdr, dxpl_id, sblock, &stats_changed, dblk_off, sblock->dblk_nelmts); if(!H5F_addr_defined(dblk_addr)) H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") @@ -522,7 +525,7 @@ HDfprintf(stderr, "%s: sblock->dblk_page_size = %Zu\n", FUNC, sblock->dblk_page_ /* Check if page has been initialized yet */ if(!H5V_bit_get(sblock->page_init, page_init_idx)) { /* Create the data block page */ - if(H5EA__dblk_page_create(hdr, dxpl_id, dblk_page_addr) < 0) + if(H5EA__dblk_page_create(hdr, dxpl_id, sblock, dblk_page_addr) < 0) H5E_THROW(H5E_CANTCREATE, "unable to create data block page") /* Mark data block page as initialized in super block */ @@ -531,7 +534,7 @@ HDfprintf(stderr, "%s: sblock->dblk_page_size = %Zu\n", FUNC, sblock->dblk_page_ } /* end if */ /* Protect data block page */ - if(NULL == (dblk_page = H5EA__dblk_page_protect(hdr, dxpl_id, dblk_page_addr, H5AC_WRITE))) + if(NULL == (dblk_page = H5EA__dblk_page_protect(hdr, dxpl_id, sblock, dblk_page_addr, H5AC_WRITE))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", (unsigned long long)dblk_page_addr) /* Set pointer to elements */ @@ -539,7 +542,7 @@ HDfprintf(stderr, "%s: sblock->dblk_page_size = %Zu\n", FUNC, sblock->dblk_page_ } /* end if */ else { /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, sblock->dblk_addrs[dblk_idx], sblock->dblk_nelmts, H5AC_WRITE))) + if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, sblock, sblock->dblk_addrs[dblk_idx], sblock->dblk_nelmts, H5AC_WRITE))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)sblock->dblk_addrs[dblk_idx]) /* Set pointer to elements */ @@ -561,12 +564,17 @@ HDfprintf(stderr, "%s: sblock->dblk_page_size = %Zu\n", FUNC, sblock->dblk_page_ #ifdef QAK HDfprintf(stderr, "%s: idx = %Hu, hdr->stats.max_idx_set = %Hu\n", FUNC, idx, hdr->stats.max_idx_set); #endif /* QAK */ - if(idx >= hdr->stats.max_idx_set) { - hdr->stats.max_idx_set = idx + 1; - hdr_dirty = TRUE; + if(idx >= hdr->stats.stored.max_idx_set) { + HDassert(iblock); + hdr->stats.stored.max_idx_set = idx + 1; + stats_changed = TRUE; } /* end if */ CATCH + /* Check for updating array statistics */ + if(stats_changed) + hdr_dirty = TRUE; + /* Check for header modified */ if(hdr_dirty) if(H5EA__hdr_modified(hdr) < 0) @@ -624,7 +632,7 @@ HDfprintf(stderr, "%s: Index %Hu\n", FUNC, idx); hdr->f = ea->f; /* Check for element beyond max. element in array */ - if(idx >= hdr->stats.max_idx_set) { + if(idx >= hdr->stats.stored.max_idx_set) { #ifdef QAK HDfprintf(stderr, "%s: Element beyond max. index set, hdr->stats.max_idx_set = %Hu, idx = %Hu\n", FUNC, hdr->stats.max_idx_set, idx); #endif /* QAK */ @@ -680,7 +688,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u\n", FUNC, dblk_idx); } /* end if */ else { /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, iblock->dblk_addrs[dblk_idx], hdr->sblk_info[sblk_idx].dblk_nelmts, H5AC_READ))) + if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, iblock, iblock->dblk_addrs[dblk_idx], hdr->sblk_info[sblk_idx].dblk_nelmts, H5AC_READ))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)iblock->dblk_addrs[dblk_idx]) /* Adjust index to offset in data block */ @@ -704,7 +712,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u\n", FUNC, dblk_idx); } /* end if */ else { /* Protect super block */ - if(NULL == (sblock = H5EA__sblock_protect(hdr, dxpl_id, iblock->sblk_addrs[sblk_off], sblk_idx, H5AC_READ))) + if(NULL == (sblock = H5EA__sblock_protect(hdr, dxpl_id, iblock, iblock->sblk_addrs[sblk_off], sblk_idx, H5AC_READ))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)iblock->sblk_addrs[sblk_off]) /* Compute the data block index in super block */ @@ -778,7 +786,7 @@ HDfprintf(stderr, "%s: elmt_idx = %Hu, dblk_page_addr = %a\n", FUNC, elmt_idx, d #endif /* QAK */ /* Protect data block page */ - if(NULL == (dblk_page = H5EA__dblk_page_protect(hdr, dxpl_id, dblk_page_addr, H5AC_READ))) + if(NULL == (dblk_page = H5EA__dblk_page_protect(hdr, dxpl_id, sblock, dblk_page_addr, H5AC_READ))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", (unsigned long long)dblk_page_addr) /* Set pointer to elements */ @@ -787,7 +795,7 @@ HDfprintf(stderr, "%s: elmt_idx = %Hu, dblk_page_addr = %a\n", FUNC, elmt_idx, d } /* end if */ else { /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, sblock->dblk_addrs[dblk_idx], sblock->dblk_nelmts, H5AC_READ))) + if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, sblock, sblock->dblk_addrs[dblk_idx], sblock->dblk_nelmts, H5AC_READ))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)sblock->dblk_addrs[dblk_idx]) /* Set pointer to elements */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 286c6a5..00d3089 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -88,22 +88,26 @@ static herr_t H5EA__cache_hdr_dest(H5F_t *f, H5EA_hdr_t *hdr); static H5EA_iblock_t *H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5EA__cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5EA_iblock_t *iblock, unsigned * flags_ptr); static herr_t H5EA__cache_iblock_clear(H5F_t *f, H5EA_iblock_t *iblock, hbool_t destroy); +static herr_t H5EA__cache_iblock_notify(H5AC_notify_action_t action, H5EA_iblock_t *iblock); static herr_t H5EA__cache_iblock_size(const H5F_t *f, const H5EA_iblock_t *iblock, size_t *size_ptr); static herr_t H5EA__cache_iblock_dest(H5F_t *f, H5EA_iblock_t *iblock); static H5EA_sblock_t *H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5EA__cache_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5EA_sblock_t *sblock, unsigned * flags_ptr); static herr_t H5EA__cache_sblock_clear(H5F_t *f, H5EA_sblock_t *sblock, hbool_t destroy); static herr_t H5EA__cache_sblock_size(const H5F_t *f, const H5EA_sblock_t *sblock, size_t *size_ptr); +static herr_t H5EA__cache_sblock_notify(H5AC_notify_action_t action, H5EA_sblock_t *sblock); static herr_t H5EA__cache_sblock_dest(H5F_t *f, H5EA_sblock_t *sblock); static H5EA_dblock_t *H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5EA__cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5EA_dblock_t *dblock, unsigned * flags_ptr); static herr_t H5EA__cache_dblock_clear(H5F_t *f, H5EA_dblock_t *dblock, hbool_t destroy); static herr_t H5EA__cache_dblock_size(const H5F_t *f, const H5EA_dblock_t *dblock, size_t *size_ptr); +static herr_t H5EA__cache_dblock_notify(H5AC_notify_action_t action, H5EA_dblock_t *dblock); static herr_t H5EA__cache_dblock_dest(H5F_t *f, H5EA_dblock_t *dblock); static H5EA_dblk_page_t *H5EA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5EA__cache_dblk_page_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5EA_dblk_page_t *dblk_page, unsigned * flags_ptr); static herr_t H5EA__cache_dblk_page_clear(H5F_t *f, H5EA_dblk_page_t *dblk_page, hbool_t destroy); static herr_t H5EA__cache_dblk_page_size(const H5F_t *f, const H5EA_dblk_page_t *dblk_page, size_t *size_ptr); +static herr_t H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, H5EA_dblk_page_t *dblk_page); static herr_t H5EA__cache_dblk_page_dest(H5F_t *f, H5EA_dblk_page_t *dblk_page); @@ -118,6 +122,7 @@ const H5AC_class_t H5AC_EARRAY_HDR[1] = {{ (H5AC_flush_func_t)H5EA__cache_hdr_flush, (H5AC_dest_func_t)H5EA__cache_hdr_dest, (H5AC_clear_func_t)H5EA__cache_hdr_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5EA__cache_hdr_size, }}; @@ -128,6 +133,7 @@ const H5AC_class_t H5AC_EARRAY_IBLOCK[1] = {{ (H5AC_flush_func_t)H5EA__cache_iblock_flush, (H5AC_dest_func_t)H5EA__cache_iblock_dest, (H5AC_clear_func_t)H5EA__cache_iblock_clear, + (H5AC_notify_func_t)H5EA__cache_iblock_notify, (H5AC_size_func_t)H5EA__cache_iblock_size, }}; @@ -138,6 +144,7 @@ const H5AC_class_t H5AC_EARRAY_SBLOCK[1] = {{ (H5AC_flush_func_t)H5EA__cache_sblock_flush, (H5AC_dest_func_t)H5EA__cache_sblock_dest, (H5AC_clear_func_t)H5EA__cache_sblock_clear, + (H5AC_notify_func_t)H5EA__cache_sblock_notify, (H5AC_size_func_t)H5EA__cache_sblock_size, }}; @@ -148,6 +155,7 @@ const H5AC_class_t H5AC_EARRAY_DBLOCK[1] = {{ (H5AC_flush_func_t)H5EA__cache_dblock_flush, (H5AC_dest_func_t)H5EA__cache_dblock_dest, (H5AC_clear_func_t)H5EA__cache_dblock_clear, + (H5AC_notify_func_t)H5EA__cache_dblock_notify, (H5AC_size_func_t)H5EA__cache_dblock_size, }}; @@ -158,6 +166,7 @@ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ (H5AC_flush_func_t)H5EA__cache_dblk_page_flush, (H5AC_dest_func_t)H5EA__cache_dblk_page_dest, (H5AC_clear_func_t)H5EA__cache_dblk_page_clear, + (H5AC_notify_func_t)H5EA__cache_dblk_page_notify, (H5AC_size_func_t)H5EA__cache_dblk_page_size, }}; @@ -190,7 +199,7 @@ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ BEGIN_FUNC(STATIC, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls, - void UNUSED *udata2)) + void *ctx_udata)) /* Local variables */ const H5EA_class_t *cls = (const H5EA_class_t *)_cls; /* Extensible array class */ @@ -208,7 +217,7 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls, HDassert(H5F_addr_defined(addr)); /* Allocate space for the extensible array data structure */ - if(NULL == (hdr = H5EA__hdr_alloc(f, cls))) + if(NULL == (hdr = H5EA__hdr_alloc(f, cls, ctx_udata))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set the extensible array header's address */ @@ -254,13 +263,13 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls, hdr->cparam.max_dblk_page_nelmts_bits = *p++; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ /* Array statistics */ - hdr->stats.hdr_size = size; /* Size of header in file */ - H5F_DECODE_LENGTH(f, p, hdr->stats.nsuper_blks); /* Number of super blocks created */ - H5F_DECODE_LENGTH(f, p, hdr->stats.super_blk_size); /* Size of super blocks created */ - H5F_DECODE_LENGTH(f, p, hdr->stats.ndata_blks); /* Number of data blocks created */ - H5F_DECODE_LENGTH(f, p, hdr->stats.data_blk_size); /* Size of data blocks created */ - H5F_DECODE_LENGTH(f, p, hdr->stats.max_idx_set); /* Max. index set (+1) */ - H5F_DECODE_LENGTH(f, p, hdr->stats.nelmts); /* Number of elements 'realized' */ + hdr->stats.computed.hdr_size = size; /* Size of header in file */ + H5F_DECODE_LENGTH(f, p, hdr->stats.stored.nsuper_blks); /* Number of super blocks created */ + H5F_DECODE_LENGTH(f, p, hdr->stats.stored.super_blk_size); /* Size of super blocks created */ + H5F_DECODE_LENGTH(f, p, hdr->stats.stored.ndata_blks); /* Number of data blocks created */ + H5F_DECODE_LENGTH(f, p, hdr->stats.stored.data_blk_size); /* Size of data blocks created */ + H5F_DECODE_LENGTH(f, p, hdr->stats.stored.max_idx_set); /* Max. index set (+1) */ + H5F_DECODE_LENGTH(f, p, hdr->stats.stored.nelmts); /* Number of elements 'realized' */ /* Internal information */ H5F_addr_decode(f, &p, &hdr->idx_blk_addr); /* Address of index block */ @@ -270,7 +279,7 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls, H5EA_iblock_t iblock; /* Fake index block for computing size */ /* Set index block count for file */ - hdr->stats.nindex_blks = 1; + hdr->stats.computed.nindex_blks = 1; /* Set up fake index block for computing size on disk */ iblock.hdr = hdr; @@ -279,11 +288,11 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls, iblock.nsblk_addrs = hdr->nsblks - iblock.nsblks; /* Compute size of index block in file */ - hdr->stats.index_blk_size = H5EA_IBLOCK_SIZE(&iblock); + hdr->stats.computed.index_blk_size = H5EA_IBLOCK_SIZE(&iblock); } /* end if */ else { - hdr->stats.nindex_blks = 0; /* Number of index blocks in file */ - hdr->stats.index_blk_size = 0; /* Size of index blocks in file */ + hdr->stats.computed.nindex_blks = 0; /* Number of index blocks in file */ + hdr->stats.computed.index_blk_size = 0; /* Size of index blocks in file */ } /* end else */ /* Sanity check */ @@ -389,12 +398,12 @@ H5EA__cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, *p++ = hdr->cparam.max_dblk_page_nelmts_bits; /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ /* Array statistics */ - H5F_ENCODE_LENGTH(f, p, hdr->stats.nsuper_blks); /* Number of super blocks created */ - H5F_ENCODE_LENGTH(f, p, hdr->stats.super_blk_size); /* Size of super blocks created */ - H5F_ENCODE_LENGTH(f, p, hdr->stats.ndata_blks); /* Number of data blocks created */ - H5F_ENCODE_LENGTH(f, p, hdr->stats.data_blk_size); /* Size of data blocks created */ - H5F_ENCODE_LENGTH(f, p, hdr->stats.max_idx_set); /* Max. index set (+1) */ - H5F_ENCODE_LENGTH(f, p, hdr->stats.nelmts); /* Number of elements 'realized' */ + H5F_ENCODE_LENGTH(f, p, hdr->stats.stored.nsuper_blks); /* Number of super blocks created */ + H5F_ENCODE_LENGTH(f, p, hdr->stats.stored.super_blk_size); /* Size of super blocks created */ + H5F_ENCODE_LENGTH(f, p, hdr->stats.stored.ndata_blks); /* Number of data blocks created */ + H5F_ENCODE_LENGTH(f, p, hdr->stats.stored.data_blk_size); /* Size of data blocks created */ + H5F_ENCODE_LENGTH(f, p, hdr->stats.stored.max_idx_set); /* Max. index set (+1) */ + H5F_ENCODE_LENGTH(f, p, hdr->stats.stored.nelmts); /* Number of elements 'realized' */ /* Internal information */ H5F_addr_encode(f, &p, hdr->idx_blk_addr); /* Address of index block */ @@ -829,6 +838,53 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_clear() */ /*------------------------------------------------------------------------- + * Function: H5EA__cache_iblock_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, +H5EA__cache_iblock_notify(H5AC_notify_action_t action, H5EA_iblock_t *iblock)) + + /* Sanity check */ + HDassert(iblock); + + /* Determine which action to take */ + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on extensible array header */ + if(H5EA__create_flush_depend(iblock->hdr, (H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between index block and header, address = %llu", (unsigned long long)iblock->addr) + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Destroy flush dependency on extensible array header */ + if(H5EA__destroy_flush_depend(iblock->hdr, (H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between index block and header, address = %llu", (unsigned long long)iblock->addr) + break; + + default: +#ifdef NDEBUG + H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +CATCH + +END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_size * * Purpose: Compute the size in bytes of a extensible array index block @@ -924,11 +980,11 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_dest() */ BEGIN_FUNC(STATIC, ERR, H5EA_sblock_t *, NULL, NULL, H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, - const void *_sblk_idx, void *_hdr)) + const void *_udata1, void *_hdr)) /* Local variables */ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_hdr; /* Shared extensible array information */ - const unsigned *sblk_idx = (const unsigned *)_sblk_idx; /* Index of this super block */ + const H5EA_sblock_load_ud_t *ud_load = (const H5EA_sblock_load_ud_t *)_udata1; /* User data for loading super block */ H5EA_sblock_t *sblock = NULL; /* Super block info */ size_t size; /* Super block size */ H5WB_t *wb = NULL; /* Wrapped buffer for super block data */ @@ -943,11 +999,11 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, /* Sanity check */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(sblk_idx && *sblk_idx > 0); + HDassert(ud_load && ud_load->parent && ud_load->sblk_idx > 0); HDassert(hdr); /* Allocate the extensible array super block */ - if(NULL == (sblock = H5EA__sblock_alloc(hdr, *sblk_idx))) + if(NULL == (sblock = H5EA__sblock_alloc(hdr, ud_load->parent, ud_load->sblk_idx))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") /* Set the extensible array super block's address */ @@ -1213,6 +1269,53 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_size() */ /*------------------------------------------------------------------------- + * Function: H5EA__cache_sblock_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, +H5EA__cache_sblock_notify(H5AC_notify_action_t action, H5EA_sblock_t *sblock)) + + /* Sanity check */ + HDassert(sblock); + + /* Determine which action to take */ + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on index block */ + if(H5EA__create_flush_depend(sblock->hdr, (H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Destroy flush dependency on index block */ + if(H5EA__destroy_flush_depend(sblock->hdr, (H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) + break; + + default: +#ifdef NDEBUG + H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +CATCH + +END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_dest * * Purpose: Destroys an extensible array super block in memory. @@ -1276,11 +1379,11 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_dest() */ BEGIN_FUNC(STATIC, ERR, H5EA_dblock_t *, NULL, NULL, H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, - const void *_nelmts, void *_hdr)) + const void *_udata1, void *_hdr)) /* Local variables */ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_hdr; /* Shared extensible array information */ - const size_t *nelmts = (const size_t *)_nelmts; /* Number of elements in data block */ + const H5EA_dblock_load_ud_t *ud_load = (const H5EA_dblock_load_ud_t *)_udata1; /* User data for loading data block */ H5EA_dblock_t *dblock = NULL; /* Data block info */ size_t size; /* Data block size */ H5WB_t *wb = NULL; /* Wrapped buffer for data block data */ @@ -1294,11 +1397,11 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, /* Sanity check */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(nelmts && *nelmts > 0); + HDassert(ud_load && ud_load->parent && ud_load->nelmts > 0); HDassert(hdr); /* Allocate the extensible array data block */ - if(NULL == (dblock = H5EA__dblock_alloc(hdr, *nelmts))) + if(NULL == (dblock = H5EA__dblock_alloc(hdr, ud_load->parent, ud_load->nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") /* Set the extensible array data block's information */ @@ -1352,9 +1455,9 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, if(!dblock->npages) { /* Decode elements in data block */ /* Convert from raw elements on disk into native elements in memory */ - if((hdr->cparam.cls->decode)(p, dblock->elmts, *nelmts, hdr->cb_ctx) < 0) + if((hdr->cparam.cls->decode)(p, dblock->elmts, ud_load->nelmts, hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") - p += (*nelmts * hdr->cparam.raw_elmt_size); + p += (ud_load->nelmts * hdr->cparam.raw_elmt_size); } /* end if */ /* Sanity check */ @@ -1531,6 +1634,53 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_clear() */ /*------------------------------------------------------------------------- + * Function: H5EA__cache_dblock_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, +H5EA__cache_dblock_notify(H5AC_notify_action_t action, H5EA_dblock_t *dblock)) + + /* Sanity check */ + HDassert(dblock); + + /* Determine which action to take */ + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on parent */ + if(H5EA__create_flush_depend(dblock->hdr, (H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block and parent, address = %llu", (unsigned long long)dblock->addr) + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Destroy flush dependency on parent */ + if(H5EA__destroy_flush_depend(dblock->hdr, (H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and parent, address = %llu", (unsigned long long)dblock->addr) + break; + + default: +#ifdef NDEBUG + H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +CATCH + +END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_size * * Purpose: Compute the size in bytes of a extensible array data block @@ -1631,10 +1781,11 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_dest() */ BEGIN_FUNC(STATIC, ERR, H5EA_dblk_page_t *, NULL, NULL, H5EA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, - const void UNUSED *udata1, void *_hdr)) + const void *_ud_load, void *_hdr)) /* Local variables */ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_hdr; /* Shared extensible array information */ + const H5EA_dblk_page_load_ud_t *ud_load = (const H5EA_dblk_page_load_ud_t *)_ud_load; /* User data for loading data block page */ H5EA_dblk_page_t *dblk_page = NULL; /* Data block page info */ size_t size; /* Data block page size */ H5WB_t *wb = NULL; /* Wrapped buffer for data block page data */ @@ -1653,7 +1804,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ /* Allocate the extensible array data block page */ - if(NULL == (dblk_page = H5EA__dblk_page_alloc(hdr))) + if(NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, ud_load->parent))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") /* Set the extensible array data block's information */ @@ -1703,10 +1854,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); /* Verify checksum */ if(stored_chksum != computed_chksum) -{ -HDfprintf(stderr, "%s: stored_chksum = %8x, computed_chksum = %8x\n", FUNC, stored_chksum, computed_chksum); H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array data block page") -} /* Set return value */ ret_value = dblk_page; @@ -1840,6 +1988,53 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_clear() */ /*------------------------------------------------------------------------- + * Function: H5EA__cache_dblk_page_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, +H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, H5EA_dblk_page_t *dblk_page)) + + /* Sanity check */ + HDassert(dblk_page); + + /* Determine which action to take */ + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on parent */ + if(H5EA__create_flush_depend(dblk_page->hdr, (H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Destroy flush dependency on parent */ + if(H5EA__destroy_flush_depend(dblk_page->hdr, (H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) + break; + + default: +#ifdef NDEBUG + H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +CATCH + +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_size * * Purpose: Compute the size in bytes of a extensible array data block page diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index 2c903b2..d9d0a4c 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -147,16 +147,16 @@ H5EA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, (unsigned)hdr->cparam.max_dblk_page_nelmts_bits); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Highest element index stored (+1):", - hdr->stats.max_idx_set); + hdr->stats.stored.max_idx_set); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Number of super blocks created:", - hdr->stats.nsuper_blks); + hdr->stats.stored.nsuper_blks); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Number of data blocks created:", - hdr->stats.ndata_blks); + hdr->stats.stored.ndata_blks); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Number of elements 'realized':", - hdr->stats.nelmts); + hdr->stats.stored.nelmts); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Index Block Address:", hdr->idx_blk_addr); @@ -320,7 +320,8 @@ H5EA__sblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Protect super block */ - if(NULL == (sblock = H5EA__sblock_protect(hdr, dxpl_id, addr, sblk_idx, H5AC_READ))) + /* (Note: setting parent of super block to 'hdr' for this operation should be OK -QAK) */ + if(NULL == (sblock = H5EA__sblock_protect(hdr, dxpl_id, (H5EA_iblock_t *)hdr, addr, sblk_idx, H5AC_READ))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)addr) /* Print opening message */ @@ -404,7 +405,8 @@ H5EA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, addr, dblk_nelmts, H5AC_READ))) + /* (Note: setting parent of data block to 'hdr' for this operation should be OK -QAK) */ + if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, hdr, addr, dblk_nelmts, H5AC_READ))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)addr) /* Print opening message */ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index a8edae1..429e9f8 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -100,7 +100,7 @@ H5FL_DEFINE_STATIC(H5EA_dblk_page_t); */ BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, -H5EA__dblk_page_alloc(H5EA_hdr_t *hdr)) +H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent)) /* Local variables */ H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ @@ -118,7 +118,7 @@ H5EA__dblk_page_alloc(H5EA_hdr_t *hdr)) dblk_page->hdr = hdr; /* Set non-zero internal fields */ - /* */ + dblk_page->parent = parent; /* Allocate buffer for elements in data block page */ if(NULL == (dblk_page->elmts = H5EA__hdr_alloc_elmts(hdr, hdr->dblk_page_nelmts))) @@ -150,7 +150,8 @@ END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, -H5EA__dblk_page_create(H5EA_hdr_t *hdr, hid_t dxpl_id, haddr_t addr)) +H5EA__dblk_page_create(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_sblock_t *parent, + haddr_t addr)) /* Local variables */ H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ @@ -163,7 +164,7 @@ HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr); HDassert(hdr); /* Allocate the data block page */ - if(NULL == (dblk_page = H5EA__dblk_page_alloc(hdr))) + if(NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, parent))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") /* Set info about data block page on disk */ @@ -208,10 +209,11 @@ END_FUNC(PKG) /* end H5EA__dblk_page_create() */ */ BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, -H5EA__dblk_page_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, haddr_t dblk_page_addr, - H5AC_protect_t rw)) +H5EA__dblk_page_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_sblock_t *parent, + haddr_t dblk_page_addr, H5AC_protect_t rw)) /* Local variables */ + H5EA_dblk_page_load_ud_t load_ud; /* Information needed for loading data block page */ #ifdef QAK HDfprintf(stderr, "%s: Called\n", FUNC); @@ -221,8 +223,11 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(hdr); HDassert(H5F_addr_defined(dblk_page_addr)); + /* Set up user data */ + load_ud.parent = parent; + /* Protect the data block page */ - if(NULL == (ret_value = (H5EA_dblk_page_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, NULL, hdr, rw))) + if(NULL == (ret_value = (H5EA_dblk_page_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, &load_ud, hdr, rw))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", (unsigned long long)dblk_page_addr) CATCH diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index af2828a..344b9fa 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -101,13 +101,14 @@ H5FL_DEFINE_STATIC(H5EA_dblock_t); */ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, -H5EA__dblock_alloc(H5EA_hdr_t *hdr, size_t nelmts)) +H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) /* Local variables */ H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ /* Check arguments */ HDassert(hdr); + HDassert(parent); HDassert(nelmts > 0); /* Allocate memory for the data block */ @@ -120,6 +121,7 @@ H5EA__dblock_alloc(H5EA_hdr_t *hdr, size_t nelmts)) dblock->hdr = hdr; /* Set non-zero internal fields */ + dblock->parent = parent; dblock->nelmts = nelmts; /* Check if the data block is not going to be paged */ @@ -160,8 +162,8 @@ END_FUNC(PKG) /* end H5EA__dblock_alloc() */ */ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty, - hsize_t dblk_off, size_t nelmts)) +H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, void *parent, + hbool_t *stats_changed, hsize_t dblk_off, size_t nelmts)) /* Local variables */ H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ @@ -173,11 +175,11 @@ HDfprintf(stderr, "%s: Called, hdr->dblk_page_nelmts = %Zu, nelmts = %Zu\n", FUN /* Sanity check */ HDassert(hdr); - HDassert(hdr_dirty); + HDassert(stats_changed); HDassert(nelmts > 0); /* Allocate the data block */ - if(NULL == (dblock = H5EA__dblock_alloc(hdr, nelmts))) + if(NULL == (dblock = H5EA__dblock_alloc(hdr, parent, nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") /* Set size of data block on disk */ @@ -208,14 +210,14 @@ HDfprintf(stderr, "%s: dblock->block_off = %Hu\n", FUNC, dblock->block_off); H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block to cache") /* Update extensible array data block statistics */ - hdr->stats.ndata_blks++; - hdr->stats.data_blk_size += dblock->size; + hdr->stats.stored.ndata_blks++; + hdr->stats.stored.data_blk_size += dblock->size; /* Increment count of elements "realized" */ - hdr->stats.nelmts += nelmts; + hdr->stats.stored.nelmts += nelmts; - /* Mark the header dirty (for updating statistics) */ - *hdr_dirty = TRUE; + /* Mark the statistics as changed */ + *stats_changed = TRUE; /* Set address of data block to return */ ret_value = dblock_addr; @@ -301,10 +303,11 @@ END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ */ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, -H5EA__dblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, haddr_t dblk_addr, - size_t dblk_nelmts, H5AC_protect_t rw)) +H5EA__dblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, void *parent, + haddr_t dblk_addr, size_t dblk_nelmts, H5AC_protect_t rw)) /* Local variables */ + H5EA_dblock_load_ud_t load_ud; /* Information needed for loading data block */ #ifdef QAK HDfprintf(stderr, "%s: Called\n", FUNC); @@ -315,8 +318,12 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(H5F_addr_defined(dblk_addr)); HDassert(dblk_nelmts); + /* Set up user data */ + load_ud.parent = parent; + load_ud.nelmts = dblk_nelmts; + /* Protect the data block */ - if(NULL == (ret_value = (H5EA_dblock_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_EARRAY_DBLOCK, dblk_addr, &dblk_nelmts, hdr, rw))) + if(NULL == (ret_value = (H5EA_dblock_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_EARRAY_DBLOCK, dblk_addr, &load_ud, hdr, rw))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)dblk_addr) CATCH @@ -374,8 +381,8 @@ END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, -H5EA__dblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, haddr_t dblk_addr, - size_t dblk_nelmts)) +H5EA__dblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, void *parent, + haddr_t dblk_addr, size_t dblk_nelmts)) /* Local variables */ H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ @@ -386,11 +393,12 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Sanity check */ HDassert(hdr); + HDassert(parent); HDassert(H5F_addr_defined(dblk_addr)); HDassert(dblk_nelmts > 0); /* Protect data block */ - if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, dblk_addr, dblk_nelmts, H5AC_WRITE))) + if(NULL == (dblock = H5EA__dblock_protect(hdr, dxpl_id, parent, dblk_addr, dblk_nelmts, H5AC_WRITE))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", (unsigned long long)dblk_addr) /* Check if this is a paged data block */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index 998e169..1e01601 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -116,7 +116,7 @@ H5FL_SEQ_DEFINE_STATIC(H5EA_sblk_info_t); */ BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, -H5EA__hdr_alloc(H5F_t *f, const H5EA_class_t *cls)) +H5EA__hdr_alloc(H5F_t *f, const H5EA_class_t *cls, void *udata)) /* Local variables */ H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ @@ -141,7 +141,7 @@ H5EA__hdr_alloc(H5F_t *f, const H5EA_class_t *cls)) hdr->cparam.cls = cls; /* Create the callback context */ - if(NULL == (hdr->cb_ctx = (*cls->crt_context)(f))) + if(NULL == (hdr->cb_ctx = (*cls->crt_context)(udata))) H5E_THROW(H5E_CANTCREATE, "unable to create extensible array client callback context") /* Set the return value */ @@ -236,7 +236,7 @@ HDfprintf(stderr, "%s: hdr->sblk_info[%Zu] = {%Zu, %Zu, %Hu, %Hu}\n", FUNC, u, h } /* end for */ /* Set size of header on disk (locally and in statistics) */ - hdr->stats.hdr_size = hdr->size = H5EA_HEADER_SIZE(hdr); + hdr->stats.computed.hdr_size = hdr->size = H5EA_HEADER_SIZE(hdr); CATCH @@ -368,7 +368,8 @@ END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ */ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__hdr_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam)) +H5EA__hdr_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam, + void *ctx_udata)) /* Local variables */ H5EA_hdr_t *hdr = NULL; /* Extensible array header */ @@ -416,7 +417,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* NDEBUG */ /* Allocate space for the shared information */ - if(NULL == (hdr = H5EA__hdr_alloc(f, cparam->cls))) + if(NULL == (hdr = H5EA__hdr_alloc(f, cparam->cls, ctx_udata))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index 2d93015..9920277 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -178,7 +178,7 @@ END_FUNC(PKG) /* end H5EA__iblock_alloc() */ */ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__iblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty)) +H5EA__iblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *stats_changed)) /* Local variables */ H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ @@ -190,7 +190,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Sanity check */ HDassert(hdr); - HDassert(hdr_dirty); + HDassert(stats_changed); /* Allocate the index block */ if(NULL == (iblock = H5EA__iblock_alloc(hdr))) @@ -235,16 +235,16 @@ HDfprintf(stderr, "%s: iblock->size = %Zu\n", FUNC, iblock->size); H5E_THROW(H5E_CANTINSERT, "can't add extensible array index block to cache") /* Update extensible array index block statistics */ - HDassert(0 == hdr->stats.nindex_blks); - HDassert(0 == hdr->stats.index_blk_size); - hdr->stats.nindex_blks = 1; - hdr->stats.index_blk_size = iblock->size; + HDassert(0 == hdr->stats.computed.nindex_blks); + HDassert(0 == hdr->stats.computed.index_blk_size); + hdr->stats.computed.nindex_blks = 1; + hdr->stats.computed.index_blk_size = iblock->size; /* Increment count of elements "realized" */ - hdr->stats.nelmts += hdr->cparam.idx_blk_elmts; + hdr->stats.stored.nelmts += hdr->cparam.idx_blk_elmts; - /* Mark the header dirty (for updating statistics) */ - *hdr_dirty = TRUE; + /* Mark the statistics as changed */ + *stats_changed = TRUE; /* Set address of index block to return */ ret_value = iblock_addr; @@ -281,8 +281,6 @@ BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, H5AC_protect_t rw)) - /* Local variables */ - #ifdef QAK HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* QAK */ @@ -378,7 +376,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Check for data block existing */ if(H5F_addr_defined(iblock->dblk_addrs[u])) { /* Delete data block */ - if(H5EA__dblock_delete(hdr, dxpl_id, iblock->dblk_addrs[u], hdr->sblk_info[sblk_idx].dblk_nelmts) < 0) + if(H5EA__dblock_delete(hdr, dxpl_id, iblock, iblock->dblk_addrs[u], hdr->sblk_info[sblk_idx].dblk_nelmts) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") iblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ @@ -403,7 +401,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Check for data block existing */ if(H5F_addr_defined(iblock->sblk_addrs[u])) { /* Delete super block */ - if(H5EA__sblock_delete(hdr, dxpl_id, iblock->sblk_addrs[u], (unsigned)(u + iblock->nsblks)) < 0) + if(H5EA__sblock_delete(hdr, dxpl_id, iblock, iblock->sblk_addrs[u], (unsigned)(u + iblock->nsblks)) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array super block") iblock->sblk_addrs[u] = HADDR_UNDEF; } /* end if */ diff --git a/src/H5EAint.c b/src/H5EAint.c index a53d4f9..5ce88fc 100644 --- a/src/H5EAint.c +++ b/src/H5EAint.c @@ -79,3 +79,66 @@ /*******************/ + +/*------------------------------------------------------------------------- + * Function: H5EA__create_flush_depend + * + * Purpose: Create a flush dependency between two data structure components + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 26 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PKG, ERR, +herr_t, SUCCEED, FAIL, +H5EA__create_flush_depend(H5EA_hdr_t *hdr, H5AC_info_t *parent_entry, + H5AC_info_t *child_entry)) + + /* Sanity check */ + HDassert(hdr); + HDassert(parent_entry); + HDassert(child_entry); + + /* Create a flush dependency between parent and child entry */ + if(H5AC_create_flush_dependency(hdr->f, parent_entry, child_entry) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") + +CATCH + +END_FUNC(PKG) /* end H5EA__create_flush_depend() */ + + +/*------------------------------------------------------------------------- + * Function: H5EA__destroy_flush_depend + * + * Purpose: Destroy a flush dependency between two data structure components + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 26 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PKG, ERR, +herr_t, SUCCEED, FAIL, +H5EA__destroy_flush_depend(H5EA_hdr_t *hdr, H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) + + /* Sanity check */ + HDassert(hdr); + HDassert(parent_entry); + HDassert(child_entry); + + /* Destroy a flush dependency between parent and child entry */ + if(H5AC_destroy_flush_dependency(hdr->f, parent_entry, child_entry) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") + +CATCH + +END_FUNC(PKG) /* end H5EA__destroy_flush_depend() */ + diff --git a/src/H5EApkg.h b/src/H5EApkg.h index e374d3a..f64f520 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -39,7 +39,6 @@ /* Revisions to FUNC_ENTER/LEAVE & Error Macros */ /************************************************/ -#ifndef NDEBUG /* `S' is the name of a function which is being tested to check if it's */ /* a public API function */ #define H5_IS_PUB(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && HDislower(S[2])) || \ @@ -58,6 +57,7 @@ ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && '_' == S[4] && HDislower(S[5])) || \ ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && '_' == S[5] && HDislower(S[6]))) +#ifndef NDEBUG #define FUNC_ENTER_NAME_CHECK(asrt) \ { \ static hbool_t func_check = FALSE; \ @@ -72,13 +72,11 @@ } /* end scope */ #else /* NDEBUG */ #define FUNC_ENTER_NAME_CHECK(asrt) -#define H5_IS_PUB(S) -#define H5_IS_PRIV(S) -#define H5_IS_PKG(S) #endif /* NDEBUG */ -/* Macro for referencing package initialization variables */ +/* Macros for referencing package initialization symbols */ #define H5_PACKAGE_INIT_VAR(x) H5_GLUE3(H5_, x, _init_g) +#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __pkg_init) /* Macros to check if a package is initialized */ #define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg)); @@ -98,14 +96,18 @@ } /* end if */ #define H5_PKG_NO_INIT(pkg) -/* Macros to declare package initialization variable, if a package initialization routine is defined */ +/* Macros to declare package initialization symbols, if a package initialization routine is defined */ #define H5_PKG_YES_INIT_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(H5_MY_PKG); #define H5_PKG_NO_INIT_VAR(pkg) +#define H5_PKG_YES_INIT_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); +#define H5_PKG_NO_INIT_FUNC(pkg) -/* Declare package initialization variable (if in a package) */ +/* Declare package initialization symbols (if in a package) */ #define H5_DECLARE_PKG_VAR(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT_VAR)(pkg) +#define H5_DECLARE_PKG_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT_FUNC)(pkg) #ifdef H5_MY_PKG H5_DECLARE_PKG_VAR(H5_MY_PKG_INIT, H5_MY_PKG) +H5_DECLARE_PKG_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) #endif /* H5_MY_PKG */ /* API re-entrance variable */ @@ -226,6 +228,13 @@ func \ #define H5_PRIV_FUNC_INIT_FAILED(pkg_init) H5_GLUE3(H5_PRIV_, pkg_init, _FUNC_INIT_FAILED) /* Macros for leaving different scopes of routines */ +#define FUNC_LEAVE_PKGINIT \ + /* Leave scope for this type of function */ \ + } \ + \ + /* Pop the name of this function off the function stack */ \ + H5_POP_FUNC + #define FUNC_LEAVE_STATIC \ /* Leave scope for this type of function */ \ } \ @@ -371,7 +380,7 @@ func_init_failed: \ + 1 /* Min. # of data block pointers for a super block */ \ + 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ \ \ - /* Extensible Array Header statistics fields */ \ + /* Extensible Array statistics fields */ \ + (h)->sizeof_size /* Number of super blocks created */ \ + (h)->sizeof_size /* Size of super blocks created */ \ + (h)->sizeof_size /* Number of data blocks created */ \ @@ -472,7 +481,7 @@ typedef struct H5EA_hdr_t { /* Index block information (stored in header) */ haddr_t idx_blk_addr; /* Address of index block in header */ - /* Statistics for array (stored in header) */ + /* Statistics for array (stored in index block, actually) */ /* (header and index number/size fields not stored) */ H5EA_stat_t stats; /* Statistics for extensible array */ @@ -539,6 +548,7 @@ typedef struct H5EA_sblock_t { /* Internal array information (not stored) */ size_t rc; /* Reference count of objects using this block */ H5EA_hdr_t *hdr; /* Shared array header info */ + H5EA_iblock_t *parent; /* Parent object for super block (index block) */ haddr_t addr; /* Address of this index block on disk */ size_t size; /* Size of index block on disk */ @@ -562,6 +572,7 @@ typedef struct H5EA_dblock_t { /* Internal array information (not stored) */ H5EA_hdr_t *hdr; /* Shared array header info */ + void *parent; /* Parent object for data block (index or super block) */ haddr_t addr; /* Address of this data block on disk */ size_t size; /* Size of data block on disk */ @@ -580,6 +591,7 @@ typedef struct H5EA_dbk_page_t { /* Internal array information (not stored) */ H5EA_hdr_t *hdr; /* Shared array header info */ + H5EA_sblock_t *parent; /* Parent object for data block page (super block) */ haddr_t addr; /* Address of this data block page on disk */ size_t size; /* Size of data block page on disk */ @@ -593,6 +605,25 @@ struct H5EA_t { H5F_t *f; /* Pointer to file for extensible array */ }; +/* Metadata cache callback user data types */ + +/* Info needed for loading data block page */ +typedef struct H5EA_dblk_page_load_ud_t { + H5EA_sblock_t *parent; /* Pointer to parent object for data block page (super block) */ +} H5EA_dblk_page_load_ud_t; + +/* Info needed for loading data block */ +typedef struct H5EA_dblock_load_ud_t { + void *parent; /* Pointer to parent object for data block (index or super block) */ + size_t nelmts; /* Number of elements in data block */ +} H5EA_dblock_load_ud_t; + +/* Info needed for loading super block */ +typedef struct H5EA_sblock_load_ud_t { + H5EA_iblock_t *parent; /* Pointer to parent object for super block (index block) */ + unsigned sblk_idx; /* Index of super block */ +} H5EA_sblock_load_ud_t; + /*****************************/ /* Package Private Variables */ @@ -623,10 +654,18 @@ H5_DLLVAR const H5EA_class_t H5EA_CLS_TEST[1]; /* Package Private Prototypes */ /******************************/ +/* Generic routines */ +H5_DLL herr_t H5EA__create_flush_depend(H5EA_hdr_t *hdr, H5AC_info_t *parent_entry, + H5AC_info_t *child_entry); +H5_DLL herr_t H5EA__destroy_flush_depend(H5EA_hdr_t *hdr, H5AC_info_t *parent_entry, + H5AC_info_t *child_entry); + /* Header routines */ -H5_DLL H5EA_hdr_t *H5EA__hdr_alloc(H5F_t *f, const H5EA_class_t *cls); +H5_DLL H5EA_hdr_t *H5EA__hdr_alloc(H5F_t *f, const H5EA_class_t *cls, + void *ctx_udata); H5_DLL herr_t H5EA__hdr_init(H5EA_hdr_t *hdr); -H5_DLL haddr_t H5EA__hdr_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam); +H5_DLL haddr_t H5EA__hdr_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam, + void *ctx_udata); H5_DLL void *H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts); H5_DLL herr_t H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts); H5_DLL herr_t H5EA__hdr_incr(H5EA_hdr_t *hdr); @@ -640,7 +679,7 @@ H5_DLL herr_t H5EA__hdr_dest(H5EA_hdr_t *hdr); /* Index block routines */ H5_DLL H5EA_iblock_t *H5EA__iblock_alloc(H5EA_hdr_t *hdr); H5_DLL haddr_t H5EA__iblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, - hbool_t *hdr_dirty); + hbool_t *stats_changed); H5_DLL H5EA_iblock_t *H5EA__iblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, H5AC_protect_t rw); H5_DLL herr_t H5EA__iblock_unprotect(H5EA_iblock_t *iblock, hid_t dxpl_id, @@ -649,36 +688,38 @@ H5_DLL herr_t H5EA__iblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id); H5_DLL herr_t H5EA__iblock_dest(H5F_t *f, H5EA_iblock_t *iblock); /* Super block routines */ -H5_DLL H5EA_sblock_t *H5EA__sblock_alloc(H5EA_hdr_t *hdr, unsigned sblk_idx); -H5_DLL haddr_t H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty, +H5_DLL H5EA_sblock_t *H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx); +H5_DLL haddr_t H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, + H5EA_iblock_t *parent, hbool_t *stats_changed, unsigned sblk_idx); H5_DLL H5EA_sblock_t *H5EA__sblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, - haddr_t sblk_addr, unsigned sblk_idx, H5AC_protect_t rw); + H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx, H5AC_protect_t rw); H5_DLL herr_t H5EA__sblock_unprotect(H5EA_sblock_t *sblock, hid_t dxpl_id, unsigned cache_flags); H5_DLL herr_t H5EA__sblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, - haddr_t sblk_addr, unsigned sblk_idx); + H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx); H5_DLL herr_t H5EA__sblock_dest(H5F_t *f, H5EA_sblock_t *sblock); /* Data block routines */ -H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, size_t nelmts); -H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty, - hsize_t dblk_off, size_t nelmts); +H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, + size_t nelmts); +H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, void *parent, + hbool_t *stats_changed, hsize_t dblk_off, size_t nelmts); H5_DLL unsigned H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx); H5_DLL H5EA_dblock_t *H5EA__dblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, - haddr_t dblk_addr, size_t dblk_nelmts, H5AC_protect_t rw); + void *parent, haddr_t dblk_addr, size_t dblk_nelmts, H5AC_protect_t rw); H5_DLL herr_t H5EA__dblock_unprotect(H5EA_dblock_t *dblock, hid_t dxpl_id, unsigned cache_flags); -H5_DLL herr_t H5EA__dblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, +H5_DLL herr_t H5EA__dblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, void *parent, haddr_t dblk_addr, size_t dblk_nelmts); H5_DLL herr_t H5EA__dblock_dest(H5F_t *f, H5EA_dblock_t *dblock); /* Data block page routines */ -H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_alloc(H5EA_hdr_t *hdr); +H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent); H5_DLL herr_t H5EA__dblk_page_create(H5EA_hdr_t *hdr, hid_t dxpl_id, - haddr_t addr); + H5EA_sblock_t *parent, haddr_t addr); H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, - haddr_t dblk_page_addr, H5AC_protect_t rw); + H5EA_sblock_t *parent, haddr_t dblk_page_addr, H5AC_protect_t rw); H5_DLL herr_t H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, hid_t dxpl_id, unsigned cache_flags); H5_DLL herr_t H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page); diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index f44d046..f525a01 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -62,7 +62,7 @@ typedef struct H5EA_class_t { size_t nat_elmt_size; /* Size of native (memory) element */ /* Extensible array client callback methods */ - void *(*crt_context)(const H5F_t *f); /* Create context for other callbacks */ + void *(*crt_context)(void *udata); /* Create context for other callbacks */ herr_t (*dst_context)(void *ctx); /* Destroy context */ herr_t (*fill)(void *nat_blk, size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, void *ctx); /* Encode elements from native form to disk storage form */ @@ -82,19 +82,26 @@ typedef struct H5EA_create_t { } H5EA_create_t; /* Extensible array metadata statistics info */ +/* (If these are ever exposed to applications, don't let the application see + * which fields are computed vs. which fields are stored. -QAK) + */ typedef struct H5EA_stat_t { /* Non-stored (i.e. computed) fields */ - hsize_t hdr_size; /* Size of header */ - hsize_t nindex_blks; /* # of index blocks (should be 0 or 1) */ - hsize_t index_blk_size; /* Size of index blocks allocated */ + struct { + hsize_t hdr_size; /* Size of header */ + hsize_t nindex_blks; /* # of index blocks (should be 0 or 1) */ + hsize_t index_blk_size; /* Size of index blocks allocated */ + } computed; /* Stored fields */ - hsize_t nsuper_blks; /* # of super blocks */ - hsize_t super_blk_size; /* Size of super blocks allocated */ - hsize_t ndata_blks; /* # of data blocks */ - hsize_t data_blk_size; /* Size of data blocks allocated */ - hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */ - hsize_t nelmts; /* # of elements "realized" */ + struct { + hsize_t nsuper_blks; /* # of super blocks */ + hsize_t super_blk_size; /* Size of super blocks allocated */ + hsize_t ndata_blks; /* # of data blocks */ + hsize_t data_blk_size; /* Size of data blocks allocated */ + hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */ + hsize_t nelmts; /* # of elements "realized" */ + } stored; } H5EA_stat_t; /* Extensible array info (forward decl - defined in H5EApkg.h) */ @@ -111,9 +118,10 @@ typedef struct H5EA_t H5EA_t; /***************************************/ /* General routines */ -H5_DLL H5EA_t *H5EA_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam); +H5_DLL H5EA_t *H5EA_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam, + void *ctx_udata); H5_DLL H5EA_t *H5EA_open(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, - const H5EA_class_t *cls); + const H5EA_class_t *cls, void *ctx_udata); H5_DLL herr_t H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts); H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr); H5_DLL herr_t H5EA_set(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, const void *elmt); diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index 3cb97a9..c6a4306 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -107,7 +107,7 @@ H5FL_BLK_DEFINE(page_init); */ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, -H5EA__sblock_alloc(H5EA_hdr_t *hdr, unsigned sblk_idx)) +H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) /* Local variables */ H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ @@ -125,6 +125,7 @@ H5EA__sblock_alloc(H5EA_hdr_t *hdr, unsigned sblk_idx)) sblock->hdr = hdr; /* Set non-zero internal fields */ + sblock->parent = parent; sblock->addr = HADDR_UNDEF; /* Compute/cache information */ @@ -190,8 +191,8 @@ END_FUNC(PKG) /* end H5EA__sblock_alloc() */ */ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, -H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty, - unsigned sblk_idx)) +H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent, + hbool_t *stats_changed, unsigned sblk_idx)) /* Local variables */ H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ @@ -204,10 +205,10 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Sanity check */ HDassert(hdr); - HDassert(hdr_dirty); + HDassert(stats_changed); /* Allocate the super block */ - if(NULL == (sblock = H5EA__sblock_alloc(hdr, sblk_idx))) + if(NULL == (sblock = H5EA__sblock_alloc(hdr, parent, sblk_idx))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") /* Set size of super block on disk */ @@ -235,11 +236,11 @@ HDfprintf(stderr, "%s: sblock->block_off = %Hu\n", FUNC, sblock->block_off); H5E_THROW(H5E_CANTINSERT, "can't add extensible array super block to cache") /* Update extensible array super block statistics */ - hdr->stats.nsuper_blks++; - hdr->stats.super_blk_size += sblock->size; + hdr->stats.stored.nsuper_blks++; + hdr->stats.stored.super_blk_size += sblock->size; - /* Mark the header dirty (for updating statistics) */ - *hdr_dirty = TRUE; + /* Mark the statistics as changed */ + *stats_changed = TRUE; /* Set address of super block to return */ ret_value = sblock_addr; @@ -274,10 +275,12 @@ END_FUNC(PKG) /* end H5EA__sblock_create() */ */ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, -H5EA__sblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, haddr_t sblk_addr, - unsigned sblk_idx, H5AC_protect_t rw)) +H5EA__sblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent, + haddr_t sblk_addr, unsigned sblk_idx, H5AC_protect_t rw)) /* Local variables */ + H5EA_sblock_load_ud_t load_ud; /* Information needed for loading super block */ + #ifdef QAK HDfprintf(stderr, "%s: Called\n", FUNC); @@ -287,8 +290,12 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(hdr); HDassert(H5F_addr_defined(sblk_addr)); + /* Set up user data */ + load_ud.parent = parent; + load_ud.sblk_idx = sblk_idx; + /* Protect the super block */ - if(NULL == (ret_value = (H5EA_sblock_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_EARRAY_SBLOCK, sblk_addr, &sblk_idx, hdr, rw))) + if(NULL == (ret_value = (H5EA_sblock_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_EARRAY_SBLOCK, sblk_addr, &load_ud, hdr, rw))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)sblk_addr) CATCH @@ -346,8 +353,8 @@ END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, -H5EA__sblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, haddr_t sblk_addr, - unsigned sblk_idx)) +H5EA__sblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent, + haddr_t sblk_addr, unsigned sblk_idx)) /* Local variables */ H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ @@ -362,7 +369,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(H5F_addr_defined(sblk_addr)); /* Protect super block */ - if(NULL == (sblock = H5EA__sblock_protect(hdr, dxpl_id, sblk_addr, sblk_idx, H5AC_WRITE))) + if(NULL == (sblock = H5EA__sblock_protect(hdr, dxpl_id, parent, sblk_addr, sblk_idx, H5AC_WRITE))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)sblk_addr) /* Iterate over data blocks */ @@ -370,7 +377,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Check for data block existing */ if(H5F_addr_defined(sblock->dblk_addrs[u])) { /* Delete data block */ - if(H5EA__dblock_delete(hdr, dxpl_id, sblock->dblk_addrs[u], sblock->dblk_nelmts) < 0) + if(H5EA__dblock_delete(hdr, dxpl_id, sblock, sblock->dblk_addrs[u], sblock->dblk_nelmts) < 0) H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") sblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index 58e8bc2..93cd518 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -69,7 +69,7 @@ typedef struct H5EA__test_ctx_t { /********************/ /* Extensible array class callbacks */ -static void *H5EA__test_crt_context(const H5F_t *f); +static void *H5EA__test_crt_context(void *udata); static herr_t H5EA__test_dst_context(void *ctx); static herr_t H5EA__test_fill(void *nat_blk, size_t nelmts); static herr_t H5EA__test_encode(void *raw, const void *elmt, size_t nelmts, @@ -126,13 +126,12 @@ H5FL_DEFINE_STATIC(H5EA__test_ctx_t); */ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, -H5EA__test_crt_context(const H5F_t UNUSED *f)) +H5EA__test_crt_context(void UNUSED *udata)) /* Local variables */ H5EA__test_ctx_t *ctx; /* Context for callbacks */ /* Sanity checks */ - HDassert(f); /* Allocate new context structure */ if(NULL == (ctx = H5FL_MALLOC(H5EA__test_ctx_t))) diff --git a/src/H5Edefin.h b/src/H5Edefin.h index b31b31b..adaaa3a 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -166,6 +166,7 @@ hid_t H5E_CANTEXPUNGE_g = FAIL; /* Unable to expunge a metadata cache en hid_t H5E_CANTRESIZE_g = FAIL; /* Unable to resize a metadata cache entry */ hid_t H5E_CANTDEPEND_g = FAIL; /* Unable to create a flush dependency */ hid_t H5E_CANTUNDEPEND_g = FAIL; /* Unable to destroy a flush dependency */ +hid_t H5E_CANTNOTIFY_g = FAIL; /* Unable to notify object about action */ /* Link related errors */ hid_t H5E_TRAVERSE_g = FAIL; /* Link traversal failure */ diff --git a/src/H5Einit.h b/src/H5Einit.h index 204644f..a9f95b7 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -632,6 +632,11 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to destroy a flush dependency") HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_CANTUNDEPEND_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTNOTIFY_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to notify object about action"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTNOTIFY_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") /* Link related errors */ assert(H5E_TRAVERSE_g==(-1)); diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 7b1d7ef..c6adb67 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -40,7 +40,7 @@ typedef struct H5E_t H5E_t; */ #define HCOMMON_ERROR(maj, min, str) \ HERROR(maj, min, str); \ - (void)H5E_dump_api_stack((hbool_t)H5_IS_API(FUNC)); + err_occurred = TRUE; /* * HDONE_ERROR macro, used to facilitate error reporting between a diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 736349a..3debf20 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -268,6 +268,7 @@ H5_DLLVAR hid_t H5E_NOIDS_g; /* Out of IDs for group */ #define H5E_CANTRESIZE (H5OPEN H5E_CANTRESIZE_g) #define H5E_CANTDEPEND (H5OPEN H5E_CANTDEPEND_g) #define H5E_CANTUNDEPEND (H5OPEN H5E_CANTUNDEPEND_g) +#define H5E_CANTNOTIFY (H5OPEN H5E_CANTNOTIFY_g) H5_DLLVAR hid_t H5E_CANTFLUSH_g; /* Unable to flush data from cache */ H5_DLLVAR hid_t H5E_CANTSERIALIZE_g; /* Unable to serialize data from cache */ H5_DLLVAR hid_t H5E_CANTLOAD_g; /* Unable to load metadata into cache */ @@ -286,6 +287,7 @@ H5_DLLVAR hid_t H5E_CANTEXPUNGE_g; /* Unable to expunge a metadata cache entry H5_DLLVAR hid_t H5E_CANTRESIZE_g; /* Unable to resize a metadata cache entry */ H5_DLLVAR hid_t H5E_CANTDEPEND_g; /* Unable to create a flush dependency */ H5_DLLVAR hid_t H5E_CANTUNDEPEND_g; /* Unable to destroy a flush dependency */ +H5_DLLVAR hid_t H5E_CANTNOTIFY_g; /* Unable to notify object about action */ /* Link related errors */ #define H5E_TRAVERSE (H5OPEN H5E_TRAVERSE_g) diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 8936dc0..ecad437 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -167,7 +167,8 @@ H5E_CANTDIRTY_g= H5E_CANTEXPUNGE_g= H5E_CANTRESIZE_g= H5E_CANTDEPEND_g= -H5E_CANTUNDEPEND_g= +H5E_CANTUNDEPEND_g= +H5E_CANTNOTIFY_g= /* Link related errors */ H5E_TRAVERSE_g= diff --git a/src/H5F.c b/src/H5F.c index e7b4cd3..fc85688 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -893,6 +893,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) f->shared->driver_addr = HADDR_UNDEF; f->shared->accum.loc = HADDR_UNDEF; f->shared->lf = lf; + f->shared->root_addr = HADDR_UNDEF; /* * Copy the file creation and file access property lists into the @@ -1116,7 +1117,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) f->shared->mtab.nalloc = 0; /* Free root group symbol table entry, if any */ - f->shared->root_ent = H5MM_xfree(f->shared->root_ent); + f->shared->root_ent = (H5G_entry_t *)H5MM_xfree(f->shared->root_ent); /* Destroy shared file struct */ f->shared = (H5F_file_t *)H5FL_FREE(H5F_file_t, f->shared); @@ -1369,7 +1370,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d /* (This must be after the space for the superblock is allocated in * the file, since the superblock must be at offset 0) */ - if(H5G_mkroot(file, dxpl_id, NULL) < 0) + if(H5G_mkroot(file, dxpl_id, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create/open root group") /* Write the superblock to the file */ @@ -1379,21 +1380,12 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d if(H5F_super_write(file, dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to write file superblock") } else if (1 == shared->nrefs) { - H5G_loc_t root_loc; /*root location */ - H5O_loc_t root_oloc; /*root object location */ - H5G_name_t root_path; /*root group hier. path */ - - /* Set up root location to fill in */ - root_loc.oloc = &root_oloc; - root_loc.path = &root_path; - H5G_loc_reset(&root_loc); - /* Read the superblock if it hasn't been read before. */ - if(H5F_super_read(file, dxpl_id, &root_loc) < 0) + if(H5F_super_read(file, dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") /* Open the root group */ - if(H5G_mkroot(file, dxpl_id, &root_loc) < 0) + if(H5G_mkroot(file, dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") } /* end if */ diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index cfad5e3..1d508dc 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -626,8 +626,15 @@ H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out* HDstrncpy(name, "NCSAfami", (size_t)8); name[8] = '\0'; - /* Store member file size */ - UINT64ENCODE(buf, (uint64_t)file->memb_size); + /* Store member file size. Use the member file size from the property here. + * This is to guarantee backward compatibility. If a file is created with + * v1.6 library and the driver info isn't saved in the superblock. We open + * it with v1.8, the FILE->MEMB_SIZE will be the actual size of the first + * member file (see H5FD_family_open). So it isn't safe to use FILE->MEMB_SIZE. + * If the file is created with v1.8, the correctness of FILE->PMEM_SIZE is + * checked in H5FD_family_sb_decode. SLU - 2009/3/21 + */ + UINT64ENCODE(buf, (uint64_t)file->pmem_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_family_sb_encode() */ @@ -668,9 +675,9 @@ H5FD_family_sb_decode(H5FD_t *_file, const char UNUSED *name, const unsigned cha /* For h5repart only. Private property of new member size is used to signal * h5repart is being used to change member file size. h5repart will open * files for read and write. When the files are closed, metadata will be - * flushed to the files and updated this new size */ + * flushed to the files and updated to this new size */ if(file->mem_newsize) { - file->memb_size = file->mem_newsize; + file->memb_size = file->pmem_size = file->mem_newsize; HGOTO_DONE(ret_value) } /* end if */ @@ -682,7 +689,7 @@ H5FD_family_sb_decode(H5FD_t *_file, const char UNUSED *name, const unsigned cha if(msize != file->pmem_size) { char err_msg[128]; - sprintf(err_msg, "family member size should be %lu, is %lu", (unsigned long)msize, (unsigned long)file->pmem_size); + sprintf(err_msg, "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size); HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, err_msg) } /* end if */ diff --git a/src/H5FDint.c b/src/H5FDint.c index aa375e2..74b3bf6 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -194,6 +194,11 @@ done: * * Purpose: Private version of H5FDset_eoa() * + * This function expects the EOA is a RELATIVE address, i.e. + * relative to the base address. This is NOT the same as the + * EOA stored in the superblock, which is an absolute + * address. Object addresses are relative. + * * Return: Success: Non-negative * Failure: Negative, no side effect * @@ -212,7 +217,7 @@ H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) HDassert(file && file->cls); HDassert(H5F_addr_defined(addr) && addr <= file->maxaddr); - /* Dispatch to driver */ + /* Dispatch to driver, convert to absolute address */ if((file->cls->set_eoa)(file, type, addr + file->base_addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver set_eoa request failed") @@ -226,6 +231,11 @@ done: * * Purpose: Private version of H5FDget_eoa() * + * This function returns the EOA as a RELATIVE address, i.e. + * relative to the base address. This is NOT the same as the + * EOA stored in the superblock, which is an absolute + * address. Object addresses are relative. + * * Return: Success: First byte after allocated memory. * Failure: HADDR_UNDEF * @@ -247,7 +257,7 @@ H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type) if(HADDR_UNDEF == (ret_value = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") - /* Adjust for base address in file */ + /* Adjust for base address in file (convert to relative address) */ ret_value -= file->base_addr; done: @@ -260,6 +270,11 @@ done: * * Purpose: Private version of H5FDget_eof() * + * This function returns the EOF as a RELATIVE address, i.e. + * relative to the base address. This will be different + * from the end of the physical file if there is a user + * block. + * * Return: Success: The EOF address. * * Failure: HADDR_UNDEF @@ -288,7 +303,7 @@ H5FD_get_eof(const H5FD_t *file) else ret_value = file->maxaddr; - /* Adjust for base address in file */ + /* Adjust for base address in file (convert to relative address) */ ret_value -= file->base_addr; done: diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index b35ea7d..35ade20 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -422,9 +422,6 @@ H5FD_sec2_close(H5FD_t *_file) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_close, FAIL) -#ifdef QAK -HDfprintf(stderr, "%s: file->eof = %a, file->eoa = %a\n", FUNC, file->eof, file->eoa); -#endif /* QAK */ /* Sanity check */ HDassert(file); @@ -863,9 +860,6 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_truncate, FAIL) -#ifdef QAK -HDfprintf(stderr, "%s: file->eof = %a, file->eoa = %a\n", FUNC, file->eof, file->eoa); -#endif /* QAK */ HDassert(file); diff --git a/src/H5FL.c b/src/H5FL.c index 1045658..c72491d 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -52,6 +52,8 @@ static size_t H5FL_arr_glb_mem_lim=4*1024*1024; /* Default to 4MB limit on all a static size_t H5FL_arr_lst_mem_lim=4*65536; /* Default to 256KB limit on each array free list */ static size_t H5FL_blk_glb_mem_lim=16*1024*1024; /* Default to 16MB limit on all block free lists */ static size_t H5FL_blk_lst_mem_lim=1024*1024; /* Default to 1024KB (1MB) limit on each block free list */ +static size_t H5FL_fac_glb_mem_lim=16*1024*1024; /* Default to 16MB limit on all factory free lists */ +static size_t H5FL_fac_lst_mem_lim=1024*1024; /* Default to 1024KB (1MB) limit on each factory free list */ /* A garbage collection node for regular free lists */ typedef struct H5FL_reg_gc_node_t { @@ -98,6 +100,26 @@ typedef struct H5FL_blk_gc_list_t { /* The head of the list of PQs to garbage collect */ static H5FL_blk_gc_list_t H5FL_blk_gc_head={0,NULL}; +/* A garbage collection node for factory free lists */ +struct H5FL_fac_gc_node_t { + H5FL_fac_head_t *list; /* Pointer to the head of the list to garbage collect */ + struct H5FL_fac_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ +}; + +/* The garbage collection head for factory free lists */ +typedef struct H5FL_fac_gc_list_t { + size_t mem_freed; /* Amount of free memory on list */ + struct H5FL_fac_gc_node_t *first; /* Pointer to the first node in the list of things to garbage collect */ +} H5FL_fac_gc_list_t; + +/* Data structure to store each block in factory free list */ +struct H5FL_fac_node_t { + struct H5FL_fac_node_t *next; /* Pointer to next block in free list */ +}; + +/* The head of the list of factory things to garbage collect */ +static H5FL_fac_gc_list_t H5FL_fac_gc_head={0,NULL}; + #ifdef H5FL_TRACK /* Extra headers needed */ @@ -114,14 +136,18 @@ static herr_t H5FL_arr_gc(void); static herr_t H5FL_arr_gc_list(H5FL_arr_head_t *head); static herr_t H5FL_blk_gc(void); static herr_t H5FL_blk_gc_list(H5FL_blk_head_t *head); -static herr_t H5FL_blk_unlink(H5FL_blk_head_t *pq); - -/* Declare a free list to manage the H5FL_fac_head_t struct */ -H5FL_DEFINE(H5FL_fac_head_t); +static herr_t H5FL_fac_gc(void); +static herr_t H5FL_fac_gc_list(H5FL_fac_head_t *head); /* Declare a free list to manage the H5FL_blk_node_t struct */ H5FL_DEFINE(H5FL_blk_node_t); +/* Declare a free list to manage the H5FL_fac_gc_node_t struct */ +H5FL_DEFINE(H5FL_fac_gc_node_t); + +/* Declare a free list to manage the H5FL_fac_head_t struct */ +H5FL_DEFINE(H5FL_fac_head_t); + /*-------------------------------------------------------------------------- NAME @@ -225,15 +251,15 @@ H5FL_reg_init(H5FL_reg_head_t *head) /* Indicate that the free list is initialized */ head->init=1; + /* Make certain that the space allocated is large enough to store a free list pointer (eventually) */ + if(head->sizesize=sizeof(H5FL_reg_node_t); + /* Make certain there's room for tracking information, if any */ #ifdef H5FL_TRACK head->size += sizeof(H5FL_track_t); #endif /* H5FL_TRACK */ - /* Make certain that the space allocated is large enough to store a free list pointer (eventually) */ - if(head->sizesize=sizeof(void *); - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_reg_init() */ @@ -259,11 +285,13 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) { void *ret_value=NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5FL_reg_free, NULL) + /* NOINIT OK here because this must be called after H5FL_reg_malloc/calloc + * -NAF */ + FUNC_ENTER_NOAPI_NOINIT(H5FL_reg_free) /* Double check parameters */ - assert(head); - assert(obj); + HDassert(head); + HDassert(obj); #ifdef H5FL_TRACK { @@ -294,7 +322,7 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) #endif /* H5FL_DEBUG */ /* Make certain that the free list is initialized */ - assert(head->init); + HDassert(head->init); /* Link into the free list */ ((H5FL_reg_node_t *)obj)->next=head->list; @@ -302,16 +330,15 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) /* Point free list at the node freed */ head->list=(H5FL_reg_node_t *)obj; - /* Increment the number of blocks & memory on free list */ + /* Increment the number of blocks on free list */ head->onlist++; - head->list_mem+=head->size; /* Increment the amount of "regular" freed memory globally */ H5FL_reg_gc_head.mem_freed+=head->size; /* Check for exceeding free list memory use limits */ /* First check this particular list */ - if(head->list_mem>H5FL_reg_lst_mem_lim) + if(head->onlist * head->size > H5FL_reg_lst_mem_lim) if(H5FL_reg_gc_list(head)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") @@ -348,7 +375,7 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) FUNC_ENTER_NOAPI(H5FL_reg_malloc, NULL) /* Double check parameters */ - assert(head); + HDassert(head); /* Make certain the list is initialized first */ if(!head->init) @@ -365,7 +392,6 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) /* Decrement the number of blocks & memory on free list */ head->onlist--; - head->list_mem-=head->size; /* Decrement the amount of global "regular" free list memory in use */ H5FL_reg_gc_head.mem_freed-=(head->size); @@ -426,7 +452,7 @@ H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) FUNC_ENTER_NOAPI(H5FL_reg_calloc, NULL) /* Double check parameters */ - assert(head); + HDassert(head); /* Allocate the block */ if (NULL==(ret_value = H5FL_reg_malloc(head H5FL_TRACK_INFO_INT))) @@ -476,17 +502,11 @@ H5FL_reg_gc_list(H5FL_reg_head_t *head) /* Decrement the count of nodes allocated and free the node */ head->allocated--; - /* Decrement count of free memory on this list */ - head->list_mem-=head->size; - - H5MM_xfree(free_list); + H5MM_free(free_list); free_list = (H5FL_reg_node_t *)tmp; } /* end while */ - /* Double check that all the memory on this list is recycled */ - HDassert(0 == head->list_mem); - /* Indicate no free nodes on the free list */ head->list=NULL; head->onlist=0; @@ -535,7 +555,7 @@ H5FL_reg_gc(void) } /* end while */ /* Double check that all the memory on the free lists is recycled */ - assert(H5FL_reg_gc_head.mem_freed==0); + HDassert(H5FL_reg_gc_head.mem_freed==0); done: FUNC_LEAVE_NOAPI(ret_value) @@ -797,7 +817,7 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) FUNC_ENTER_NOAPI(H5FL_blk_free_block_avail, FAIL) /* Double check parameters */ - assert(head); + HDassert(head); /* check if there is a free list for blocks of this size */ /* and if there are any blocks available on the list */ @@ -838,8 +858,8 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) FUNC_ENTER_NOAPI(H5FL_blk_malloc, NULL) /* Double check parameters */ - assert(head); - assert(size); + HDassert(head); + HDassert(size); /* Make certain the list is initialized first */ if(!head->init) @@ -928,8 +948,8 @@ H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) FUNC_ENTER_NOAPI(H5FL_blk_calloc, NULL) /* Double check parameters */ - assert(head); - assert(size); + HDassert(head); + HDassert(size); /* Allocate the block */ if (NULL==(ret_value = H5FL_blk_malloc(head,size H5FL_TRACK_INFO_INT))) @@ -969,11 +989,13 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) size_t free_size; /* Size of the block freed */ void *ret_value=NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5FL_blk_free, NULL) + /* NOINIT OK here because this must be called after H5FL_blk_malloc/calloc + * -NAF */ + FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_free) /* Double check parameters */ - assert(head); - assert(block); + HDassert(head); + HDassert(block); #ifdef H5FL_TRACK { @@ -1070,8 +1092,8 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ FUNC_ENTER_NOAPI(H5FL_blk_realloc, NULL) /* Double check parameters */ - assert(head); - assert(new_size); + HDassert(head); + HDassert(new_size); /* Check if we are actually re-allocating a block */ if(block!=NULL) { @@ -1119,67 +1141,6 @@ done: } /* end H5FL_blk_realloc() */ -/*-------------------------------------------------------------------------- - NAME - H5FL_blk_unlink - PURPOSE - Remove a block free list from the global list of initialized block free - lists. - USAGE - void H5FL_blk_unlink(H5FL_blk_head_t *pq) - H5FL_blk_head_t *pq; IN: Block free list to remove from global list - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Search through the global list of initialized block free lists and remove - a particular free list. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5FL_blk_unlink(H5FL_blk_head_t *pq) -{ - H5FL_blk_gc_node_t *last; /* Pointer to the last garbage collection node examined */ - H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_unlink) - - /* Find the node to remove from the global list */ - last=NULL; - tmp=H5FL_blk_gc_head.first; - while(tmp!=NULL) { - /* Check if the list has allocations outstanding */ - if(tmp->pq==pq) { - /* Unlink node from linked list */ - if(last==NULL) - H5FL_blk_gc_head.first=H5FL_blk_gc_head.first->next; - else - last->next=tmp->next; - - /* Free the block node */ - H5MM_xfree(tmp); - - /* Leave now */ - break; - } /* end if */ - - /* Advance to next node in list */ - last=tmp; - tmp=tmp->next; - } /* end while */ - - if(tmp==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't release block free list") - -done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5FL_blk_unlink() */ - - /*------------------------------------------------------------------------- * Function: H5FL_blk_gc_list * @@ -1221,7 +1182,7 @@ H5FL_blk_gc_list(H5FL_blk_head_t *head) H5FL_blk_gc_head.mem_freed-=head->head->size; /* Free the block */ - H5MM_xfree(list); + H5MM_free(list); list = (H5FL_blk_list_t *)next; } /* end while */ @@ -1279,7 +1240,7 @@ H5FL_blk_gc(void) } /* end while */ /* Double check that all the memory on the free lists are recycled */ - assert(H5FL_blk_gc_head.mem_freed==0); + HDassert(H5FL_blk_gc_head.mem_freed==0); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1334,7 +1295,7 @@ printf("H5FL_blk_term: head->name=%s, head->allocated=%d\n", H5FL_blk_gc_head.fi H5FL_blk_gc_head.first->pq->init=0; /* Free the node from the garbage collection list */ - H5MM_xfree(H5FL_blk_gc_head.first); + H5MM_free(H5FL_blk_gc_head.first); } /* end else */ H5FL_blk_gc_head.first=tmp; @@ -1422,17 +1383,19 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) size_t free_nelem; /* Number of elements in node being free'd */ void *ret_value=NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5FL_arr_free, NULL) + /* NOINIT OK here because this must be called after H5FL_arr_malloc/calloc + * -NAF */ + FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_free) /* The H5MM_xfree code allows obj to null */ if (!obj) HGOTO_DONE (NULL) /* Double check parameters */ - assert(head); + HDassert(head); /* Make certain that the free list is initialized */ - assert(head->init); + HDassert(head->init); /* Get the pointer to the info header in front of the block to free */ temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ @@ -1441,7 +1404,7 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) free_nelem=temp->nelem; /* Double-check that there is enough room for arrays of this size */ - assert((int)free_nelem<=head->maxelem); + HDassert((int)free_nelem<=head->maxelem); /* Link into the free list */ temp->next=head->list_arr[free_nelem].list; @@ -1500,8 +1463,8 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) FUNC_ENTER_NOAPI(H5FL_arr_malloc, NULL) /* Double check parameters */ - assert(head); - assert(elem); + HDassert(head); + HDassert(elem); /* Make certain the list is initialized first */ if(!head->init) @@ -1509,7 +1472,7 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'array' blocks") /* Sanity check that the number of elements is supported */ - assert(elem<=(unsigned) head->maxelem); + HDassert(elem<=(unsigned) head->maxelem); /* Get the set of the memory block */ mem_size=head->list_arr[elem].size; @@ -1573,8 +1536,8 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) FUNC_ENTER_NOAPI(H5FL_arr_calloc, NULL) /* Double check parameters */ - assert(head); - assert(elem); + HDassert(head); + HDassert(elem); /* Allocate the array */ if (NULL==(ret_value = H5FL_arr_malloc(head,elem))) @@ -1611,8 +1574,8 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) FUNC_ENTER_NOAPI(H5FL_arr_realloc, NULL) /* Double check parameters */ - assert(head); - assert(new_elem); + HDassert(head); + HDassert(new_elem); /* Check if we are really allocating the object */ if(obj==NULL) @@ -1621,7 +1584,7 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ /* Sanity check that the number of elements is supported */ - assert((int)new_elem<=head->maxelem); + HDassert((int)new_elem<=head->maxelem); /* Get the pointer to the info header in front of the block to free */ temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ @@ -1687,7 +1650,7 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head) /* Decrement the count of nodes allocated and free the node */ head->allocated--; - H5MM_xfree(arr_free_list); + H5MM_free(arr_free_list); arr_free_list = (H5FL_arr_list_t *)tmp; } /* end while */ @@ -1705,7 +1668,7 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head) } /* end for */ /* Double check that all the memory on this list is recycled */ - assert(head->list_mem==0); + HDassert(head->list_mem==0); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FL_arr_gc_list() */ @@ -1746,7 +1709,7 @@ H5FL_arr_gc(void) } /* end while */ /* Double check that all the memory on the free lists are recycled */ - assert(H5FL_arr_gc_head.mem_freed==0); + HDassert(H5FL_arr_gc_head.mem_freed==0); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1803,7 +1766,7 @@ printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi H5FL_arr_gc_head.first->list->init=0; /* Free the node from the garbage collection list */ - H5MM_xfree(H5FL_arr_gc_head.first); + H5MM_free(H5FL_arr_gc_head.first); } /* end else */ H5FL_arr_gc_head.first=tmp; @@ -1834,14 +1797,16 @@ printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj) { + /* NOINIT OK here because this must be called after H5FL_seq_malloc/calloc + * -NAF */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_seq_free) /* Double check parameters */ - assert(head); - assert(obj); + HDassert(head); + HDassert(obj); /* Make certain that the free list is initialized */ - assert(head->queue.init); + HDassert(head->queue.init); /* Use block routine */ H5FL_blk_free(&(head->queue),obj); @@ -1873,8 +1838,8 @@ H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) FUNC_ENTER_NOAPI(H5FL_seq_malloc, NULL) /* Double check parameters */ - assert(head); - assert(elem); + HDassert(head); + HDassert(elem); /* Use block routine */ ret_value=H5FL_blk_malloc(&(head->queue),head->size*elem H5FL_TRACK_INFO_INT); @@ -1907,8 +1872,8 @@ H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) FUNC_ENTER_NOAPI(H5FL_seq_calloc, NULL) /* Double check parameters */ - assert(head); - assert(elem); + HDassert(head); + HDassert(elem); /* Use block routine */ ret_value=H5FL_blk_calloc(&(head->queue),head->size*elem H5FL_TRACK_INFO_INT); @@ -1941,8 +1906,8 @@ H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_P FUNC_ENTER_NOAPI(H5FL_seq_realloc, NULL) /* Double check parameters */ - assert(head); - assert(new_elem); + HDassert(head); + HDassert(new_elem); /* Use block routine */ ret_value=H5FL_blk_realloc(&(head->queue),obj,head->size*new_elem H5FL_TRACK_INFO_INT); @@ -1964,14 +1929,18 @@ done: * Wednesday, February 2, 2005 * * Modifications: + * Neil Fortner + * Friday, December 19, 2008 + * Totally rewritten to support new factory implementation * *------------------------------------------------------------------------- */ H5FL_fac_head_t * H5FL_fac_init(size_t size) { - H5FL_fac_head_t *factory; /* Pointer to new block factory */ - H5FL_fac_head_t *ret_value; /* Return value */ + H5FL_fac_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ + H5FL_fac_head_t *factory; /* Pointer to new block factory */ + H5FL_fac_head_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FL_fac_init, NULL) @@ -1979,15 +1948,38 @@ H5FL_fac_init(size_t size) HDassert(size>0); /* Allocate room for the new factory */ - if(NULL==(factory=H5FL_MALLOC(H5FL_fac_head_t))) + if(NULL == (factory = (H5FL_fac_head_t *)H5FL_CALLOC(H5FL_fac_head_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for factory object") - /* Initialize block header information */ - HDmemset(&(factory->queue),0,sizeof(H5FL_blk_head_t)); - /* Set size of blocks for factory */ factory->size=size; + /* Allocate a new garbage collection node */ + if(NULL == (new_node = (H5FL_fac_gc_node_t *)H5FL_MALLOC(H5FL_fac_gc_node_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Initialize the new garbage collection node */ + new_node->list = factory; + + /* Link in to the garbage collection list */ + new_node->next=H5FL_fac_gc_head.first; + H5FL_fac_gc_head.first=new_node; + if(new_node->next) + new_node->next->list->prev_gc=new_node; + /* The new factory's prev_gc field will be set to NULL */ + + /* Make certain that the space allocated is large enough to store a free list pointer (eventually) */ + if(factory->sizesize=sizeof(H5FL_fac_node_t); + + /* Make certain there's room for tracking information, if any */ +#ifdef H5FL_TRACK + factory->size += sizeof(H5FL_track_t); +#endif /* H5FL_TRACK */ + + /* Indicate that the free list is initialized */ + factory->init=1; + /* Set return value */ ret_value=factory; @@ -2001,32 +1993,86 @@ done: * * Purpose: Release a block back to a factory & put on free list * - * Return: Success: Non-negative - * Failure: Negative + * Return: NULL * * Programmer: Quincey Koziol * Wednesday, February 2, 2005 * * Modifications: + * Neil Fortner + * Friday, December 19, 2008 + * Totally rewritten to support new factory implementation * *------------------------------------------------------------------------- */ void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_fac_free) + void *ret_value=NULL; /* Return value */ + + /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ + FUNC_ENTER_NOAPI_NOINIT(H5FL_fac_free) /* Double check parameters */ - assert(head); - assert(obj); + HDassert(head); + HDassert(obj); + +#ifdef H5FL_TRACK + { + H5FL_track_t *trk = obj = ((unsigned char *)obj) - sizeof(H5FL_track_t); + + /* Free tracking information about the allocation location */ + H5CS_close_stack(trk->stack); + trk->stack = H5MM_xfree(trk->stack); + trk->file = H5MM_xfree(trk->file); + trk->func = H5MM_xfree(trk->func); + + /* Remove from "outstanding allocations" list */ + if(trk == H5FL_out_head_g) { + H5FL_out_head_g = H5FL_out_head_g->next; + if(H5FL_out_head_g) + H5FL_out_head_g->prev = NULL; + } /* end if */ + else { + trk->prev->next = trk->next; + if(trk->next) + trk->next->prev = trk->prev; + } /* end else */ + } +#endif /* H5FL_TRACK */ + +#ifdef H5FL_DEBUG + HDmemset(obj,255,head->size); +#endif /* H5FL_DEBUG */ /* Make certain that the free list is initialized */ - assert(head->queue.init); + HDassert(head->init); - /* Use block routine */ - H5FL_blk_free(&(head->queue),obj); + /* Link into the free list */ + ((H5FL_fac_node_t *)obj)->next=head->list; - FUNC_LEAVE_NOAPI(NULL) + /* Point free list at the node freed */ + head->list=(H5FL_fac_node_t *)obj; + + /* Increment the number of blocks on free list */ + head->onlist++; + + /* Increment the amount of "factory" freed memory globally */ + H5FL_fac_gc_head.mem_freed+=head->size; + + /* Check for exceeding free list memory use limits */ + /* First check this particular list */ + if(head->onlist * head->size > H5FL_fac_lst_mem_lim) + if(H5FL_fac_gc_list(head)<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") + + /* Then check the global amount memory on factory free lists */ + if(H5FL_fac_gc_head.mem_freed > H5FL_fac_glb_mem_lim) + if(H5FL_fac_gc()<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, NULL, "garbage collection failed during free") + +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_fac_free() */ @@ -2042,6 +2088,9 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) * Wednesday, February 2, 2005 * * Modifications: + * Neil Fortner + * Friday, December 19, 2008 + * Totally rewritten to support new factory implementation * *------------------------------------------------------------------------- */ @@ -2050,13 +2099,54 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { void *ret_value; /* Pointer to object to return */ - FUNC_ENTER_NOAPI(H5FL_fac_malloc, NULL) + /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ + FUNC_ENTER_NOAPI_NOINIT(H5FL_fac_malloc) /* Double check parameters */ - assert(head); + HDassert(head); + HDassert(head->init); - /* Use block routine */ - ret_value=H5FL_blk_malloc(&(head->queue),head->size H5FL_TRACK_INFO_INT); + /* Check for nodes available on the free list first */ + if(head->list!=NULL) { + /* Get a pointer to the block on the free list */ + ret_value=(void *)(head->list); + + /* Remove node from free list */ + head->list=head->list->next; + + /* Decrement the number of blocks & memory on free list */ + head->onlist--; + + /* Decrement the amount of global "factory" free list memory in use */ + H5FL_fac_gc_head.mem_freed-=(head->size); + } /* end if */ + /* Otherwise allocate a node */ + else { + if (NULL==(ret_value = H5FL_malloc(head->size))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Increment the number of blocks allocated in list */ + head->allocated++; + } /* end else */ + +#ifdef H5FL_TRACK + /* Copy allocation location information */ + ((H5FL_track_t *)ret_value)->stack = H5MM_calloc(sizeof(H5CS_t)); + H5CS_copy_stack(((H5FL_track_t *)ret_value)->stack); + ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); + ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); + ((H5FL_track_t *)ret_value)->line = call_line; + + /* Add to "outstanding allocations" list */ + ((H5FL_track_t *)ret_value)->prev = NULL; + ((H5FL_track_t *)ret_value)->next = H5FL_out_head_g; + if(H5FL_out_head_g) + H5FL_out_head_g->prev = (H5FL_track_t *)ret_value; + H5FL_out_head_g = (H5FL_track_t *)ret_value; + + /* Adjust for allocation tracking information */ + ret_value = ((unsigned char *)ret_value) + sizeof(H5FL_track_t); +#endif /* H5FL_TRACK */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -2075,6 +2165,9 @@ done: * Wednesday, February 2, 2005 * * Modifications: + * Neil Fortner + * Friday, December 19, 2008 + * Totally rewritten to support new factory implementation * *------------------------------------------------------------------------- */ @@ -2083,17 +2176,115 @@ H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { void *ret_value; /* Pointer to object to return */ - FUNC_ENTER_NOAPI(H5FL_fac_calloc, NULL) + /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ + FUNC_ENTER_NOAPI_NOINIT(H5FL_fac_calloc) /* Double check parameters */ - assert(head); + HDassert(head); - /* Use block routine */ - ret_value=H5FL_blk_calloc(&(head->queue),head->size H5FL_TRACK_INFO_INT); + /* Allocate the block */ + if (NULL==(ret_value = H5FL_fac_malloc(head H5FL_TRACK_INFO_INT))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + /* Clear to zeros */ + /* (Accomodate tracking information, if present) */ + HDmemset(ret_value,0,head->size - H5FL_TRACK_SIZE); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_fac_calloc() */ + +/*------------------------------------------------------------------------- + * Function: H5FL_fac_gc_list + * + * Purpose: Garbage collect on a particular factory free list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Friday, December 19, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FL_fac_gc_list(H5FL_fac_head_t *head) +{ + H5FL_fac_node_t *free_list; /* Pointer to nodes in free list being garbage collected */ + void *tmp; /* Temporary node pointer */ + size_t total_mem; /* Total memory used on list */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_fac_gc_list) + + /* Calculate the total memory used on this list */ + total_mem=head->onlist*head->size; + + /* For each free list being garbage collected, walk through the nodes and free them */ + free_list=head->list; + while(free_list!=NULL) { + tmp=free_list->next; + + /* Decrement the count of nodes allocated and free the node */ + head->allocated--; + + H5MM_free(free_list); + + free_list = (H5FL_fac_node_t *)tmp; + } /* end while */ + + /* Indicate no free nodes on the free list */ + head->list=NULL; + head->onlist=0; + + /* Decrement global count of free memory on "factory" lists */ + H5FL_fac_gc_head.mem_freed-=total_mem; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FL_fac_gc_list() */ + + +/*------------------------------------------------------------------------- + * Function: H5FL_fac_gc + * + * Purpose: Garbage collect on all the factory free lists + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Friday, December 19, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FL_fac_gc(void) +{ + H5FL_fac_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */ + herr_t ret_value=SUCCEED; /* return value*/ + + FUNC_ENTER_NOAPI_NOINIT(H5FL_fac_gc) + + /* Walk through all the free lists, free()'ing the nodes */ + gc_node=H5FL_fac_gc_head.first; + while(gc_node!=NULL) { + /* Release the free nodes on the list */ + if(H5FL_fac_gc_list(gc_node->list)<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of list failed") + + /* Go on to the next free list to garbage collect */ + gc_node=gc_node->next; + } /* end while */ + + /* Double check that all the memory on the free lists is recycled */ + HDassert(H5FL_fac_gc_head.mem_freed==0); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FL_fac_gc() */ /*------------------------------------------------------------------------- @@ -2108,29 +2299,50 @@ done: * Wednesday, February 2, 2005 * * Modifications: + * Neil Fortner + * Friday, December 19, 2008 + * Totally rewritten to support new factory implementation * *------------------------------------------------------------------------- */ herr_t H5FL_fac_term(H5FL_fac_head_t *factory) { - herr_t ret_value=SUCCEED; /* Return value */ + H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + herr_t ret_value = SUCCEED; /* Return value */ + /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT(H5FL_fac_term) /* Sanity check */ HDassert(factory); /* Garbage collect all the blocks in the factory's free list */ - if(H5FL_blk_gc_list(&(factory->queue))<0) + if(H5FL_fac_gc_list(factory)<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of factory failed") /* Verify that all the blocks have been freed */ - if(factory->queue.allocated>0) + if(factory->allocated>0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "factory still has objects allocated") /* Unlink block free list for factory from global free list */ - H5FL_blk_unlink(&(factory->queue)); + if(factory->prev_gc) { + H5FL_fac_gc_node_t *last = factory->prev_gc; /* Garbage collection node before the one being removed */ + + HDassert(last->next->list == factory); + tmp = last->next->next; + (void)H5FL_FREE(H5FL_fac_gc_node_t, last->next); + last->next = tmp; + if(tmp) + tmp->list->prev_gc = last; + } else { + HDassert(H5FL_fac_gc_head.first->list == factory); + tmp = H5FL_fac_gc_head.first->next; + (void)H5FL_FREE(H5FL_fac_gc_node_t, H5FL_fac_gc_head.first); + H5FL_fac_gc_head.first = tmp; + if(tmp) + tmp->list->prev_gc = NULL; + } /* end else */ /* Free factory info */ (void)H5FL_FREE(H5FL_fac_head_t, factory); @@ -2141,6 +2353,52 @@ done: /*------------------------------------------------------------------------- + * Function: H5FL_fac_term_all + * + * Purpose: Terminate all block factories + * + * Return: 0. There should never be any outstanding allocations + * when this is called. + * + * Programmer: Neil Fortner + * Friday, December 19, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +H5FL_fac_term_all(void) +{ + H5FL_fac_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_fac_term_all) + + /* Free the nodes on the garbage collection list */ + while(H5FL_fac_gc_head.first != NULL) { + tmp=H5FL_fac_gc_head.first->next; + +#ifdef H5FL_DEBUG +printf("H5FL_fac_term: head->size=%d, head->allocated=%d\n", (int)H5FL_fac_gc_head.first->list->size,(int)H5FL_fac_gc_head.first->list->allocated); +#endif /* H5FL_DEBUG */ + + /* The list cannot have any allocations outstanding */ + HDassert(H5FL_fac_gc_head.first->list->allocated == 0); + + /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ + H5FL_fac_gc_head.first->list->init = 0; + + /* Free the node from the garbage collection list */ + (void)H5FL_FREE(H5FL_fac_gc_node_t, H5FL_fac_gc_head.first); + + H5FL_fac_gc_head.first = tmp; + } /* end while */ + + FUNC_LEAVE_NOAPI(0) +} /* end H5FL_fac_term_all() */ + + +/*------------------------------------------------------------------------- * Function: H5FL_garbage_coll * * Purpose: Garbage collect on all the free lists @@ -2160,7 +2418,7 @@ H5FL_garbage_coll(void) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT(H5FL_garbage_coll) + FUNC_ENTER_NOAPI(H5FL_garbage_coll, FAIL) /* Garbage collect the free lists for array objects */ if(H5FL_arr_gc()<0) @@ -2174,6 +2432,10 @@ H5FL_garbage_coll(void) if(H5FL_reg_gc()<0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect regular objects") + /* Garbage collect the free lists for factory objects */ + if(H5FL_fac_gc()<0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "can't garbage collect regular objects") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_garbage_coll() */ @@ -2204,13 +2466,16 @@ done: * Programmer: Quincey Koziol * Wednesday, August 2, 2000 * - * Modifications: + * Modifications: Neil Fortner + * Wednesday, April 8, 2009 + * Added support for factory free lists * *------------------------------------------------------------------------- */ herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, - int arr_list_lim, int blk_global_lim, int blk_list_lim) + int arr_list_lim, int blk_global_lim, int blk_list_lim, int fac_global_lim, + int fac_list_lim) { herr_t ret_value = SUCCEED; @@ -2229,6 +2494,10 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l H5FL_blk_glb_mem_lim=(blk_global_lim==-1 ? UINT_MAX : (size_t)blk_global_lim); /* limit on each block free list */ H5FL_blk_lst_mem_lim=(blk_list_lim==-1 ? UINT_MAX : (size_t)blk_list_lim); + /* limit on all factory free lists */ + H5FL_fac_glb_mem_lim=(fac_global_lim==-1 ? UINT_MAX : (size_t)fac_global_lim); + /* limit on each factory free list */ + H5FL_fac_lst_mem_lim=(fac_list_lim==-1 ? UINT_MAX : (size_t)fac_list_lim); done: FUNC_LEAVE_NOAPI(ret_value) @@ -2264,7 +2533,7 @@ H5FL_term_interface(void) /* Garbage collect any nodes on the free lists */ (void)H5FL_garbage_coll(); - ret_value=H5FL_reg_term()+H5FL_arr_term()+H5FL_blk_term(); + ret_value=H5FL_reg_term()+H5FL_fac_term_all()+H5FL_arr_term()+H5FL_blk_term(); #ifdef H5FL_TRACK /* If we haven't freed all the allocated memory, dump out the list now */ diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index a799dc4..ea2ec55 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -100,7 +100,6 @@ typedef struct H5FL_reg_head_t { unsigned init; /* Whether the free list has been initialized */ unsigned allocated; /* Number of blocks allocated */ unsigned onlist; /* Number of blocks on free list */ - size_t list_mem; /* Amount of memory on free list */ const char *name; /* Name of the type */ size_t size; /* Size of the blocks in the list */ H5FL_reg_node_t *list; /* List of free blocks */ @@ -112,7 +111,7 @@ typedef struct H5FL_reg_head_t { #define H5FL_REG_NAME(t) H5_##t##_reg_free_list #ifndef H5_NO_REG_FREE_LISTS /* Common macros for H5FL_DEFINE & H5FL_DEFINE_STATIC */ -#define H5FL_DEFINE_COMMON(t) H5FL_reg_head_t H5FL_REG_NAME(t)={0,0,0,0,#t,sizeof(t),NULL} +#define H5FL_DEFINE_COMMON(t) H5FL_reg_head_t H5FL_REG_NAME(t)={0,0,0,#t,sizeof(t),NULL} /* Declare a free list to manage objects of type 't' */ #define H5FL_DEFINE(t) H5_DLL H5FL_DEFINE_COMMON(t) @@ -349,12 +348,21 @@ typedef struct H5FL_seq_head_t { #define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5MM_realloc(obj,(new_elem)*sizeof(t)) #endif /* H5_NO_SEQ_FREE_LISTS */ +/* Forward declarations of the data structures for free list block factory */ +typedef struct H5FL_fac_gc_node_t H5FL_fac_gc_node_t; +typedef struct H5FL_fac_node_t H5FL_fac_node_t; + /* Data structure for free list block factory */ typedef struct H5FL_fac_head_t { - H5FL_blk_head_t queue; /* Priority queue of blocks */ - size_t size; /* Size of the blocks managed */ + unsigned init; /* Whether the free list has been initialized */ + unsigned allocated; /* Number of blocks allocated */ + unsigned onlist; /* Number of blocks on free list */ + size_t size; /* Size of the blocks in the list */ + H5FL_fac_node_t *list; /* List of free blocks */ + H5FL_fac_gc_node_t *prev_gc; /* Previous garbage collection node in list */ } H5FL_fac_head_t; + /* * Macros for defining & using free list factories * @@ -381,30 +389,42 @@ typedef struct H5FL_fac_head_t { /* * Library prototypes. */ + /* Block free lists */ H5_DLL void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS); H5_DLL void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS); H5_DLL void * H5FL_blk_free(H5FL_blk_head_t *head, void *block); H5_DLL void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_PARAMS); H5_DLL htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size); + +/* Regular free lists */ H5_DLL void * H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); H5_DLL void * H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); H5_DLL void * H5FL_reg_free(H5FL_reg_head_t *head, void *obj); + +/* Array free lists */ H5_DLL void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem); H5_DLL void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem); H5_DLL void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj); H5_DLL void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); + +/* Sequence free lists */ H5_DLL void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); H5_DLL void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); H5_DLL void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj); H5_DLL void * H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS); + +/* Factory free lists */ H5_DLL H5FL_fac_head_t *H5FL_fac_init(size_t size); H5_DLL void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); H5_DLL void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); H5_DLL void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj); H5_DLL herr_t H5FL_fac_term(H5FL_fac_head_t *head); + +/* General free list routines */ H5_DLL herr_t H5FL_garbage_coll(void); H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, - int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); + int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim, + int fac_global_lim, int fac_list_lim); H5_DLL int H5FL_term_interface(void); #endif diff --git a/src/H5FO.c b/src/H5FO.c index fe3eaa9..33241f0 100644 --- a/src/H5FO.c +++ b/src/H5FO.c @@ -82,7 +82,7 @@ H5FO_create(const H5F_t *f) assert(f->shared); /* Create container used to store open object info */ - if((f->shared->open_objs = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16)) == NULL) + if((f->shared->open_objs = H5SL_create(H5SL_TYPE_HADDR)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create open object container") done: @@ -400,7 +400,7 @@ H5FO_top_create(H5F_t *f) HDassert(f); /* Create container used to store open object info */ - if((f->obj_count = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16)) == NULL) + if((f->obj_count = H5SL_create(H5SL_TYPE_HADDR)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create open object container") done: diff --git a/src/H5FScache.c b/src/H5FScache.c index a7af72b..5d901e9 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -100,6 +100,7 @@ const H5AC_class_t H5AC_FSPACE_HDR[1] = {{ (H5AC_flush_func_t)H5FS_cache_hdr_flush, (H5AC_dest_func_t)H5FS_cache_hdr_dest, (H5AC_clear_func_t)H5FS_cache_hdr_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5FS_cache_hdr_size, }}; @@ -110,6 +111,7 @@ const H5AC_class_t H5AC_FSPACE_SINFO[1] = {{ (H5AC_flush_func_t)H5FS_cache_sinfo_flush, (H5AC_dest_func_t)H5FS_cache_sinfo_dest, (H5AC_clear_func_t)H5FS_cache_sinfo_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5FS_cache_sinfo_size, }}; @@ -201,7 +203,7 @@ HDfprintf(stderr, "%s: Load free space header, addr = %a\n", FUNC, addr); HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space header version") /* Client ID */ - fspace->client = *p++; + fspace->client = (H5FS_client_t)*p++; if(fspace->client >= H5FS_NUM_CLIENT_ID) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "unknown client ID in free space header") diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 42c0f86..9ad6c70 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -45,9 +45,6 @@ /* Default starting size of section buffer */ #define H5FS_SINFO_SIZE_DEFAULT 64 -/* Max. height of the skip list holding free list nodes */ -#define H5FS_DEFAULT_SKIPLIST_HEIGHT 16 - /******************/ /* Local Typedefs */ @@ -235,7 +232,7 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space section info") /* Re-protect the section info with read-write access */ - if(NULL == (fspace->sinfo = H5AC_protect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, NULL, fspace, H5AC_WRITE))) + if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, NULL, fspace, H5AC_WRITE))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to load free space sections") /* Switch the access mode we have */ @@ -254,7 +251,7 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); #endif /* H5FS_SINFO_DEBUG */ /* Protect the free space sections */ - if(NULL == (fspace->sinfo = H5AC_protect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, NULL, fspace, accmode))) + if(NULL == (fspace->sinfo = (H5FS_sinfo_t *)H5AC_protect(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, NULL, fspace, accmode))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to load free space sections") /* Remember that we protected the section info & the access mode */ @@ -962,7 +959,7 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s bin = H5V_log2_gen(sect->size); HDassert(bin < sinfo->nbins); if(sinfo->bins[bin].bin_list == NULL) { - if(NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE, 0.5, (size_t)H5FS_DEFAULT_SKIPLIST_HEIGHT))) + if(NULL == (sinfo->bins[bin].bin_list = H5SL_create(H5SL_TYPE_HSIZE))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes") } /* end if */ else { @@ -979,7 +976,7 @@ HDfprintf(stderr, "%s: sect->size = %Hu, sect->addr = %a\n", FUNC, sect->size, s /* Initialize the free list size node */ fspace_node->sect_size = sect->size; fspace_node->serial_count = fspace_node->ghost_count = 0; - if(NULL == (fspace_node->sect_list = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)H5FS_DEFAULT_SKIPLIST_HEIGHT))) + if(NULL == (fspace_node->sect_list = H5SL_create(H5SL_TYPE_HADDR))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for free space nodes") /* Insert new free space size node into bin's list */ @@ -1058,7 +1055,7 @@ H5FS_sect_link_rest(H5FS_t *fspace, const H5FS_section_class_t *cls, HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, (unsigned)sect->type); #endif /* QAK */ if(fspace->sinfo->merge_list == NULL) - if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)H5FS_DEFAULT_SKIPLIST_HEIGHT))) + if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for merging free space sections") if(H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into merging skip list") @@ -1189,7 +1186,7 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) greater_sect_node_valid = TRUE; /* Get section for 'less than' skip list node */ - tmp_sect = H5SL_item(less_sect_node); + tmp_sect = (H5FS_section_info_t *)H5SL_item(less_sect_node); /* Get classes for right & left sections */ tmp_sect_cls = &fspace->sect_cls[tmp_sect->type]; @@ -1232,7 +1229,7 @@ H5FS_sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) /* Check for node after new node able to merge with new node */ if(greater_sect_node) { /* Get section for 'greater than' skip list node */ - tmp_sect = H5SL_item(greater_sect_node); + tmp_sect = (H5FS_section_info_t *)H5SL_item(greater_sect_node); /* Get classes for right & left sections */ sect_cls = &fspace->sect_cls[(*sect)->type]; @@ -1310,7 +1307,7 @@ HDfprintf(stderr, "%s: Can shrink!\n", FUNC); /* Check for last node in the merge list */ if(NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { /* Get the pointer to the last section, from the last node */ - *sect = H5SL_item(last_node); + *sect = (H5FS_section_info_t *)H5SL_item(last_node); HDassert(*sect); /* Indicate that this section needs to be removed if it causes a shrink */ @@ -1503,7 +1500,7 @@ if(_section_) */ /* Look for a section after block to extend */ - if((sect = H5SL_greater(fspace->sinfo->merge_list, &addr))) { + if((sect = (H5FS_section_info_t *)H5SL_greater(fspace->sinfo->merge_list, &addr))) { /* Check if this section adjoins the block and is large enough to * fulfill extension request. * @@ -1643,10 +1640,10 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); H5SL_node_t *curr_sect_node=NULL; /* Get the free space node for free space sections of the same size */ - curr_fspace_node = H5SL_item(curr_size_node); + curr_fspace_node = (H5FS_node_t *)H5SL_item(curr_size_node); /* Get the Skip list which holds pointers to actual free list sections */ - curr_sect_node = H5SL_first(curr_fspace_node->sect_list); + curr_sect_node = (H5SL_node_t *)H5SL_first(curr_fspace_node->sect_list); while(curr_sect_node != NULL) { H5FS_section_info_t *curr_sect=NULL; @@ -1654,7 +1651,7 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); H5FS_section_info_t *split_sect=NULL; /* Get section node */ - curr_sect = H5SL_item(curr_sect_node); + curr_sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node); HDassert(H5F_addr_defined(curr_sect->addr)); HDassert(curr_fspace_node->sect_size == curr_sect->size); @@ -1669,7 +1666,7 @@ HDfprintf(stderr, "%s: bin = %u\n", FUNC, bin); if ((curr_sect->size >= (request + frag_size)) && (cls->split)) { /* remove the section with aligned address */ - if(NULL == (*node = H5SL_remove(curr_fspace_node->sect_list, &curr_sect->addr))) + if(NULL == (*node = (H5FS_section_info_t *)H5SL_remove(curr_fspace_node->sect_list, &curr_sect->addr))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTREMOVE, FAIL, "can't remove free space node from skip list") /* Decrement # of sections in section size node */ if(H5FS_size_node_decr(fspace->sinfo, bin, curr_fspace_node, cls) < 0) @@ -2101,7 +2098,7 @@ HDfprintf(stderr, "%s: to_mergable = %u\n", FUNC, to_mergable); HDfprintf(stderr, "%s: inserting object into merge list, sect->type = %u\n", FUNC, (unsigned)sect->type); #endif /* QAK */ if(fspace->sinfo->merge_list == NULL) - if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)H5FS_DEFAULT_SKIPLIST_HEIGHT))) + if(NULL == (fspace->sinfo->merge_list = H5SL_create(H5SL_TYPE_HADDR))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCREATE, FAIL, "can't create skip list for merging free space sections") if(H5SL_insert(fspace->sinfo->merge_list, sect, §->addr) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space node into merging skip list") diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 4080705..49af73e 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -158,7 +158,8 @@ typedef struct H5F_file_t { int ncwfs; /* Num entries on cwfs list */ struct H5HG_heap_t **cwfs; /* Global heap cache */ struct H5G_t *root_grp; /* Open root group */ - H5G_entry_t *root_ent; /* Root group symbol table entry */ + H5G_entry_t *root_ent; /* Root group symbol table entry */ + haddr_t root_addr; /* Root group address */ H5FO_t *open_objs; /* Open objects in file */ H5RC_t *grp_btree_shared; /* Ref-counted group B-tree node info */ @@ -225,7 +226,7 @@ H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nop /* Superblock related routines */ H5_DLL herr_t H5F_super_init(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_write(H5F_t *f, hid_t dxpl_id); -H5_DLL herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc); +H5_DLL herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_ext_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_ext_info); /* Metadata accumulator routines */ @@ -247,6 +248,7 @@ H5_DLL herr_t H5F_sfile_remove(H5F_file_t *shared); #ifdef H5F_TESTING H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id, size_t *mesg_count); +H5_DLL herr_t H5F_check_cached_stab_test(hid_t file_id); #endif /* H5F_TESTING */ #endif /* _H5Fpkg_H */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 70e0954..32541ae 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -32,6 +32,7 @@ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ @@ -230,7 +231,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc) +H5F_super_read(H5F_t *f, hid_t dxpl_id) { uint8_t sbuf[H5F_MAX_SUPERBLOCK_SIZE]; /* Buffer for superblock */ H5P_genplist_t *c_plist; /* File creation property list */ @@ -383,8 +384,9 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc) H5F_addr_decode(f, (const uint8_t **)&p, &shared->extension_addr/*out*/); H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/); H5F_addr_decode(f, (const uint8_t **)&p, &shared->driver_addr/*out*/); - if(H5G_obj_ent_decode(f, (const uint8_t **)&p, root_loc->oloc/*out*/, - &shared->root_ent/*out*/) < 0) + + /* Decode the symbol table entry */ + if(H5G_root_ent_decode(f, (const uint8_t **)&p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read root symbol entry") /* @@ -468,7 +470,6 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc) } /* end if */ } /* end if */ else { - haddr_t root_addr; /* Address of root group */ uint32_t computed_chksum; /* Computed checksum */ uint32_t read_chksum; /* Checksum read from file */ @@ -499,7 +500,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc) H5F_addr_decode(f, (const uint8_t **)&p, &shared->base_addr/*out*/); H5F_addr_decode(f, (const uint8_t **)&p, &shared->extension_addr/*out*/); H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/); - H5F_addr_decode(f, (const uint8_t **)&p, &root_addr/*out*/); + H5F_addr_decode(f, (const uint8_t **)&p, &shared->root_addr/*out*/); /* Compute checksum for superblock */ computed_chksum = H5_checksum_metadata(sbuf, (size_t)(p - sbuf), 0); @@ -511,11 +512,6 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc) if(read_chksum != computed_chksum) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad checksum on driver information block") - /* Create root group object location */ - H5O_loc_reset(root_loc->oloc); - root_loc->oloc->file = f; - root_loc->oloc->addr = root_addr; - /* * Check if superblock address is different from base address and * adjust base address and "end of address" address if so. @@ -560,7 +556,8 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc) * Tell the file driver how much address space has already been * allocated so that it knows how to allocate additional memory. */ - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, stored_eoa) < 0) + /* (Account for the stored EOA being absolute offset -NAF) */ + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, stored_eoa - H5F_BASE_ADDR(f)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to set end-of-address marker for file") /* Read the file's superblock extension, if there is one. */ @@ -929,12 +926,22 @@ H5F_super_write(H5F_t *f, hid_t dxpl_id) rel_eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER); H5F_addr_encode(f, &p, (rel_eoa + f->shared->base_addr)); H5F_addr_encode(f, &p, f->shared->driver_addr); - if(H5G_obj_ent_encode(f, &p, H5G_oloc(f->shared->root_grp)) < 0) + + /* Encode the root group object entry, including the cached stab info */ + if(H5G_root_ent_encode(f, &p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode root group information") /* Encode the driver information block. */ H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t); - if(driver_size > 0) { + + /* Checking whether driver block address is defined here is to handle backward + * compatibility. If the file was created with v1.6 library or earlier and no + * driver info block was written in the superblock, we don't write it either even + * though there's some driver info. Otherwise, the driver block extended will + * overwrite the (meta)data right after the superblock. This situation happens to + * the family driver particularly. SLU - 2009/3/24 + */ + if(driver_size > 0 && H5F_addr_defined(f->shared->driver_addr)) { char driver_name[9]; /* Name of driver, for driver info block */ uint8_t *dbuf = p; /* Pointer to beginning of driver info */ diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 1d7e514..8cbc133 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -32,6 +32,8 @@ #define H5F_TESTING /*suppress warning about H5F testing funcs*/ #define H5SM_PACKAGE /*suppress error about including H5SMpkg */ #define H5SM_TESTING /*suppress warning about H5SM testing funcs*/ +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#define H5G_TESTING /*suppress warning about H5G testing funcs*/ /***********/ @@ -40,6 +42,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5SMpkg.h" /* Shared object header messages */ @@ -113,3 +116,40 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_sohm_mesg_count_test() */ + +/*------------------------------------------------------------------------- + * Function: H5F_check_cached_stab_test + * + * Purpose: Check that a file's superblock contains a cached symbol + * table entry, that the entry matches that in the root + * group's object header, and check that the addresses are + * valid. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Mar 31, 2009 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_check_cached_stab_test(hid_t file_id) +{ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5F_check_cached_stab_test) + + /* Check arguments */ + if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + + /* Verify the cached stab info */ + if(H5G_verify_cached_stab_test(H5G_oloc(file->shared->root_grp), file->shared->root_ent) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to verify cached symbol table info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_check_cached_stab_test() */ + diff --git a/src/H5G.c b/src/H5G.c index 042ce90..2afd837 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -817,141 +817,6 @@ H5G_term_interface(void) /*------------------------------------------------------------------------- - * Function: H5G_mkroot - * - * Purpose: Creates a root group in an empty file and opens it. If a - * root group is already open then this function immediately - * returns. If ENT is non-null then it's the symbol table - * entry for an existing group which will be opened as the root - * group. Otherwise a new root group is created and then - * opened. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 11 1997 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_mkroot(H5F_t *f, hid_t dxpl_id, H5G_loc_t *loc) -{ - H5O_loc_t new_root_oloc; /* New root object location */ - H5G_name_t new_root_path; /* New root path */ - H5G_loc_t new_root_loc; /* New root location information */ - H5G_loc_t root_loc; /* Root location information */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_mkroot, FAIL) - - /* check args */ - HDassert(f); - - /* Check if the root group is already initialized */ - if(f->shared->root_grp) - HGOTO_DONE(SUCCEED) - - /* Create information needed for group nodes */ - if(H5G_node_init(f) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group node info") - - /* - * If there is no root object then create one. The root group always starts - * with a hard link count of one since it's pointed to by the superblock. - */ - if(loc == NULL) { - H5P_genplist_t *fc_plist; /* File creation property list */ - H5O_ginfo_t ginfo; /* Group info parameters */ - H5O_linfo_t linfo; /* Link info parameters */ - - /* Get the file creation property list */ - /* (Which is a sub-class of the group creation property class) */ - if(NULL == (fc_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Get the group info property */ - if(H5P_get(fc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") - - /* Get the link info property */ - if(H5P_get(fc_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") - - /* Set up group location for root group */ - new_root_loc.oloc = &new_root_oloc; - new_root_loc.path = &new_root_path; - H5G_loc_reset(&new_root_loc); - loc = &new_root_loc; - - /* Create root group */ - if(H5G_obj_create(f, dxpl_id, &ginfo, &linfo, f->shared->fcpl_id, loc->oloc/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") - if(1 != H5O_link(loc->oloc, 1, dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)") - } /* end if */ - else { - /* - * Open the root object as a group. - */ - if(H5O_open(loc->oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group") - -#ifndef H5_STRICT_FORMAT_CHECKS - /* If symbol table information is cached, check if we should replace the - * symbol table message with the cached symbol table information */ - if((H5F_INTENT(f) & H5F_ACC_RDWR) && f->shared->root_ent - && (f->shared->root_ent->type == H5G_CACHED_STAB)) { - H5O_stab_t cached_stab; - - /* Retrieve the cached symbol table information */ - cached_stab.btree_addr = f->shared->root_ent->cache.stab.btree_addr; - cached_stab.heap_addr = f->shared->root_ent->cache.stab.heap_addr; - - /* Check if the symbol table message is valid, and replace with the - * cached symbol table if necessary */ - if(H5G_stab_valid(loc->oloc, dxpl_id, &cached_stab) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to verify symbol table") - } /* end if */ -#endif /* H5_STRICT_FORMAT_CHECKS */ - } /* end else */ - - /* Create the path names for the root group's entry */ - H5G_name_init(loc->path, "/"); - - /* - * Create the group pointer. Also decrement the open object count so we - * don't count the root group as an open object. The root group will - * never be closed. - */ - if(NULL == (f->shared->root_grp = H5FL_CALLOC(H5G_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (f->shared->root_grp->shared = H5FL_CALLOC(H5G_shared_t))) { - (void)H5FL_FREE(H5G_t, f->shared->root_grp); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - } /* end if */ - - /* Shallow copy (take ownership) of the group object info */ - root_loc.oloc = &(f->shared->root_grp->oloc); - root_loc.path = &(f->shared->root_grp->path); - if(H5G_loc_copy(&root_loc, loc, H5_COPY_SHALLOW) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "can't copy group object location") - - f->shared->root_grp->shared->fo_count = 1; - /* The only other open object should be the superblock extension, if it - * exists. Don't count either the superblock extension or the root group - * in the number of open objects in the file. - */ - HDassert((1 == f->nopen_objs) || - (2 == f->nopen_objs && HADDR_UNDEF != f->shared->extension_addr)); - f->nopen_objs--; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_mkroot() */ - - -/*------------------------------------------------------------------------- * Function: H5G_create * * Purpose: Creates a new empty group with the specified name. The name @@ -1351,36 +1216,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_rootof - * - * Purpose: Return a pointer to the root group of the file. If the file - * is part of a virtual file then the root group of the virtual - * file is returned. - * - * Return: Success: Ptr to the root group of the file. Do not - * free the pointer -- it points directly into - * the file struct. - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Tuesday, October 13, 1998 - * - *------------------------------------------------------------------------- - */ -H5G_t * -H5G_rootof(H5F_t *f) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_rootof) - - while(f->parent) - f = f->parent; - - FUNC_LEAVE_NOAPI(f->shared->root_grp) -} /* end H5G_rootof() */ - - -/*------------------------------------------------------------------------- * Function: H5G_oloc * * Purpose: Returns a pointer to the object location for a group. @@ -1975,7 +1810,7 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, udata.curr_path_len = 0; /* Create skip list to store visited object information */ - if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, 0.5, (size_t)16)) == NULL) + if((udata.visited = H5SL_create(H5SL_TYPE_OBJ)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects") /* Get the group's reference count and type */ diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index c16fc16..9afd882 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -389,8 +389,8 @@ H5G_dense_btree2_name_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dx FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_dense_btree2_name_debug) - HDfprintf(stream, "%*s%-*s {%lx, ", indent, "", fwidth, "Record:", - nrecord->hash); + HDfprintf(stream, "%*s%-*s {%x, ", indent, "", fwidth, "Record:", + (unsigned)nrecord->hash); for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) HDfprintf(stderr, "%02x%s", nrecord->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); @@ -579,8 +579,8 @@ H5G_dense_btree2_corder_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_dense_btree2_corder_debug) - HDfprintf(stream, "%*s%-*s {%Hu, ", indent, "", fwidth, "Record:", - nrecord->corder); + HDfprintf(stream, "%*s%-*s {%llu, ", indent, "", fwidth, "Record:", + (unsigned long long)nrecord->corder); for(u = 0; u < H5G_DENSE_FHEAP_ID_LEN; u++) HDfprintf(stderr, "%02x%s", nrecord->id[u], (u < (H5G_DENSE_FHEAP_ID_LEN - 1) ? " " : "}\n")); diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 0e2a699..c17c97f 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -94,6 +94,7 @@ const H5AC_class_t H5AC_SNODE[1] = {{ (H5AC_flush_func_t)H5G_node_flush, (H5AC_dest_func_t)H5G_node_dest, (H5AC_clear_func_t)H5G_node_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5G_node_size, }}; diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 2eb1924..08a9268 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -221,115 +221,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_obj_ent_decode - * - * Purpose: Decodes a symbol table entry into a object location - * - * Return: Success: Non-negative with *pp pointing to the first byte - * following the symbol table entry. - * - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 26 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_obj_ent_decode(H5F_t *f, const uint8_t **pp, H5O_loc_t *oloc, H5G_entry_t **entp) -{ - const uint8_t *p_ret = *pp; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_obj_ent_decode, FAIL) - - /* check arguments */ - HDassert(f); - HDassert(pp); - HDassert(oloc); - - if(entp) { - /* If entp is not NULL we allocate space for the symbol table entry and - * decode the entire entry. */ - if(!(*entp)) /* Only allocate space if *entp is NULL */ - if(NULL == (*entp = (H5G_entry_t *) H5MM_calloc(sizeof(H5G_entry_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") - if(H5G_ent_decode_vec(f, pp, *entp, 1) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode symbol table entry") - - /* Set oloc to the correct values */ - oloc->file = (*entp)->file; - oloc->addr = (*entp)->header; - } else { - /* Set file pointer for root object location */ - oloc->file = f; - - /* decode header */ - *pp += H5F_SIZEOF_SIZE(f); /* Skip over local heap address */ - H5F_addr_decode(f, pp, &(oloc->addr)); - *pp += 4; /* Skip over "cache type" */ - *pp += 4; /* Reserved */ - } - - /* Common oloc settings */ - oloc->holding_file = FALSE; - - /* Set decode pointer */ - *pp = p_ret + H5G_SIZEOF_ENTRY(f); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_obj_ent_decode() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_obj_ent_encode - * - * Purpose: Encodes the specified object location into a symbol table - * entry in the buffer pointed to by *pp. - * - * Return: Success: Non-negative, with *pp pointing to the first byte - * after the symbol table entry. - * - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 26 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_obj_ent_encode(const H5F_t *f, uint8_t **pp, const H5O_loc_t *oloc) -{ - uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); - - FUNC_ENTER_NOAPI_NOFUNC(H5G_obj_ent_encode) - - /* check arguments */ - HDassert(f); - HDassert(pp); - - /* encode header */ - H5F_ENCODE_LENGTH(f, *pp, 0); /* No name for root group */ - if(oloc) - H5F_addr_encode(f, pp, oloc->addr); - else - H5F_addr_encode(f, pp, HADDR_UNDEF); - UINT32ENCODE(*pp, H5G_NOTHING_CACHED); - UINT32ENCODE(*pp, 0); /*reserved*/ - - /* fill with zero */ - while(*pp < p_ret) - *(*pp)++ = 0; - *pp = p_ret; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_obj_ent_encode() */ - - -/*------------------------------------------------------------------------- * Function: H5G_obj_get_linfo * * Purpose: Retrieves the "link info" message for an object. Also diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 38c7628..3d25109 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -144,13 +144,15 @@ struct H5G_t { typedef herr_t (*H5G_lib_iterate_t)(const H5O_link_t *lnk, void *op_data); /* Describe kind of callback to make for each link */ -typedef struct { - enum { +typedef enum H5G_link_iterate_op_type_t { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5G_LINK_OP_OLD, /* "Old" application callback */ + H5G_LINK_OP_OLD, /* "Old" application callback */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5G_LINK_OP_NEW /* "New" application callback */ - } op_type; + H5G_LINK_OP_NEW /* "New" application callback */ +} H5G_link_iterate_op_type_t; + +typedef struct { + H5G_link_iterate_op_type_t op_type; union { #ifndef H5_NO_DEPRECATED_SYMBOLS H5G_iterate_t op_old; /* "Old" application callback for each link */ @@ -340,6 +342,12 @@ H5_DLLVAR const H5B2_class_t H5G_BT2_NAME[1]; /* The v2 B-tree class for indexing 'creation order' field on links */ H5_DLLVAR const H5B2_class_t H5G_BT2_CORDER[1]; +/* Free list for managing H5G_t structs */ +H5FL_EXTERN(H5G_t); + +/* Free list for managing H5G_shared_t structs */ +H5FL_EXTERN(H5G_shared_t); + /******************************/ /* Package Private Prototypes */ /******************************/ @@ -565,6 +573,7 @@ H5_DLL htri_t H5G_is_new_dense_test(hid_t gid); H5_DLL herr_t H5G_new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count); H5_DLL herr_t H5G_lheap_size_test(hid_t gid, size_t *lheap_size); H5_DLL herr_t H5G_user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *user_path_hidden); +H5_DLL herr_t H5G_verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent); #endif /* H5G_TESTING */ #endif /* _H5Gpkg_H */ diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index b1db96f..7f001e0 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -151,7 +151,7 @@ typedef struct H5G_entry_t H5G_entry_t; * Library prototypes... These are the ones that other packages routinely * call. */ -H5_DLL herr_t H5G_mkroot(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc); +H5_DLL herr_t H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root); H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp); H5_DLL H5G_t *H5G_rootof(H5F_t *f); H5_DLL H5G_name_t * H5G_nameof(H5G_t *grp); @@ -181,10 +181,8 @@ H5_DLL herr_t H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream /* * These functions operate on group object locations. */ -H5_DLL herr_t H5G_obj_ent_decode(H5F_t *f, const uint8_t **pp, - struct H5O_loc_t *oloc, H5G_entry_t **entp); -H5_DLL herr_t H5G_obj_ent_encode(const H5F_t *f, uint8_t **pp, - const struct H5O_loc_t *oloc); +H5_DLL herr_t H5G_root_ent_decode(H5F_t *f, const uint8_t **pp); +H5_DLL herr_t H5G_root_ent_encode(H5F_t *f, uint8_t **pp); /* * These functions operate on group hierarchy names. diff --git a/src/H5Groot.c b/src/H5Groot.c new file mode 100644 index 0000000..b8a1468 --- /dev/null +++ b/src/H5Groot.c @@ -0,0 +1,368 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /*------------------------------------------------------------------------- + * + * Created: H5Gobj.c + * Apr 8 2009 + * Neil Fortner + * + * Purpose: Functions for operating on the root group. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property Lists */ + + + +/*------------------------------------------------------------------------- + * Function: H5G_rootof + * + * Purpose: Return a pointer to the root group of the file. If the file + * is part of a virtual file then the root group of the virtual + * file is returned. + * + * Return: Success: Ptr to the root group of the file. Do not + * free the pointer -- it points directly into + * the file struct. + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Tuesday, October 13, 1998 + * + *------------------------------------------------------------------------- + */ +H5G_t * +H5G_rootof(H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_rootof) + + while(f->parent) + f = f->parent; + + FUNC_LEAVE_NOAPI(f->shared->root_grp) +} /* end H5G_rootof() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_root_ent_decode + * + * Purpose: Decodes the root group symbol table entry into the file + * structure, and updates the root group address in the file + * structure. + * + * Return: Success: Non-negative with *pp pointing to the first byte + * following the symbol table entry. + * + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Sep 26 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_root_ent_decode(H5F_t *f, const uint8_t **pp) +{ + const uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_root_ent_decode, FAIL) + + /* check arguments */ + HDassert(f); + HDassert(pp); + + /* Allocate space for the root group symbol table entry */ + HDassert(!f->shared->root_ent); + if(NULL == (f->shared->root_ent = (H5G_entry_t *) H5MM_calloc(sizeof(H5G_entry_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") + + /* decode the root group symbol table entry */ + if(H5G_ent_decode_vec(f, pp, f->shared->root_ent, 1) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode symbol table entry") + + /* Set the root group address to the correct value */ + f->shared->root_addr = f->shared->root_ent->header; + + /* Set decode pointer */ + *pp = p_ret; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_root_ent_decode() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_root_ent_encode + * + * Purpose: Encodes the root group symbol table entry into the buffer + * pointed to by *pp. + * + * Return: Success: Non-negative, with *pp pointing to the first byte + * after the symbol table entry. + * + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Sep 26 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_root_ent_encode(H5F_t *f, uint8_t **pp) +{ + uint8_t *p_ret = *pp + H5G_SIZEOF_ENTRY(f); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_root_ent_encode, FAIL) + + /* check arguments */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->root_ent); + HDassert(pp); + + /* Encode entry */ + if(H5G_ent_encode_vec(f, pp, f->shared->root_ent, 1) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode symbol table entry") + + /* Set encode pointer */ + *pp = p_ret; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_root_ent_encode() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_mkroot + * + * Purpose: Creates a root group in an empty file and opens it. If a + * root group is already open then this function immediately + * returns. If ENT is non-null then it's the symbol table + * entry for an existing group which will be opened as the root + * group. Otherwise a new root group is created and then + * opened. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * matzke@llnl.gov + * Aug 11 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) +{ + H5G_loc_t root_loc; /* Root location information */ + htri_t stab_exists = -1; /* Whether the symbol table exists */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_mkroot, FAIL) + + /* check args */ + HDassert(f); + + /* Check if the root group is already initialized */ + if(f->shared->root_grp) + HGOTO_DONE(SUCCEED) + + /* Create information needed for group nodes */ + if(H5G_node_init(f) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group node info") + + /* + * Create the group pointer + */ + if(NULL == (f->shared->root_grp = H5FL_CALLOC(H5G_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if(NULL == (f->shared->root_grp->shared = H5FL_CALLOC(H5G_shared_t))) { + (void)H5FL_FREE(H5G_t, f->shared->root_grp); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + } /* end if */ + + /* Initialize the root_loc structure to point to fields in the newly created + * f->shared->root_grp structure */ + root_loc.oloc = &(f->shared->root_grp->oloc); + root_loc.path = &(f->shared->root_grp->path); + H5G_loc_reset(&root_loc); + + /* + * If there is no root object then create one. The root group always starts + * with a hard link count of one since it's pointed to by the superblock. + */ + if(create_root) { + H5P_genplist_t *fc_plist; /* File creation property list */ + H5O_ginfo_t ginfo; /* Group info parameters */ + H5O_linfo_t linfo; /* Link info parameters */ + unsigned super_vers; /* Superblock version */ + + /* Get the file creation property list */ + /* (Which is a sub-class of the group creation property class) */ + if(NULL == (fc_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Get the group info property */ + if(H5P_get(fc_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info") + + /* Get the link info property */ + if(H5P_get(fc_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info") + + /* Get the superblock version */ + if(H5P_get(fc_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get superblock version") + + /* Create root group */ + if(H5G_obj_create(f, dxpl_id, &ginfo, &linfo, f->shared->fcpl_id, root_loc.oloc/*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") + if(1 != H5O_link(root_loc.oloc, 1, dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_LINKCOUNT, FAIL, "internal error (wrong link count)") + + /* Create the root group symbol table entry */ + HDassert(!f->shared->root_ent); + if(super_vers < HDF5_SUPERBLOCK_VERSION_2) { + /* Allocate space for the root group symbol table entry */ + if(NULL == (f->shared->root_ent = (H5G_entry_t *) H5MM_calloc(sizeof(H5G_entry_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") + + /* Initialize the root group symbol table entry */ + f->shared->root_ent->dirty = TRUE; + f->shared->root_ent->type = H5G_NOTHING_CACHED; /* We will cache the stab later */ + f->shared->root_ent->name_off = 0; /* No name (yet) */ + f->shared->root_ent->header = root_loc.oloc->addr; + f->shared->root_ent->file = root_loc.oloc->file; + } /* end if */ + } /* end if */ + else { + /* Create root group object location from f */ + root_loc.oloc->addr = f->shared->root_addr; + root_loc.oloc->file = f; + + /* + * Open the root object as a group. + */ + if(H5O_open(root_loc.oloc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group") + + /* Actions to take if the symbol table information is cached */ + if(f->shared->root_ent && f->shared->root_ent->type == H5G_CACHED_STAB) { + /* Check for the situation where the symbol table is cached but does + * not exist. This can happen if, for example, an external link is + * added to the root group. */ + if((stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check if symbol table message exists") + + /* Remove the cache if the stab does not exist */ + if(!stab_exists) + f->shared->root_ent->type = H5G_NOTHING_CACHED; +#ifndef H5_STRICT_FORMAT_CHECKS + /* If symbol table information is cached, check if we should replace the + * symbol table message with the cached symbol table information */ + else if(H5F_INTENT(f) & H5F_ACC_RDWR) { + H5O_stab_t cached_stab; + + /* Retrieve the cached symbol table information */ + cached_stab.btree_addr = f->shared->root_ent->cache.stab.btree_addr; + cached_stab.heap_addr = f->shared->root_ent->cache.stab.heap_addr; + + /* Check if the symbol table message is valid, and replace with the + * cached symbol table if necessary */ + if(H5G_stab_valid(root_loc.oloc, dxpl_id, &cached_stab) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to verify symbol table") + } /* end if */ +#endif /* H5_STRICT_FORMAT_CHECKS */ + } /* end if */ + } /* end else */ + + /* Cache the root group's symbol table information in the root group symbol + * table entry. It will have been allocated by now if it needs to be + * present, so we don't need to check the superblock version. We do this if + * we have write access, the root entry has been allocated (i.e. + * super_vers < 2) and the stab info is not already cached. */ + if((H5F_INTENT(f) & H5F_ACC_RDWR) && stab_exists != FALSE && f->shared->root_ent + && f->shared->root_ent->type != H5G_CACHED_STAB) { + H5O_stab_t stab; /* Symbol table */ + + /* Check if the stab message exists. It's possible for the root group + * to use the latest version while the superblock is an old version. + * If stab_exists is not -1 then we have already checked. */ + if(stab_exists == -1 && (stab_exists = H5O_msg_exists(root_loc.oloc, H5O_STAB_ID, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't check if symbol table message exists") + + if(stab_exists) { + /* Read the root group's symbol table message */ + if(NULL == H5O_msg_read(root_loc.oloc, H5O_STAB_ID, &stab, dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message") + + /* Update the root group symbol table entry */ + f->shared->root_ent->type = H5G_CACHED_STAB; + f->shared->root_ent->cache.stab.btree_addr = stab.btree_addr; + f->shared->root_ent->cache.stab.heap_addr = stab.heap_addr; + } /* end if */ + } /* end if */ + + /* Create the path names for the root group's entry */ + H5G_name_init(root_loc.path, "/"); + + f->shared->root_grp->shared->fo_count = 1; + /* The only other open object should be the superblock extension, if it + * exists. Don't count either the superblock extension or the root group + * in the number of open objects in the file. + */ + HDassert((1 == f->nopen_objs) || + (2 == f->nopen_objs && HADDR_UNDEF != f->shared->extension_addr)); + f->nopen_objs--; + +done: + /* In case of error, free various memory locations that may have been + * allocated */ + if(ret_value < 0) { + if(f->shared->root_grp) { + if(f->shared->root_grp->shared) + f->shared->root_grp->shared = H5FL_FREE(H5G_shared_t, f->shared->root_grp->shared); + f->shared->root_grp = H5FL_FREE(H5G_t, f->shared->root_grp); + } /* end if */ + f->shared->root_ent = (H5G_entry_t *) H5MM_xfree(f->shared->root_ent); + H5G_name_free(root_loc.path); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_mkroot() */ + diff --git a/src/H5Gstab.c b/src/H5Gstab.c index c2df8e7..52c9d07 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -1011,7 +1011,8 @@ H5G_stab_valid(H5O_loc_t *grp_oloc, hid_t dxpl_id, H5O_stab_t *alt_stab) FUNC_ENTER_NOAPI(H5G_stab_valid, FAIL) /* Read the symbol table message */ - H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab, dxpl_id); + if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab, dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message"); /* Check if the symbol table message's b-tree address is valid */ if(H5B_valid(grp_oloc->file, dxpl_id, H5B_SNODE, stab.btree_addr) < 0) { diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 1f09048..f3508eb 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -550,3 +550,59 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5G_user_path_test() */ + +/*------------------------------------------------------------------------- + * Function: H5G_verify_cached_stab_test + * + * Purpose: Check that a that the provided group entry contains a + * cached symbol table entry, that the entry matches that in + * the provided group's object header, and check that the + * addresses are valid. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Mar 31, 2009 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent) +{ + H5O_stab_t stab; /* Symbol table */ + H5HL_t *heap = NULL; /* Pointer to local heap */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_verify_cached_stab_test) + + /* Verify that stab info is cached in ent */ + if(ent->type != H5G_CACHED_STAB) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "symbol table information is not cached") + + /* Read the symbol table message from the group */ + if(NULL == H5O_msg_read(grp_oloc, H5O_STAB_ID, &stab, H5AC_ind_dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "unable to read symbol table message") + + /* Verify that the cached symbol table info matches the symbol table message + * in the object header */ + if((ent->cache.stab.btree_addr != stab.btree_addr) + || (ent->cache.stab.heap_addr != stab.heap_addr)) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "cached stab info does not match object header") + + /* Verify that the btree address is valid */ + if(H5B_valid(grp_oloc->file, H5AC_ind_dxpl_id, H5B_SNODE, stab.btree_addr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "b-tree address is invalid") + + /* Verify that the heap address is valid */ + if(NULL == (heap = H5HL_protect(grp_oloc->file, H5AC_ind_dxpl_id, stab.heap_addr, H5AC_READ))) + HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap address is invalid") + +done: + /* Release resources */ + if(heap && H5HL_unprotect(grp_oloc->file, H5AC_ind_dxpl_id, heap, stab.heap_addr) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_verify_cached_stab_test() */ + diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 8ab35cb..0fcca97 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -103,6 +103,7 @@ const H5AC_class_t H5AC_FHEAP_HDR[1] = {{ (H5AC_flush_func_t)H5HF_cache_hdr_flush, (H5AC_dest_func_t)H5HF_cache_hdr_dest, (H5AC_clear_func_t)H5HF_cache_hdr_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5HF_cache_hdr_size, }}; @@ -113,6 +114,7 @@ const H5AC_class_t H5AC_FHEAP_IBLOCK[1] = {{ (H5AC_flush_func_t)H5HF_cache_iblock_flush, (H5AC_dest_func_t)H5HF_cache_iblock_dest, (H5AC_clear_func_t)H5HF_cache_iblock_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5HF_cache_iblock_size, }}; @@ -123,6 +125,7 @@ const H5AC_class_t H5AC_FHEAP_DBLOCK[1] = {{ (H5AC_flush_func_t)H5HF_cache_dblock_flush, (H5AC_dest_func_t)H5HF_cache_dblock_dest, (H5AC_clear_func_t)H5HF_cache_dblock_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5HF_cache_dblock_size, }}; diff --git a/src/H5HG.c b/src/H5HG.c index b5f8988..9042146 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -249,9 +249,8 @@ HDmemset(heap->chunk, 0, size); } /* Add the heap to the cache */ - if (H5AC_set (f, dxpl_id, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET)<0) - HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, \ - "unable to cache global heap collection"); + if(H5AC_set(f, dxpl_id, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to cache global heap collection") ret_value = addr; diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 1a9e92c..747c41e 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -92,6 +92,7 @@ const H5AC_class_t H5AC_GHEAP[1] = {{ (H5AC_flush_func_t)H5HG_flush, (H5AC_dest_func_t)H5HG_dest, (H5AC_clear_func_t)H5HG_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5HG_size, }}; diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 449e166..fa458ca 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -93,6 +93,7 @@ const H5AC_class_t H5AC_LHEAP[1] = {{ (H5AC_flush_func_t)H5HL_flush, (H5AC_dest_func_t)H5HL_dest, (H5AC_clear_func_t)H5HL_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5HL_size, }}; diff --git a/src/H5I.c b/src/H5I.c index c6fcb17..841b491 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -1847,40 +1847,35 @@ done: /*------------------------------------------------------------------------- * Function: H5Iis_valid * - * Purpose: Check if the given id is valid. And id is valid if it is in - * use and has an application reference count of at least 1. + * Purpose: Check if the given id is valid. An id is valid if it is in + * use and has an application reference count of at least 1. * - * Return: Success: TRUE if the id is valid, FALSE otherwise. + * Return: Success: TRUE if the id is valid, FALSE otherwise. * - * Failure: Negative (never fails currently) + * Failure: Negative (never fails currently) * * Programmer: Neil Fortner * Friday, October 31, 2008 (boo) * + * Modifications: + * Raymond Lu + * 1 April 2009 (Believe it or not!) + * Moved the argument check down to H5I_find_id because other + * caller functions may pass in some invalid IDs to H5I_find_id. + * It used to do assertion check. *------------------------------------------------------------------------- */ htri_t H5Iis_valid(hid_t id) { - H5I_id_type_t *type_ptr; /* ptr to ID's type */ H5I_id_info_t *id_ptr; /* ptr to the ID */ - H5I_type_t type; /* ID's type */ htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(H5Iis_valid, FAIL) H5TRACE1("t", "i", id); - type = H5I_TYPE(id); - /* Check for conditions that would cause H5I_find_id to throw an assertion */ - if (type <= H5I_BADID || type >= H5I_next_type) - HGOTO_DONE(FALSE); - - type_ptr = H5I_id_type_list_g[type]; - if (!type_ptr || type_ptr->count <= 0) - ret_value = FALSE; - /* Find the ID */ - else if (NULL == (id_ptr = H5I_find_id(id))) + if (NULL == (id_ptr = H5I_find_id(id))) ret_value = FALSE; /* Check if the found id is an internal id */ @@ -2012,7 +2007,9 @@ done: * Programmer: * * Modifications: - * + * Raymond Lu + * 1 April 2009 (Believe it or not!) + * Added argument check, took away assertion check. *------------------------------------------------------------------------- */ static H5I_id_info_t * @@ -2029,10 +2026,12 @@ H5I_find_id(hid_t id) /* Check arguments */ type = H5I_TYPE(id); - HDassert(type > H5I_BADID && type < H5I_next_type); - type_ptr = H5I_id_type_list_g[type]; + if (type <= H5I_BADID || type >= H5I_next_type) + HGOTO_DONE(NULL); - HDassert(type_ptr && type_ptr->count > 0); + type_ptr = H5I_id_type_list_g[type]; + if (!type_ptr || type_ptr->count <= 0) + HGOTO_DONE(NULL); /* Get the bucket in which the ID is located */ hash_loc = (unsigned)H5I_LOC(id, type_ptr->hash_size); @@ -2057,6 +2056,7 @@ H5I_find_id(hid_t id) /* Set the return value */ ret_value = id_ptr; +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_find_id() */ diff --git a/src/H5L.c b/src/H5L.c index 368272b..0de2e10 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -82,6 +82,7 @@ typedef struct { const char *dst_name; /* Destination name for moving object */ H5T_cset_t cset; /* Char set for new name */ H5G_loc_t *dst_loc; /* Destination location for moving object */ + unsigned dst_target_flags; /* Target flags for destination object */ hbool_t copy; /* TRUE if this is a copy operation */ hid_t lapl_id; /* LAPL to use in callback */ hid_t dxpl_id; /* DXPL to use in callback */ @@ -285,6 +286,9 @@ H5L_term_interface(void) H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); H5L_table_used_g = H5L_table_alloc_g = 0; + /* Mark the interface as uninitialized */ + H5_interface_initialize_g = 0; + FUNC_LEAVE_NOAPI(n) } /* H5L_term_interface() */ @@ -557,6 +561,8 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") + if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") /* Create external link */ if(H5L_create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) @@ -2528,7 +2534,8 @@ H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, orig_name = H5MM_xstrdup(name); /* Insert the link into its new location */ - if(H5G_traverse(udata->dst_loc, udata->dst_name, H5G_TARGET_NORMAL, H5L_move_dest_cb, &udata_out, udata->lapl_id, udata->dxpl_id) < 0) + if(H5G_traverse(udata->dst_loc, udata->dst_name, udata->dst_target_flags, + H5L_move_dest_cb, &udata_out, udata->lapl_id, udata->dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") /* If this is a move and not a copy operation, change the object's name and remove the old link */ @@ -2614,7 +2621,7 @@ H5L_move(H5G_loc_t *src_loc, const char *src_name, H5G_loc_t *dst_loc, const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id) { - unsigned target_flags = H5G_TARGET_MOUNT|H5G_TARGET_SLINK|H5G_TARGET_UDLINK; + unsigned dst_target_flags = H5G_TARGET_NORMAL; H5T_cset_t char_encoding = H5F_DEFAULT_CSET; /* Character encoding for link */ H5P_genplist_t* lc_plist; /* Link creation property list */ H5P_genplist_t* la_plist; /* Link access property list */ @@ -2641,8 +2648,9 @@ H5L_move(H5G_loc_t *src_loc, const char *src_name, H5G_loc_t *dst_loc, if(H5P_get(lc_plist, H5L_CRT_INTERMEDIATE_GROUP_NAME, &crt_intmd_group) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for creating missing groups") + /* Set target flags for source and destination */ if(crt_intmd_group > 0) - target_flags |= H5G_CRT_INTMD_GROUP; + dst_target_flags |= H5G_CRT_INTMD_GROUP; /* Get character encoding property */ if(H5P_get(lc_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &char_encoding) < 0) @@ -2664,13 +2672,15 @@ H5L_move(H5G_loc_t *src_loc, const char *src_name, H5G_loc_t *dst_loc, /* Set up user data */ udata.dst_loc = dst_loc; udata.dst_name= dst_name; + udata.dst_target_flags = dst_target_flags; udata.cset = char_encoding; udata.copy = copy_flag; udata.lapl_id = lapl_copy; udata.dxpl_id = dxpl_id; /* Do the move */ - if(H5G_traverse(src_loc, src_name, target_flags, H5L_move_cb, &udata, lapl_id, dxpl_id) < 0) + if(H5G_traverse(src_loc, src_name, H5G_TARGET_MOUNT | H5G_TARGET_SLINK | H5G_TARGET_UDLINK, + H5L_move_cb, &udata, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to find link") done: diff --git a/src/H5O.c b/src/H5O.c index 9b9d0ef..85fda74 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -2879,7 +2879,7 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, udata.op_data = op_data; /* Create skip list to store visited object information */ - if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, 0.5, (size_t)16)) == NULL) + if((udata.visited = H5SL_create(H5SL_TYPE_OBJ)) == NULL) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects") /* If its ref count is > 1, we add it to the list of visited objects */ diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 551eca8..6c86681 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -98,6 +98,7 @@ const H5AC_class_t H5AC_OHDR[1] = {{ (H5AC_flush_func_t)H5O_flush, (H5AC_dest_func_t)H5O_dest, (H5AC_clear_func_t)H5O_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5O_size, }}; diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 7b76f3d..2926c6b 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -913,7 +913,7 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, cpy_info.preserve_null = TRUE; /* Create a skip list to keep track of which objects are copied */ - if((cpy_info.map_list = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16)) == NULL) + if((cpy_info.map_list = H5SL_create(H5SL_TYPE_HADDR)) == NULL) HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, FAIL, "cannot make skip list") /* copy the object from the source file to the destination file */ diff --git a/src/H5Opline.c b/src/H5Opline.c index 20a9d26..070ab87 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -273,7 +273,7 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) name = NULL; } /* end if */ else { - H5Z_class_t *cls; /* Filter class */ + H5Z_class2_t *cls; /* Filter class */ /* * Get the filter name. If the pipeline message has a name in it then @@ -453,7 +453,7 @@ H5O_pline_size(const H5F_t UNUSED *f, const void *mesg) if(pline->version > H5O_PLINE_VERSION_1 && pline->filter[i].id < H5Z_FILTER_RESERVED) name_len = 0; else { - H5Z_class_t *cls; /* Filter class */ + H5Z_class2_t *cls; /* Filter class */ /* Get the name of the filter, same as done with H5O_pline_encode() */ if(NULL == (name = pline->filter[i].name) && (cls = H5Z_find(pline->filter[i].id))) diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index d3e3313..018bc77 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -546,11 +546,13 @@ typedef herr_t (*H5O_lib_operator_t)(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, hbool_t *oh_modified/*out*/, void *operator_data/*in,out*/); /* Some syntactic sugar to make the compiler happy with two different kinds of iterator callbacks */ +typedef enum H5O_mesg_operator_type_t { + H5O_MESG_OP_APP, /* Application callback */ + H5O_MESG_OP_LIB /* Library internal callback */ +} H5O_mesg_operator_type_t; + typedef struct { - enum { - H5O_MESG_OP_APP, /* Application callback */ - H5O_MESG_OP_LIB /* Library internal callback */ - } op_type; + H5O_mesg_operator_type_t op_type; union { H5O_operator_t app_op; /* Application callback for each message */ H5O_lib_operator_t lib_op; /* Library internal callback for each message */ diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index a4d036d..db66366 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -154,7 +154,7 @@ done: * property list. Each of thhese values can be individually unset * (or not set at all) by passing the macros: * H5D_CHUNK_CACHE_NCHUNKS_DEFAULT, - * H5D_CHUNK_CACHE_NBYTES_DEFAULT, and/or + * H5D_CHUNK_CACHE_NSLOTS_DEFAULT, and/or * H5D_CHUNK_CACHE_W0_DEFAULT * as appropriate. * diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 43696fc..c64a70b 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1555,7 +1555,7 @@ H5P_get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, /* If there's no name on the filter, use the class's filter name */ if(!s) { - H5Z_class_t *cls = H5Z_find(filter->id); + H5Z_class2_t *cls = H5Z_find(filter->id); if(cls) s = cls->name; diff --git a/src/H5Pint.c b/src/H5Pint.c index 799535f..56f1929 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -42,8 +42,6 @@ /* Local Macros */ /****************/ -#define H5P_DEFAULT_SKIPLIST_HEIGHT 8 - /******************/ /* Local Typedefs */ @@ -652,11 +650,11 @@ H5P_copy_plist(H5P_genplist_t *old_plist, hbool_t app_ref) new_plist->class_init = 0; /* Initially, wait until the class callback finishes to set */ /* Initialize the skip list to hold the changed properties */ - if((new_plist->props = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL) + if((new_plist->props = H5SL_create(H5SL_TYPE_STR)) == NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for changed properties"); /* Create the skip list for deleted properties */ - if((new_plist->del = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL) + if((new_plist->del = H5SL_create(H5SL_TYPE_STR)) == NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for deleted properties"); /* Create the skip list to hold names of properties already seen @@ -664,7 +662,7 @@ H5P_copy_plist(H5P_genplist_t *old_plist, hbool_t app_ref) * 'create' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT))== NULL) + if((seen = H5SL_create(H5SL_TYPE_STR))== NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties"); nseen = 0; @@ -1462,7 +1460,7 @@ H5P_create_class(H5P_genclass_t *par_class, const char *name, unsigned internal, pclass->revision = H5P_GET_NEXT_REV; /* Get a revision number for the class */ /* Create the skip list for properties */ - if((pclass->props = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL) + if((pclass->props = H5SL_create(H5SL_TYPE_STR)) == NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for properties"); /* Set callback functions and pass-along data */ @@ -1544,11 +1542,11 @@ H5P_create(H5P_genclass_t *pclass) plist->class_init = 0; /* Initially, wait until the class callback finishes to set */ /* Create the skip list for changed properties */ - if((plist->props = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL) + if((plist->props = H5SL_create(H5SL_TYPE_STR)) == NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for changed properties"); /* Create the skip list for deleted properties */ - if((plist->del = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL) + if((plist->del = H5SL_create(H5SL_TYPE_STR)) == NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for deleted properties"); /* Create the skip list to hold names of properties already seen @@ -1556,7 +1554,7 @@ H5P_create(H5P_genclass_t *pclass) * 'create' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL) + if((seen = H5SL_create(H5SL_TYPE_STR)) == NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for seen properties"); /* @@ -3147,7 +3145,7 @@ H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Create the skip list to hold names of properties already seen */ - if((seen = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL) + if((seen = H5SL_create(H5SL_TYPE_STR)) == NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties"); /* Walk through the changed properties in the list */ @@ -4071,7 +4069,7 @@ H5P_close(void *_plist) * 'close' callback called, if a property in the class hierarchy has * already been seen) */ - if((seen = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL) + if((seen = H5SL_create(H5SL_TYPE_STR)) == NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties"); nseen = 0; diff --git a/src/H5SL.c b/src/H5SL.c index fe810d1..31e81c2 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -16,17 +16,34 @@ /* * Purpose: Provides a skip list abstract data type. * + * (See "Deterministic Skip Lists" by Munro, Papadakis & Sedgewick) + * + * (Implementation changed to a deterministic skip list from a + * probabilistic one. This implementation uses a 1-2-3 skip list + * using arrays, as described by Munro, Papadakis & Sedgewick. + * + * Arrays are allocated using a free list factory for each size + * that is a power of two. Factories are created as soon as they + * are needed, and are never destroyed until the package is shut + * down. There is no longer a maximum level or "p" value. + * -NAF 2008/11/05) + * * (See "Skip Lists: A Probabilistic Alternative to Balanced Trees" * by William Pugh for additional information) * * (This implementation has the optimization for reducing key * key comparisons mentioned in section 3.5 of "A Skip List - * Cookbook" by William Pugh) + * Cookbook" by William Pugh + * -Removed as our implementation of this was useless for a 1-2-3 + * skip list. The implementation in that document hurts + * performance, at least for integer keys. -NAF) * * (Also, this implementation has a couple of home-grown * optimizations, including setting the "update" vector to the * actual 'forward' pointer to update, instead of the node - * containing the forward pointer -QAK) + * containing the forward pointer -QAK + * -No longer uses update vector, as insertions/deletions are now + * always at level 0. -NAF) * * (Note: This implementation does not have the information for * implementing the "Linear List Operations" (like insert/delete/ @@ -36,9 +53,6 @@ * (This implementation has an additional backward pointer, which * allows the list to be iterated in reverse) * - * (We should also look into "Deterministic Skip Lists" (see - * paper by Munro, Papadakis & Sedgewick)) - * * (There's also an article on "Alternating Skip Lists", which * are similar to deterministic skip lists, in the August 2000 * issue of Dr. Dobb's Journal) @@ -54,61 +68,28 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5SLprivate.h" /* Skip list routines */ +#include "H5MMprivate.h" /* Memory management */ /* Local Macros */ -/* Define the code template for insertions for the "OP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_INSERT_FOUND(SLIST, X, UPDATE, I) \ - HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, NULL, "can't insert duplicate key") - -/* Define the code template for removals for the "OP" in the H5SL_LOCATE macro */ -/* (NOTE: the code in H5SL_remove_first() is largely the same, fix bugs in both places) */ -#define H5SL_LOCATE_REMOVE_FOUND(SLIST,X,UPDATE,I) \ - void *tmp; \ - \ - for(I=0; I<=(int)SLIST->curr_level; I++) { \ - if(*UPDATE[I]!=X) \ - break; \ - *UPDATE[I]=X->forward[I]; \ - } /* end for */ \ - if(SLIST->last==X) \ - SLIST->last=X->backward; \ - else \ - X->forward[0]->backward=X->backward; \ - tmp=X->item; \ - H5FL_ARR_FREE(H5SL_node_ptr_t,X); \ - while(SLIST->curr_level>0 && SLIST->header->forward[SLIST->curr_level]==NULL) \ - SLIST->curr_level--; \ - SLIST->nobjs--; \ - HGOTO_DONE(tmp); - /* Define the code template for searches for the "OP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_SEARCH_FOUND(SLIST, X, UPDATE, I) \ +#define H5SL_LOCATE_SEARCH_FOUND(SLIST, X, I) \ HGOTO_DONE(X->item); /* Define the code template for finds for the "OP" in the H5SL_LOCATE macro */ -#define H5SL_LOCATE_FIND_FOUND(SLIST, X, UPDATE, I) \ +#define H5SL_LOCATE_FIND_FOUND(SLIST, X, I) \ HGOTO_DONE(X); -/* Define a code template for "OP"s that update the "update" vector for the H5SL_LOCATE macro */ -#define H5SL_LOCATE_INSERT_UPDATE(X, UPDATE, I) \ - UPDATE[I] = &X->forward[I]; -#define H5SL_LOCATE_REMOVE_UPDATE(X, UPDATE, I) \ - UPDATE[I] = &X->forward[I]; - -/* Define a code template for "OP"s that _DON'T_ update the "update" vector for the H5SL_LOCATE macro */ -#define H5SL_LOCATE_SEARCH_UPDATE(X, UPDATE, I) -#define H5SL_LOCATE_FIND_UPDATE(X, UPDATE, I) - - /* Define a code template for comparing scalar keys for the "CMP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_SCALAR_CMP(TYPE, PNODE, PKEY, HASHVAL) \ (*(TYPE *)((PNODE)->key) < *(TYPE *)PKEY) /* Define a code template for comparing string keys for the "CMP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_STRING_CMP(TYPE, PNODE, PKEY, HASHVAL) \ - (((PNODE)->hashval == HASHVAL) ? (HDstrcmp((PNODE)->key, PKEY) < 0) : ((PNODE)->hashval < HASHVAL)) + (((PNODE)->hashval == HASHVAL) ? \ + (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) < 0) : \ + ((PNODE)->hashval < HASHVAL)) /* Define a code template for comparing H5_obj_t keys for the "CMP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_OBJ_CMP(TYPE, PNODE, PKEY, HASHVAL) \ @@ -121,7 +102,7 @@ /* Define a code template for comparing string keys for the "EQ" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_STRING_EQ(TYPE, PNODE, PKEY, HASHVAL) \ - (((PNODE)->hashval == HASHVAL) && (HDstrcmp(((PNODE)->key), PKEY) == 0)) + (((PNODE)->hashval == HASHVAL) && (HDstrcmp((const char *)(PNODE)->key, (const char *)PKEY) == 0)) /* Define a code template for comparing H5_obj_t keys for the "EQ" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_OBJ_EQ(TYPE, PNODE, PKEY, HASHVAL) \ @@ -133,50 +114,358 @@ /* Define a code template for initializing the hash value for string keys for the "HASHINIT" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_STRING_HASHINIT(KEY, HASHVAL) \ - HASHVAL = H5_hash_string(KEY); + HASHVAL = H5_hash_string((const char *)KEY); /* Define a code template for initializing the hash value for H5_obj_t keys for the "HASHINIT" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_OBJ_HASHINIT(KEY, HASHVAL) /* Macro used to find node for operation */ -#define H5SL_LOCATE(OP, CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) \ +#define H5SL_LOCATE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ { \ - H5SL_node_t *_checked; /* Pointer to last node checked */ \ int _i; /* Local index variable */ \ + unsigned _count; /* Num nodes searched at this height */ \ \ - _checked = NULL; \ H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ for(_i = (int)SLIST->curr_level; _i >= 0; _i--) { \ - if(X->forward[_i] != _checked) { \ - while(X->forward[_i] && H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(TYPE, X->forward[_i], KEY, HASHVAL) ) \ - X = X->forward[_i]; \ - _checked = X->forward[_i]; \ - } /* end if */ \ - H5_GLUE3(H5SL_LOCATE_,OP,_UPDATE)(X, UPDATE, _i) \ + _count = 0; \ + while(_count < 3 && X->forward[_i] && \ + H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(TYPE, X->forward[_i], KEY, HASHVAL) ) { \ + X = X->forward[_i]; \ + _count++; \ + } /* end while */ \ } /* end for */ \ X = X->forward[0]; \ if(X != NULL && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(TYPE, X, KEY, HASHVAL) ) { \ /* What to do when a node is found */ \ - H5_GLUE3(H5SL_LOCATE_,OP,_FOUND)(SLIST, X, UPDATE, _i) \ + H5_GLUE3(H5SL_LOCATE_,OP,_FOUND)(SLIST, X, _i) \ } /* end if */ \ } -/* Macro used to insert node */ -#define H5SL_INSERT(CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) \ - H5SL_LOCATE(INSERT, CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) + +/* Macro used to grow a node by 1. Does not update pointers. LVL is the current + * level of X. Does not update LVL but does update X->lvl. */ +#define H5SL_GROW(X, LVL) \ +{ \ + /* Check if we need to increase allocation of forward pointers */ \ + if(LVL + 1 >= 1u << X->log_nalloc) { \ + H5SL_node_t **_tmp; \ + HDassert(LVL + 1 == 1u << X->log_nalloc); \ + /* Double the amount of allocated space */ \ + X->log_nalloc++; \ + \ + /* Check if we need to create a new factory */ \ + if(X->log_nalloc >= H5SL_fac_nused_g) { \ + HDassert(X->log_nalloc == H5SL_fac_nused_g); \ + \ + /* Check if we need to allocate space for the factory pointer*/ \ + if(H5SL_fac_nused_g >= H5SL_fac_nalloc_g) { \ + HDassert(H5SL_fac_nused_g == H5SL_fac_nalloc_g); \ + /* Double the size of the array of factory pointers */ \ + H5SL_fac_nalloc_g *= 2; \ + H5SL_fac_g = (H5FL_fac_head_t **)H5MM_realloc((void *)H5SL_fac_g, \ + H5SL_fac_nalloc_g * sizeof(H5FL_fac_head_t *)); \ + } /* end if */ \ + \ + /* Create the new factory */ \ + H5SL_fac_g[H5SL_fac_nused_g] = H5FL_fac_init((1u << H5SL_fac_nused_g) * sizeof(H5SL_node_t *)); \ + H5SL_fac_nused_g++; \ + } /* end if */ \ + \ + /* Allocate space for new forward pointers */ \ + if(NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") \ + HDmemcpy((void *)_tmp, (const void *)X->forward, (LVL + 1) * sizeof(H5SL_node_t *)); \ + (void)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc-1], (void *)X->forward); \ + X->forward = _tmp; \ + } /* end if */ \ + \ + X->level++; \ +} + + +/* Macro used to shrink a node by 1. Does not update pointers. LVL is the + * current level of X. Does not update LVL but does update X->level. */ +#define H5SL_SHRINK(X, LVL) \ +{ \ + /* Check if we can reduce the allocation of forward pointers */ \ + if(LVL <= 1u << (X->log_nalloc - 1)) { \ + H5SL_node_t **_tmp; \ + HDassert(LVL == 1u << (X->log_nalloc - 1)); \ + X->log_nalloc--; \ + \ + /* Allocate space for new forward pointers */ \ + if(NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") \ + HDmemcpy((void *)_tmp, (const void *)X->forward, (LVL) * sizeof(H5SL_node_t *)); \ + (void)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc+1], (void *)X->forward); \ + X->forward = _tmp; \ + } /* end if */ \ + \ + X->level--; \ +} + + +/* Macro used to grow the level of a node by 1, with appropriate changes to the + * head node if necessary. PREV is the previous node of the height that X is to + * grow to. */ +#define H5SL_PROMOTE(SLIST, X, PREV) \ +{ \ + size_t _lvl = X->level; \ + \ + H5SL_GROW(X, _lvl); \ + \ + if(_lvl == (size_t) SLIST->curr_level) { \ + HDassert(PREV == SLIST->header); \ + /* Grow the head */ \ + H5SL_GROW(PREV, _lvl); \ + SLIST->curr_level++; \ + X->forward[_lvl+1] = NULL; \ + } else { \ + HDassert(_lvl < (size_t) SLIST->curr_level); \ + X->forward[_lvl+1] = PREV->forward[_lvl+1]; \ + } /* end else */ \ + PREV->forward[_lvl+1] = X; \ +} + + +/* Macro used to reduce the level of a node by 1. Does not update the head node + * "current level". PREV is the previous node of the currrent height of X. */ +#define H5SL_DEMOTE(X, PREV) \ +{ \ + size_t _lvl = X->level; \ + \ + HDassert(PREV->forward[_lvl] == X); \ + PREV->forward[_lvl] = X->forward[_lvl]; \ + H5SL_SHRINK(X, _lvl); \ +} + + +/* Macro used to insert node. Does not actually insert the node. After running + * this macro, X will contain the node before where the new node should be + * inserted (at level 0). */ +#define H5SL_INSERT(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ +{ \ + H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ + H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ + H5SL_node_t *_drop; /* Low node of the gap to drop into */ \ + int _count; /* Number of nodes in the current gap */ \ + int _i; \ + \ + H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ + for(_i = (int)SLIST->curr_level; _i >= 0; _i--) { \ + /* Search for the node to drop into, also count the number of nodes */ \ + /* of height _i in this gap */ \ + _drop = NULL; \ + for(_count = 0; ; _count++) { \ + /* Terminate if this is the last node in the gap */ \ + if(X->forward[_i] == _next) { \ + if(!_drop) \ + _drop = X; \ + break; \ + } /* end if */ \ + \ + /* Check if this node is the start of the next gap */ \ + if(!_drop && !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(TYPE, X->forward[_i], KEY, HASHVAL)) \ + _drop = X; \ + \ + /* No need to check the last node in the gap if there are 3, as */ \ + /* there cannot be a fourth */ \ + if(_count == 2) { \ + if(!_drop) \ + _drop = X->forward[_i]; \ + _count = 3; \ + break; \ + } \ + X = X->forward[_i]; \ + } /* end for */ \ + HDassert(!_drop->forward[_i] || \ + !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(TYPE, _drop->forward[_i], KEY, HASHVAL)); \ + \ + /* Promote the middle node if necessary */ \ + if(_count == 3) { \ + HDassert(X == _last->forward[_i]->forward[_i]); \ + H5SL_PROMOTE(SLIST, X, _last) \ + } \ + \ + /* Prepare to drop down */ \ + X = _last = _drop; \ + _next = _drop->forward[_i]; \ + } /* end for */ \ + \ + if(_next && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(TYPE, _next, KEY, HASHVAL)) \ + HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, NULL, "can't insert duplicate key") \ +} + /* Macro used to remove node */ -#define H5SL_REMOVE(CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) \ - H5SL_LOCATE(REMOVE, CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) +#define H5SL_REMOVE(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ +{ \ + H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ + H5SL_node_t *_llast = X; /* Lowest node in the previous gap */ \ + H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ + H5SL_node_t *_drop = NULL; /* Low node of the gap to drop into */ \ + H5SL_node_t *_ldrop = NULL; /* Low node of gap before the one to drop into */ \ + H5SL_node_t *_head = SLIST->header; /* Head of the skip list */ \ + int _count; /* Number of nodes in the current gap */ \ + int _i = (int)SLIST->curr_level; \ + \ + if(_i < 0) \ + HGOTO_DONE(NULL); \ + \ + H5_GLUE3(H5SL_LOCATE_,CMP,_HASHINIT)(KEY, HASHVAL) \ + \ + /* Find the gap to drop in to at the highest level */ \ + while(X && (!X->key || H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(TYPE, X, KEY, HASHVAL))) { \ + _llast = _last; \ + _last = X; \ + X = X->forward[_i]; \ + } \ + _next = X; \ + \ + /* Main loop */ \ + for(_i--; _i >= 0; _i--) { \ + /* Search for the node to drop into, also count the number of nodes */ \ + /* of height _i in this gap and keep track of of the node before */ \ + /* the one to drop into (_ldrop will become _llast, _drop will */ \ + /* become _last). */ \ + X = _ldrop = _last; \ + _drop = NULL; \ + for(_count = 0; ; _count++) { \ + /* Terminate if this is the last node in the gap */ \ + if(X->forward[_i] == _next) { \ + if(!_drop) \ + _drop = X; \ + break; \ + } /* end if */ \ + \ + /* If we have already found the node to drop into and there is */ \ + /* more than one node in this gap, we can stop searching */ \ + if(_drop) { \ + HDassert(_count >= 1); \ + _count = 2; \ + break; \ + } else { /* !_drop */ \ + /* Check if this node is the start of the next gap */ \ + if (!H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(TYPE, X->forward[_i], KEY, HASHVAL)) { \ + _drop = X; \ + /* Again check if we can stop searching */ \ + if(_count) { \ + _count = 2; \ + break; \ + } /* end if */ \ + } /* end if */ \ + else \ + _ldrop = X; \ + } /* end else */ \ + \ + /* No need to check the last node in the gap if there are 3, as */ \ + /* there cannot be a fourth */ \ + if(_count == 2) { \ + if(!_drop) \ + _drop = X->forward[_i]; \ + break; \ + } /* end if */ \ + X = X->forward[_i]; \ + } /* end for */ \ + HDassert(_count >= 1 && _count <= 3); \ + HDassert(!_drop->forward[_i] || \ + !H5_GLUE3(H5SL_LOCATE_,CMP,_CMP)(TYPE, _drop->forward[_i], KEY, HASHVAL)); \ + \ + /* Check if we need to adjust node heights */ \ + if(_count == 1) { \ + /* Check if we are in the first gap */ \ + if(_llast == _last) { \ + /* We are in the first gap, count the number of nodes of */ \ + /* height _i in the next gap. We need only check one node */ \ + /* to see if we should promote the first node in the next */ \ + /* gap */ \ + _llast = _next->forward[_i+1]; \ + \ + /* Demote the separator node */ \ + H5SL_DEMOTE(_next, _last) \ + \ + /* If there are 2 or more nodes, promote the first */ \ + if(_next->forward[_i]->forward[_i] != _llast) { \ + X = _next->forward[_i]; \ + H5SL_PROMOTE(SLIST, X, _last) \ + } else if(!_head->forward[_i+1]) { \ + /* shrink the header */ \ + HDassert(_i == SLIST->curr_level - 1); \ + HDassert((size_t) SLIST->curr_level == _head->level); \ + \ + H5SL_SHRINK(_head, (size_t) (_i+1)) \ + SLIST->curr_level--; \ + } /* end else */ \ + } else { \ + /* We are not in the first gap, count the number of nodes */ \ + /* of height _i in the previous gap. Note we "look ahead" */ \ + /* in this loop so X has the value of the last node in the */ \ + /* previous gap. */ \ + X = _llast->forward[_i]; \ + for(_count = 1; _count < 3 && X->forward[_i] != _last; _count++) \ + X = X->forward[_i]; \ + HDassert(X->forward[_i] == _last); \ + \ + /* Demote the separator node */ \ + H5SL_DEMOTE(_last, _llast) \ + \ + /* If there are 2 or more nodes, promote the last */ \ + if(_count >= 2) \ + H5SL_PROMOTE(SLIST, X, _llast) \ + else if(!_head->forward[_i+1]) { \ + /* shrink the header */ \ + HDassert(_i == SLIST->curr_level - 1); \ + HDassert((size_t) SLIST->curr_level == _head->level); \ + \ + H5SL_SHRINK(_head, (size_t) (_i+1)) \ + SLIST->curr_level--; \ + } /* end else */ \ + } /* end else */ \ + } /* end if */ \ + \ + /* Prepare to drop down */ \ + _llast = _ldrop; \ + _last = _drop; \ + _next = _drop->forward[_i]; \ + } /* end for */ \ + \ + /* Check if we've found the node */ \ + if(_next && H5_GLUE3(H5SL_LOCATE_,CMP,_EQ)(TYPE, _next, KEY, HASHVAL)) { \ + void *tmp = _next->item; \ + X = _next; \ + \ + /* If the node has a height > 0, swap it with its (lower) neighbor */ \ + if(X->level) { \ + X = X->backward; \ + _next->key = X->key; \ + _next->item = X->item; \ + _next->hashval = X->hashval; \ + } /* end if */ \ + HDassert(!X->level); \ + \ + /* Remove the node */ \ + X->backward->forward[0] = X->forward[0]; \ + if(SLIST->last == X) \ + SLIST->last = X->backward; \ + else \ + X->forward[0]->backward = X->backward; \ + SLIST->nobjs--; \ + (void)H5FL_FAC_FREE(H5SL_fac_g[0], X->forward); \ + (void)H5FL_FREE(H5SL_node_t, X); \ + \ + HGOTO_DONE(tmp); \ + } /* end if */ \ +} + /* Macro used to search for node */ -#define H5SL_SEARCH(CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) \ - H5SL_LOCATE(SEARCH, CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) +#define H5SL_SEARCH(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + H5SL_LOCATE(SEARCH, CMP, SLIST, X, TYPE, KEY, HASHVAL) /* Macro used to find a node */ -#define H5SL_FIND(CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) \ - H5SL_LOCATE(FIND, CMP, SLIST, X, UPDATE, TYPE, KEY, HASHVAL) +#define H5SL_FIND(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + H5SL_LOCATE(FIND, CMP, SLIST, X, TYPE, KEY, HASHVAL) /* Private typedefs & structs */ @@ -186,6 +475,7 @@ struct H5SL_node_t { const void *key; /* Pointer to node's key */ void *item; /* Pointer to node's item */ size_t level; /* The level of this node */ + size_t log_nalloc; /* log2(Number of slots allocated in forward) */ uint32_t hashval; /* Hash value for key (only for strings, currently) */ struct H5SL_node_t **forward; /* Array of forward pointers from this node */ struct H5SL_node_t *backward; /* Backward pointer from this node */ @@ -195,9 +485,6 @@ struct H5SL_node_t { struct H5SL_t { /* Static values for each list */ H5SL_type_t type; /* Type of skip list */ - double p; /* Probability of using a higher level [0..1) */ - int p1; /* Probability converted into appropriate value for random # generator on this machine */ - size_t max_level; /* Maximum number of levels */ /* Dynamic values for each list */ int curr_level; /* Current top level used in list */ @@ -207,8 +494,7 @@ struct H5SL_t { }; /* Static functions */ -static size_t H5SL_random_level(int p1, size_t max_level); -static H5SL_node_t * H5SL_new_node(size_t lvl, void *item, const void *key, uint32_t hashval); +static H5SL_node_t * H5SL_new_node(void *item, const void *key, uint32_t hashval); static H5SL_node_t *H5SL_insert_common(H5SL_t *slist, void *item, const void *key); static herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); static herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data); @@ -216,9 +502,13 @@ static herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data /* Declare a free list to manage the H5SL_t struct */ H5FL_DEFINE_STATIC(H5SL_t); -/* Declare a "base + array" list to manage the H5SL_node_t struct */ -typedef H5SL_node_t *H5SL_node_ptr_t; -H5FL_BARR_DEFINE_STATIC(H5SL_node_t,H5SL_node_ptr_t,H5SL_LEVEL_MAX); +/* Declare a free list to manage the H5SL_node_t struct */ +H5FL_DEFINE_STATIC(H5SL_node_t); + +/* Global variables */ +static H5FL_fac_head_t **H5SL_fac_g; +static size_t H5SL_fac_nused_g; +static size_t H5SL_fac_nalloc_g; /*-------------------------------------------------------------------------- @@ -241,13 +531,15 @@ H5FL_BARR_DEFINE_STATIC(H5SL_node_t,H5SL_node_ptr_t,H5SL_LEVEL_MAX); static herr_t H5SL_init_interface(void) { - time_t curr_time; /* Current time, for seeding random number generator */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_init_interface) - /* Create randomized set of numbers */ - curr_time=HDtime(NULL); - HDsrand((unsigned)curr_time); + /* Allocate space for array of factories */ + H5SL_fac_g = (H5FL_fac_head_t **)H5MM_malloc(sizeof(H5FL_fac_head_t *)); + H5SL_fac_nalloc_g = 1; + + /* Initialize first factory */ + H5SL_fac_g[0] = H5FL_fac_init(sizeof(H5SL_node_t *)); + H5SL_fac_nused_g = 1; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5SL_init_interface() */ @@ -255,87 +547,45 @@ H5SL_init_interface(void) /*-------------------------------------------------------------------------- NAME - H5SL_random_level - PURPOSE - Generate a random level - USAGE - size_t H5SL_random_level(p,max_level) - int p1; IN: probability distribution - size_t max_level; IN: Maximum level for node height - - RETURNS - Returns non-negative level value - DESCRIPTION - Count elements in a skip list. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Do we really need a 'random' value, or is a series of nodes with the - correct heights "good enough". We could track the state of the nodes - allocated for this list and issue node heights appropriately (i.e. 1,2, - 1,4,1,2,1,8,...) (or would that be 1,1,2,1,1,2,4,... ?) - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static size_t -H5SL_random_level(int p1, size_t max_level) -{ - size_t lvl; /* Level generated */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_random_level); - - /* Account for starting at zero offset */ - max_level--; - - lvl=0; - while(HDrand()key = key; ret_value->item = item; - ret_value->level = lvl; + ret_value->level = 0; ret_value->hashval = hashval; - ret_value->forward = (H5SL_node_t **)((unsigned char *)ret_value + sizeof(H5SL_node_t)); + if(NULL == (ret_value->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") + ret_value->log_nalloc = 0; done: FUNC_LEAVE_NOAPI(ret_value) @@ -366,18 +616,16 @@ done: static H5SL_node_t * H5SL_insert_common(H5SL_t *slist, void *item, const void *key) { - H5SL_node_t **update[H5SL_LEVEL_MAX]; /* 'update' vector */ H5SL_node_t *x; /* Current node to examine */ + H5SL_node_t *prev; /* Node before the new node */ uint32_t hashval = 0; /* Hash value for key */ - size_t lvl; /* Level of new node */ - int i; /* Local index value */ H5SL_node_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5SL_insert_common); /* Check args */ - assert(slist); - assert(key); + HDassert(slist); + HDassert(key); /* Check internal consistency */ /* (Pre-condition) */ @@ -387,75 +635,60 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) /* Work through the forward pointers for a node, finding the node at each * level that is before the location to insert */ - x=slist->header; + prev=slist->header; switch(slist->type) { case H5SL_TYPE_INT: - H5SL_INSERT(SCALAR, slist, x, update, const int, key, -) + H5SL_INSERT(SCALAR, slist, prev, const int, key, -) break; case H5SL_TYPE_HADDR: - H5SL_INSERT(SCALAR, slist, x, update, const haddr_t, key, -) + H5SL_INSERT(SCALAR, slist, prev, const haddr_t, key, -) break; case H5SL_TYPE_STR: - H5SL_INSERT(STRING, slist, x, update, char *, key, hashval) + H5SL_INSERT(STRING, slist, prev, char *, key, hashval) break; case H5SL_TYPE_HSIZE: - H5SL_INSERT(SCALAR, slist, x, update, const hsize_t, key, -) + H5SL_INSERT(SCALAR, slist, prev, const hsize_t, key, -) break; case H5SL_TYPE_UNSIGNED: - H5SL_INSERT(SCALAR, slist, x, update, const unsigned, key, -) + H5SL_INSERT(SCALAR, slist, prev, const unsigned, key, -) break; case H5SL_TYPE_SIZE: - H5SL_INSERT(SCALAR, slist, x, update, const size_t, key, -) + H5SL_INSERT(SCALAR, slist, prev, const size_t, key, -) break; case H5SL_TYPE_OBJ: - H5SL_INSERT(OBJ, slist, x, update, const H5_obj_t, key, -) + H5SL_INSERT(OBJ, slist, prev, const H5_obj_t, key, -) break; default: HDassert(0 && "Unknown skiplist type!"); } /* end switch */ - /* 'key' must not have been found in existing list, if we get here */ - - /* Generate level for new node */ - lvl=H5SL_random_level(slist->p1,slist->max_level); - if((int)lvl>slist->curr_level) { - /* Cap the increase in the current level to just one greater */ - lvl=slist->curr_level+1; - /* Set the update pointer correctly */ - update[lvl]=&slist->header->forward[lvl]; + /* 'key' must not have been found in existing list, if we get here */ - /* Increase the maximum level of the list */ - slist->curr_level=(int)lvl; - } /* end if */ + if(slist->curr_level < 0) + slist->curr_level = 0; - /* Create new node of proper level */ - if(NULL == (x = H5SL_new_node(lvl, item, key, hashval))) + /* Create new node of level 0 */ + if(NULL == (x = H5SL_new_node(item, key, hashval))) HGOTO_ERROR(H5E_SLIST ,H5E_NOSPACE, NULL, "can't create new skip list node") - /* Update the backward links */ - if(*update[0]!=NULL) { - x->backward=(*update[0])->backward; - (*update[0])->backward=x; - } /* end if */ + /* Update the links */ + x->backward = prev; + x->forward[0] = prev->forward[0]; + prev->forward[0] = x; + if(x->forward[0]) + x->forward[0]->backward = x; else { HDassert(slist->last); - x->backward=slist->last; - slist->last=x; - } /* end else */ - - /* Link the new node into the existing forward pointers */ - for(i=0; i<=(int)lvl; i++) { - x->forward[i]=*update[i]; - *update[i]=x; - } /* end for */ + slist->last = x; + } /* Increment the number of nodes in the skip list */ slist->nobjs++; @@ -474,7 +707,7 @@ done: PURPOSE Release all nodes from a skip list, optionally calling a 'free' operator USAGE - herr_t H5SL_release_common(slist) + herr_t H5SL_release_common(slist,op,opdata) H5SL_t *slist; IN/OUT: Pointer to skip list to release nodes H5SL_operator_t op; IN: Callback function to free item & key void *op_data; IN/OUT: Pointer to application data for callback @@ -496,9 +729,9 @@ herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */ - size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_release_common); + FUNC_ENTER_NOAPI_NOINIT(H5SL_release_common); /* Check args */ assert(slist); @@ -516,13 +749,18 @@ H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Casting away const OK -QAK */ (void)(op)(node->item,(void *)node->key,op_data); - H5FL_ARR_FREE(H5SL_node_ptr_t,node); + (void)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], node->forward); + (void)H5FL_FREE(H5SL_node_t, node); node=next_node; } /* end while */ /* Reset the header pointers */ - for(u=0; umax_level; u++) - slist->header->forward[u]=NULL; + (void)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); + if(NULL == (slist->header->forward = (H5SL_node_t **) H5FL_FAC_MALLOC(H5SL_fac_g[0]))) + HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, FAIL, "memory allocation failed") + slist->header->forward[0] = NULL; + slist->header->log_nalloc = 0; + slist->header->level = 0; /* Reset the last pointer */ slist->last=slist->header; @@ -531,7 +769,8 @@ H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) slist->curr_level=-1; slist->nobjs=0; - FUNC_LEAVE_NOAPI(SUCCEED); +done: + FUNC_LEAVE_NOAPI(ret_value); } /* end H5SL_release_common() */ @@ -561,7 +800,9 @@ H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_close_common) + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT(H5SL_close_common) /* Check args */ HDassert(slist); @@ -570,15 +811,18 @@ H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* (Pre-condition) */ /* Free skip list nodes */ - (void)H5SL_release_common(slist, op, op_data); /* always succeeds */ + if(H5SL_release_common(slist, op, op_data) < 0) + HGOTO_ERROR(H5E_SLIST, H5E_CANTFREE, FAIL, "can't release skip list nodes") /* Release header node */ - H5FL_ARR_FREE(H5SL_node_ptr_t, slist->header); + (void)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], slist->header->forward); + (void)H5FL_FREE(H5SL_node_t, slist->header); /* Free skip list object */ (void)H5FL_FREE(H5SL_t, slist); - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_close_common() */ @@ -588,7 +832,7 @@ H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) PURPOSE Create a skip list USAGE - H5SL_t *H5SL_create(void) + H5SL_t *H5SL_create(H5SL_type_t type) RETURNS Returns a pointer to a skip list on success, NULL on failure. @@ -600,18 +844,15 @@ H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) REVISION LOG --------------------------------------------------------------------------*/ H5SL_t * -H5SL_create(H5SL_type_t type, double p, size_t max_level) +H5SL_create(H5SL_type_t type) { H5SL_t *new_slist = NULL; /* Pointer to new skip list object created */ H5SL_node_t *header; /* Pointer to skip list header node */ - size_t u; /* Local index variable */ H5SL_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5SL_create,NULL); /* Check args */ - HDassert(p>0.0 && p<1.0); - HDassert(max_level>0 && max_level<=H5SL_LEVEL_MAX); HDassert(type>=H5SL_TYPE_INT && type<=H5SL_TYPE_OBJ); /* Allocate skip list structure */ @@ -620,21 +861,17 @@ H5SL_create(H5SL_type_t type, double p, size_t max_level) /* Set the static internal fields */ new_slist->type = type; - new_slist->p = p; - new_slist->p1 = (int)(p*RAND_MAX); - new_slist->max_level = max_level; /* Set the dynamic internal fields */ new_slist->curr_level = -1; new_slist->nobjs = 0; /* Allocate the header node */ - if(NULL == (header = H5SL_new_node((max_level - 1), NULL, NULL, ULONG_MAX))) + if(NULL == (header = H5SL_new_node(NULL, NULL, ULONG_MAX))) HGOTO_ERROR(H5E_SLIST ,H5E_NOSPACE, NULL, "can't create new skip list node") - /* Initialize header node's forward pointers */ - for(u = 0; u < max_level; u++) - header->forward[u] = NULL; + /* Initialize header node's forward pointer */ + header->forward[0] = NULL; /* Initialize header node's backward pointer */ header->backward = NULL; @@ -803,12 +1040,11 @@ done: void * H5SL_remove(H5SL_t *slist, const void *key) { - H5SL_node_t **update[H5SL_LEVEL_MAX]; /* 'update' vector */ H5SL_node_t *x; /* Current node to examine */ uint32_t hashval = 0; /* Hash value for key */ void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_remove) + FUNC_ENTER_NOAPI_NOINIT(H5SL_remove) /* Check args */ HDassert(slist); @@ -825,31 +1061,31 @@ H5SL_remove(H5SL_t *slist, const void *key) x = slist->header; switch(slist->type) { case H5SL_TYPE_INT: - H5SL_REMOVE(SCALAR, slist, x, update, const int, key, -) + H5SL_REMOVE(SCALAR, slist, x, const int, key, -) break; case H5SL_TYPE_HADDR: - H5SL_REMOVE(SCALAR, slist, x, update, const haddr_t, key, -) + H5SL_REMOVE(SCALAR, slist, x, const haddr_t, key, -) break; case H5SL_TYPE_STR: - H5SL_REMOVE(STRING, slist, x, update, char *, key, hashval) + H5SL_REMOVE(STRING, slist, x, char *, key, hashval) break; case H5SL_TYPE_HSIZE: - H5SL_REMOVE(SCALAR, slist, x, update, const hsize_t, key, -) + H5SL_REMOVE(SCALAR, slist, x, const hsize_t, key, -) break; case H5SL_TYPE_UNSIGNED: - H5SL_REMOVE(SCALAR, slist, x, update, const unsigned, key, -) + H5SL_REMOVE(SCALAR, slist, x, const unsigned, key, -) break; case H5SL_TYPE_SIZE: - H5SL_REMOVE(SCALAR, slist, x, update, const size_t, key, -) + H5SL_REMOVE(SCALAR, slist, x, const size_t, key, -) break; case H5SL_TYPE_OBJ: - H5SL_REMOVE(OBJ, slist, x, update, const H5_obj_t, key, -) + H5SL_REMOVE(OBJ, slist, x, const H5_obj_t, key, -) break; default: @@ -876,8 +1112,6 @@ done: Remove first element from a skip list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS - This algorithm is basically the same as the one in the - H5SL_LOCATE_REMOVE_FOUND macro, fix bugs in both places EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ @@ -885,8 +1119,13 @@ void * H5SL_remove_first(H5SL_t *slist) { void *ret_value = NULL; /* Return value */ + H5SL_node_t *head = slist->header; /* Skip list header */ + H5SL_node_t *tmp = slist->header->forward[0]; /* Temporary node pointer */ + H5SL_node_t *next; /* Next node to search for */ + size_t level = slist->curr_level; /* Skip list level */ + size_t i; /* Index */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_remove_first) + FUNC_ENTER_NOAPI_NOINIT(H5SL_remove_first) /* Check args */ HDassert(slist); @@ -898,39 +1137,62 @@ H5SL_remove_first(H5SL_t *slist) /* Check for empty list */ if(slist->last != slist->header) { - H5SL_node_t *x; /* Current node to examine */ - int i; /* Local index value */ - /* Get pointer to first node on the list */ - x = slist->header->forward[0]; - - /* Patch forward pointers in list header around node to remove */ - for(i = 0; i <= (int)slist->curr_level; i++) { - if(slist->header->forward[i] != x) - break; - slist->header->forward[i] = x->forward[i]; - } /* end for */ + /* Assign return value */ + ret_value = tmp->item; + HDassert(level == head->level); + HDassert(0 == tmp->level); - /* Update tail/backward pointer */ - if(slist->last == x) - slist->last = x->backward; + /* Remove the first node */ + head->forward[0] = tmp->forward[0]; + if(slist->last == tmp) + slist->last = head; else - x->forward[0]->backward = x->backward; - - /* Get the item to return */ - ret_value = x->item; - - /* Free the skip list node */ - H5FL_ARR_FREE(H5SL_node_ptr_t, x); - - /* Lower the level of the list, if we removed the tallest node */ - while(slist->curr_level > 0 && slist->header->forward[slist->curr_level] == NULL) - slist->curr_level--; - - /* Decrement the # of objects in the list */ + tmp->forward[0]->backward = head; slist->nobjs--; + /* Free memory */ + (void)H5FL_FAC_FREE(H5SL_fac_g[0], tmp->forward); + (void)H5FL_FREE(H5SL_node_t, tmp); + + /* Reshape the skip list as necessary to maintain 1-2-3 condition */ + for(i=0; i < level; i++) { + next = head->forward[i+1]; + HDassert(next); + + /* Check if head->forward[i] == head->forward[i+1] (illegal) */ + if(head->forward[i] == next) { + tmp = next; + next = next->forward[i+1]; + + HDassert(tmp->level == i+1); + + /* Demote head->forward[i] */ + H5SL_DEMOTE(tmp, head) + + /* Check if we need to promote the following node to maintain + * 1-2-3 condition */ + if(tmp->forward[i]->forward[i] != next) { + HDassert(tmp->forward[i]->forward[i]->forward[i] == next || + tmp->forward[i]->forward[i]->forward[i]->forward[i] == next); + tmp = tmp->forward[i]; + H5SL_PROMOTE(slist, tmp, head); + /* In this case, since there is a node of height = i+1 here + * now (tmp), we know the skip list must be valid and can + * break */ + break; + } else if(!head->forward[i+1]) { + /* We just shrunk the largest node, shrink the header */ + HDassert(i == level - 1); + + H5SL_SHRINK(head, level) + slist->curr_level--; + } /* end else */ + } else + break; + } /* end for */ } /* end if */ +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_remove_first() */ @@ -978,31 +1240,31 @@ H5SL_search(H5SL_t *slist, const void *key) x=slist->header; switch(slist->type) { case H5SL_TYPE_INT: - H5SL_SEARCH(SCALAR, slist, x, -, const int, key, -) + H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; case H5SL_TYPE_HADDR: - H5SL_SEARCH(SCALAR, slist, x, -, const haddr_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const haddr_t, key, -) break; case H5SL_TYPE_STR: - H5SL_SEARCH(STRING, slist, x, -, char *, key, hashval) + H5SL_SEARCH(STRING, slist, x, char *, key, hashval) break; case H5SL_TYPE_HSIZE: - H5SL_SEARCH(SCALAR, slist, x, -, const hsize_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const hsize_t, key, -) break; case H5SL_TYPE_UNSIGNED: - H5SL_SEARCH(SCALAR, slist, x, -, const unsigned, key, -) + H5SL_SEARCH(SCALAR, slist, x, const unsigned, key, -) break; case H5SL_TYPE_SIZE: - H5SL_SEARCH(SCALAR, slist, x, -, const size_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const size_t, key, -) break; case H5SL_TYPE_OBJ: - H5SL_SEARCH(OBJ, slist, x, -, const H5_obj_t, key, -) + H5SL_SEARCH(OBJ, slist, x, const H5_obj_t, key, -) break; default: @@ -1063,31 +1325,31 @@ H5SL_less(H5SL_t *slist, const void *key) x=slist->header; switch(slist->type) { case H5SL_TYPE_INT: - H5SL_SEARCH(SCALAR, slist, x, -, const int, key, -) + H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; case H5SL_TYPE_HADDR: - H5SL_SEARCH(SCALAR, slist, x, -, const haddr_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const haddr_t, key, -) break; case H5SL_TYPE_STR: - H5SL_SEARCH(STRING, slist, x, -, char *, key, hashval) + H5SL_SEARCH(STRING, slist, x, char *, key, hashval) break; case H5SL_TYPE_HSIZE: - H5SL_SEARCH(SCALAR, slist, x, -, const hsize_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const hsize_t, key, -) break; case H5SL_TYPE_UNSIGNED: - H5SL_SEARCH(SCALAR, slist, x, -, const unsigned, key, -) + H5SL_SEARCH(SCALAR, slist, x, const unsigned, key, -) break; case H5SL_TYPE_SIZE: - H5SL_SEARCH(SCALAR, slist, x, -, const size_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const size_t, key, -) break; case H5SL_TYPE_OBJ: - H5SL_SEARCH(OBJ, slist, x, -, const H5_obj_t, key, -) + H5SL_SEARCH(OBJ, slist, x, const H5_obj_t, key, -) break; default: @@ -1161,31 +1423,31 @@ H5SL_greater(H5SL_t *slist, const void *key) x = slist->header; switch(slist->type) { case H5SL_TYPE_INT: - H5SL_SEARCH(SCALAR, slist, x, -, const int, key, -) + H5SL_SEARCH(SCALAR, slist, x, const int, key, -) break; case H5SL_TYPE_HADDR: - H5SL_SEARCH(SCALAR, slist, x, -, const haddr_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const haddr_t, key, -) break; case H5SL_TYPE_STR: - H5SL_SEARCH(STRING, slist, x, -, char *, key, hashval) + H5SL_SEARCH(STRING, slist, x, char *, key, hashval) break; case H5SL_TYPE_HSIZE: - H5SL_SEARCH(SCALAR, slist, x, -, const hsize_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const hsize_t, key, -) break; case H5SL_TYPE_UNSIGNED: - H5SL_SEARCH(SCALAR, slist, x, -, const unsigned, key, -) + H5SL_SEARCH(SCALAR, slist, x, const unsigned, key, -) break; case H5SL_TYPE_SIZE: - H5SL_SEARCH(SCALAR, slist, x, -, const size_t, key, -) + H5SL_SEARCH(SCALAR, slist, x, const size_t, key, -) break; case H5SL_TYPE_OBJ: - H5SL_SEARCH(OBJ, slist, x, -, const H5_obj_t, key, -) + H5SL_SEARCH(OBJ, slist, x, const H5_obj_t, key, -) break; default: @@ -1249,31 +1511,31 @@ H5SL_find(H5SL_t *slist, const void *key) x=slist->header; switch(slist->type) { case H5SL_TYPE_INT: - H5SL_FIND(SCALAR, slist, x, -, const int, key, -) + H5SL_FIND(SCALAR, slist, x, const int, key, -) break; case H5SL_TYPE_HADDR: - H5SL_FIND(SCALAR, slist, x, -, const haddr_t, key, -) + H5SL_FIND(SCALAR, slist, x, const haddr_t, key, -) break; case H5SL_TYPE_STR: - H5SL_FIND(STRING, slist, x, -, char *, key, hashval) + H5SL_FIND(STRING, slist, x, char *, key, hashval) break; case H5SL_TYPE_HSIZE: - H5SL_FIND(SCALAR, slist, x, -, const hsize_t, key, -) + H5SL_FIND(SCALAR, slist, x, const hsize_t, key, -) break; case H5SL_TYPE_UNSIGNED: - H5SL_FIND(SCALAR, slist, x, -, const unsigned, key, -) + H5SL_FIND(SCALAR, slist, x, const unsigned, key, -) break; case H5SL_TYPE_SIZE: - H5SL_FIND(SCALAR, slist, x, -, const size_t, key, -) + H5SL_FIND(SCALAR, slist, x, const size_t, key, -) break; case H5SL_TYPE_OBJ: - H5SL_FIND(OBJ, slist, x, -, const H5_obj_t, key, -) + H5SL_FIND(OBJ, slist, x, const H5_obj_t, key, -) break; default: @@ -1334,31 +1596,31 @@ H5SL_below(H5SL_t *slist, const void *key) x = slist->header; switch(slist->type) { case H5SL_TYPE_INT: - H5SL_FIND(SCALAR, slist, x, -, const int, key, -) + H5SL_FIND(SCALAR, slist, x, const int, key, -) break; case H5SL_TYPE_HADDR: - H5SL_FIND(SCALAR, slist, x, -, const haddr_t, key, -) + H5SL_FIND(SCALAR, slist, x, const haddr_t, key, -) break; case H5SL_TYPE_STR: - H5SL_FIND(STRING, slist, x, -, char *, key, hashval) + H5SL_FIND(STRING, slist, x, char *, key, hashval) break; case H5SL_TYPE_HSIZE: - H5SL_FIND(SCALAR, slist, x, -, const hsize_t, key, -) + H5SL_FIND(SCALAR, slist, x, const hsize_t, key, -) break; case H5SL_TYPE_UNSIGNED: - H5SL_FIND(SCALAR, slist, x, -, const unsigned, key, -) + H5SL_FIND(SCALAR, slist, x, const unsigned, key, -) break; case H5SL_TYPE_SIZE: - H5SL_FIND(SCALAR, slist, x, -, const size_t, key, -) + H5SL_FIND(SCALAR, slist, x, const size_t, key, -) break; case H5SL_TYPE_OBJ: - H5SL_FIND(OBJ, slist, x, -, const H5_obj_t, key, -) + H5SL_FIND(OBJ, slist, x, const H5_obj_t, key, -) break; } /* end switch */ @@ -1429,31 +1691,31 @@ H5SL_above(H5SL_t *slist, const void *key) x = slist->header; switch(slist->type) { case H5SL_TYPE_INT: - H5SL_FIND(SCALAR, slist, x, -, const int, key, -) + H5SL_FIND(SCALAR, slist, x, const int, key, -) break; case H5SL_TYPE_HADDR: - H5SL_FIND(SCALAR, slist, x, -, const haddr_t, key, -) + H5SL_FIND(SCALAR, slist, x, const haddr_t, key, -) break; case H5SL_TYPE_STR: - H5SL_FIND(STRING, slist, x, -, char *, key, hashval) + H5SL_FIND(STRING, slist, x, char *, key, hashval) break; case H5SL_TYPE_HSIZE: - H5SL_FIND(SCALAR, slist, x, -, const hsize_t, key, -) + H5SL_FIND(SCALAR, slist, x, const hsize_t, key, -) break; case H5SL_TYPE_UNSIGNED: - H5SL_FIND(SCALAR, slist, x, -, const unsigned, key, -) + H5SL_FIND(SCALAR, slist, x, const unsigned, key, -) break; case H5SL_TYPE_SIZE: - H5SL_FIND(SCALAR, slist, x, -, const size_t, key, -) + H5SL_FIND(SCALAR, slist, x, const size_t, key, -) break; case H5SL_TYPE_OBJ: - H5SL_FIND(OBJ, slist, x, -, const H5_obj_t, key, -) + H5SL_FIND(OBJ, slist, x, const H5_obj_t, key, -) break; } /* end switch */ @@ -1868,3 +2130,50 @@ H5SL_close(H5SL_t *slist) FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5SL_close() */ + +/*-------------------------------------------------------------------------- + NAME + H5SL_term_interface + PURPOSE + Terminate all the H5FL factories used in this package, and clear memory + USAGE + int H5SL_term_interface() + RETURNS + Success: Positive if any action might have caused a change in some + other interface; zero otherwise. + Failure: Negative + DESCRIPTION + Release any resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int H5SL_term_interface(void) +{ + size_t i; + herr_t ret; + int n = H5_interface_initialize_g ? 1 : 0; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_term_interface) + + if(n) { + /* Terminate all the factories */ + for(i=0; i= 0); + } + H5SL_fac_nused_g = 0; + + /* Free the list of factories */ + H5SL_fac_g = (H5FL_reg_head_t **)H5MM_xfree((void *)H5SL_fac_g); + H5SL_fac_nalloc_g = 0; + + /* Mark the interface as uninitialized */ + H5_interface_initialize_g = 0; + } /* end if */ + + FUNC_LEAVE_NOAPI(n); +} /* H5SL_term_interface() */ + diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index 27bb4d1..40fbfa9 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -53,7 +53,6 @@ typedef enum { /**********/ /* Macros */ /**********/ -#define H5SL_LEVEL_MAX 32 /* (for now) */ /* Typedef for iteration operations */ typedef herr_t (*H5SL_operator_t)(void *item, void *key, @@ -62,7 +61,7 @@ typedef herr_t (*H5SL_operator_t)(void *item, void *key, /********************/ /* Private routines */ /********************/ -H5_DLL H5SL_t *H5SL_create(H5SL_type_t type, double p, size_t max_level); +H5_DLL H5SL_t *H5SL_create(H5SL_type_t type); H5_DLL size_t H5SL_count(H5SL_t *slist); H5_DLL herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key); H5_DLL H5SL_node_t *H5SL_add(H5SL_t *slist, void *item, const void *key); @@ -84,6 +83,7 @@ H5_DLL herr_t H5SL_release(H5SL_t *slist); H5_DLL herr_t H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data); H5_DLL herr_t H5SL_close(H5SL_t *slist); H5_DLL herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data); +H5_DLL int H5SL_term_interface(void); #endif /* _H5SLprivate_H */ diff --git a/src/H5SMcache.c b/src/H5SMcache.c index 91478c5..d53993e 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -76,6 +76,7 @@ const H5AC_class_t H5AC_SOHM_TABLE[1] = {{ (H5AC_flush_func_t)H5SM_table_flush, (H5AC_dest_func_t)H5SM_table_dest, (H5AC_clear_func_t)H5SM_table_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5SM_table_size, }}; @@ -85,6 +86,7 @@ const H5AC_class_t H5AC_SOHM_LIST[1] = {{ (H5AC_flush_func_t)H5SM_list_flush, (H5AC_dest_func_t)H5SM_list_dest, (H5AC_clear_func_t)H5SM_list_clear, + (H5AC_notify_func_t)NULL, (H5AC_size_func_t)H5SM_list_size, }}; diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 90b7a21..c621bf4 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -194,7 +194,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -203,7 +203,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MIN); \ + *((DT*)D) = (DT)(D_MIN); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -212,9 +212,9 @@ } #define H5T_CONV_Xx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else if (*((ST*)S) < (DT)(D_MIN)) { \ - *((DT*)D) = (D_MIN); \ + *((DT*)D) = (DT)(D_MIN); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } @@ -225,7 +225,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -234,7 +234,7 @@ } #define H5T_CONV_Ux_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } @@ -270,12 +270,12 @@ } #define H5T_CONV_uS_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ - if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (D_MAX)) { \ + if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ H5T_conv_ret_t except_ret = (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, \ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -319,7 +319,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -330,7 +330,7 @@ if (*((ST*)S) < 0) { \ *((DT*)D) = 0; \ } else if (sizeof(ST)>sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } @@ -384,7 +384,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -394,7 +394,7 @@ #define H5T_CONV_us_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ /* Assumes memory format of unsigned & signed integers is same */ \ if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else \ *((DT*)D) = (DT)(*((ST*)S)); \ } @@ -553,7 +553,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -562,7 +562,7 @@ src_id, dst_id, S, D, cb_struct.user_data); \ if(except_ret == H5T_CONV_UNHANDLED) \ /* Let compiler convert if case is ignored by user handler*/ \ - *((DT*)D) = (D_MIN); \ + *((DT*)D) = (DT)(D_MIN); \ else if(except_ret == H5T_CONV_ABORT) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") \ /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ @@ -581,9 +581,9 @@ } #define H5T_CONV_Fx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \ if (*((ST*)S) > (DT)(D_MAX)) { \ - *((DT*)D) = (D_MAX); \ + *((DT*)D) = (DT)(D_MAX); \ } else if (*((ST*)S) < (DT)(D_MIN)) { \ - *((DT*)D) = (D_MIN); \ + *((DT*)D) = (DT)(D_MIN); \ } \ else \ *((DT*)D) = (DT)(*((ST*)S)); \ @@ -621,7 +621,7 @@ case H5T_CONV_INIT: \ /* Sanity check and initialize statistics */ \ cdata->need_bkg = H5T_BKG_NO; \ - if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \ + if (NULL==(st=(H5T_t*)H5I_object(src_id)) || NULL==(dt=(H5T_t*)H5I_object(dst_id))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "unable to dereference datatype object ID") \ if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \ @@ -669,7 +669,7 @@ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback"); \ \ /* Get source and destination datatypes */ \ - if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \ + if (NULL==(st=(H5T_t*)H5I_object(src_id)) || NULL==(dt=(H5T_t*)H5I_object(dst_id))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "unable to dereference datatype object ID") \ \ @@ -714,7 +714,7 @@ } /* end if */ \ else { \ /* Single forward pass over all data */ \ - src = dst = buf; \ + src = dst = (uint8_t*)buf; \ safe=nelmts; \ } /* end else */ \ \ @@ -9755,8 +9755,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -9774,8 +9774,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -10345,8 +10345,8 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -10364,8 +10364,8 @@ H5T_conv_i_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if (NULL==(src_p=H5I_object(src_id)) || - NULL==(dst_p=H5I_object(dst_id))) + if (NULL==(src_p=(H5T_t*)H5I_object(src_id)) || + NULL==(dst_p=(H5T_t*)H5I_object(dst_id))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; diff --git a/src/H5Z.c b/src/H5Z.c index 4df6abd..417ae77 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -53,7 +53,7 @@ typedef enum { /* Local variables */ static size_t H5Z_table_alloc_g = 0; static size_t H5Z_table_used_g = 0; -static H5Z_class_t *H5Z_table_g = NULL; +static H5Z_class2_t *H5Z_table_g = NULL; #ifdef H5Z_DEBUG static H5Z_stats_t *H5Z_stat_table_g = NULL; #endif /* H5Z_DEBUG */ @@ -191,7 +191,7 @@ H5Z_term_interface(void) } #endif /* H5Z_DEBUG */ /* Free the table of filters */ - H5Z_table_g = (H5Z_class_t *)H5MM_xfree(H5Z_table_g); + H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); #ifdef H5Z_DEBUG H5Z_stat_table_g = (H5Z_stats_t *)H5MM_xfree(H5Z_stat_table_g); #endif /* H5Z_DEBUG */ @@ -220,32 +220,62 @@ H5Z_term_interface(void) *------------------------------------------------------------------------- */ herr_t -H5Zregister(const H5Z_class_t *cls) +H5Zregister(const void *cls) { - herr_t ret_value=SUCCEED; /* Return value */ + const H5Z_class2_t *cls_real = (const H5Z_class2_t *) cls; /* "Real" class pointer */ + H5Z_class2_t cls_new; /* Translated class struct */ + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Zregister, FAIL) - H5TRACE1("e", "*Zc", cls); + H5TRACE1("e", "*x", cls); /* Check args */ - if (cls==NULL) + if (cls_real==NULL) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class") /* Check H5Z_class_t version number; this is where a function to convert * from an outdated version should be called. + * + * If the version number is invalid, we assume that the target of cls is the + * old style "H5Z_class1_t" structure, which did not contain a version + * field. In this structure, the first field is the id. Since both version + * and id are integers they will have the same value, and since id must be + * at least 256, there should be no overlap and the version of the struct + * can be determined by the value of the first field. */ - if(cls->version != H5Z_CLASS_T_VERS) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number"); + if(cls_real->version != H5Z_CLASS_T_VERS) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Assume it is an old "H5Z_class1_t" instead */ + const H5Z_class1_t *cls_old = (const H5Z_class1_t *) cls; + + /* Translate to new H5Z_class2_t */ + cls_new.version = H5Z_CLASS_T_VERS; + cls_new.id = cls_old->id; + cls_new.encoder_present = 1; + cls_new.decoder_present = 1; + cls_new.name = cls_old->name; + cls_new.can_apply = cls_old->can_apply; + cls_new.set_local = cls_old->set_local; + cls_new.filter = cls_old->filter; + + /* Set cls_real to point to the translated structure */ + cls_real = &cls_new; + +#else /* H5_NO_DEPRECATED_SYMBOLS */ + /* Deprecated symbols not allowed, throw an error */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number"); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + } /* end if */ - if (cls->id<0 || cls->id>H5Z_FILTER_MAX) + if (cls_real->id<0 || cls_real->id>H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") - if (cls->ididfilter==NULL) + if (cls_real->filter==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified") /* Do it */ - if (H5Z_register (cls)<0) + if (H5Z_register (cls_real)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") done: @@ -269,7 +299,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Z_register (const H5Z_class_t *cls) +H5Z_register (const H5Z_class2_t *cls) { size_t i; herr_t ret_value = SUCCEED; /* Return value */ @@ -288,7 +318,7 @@ H5Z_register (const H5Z_class_t *cls) if(i >= H5Z_table_used_g) { if(H5Z_table_used_g >= H5Z_table_alloc_g) { size_t n = MAX(H5Z_MAX_NFILTERS, 2*H5Z_table_alloc_g); - H5Z_class_t *table = (H5Z_class_t *)H5MM_realloc(H5Z_table_g, n * sizeof(H5Z_class_t)); + H5Z_class2_t *table = (H5Z_class2_t *)H5MM_realloc(H5Z_table_g, n * sizeof(H5Z_class2_t)); #ifdef H5Z_DEBUG H5Z_stats_t *stat_table = (H5Z_stats_t *)H5MM_realloc(H5Z_stat_table_g, n * sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ @@ -305,7 +335,7 @@ H5Z_register (const H5Z_class_t *cls) /* Initialize */ i = H5Z_table_used_g++; - HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class_t)); + HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); #ifdef H5Z_DEBUG HDmemset(H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ @@ -313,7 +343,7 @@ H5Z_register (const H5Z_class_t *cls) /* Filter already registered */ else { /* Replace old contents */ - HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class_t)); + HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); } /* end else */ done: @@ -394,7 +424,7 @@ H5Z_unregister (H5Z_filter_t id) /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ - HDmemmove(&H5Z_table_g[i],&H5Z_table_g[i+1],sizeof(H5Z_class_t)*((H5Z_table_used_g-1)-i)); + HDmemmove(&H5Z_table_g[i],&H5Z_table_g[i+1],sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-i)); #ifdef H5Z_DEBUG HDmemmove(&H5Z_stat_table_g[i],&H5Z_stat_table_g[i+1],sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-i)); #endif /* H5Z_DEBUG */ @@ -516,7 +546,7 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Iterate over filters */ for(u = 0; u < dcpl_pline.nused; u++) { - H5Z_class_t *fclass; /* Individual filter information */ + H5Z_class2_t *fclass; /* Individual filter information */ /* Get filter information */ if(NULL == (fclass = H5Z_find(dcpl_pline.filter[u].id))) { @@ -890,11 +920,11 @@ done: * *------------------------------------------------------------------------- */ -H5Z_class_t * +H5Z_class2_t * H5Z_find(H5Z_filter_t id) { int idx; /* Filter index in global table */ - H5Z_class_t *ret_value=NULL; /* Return value */ + H5Z_class2_t *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5Z_find, NULL) @@ -946,7 +976,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, { size_t i, idx, new_nbytes; int fclass_idx; /* Index of filter class in global table */ - H5Z_class_t *fclass=NULL; /* Filter class pointer */ + H5Z_class2_t *fclass=NULL; /* Filter class pointer */ #ifdef H5Z_DEBUG H5Z_stats_t *fstats=NULL; /* Filter stats pointer */ H5_timer_t timer; @@ -1242,7 +1272,7 @@ done: herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) { - H5Z_class_t *fclass; + H5Z_class2_t *fclass; herr_t ret_value = SUCCEED; FUNC_ENTER_API(H5Zget_filter_info, FAIL) diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index 56b910b..c0bcd70 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -37,7 +37,7 @@ static size_t H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ -const H5Z_class_t H5Z_DEFLATE[1] = {{ +const H5Z_class2_t H5Z_DEFLATE[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DEFLATE, /* Filter id number */ 1, /* encoder_present flag (set to true) */ @@ -94,9 +94,9 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, /* Set the uncompression parameters */ HDmemset(&z_strm, 0, sizeof(z_strm)); z_strm.next_in = *buf; - H5_ASSIGN_OVERFLOW(z_strm.avail_in,nbytes,size_t,uInt); + H5_ASSIGN_OVERFLOW(z_strm.avail_in,nbytes,size_t,unsigned); z_strm.next_out = outbuf; - H5_ASSIGN_OVERFLOW(z_strm.avail_out,nalloc,size_t,uInt); + H5_ASSIGN_OVERFLOW(z_strm.avail_out,nalloc,size_t,unsigned); /* Initialize the uncompression routines */ if (Z_OK!=inflateInit(&z_strm)) diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index aa3a173..e3a77bd 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -34,7 +34,7 @@ static size_t H5Z_filter_fletcher32 (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ -const H5Z_class_t H5Z_FLETCHER32[1] = {{ +const H5Z_class2_t H5Z_FLETCHER32[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_FLETCHER32, /* Filter id number */ 1, /* encoder_present flag (set to true) */ diff --git a/src/H5Znbit.c b/src/H5Znbit.c index 97a00f0..6f090c3 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -80,7 +80,7 @@ static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned c size_t *buffer_size, const unsigned parms[]); /* This message derives from H5Z */ -H5Z_class_t H5Z_NBIT[1] = {{ +H5Z_class2_t H5Z_NBIT[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_NBIT, /* Filter id number */ 1, /* Assume encoder present: check before registering */ diff --git a/src/H5Zpkg.h b/src/H5Zpkg.h index 9cd126e..ae33def 100644 --- a/src/H5Zpkg.h +++ b/src/H5Zpkg.h @@ -42,46 +42,46 @@ /* * Deflate filter */ -H5_DLLVAR const H5Z_class_t H5Z_DEFLATE[1]; +H5_DLLVAR const H5Z_class2_t H5Z_DEFLATE[1]; #endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SHUFFLE /* * Shuffle filter */ -H5_DLLVAR const H5Z_class_t H5Z_SHUFFLE[1]; +H5_DLLVAR const H5Z_class2_t H5Z_SHUFFLE[1]; #endif /* H5_HAVE_FILTER_SHUFFLE */ #ifdef H5_HAVE_FILTER_FLETCHER32 /* * Fletcher32 filter */ -H5_DLLVAR const H5Z_class_t H5Z_FLETCHER32[1]; +H5_DLLVAR const H5Z_class2_t H5Z_FLETCHER32[1]; #endif /* H5_HAVE_FILTER_FLETCHER32 */ #ifdef H5_HAVE_FILTER_SZIP /* * szip filter */ -H5_DLLVAR H5Z_class_t H5Z_SZIP[1]; +H5_DLLVAR H5Z_class2_t H5Z_SZIP[1]; #endif /* H5_HAVE_FILTER_SZIP */ #ifdef H5_HAVE_FILTER_NBIT /* * nbit filter */ -H5_DLLVAR H5Z_class_t H5Z_NBIT[1]; +H5_DLLVAR H5Z_class2_t H5Z_NBIT[1]; #endif /* H5_HAVE_FILTER_NBIT */ #ifdef H5_HAVE_FILTER_SCALEOFFSET /* * scaleoffset filter */ -H5_DLLVAR H5Z_class_t H5Z_SCALEOFFSET[1]; +H5_DLLVAR H5Z_class2_t H5Z_SCALEOFFSET[1]; #endif /* H5_HAVE_FILTER_SCALEOFFSET */ /* Package-local function prototypes */ -H5_DLL void H5Z_update_class_vers(H5Z_class_t * old_vers, H5Z_class_t * curr_vers); +H5_DLL void H5Z_update_class_vers(H5Z_class2_t * old_vers, H5Z_class2_t * curr_vers); #endif /* _H5Zpkg_H */ diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 15b7289..3ce0a0c 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -72,7 +72,8 @@ typedef struct { struct H5O_pline_t; /*forward decl*/ /* Internal API routines */ -H5_DLL herr_t H5Z_register(const H5Z_class_t *cls); +H5_DLL herr_t H5Z_init(void); +H5_DLL herr_t H5Z_register(const H5Z_class2_t *cls); H5_DLL herr_t H5Z_unregister(H5Z_filter_t id); H5_DLL herr_t H5Z_append(struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); @@ -83,7 +84,7 @@ H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, void **buf/*in,out*/); -H5_DLL H5Z_class_t *H5Z_find(H5Z_filter_t id); +H5_DLL H5Z_class2_t *H5Z_find(H5Z_filter_t id); H5_DLL herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id); H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index ce60650..44d2bbb 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -206,7 +206,7 @@ typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts, * The filter table maps filter identification numbers to structs that * contain a pointers to the filter function and timing statistics. */ -typedef struct H5Z_class_t { +typedef struct H5Z_class2_t { int version; /* Version number of the H5Z_class_t struct */ H5Z_filter_t id; /* Filter ID number */ unsigned encoder_present; /* Does this filter have an encoder? */ @@ -215,13 +215,33 @@ typedef struct H5Z_class_t { H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ H5Z_func_t filter; /* The actual filter function */ -} H5Z_class_t; +} H5Z_class2_t; -H5_DLL herr_t H5Zregister(const H5Z_class_t *cls); +H5_DLL herr_t H5Zregister(const void *cls); H5_DLL herr_t H5Zunregister(H5Z_filter_t id); H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id); H5_DLL herr_t H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags); +/* Symbols defined for compatibility with previous versions of the HDF5 API. + * + * Use of these symbols is deprecated. + */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/* + * The filter table maps filter identification numbers to structs that + * contain a pointers to the filter function and timing statistics. + */ +typedef struct H5Z_class1_t { + H5Z_filter_t id; /* Filter ID number */ + const char *name; /* Comment for debugging */ + H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */ + H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */ + H5Z_func_t filter; /* The actual filter function */ +} H5Z_class1_t; + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + #ifdef __cplusplus } #endif diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 10618c3..d59499c 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -80,7 +80,7 @@ static void H5Z_scaleoffset_compress(unsigned char *data, unsigned d_nelmts, uns size_t buffer_size, parms_atomic p); /* This message derives from H5Z */ -H5Z_class_t H5Z_SCALEOFFSET[1] = {{ +H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_SCALEOFFSET, /* Filter id number */ 1, /* Assume encoder present: check before registering */ diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index 3f40707..2e4f1fa 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -32,7 +32,7 @@ static size_t H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ -const H5Z_class_t H5Z_SHUFFLE[1] = {{ +const H5Z_class2_t H5Z_SHUFFLE[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_SHUFFLE, /* Filter id number */ 1, /* encoder_present flag (set to true) */ diff --git a/src/H5Zszip.c b/src/H5Zszip.c index b40c028..5da92ac 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -40,7 +40,7 @@ static size_t H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ -H5Z_class_t H5Z_SZIP[1] = {{ +H5Z_class2_t H5Z_SZIP[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_SZIP, /* Filter id number */ 1, /* Assume encoder present: check before registering */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 1c70790..8ac19fc 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -84,6 +84,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DMALLOC_H +/* Define if library information should be embedded in the executables */ +#undef HAVE_EMBEDDED_LIBINFO + /* Define to 1 if you have the header file. */ #undef HAVE_FEATURES_H @@ -581,6 +584,9 @@ /* The size of `uint_least8_t', as computed by sizeof. */ #undef SIZEOF_UINT_LEAST8_T +/* The size of `unsigned', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED + /* The size of `__int64', as computed by sizeof. */ #undef SIZEOF___INT64 diff --git a/src/H5detect.c b/src/H5detect.c index b67c2b0..8d7b93b 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -108,6 +108,7 @@ static void detect_C99_integers16(void); static void detect_C99_integers32(void); static void detect_C99_integers64(void); static void detect_alignments(void); +static void insert_libhdf5_settings(void); static size_t align_g[] = {1, 2, 4, 8, 16}; static jmp_buf jbuf_g; @@ -502,6 +503,64 @@ sigbus_handler(int UNUSED signo) /*------------------------------------------------------------------------- + * Function: insert_libhdf5_settings + * + * Purpose: Insert contents of libhdf5.settings so that it is included + * in all hdf5 executables. + * + * Return: void + * + * Programmer: Albert Cheng + * Apr 20, 2009 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +#define LIBSETTINGSFNAME "libhdf5.settings" +static void +insert_libhdf5_settings(void) +{ + FILE *fsettings; + int inchar; + int bol=0; /* indicates the beginning of a new line */ + + if (NULL==(fsettings=HDfopen(LIBSETTINGSFNAME, "r"))){ + perror(LIBSETTINGSFNAME); + exit(1); + } + /* print variable definition */ + printf("extern char H5libhdf5_settings[]=\n"); + bol++; + while (EOF != (inchar = getc(fsettings))){ + if (bol){ + /* Start a new line */ + printf("\t\""); + bol = 0; + } + if (inchar == '\n'){ + /* end of a line */ + printf("\\n\"\n"); + bol++; + }else{ + putchar(inchar); + } + } + if (feof(fsettings)){ + /* wrap up */ + if (!bol){ + /* EOF found without a new line */ + printf("\\n\"\n"); + }; + printf(";\n\n"); + }else{ + fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME); + exit(1); + } +} + + +/*------------------------------------------------------------------------- * Function: print_results * * Purpose: Prints information about the detected data types. @@ -580,6 +639,11 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) /*******************/\n\ \n"); +#ifdef H5_HAVE_EMBEDDED_LIBINFO + /* Insert content of libhdf5.settings */ + insert_libhdf5_settings(); +#endif + /* The interface initialization function */ printf("\n\ \n\ diff --git a/src/H5err.txt b/src/H5err.txt index 64e9729..2c5ca04 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -171,6 +171,7 @@ MINOR, CACHE, H5E_CANTEXPUNGE, Unable to expunge a metadata cache entry MINOR, CACHE, H5E_CANTRESIZE, Unable to resize a metadata cache entry MINOR, CACHE, H5E_CANTDEPEND, Unable to create a flush dependency MINOR, CACHE, H5E_CANTUNDEPEND, Unable to destroy a flush dependency +MINOR, CACHE, H5E_CANTNOTIFY, Unable to notify object about action # B-tree related errors MINOR, BTREE, H5E_NOTFOUND, Object not found diff --git a/src/H5overflow.h b/src/H5overflow.h new file mode 100644 index 0000000..1c00acf --- /dev/null +++ b/src/H5overflow.h @@ -0,0 +1,1381 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Generated automatically by bin/make_overflow -- do not edit */ +/* Add new types to H5overflow.txt file */ + + +#ifndef _H5overflow_H +#define _H5overflow_H + + +/* Each type in this file is tested for assignment to the other types, + * and range checks are defined for bad assignments at run-time. + */ + +/* Assignment checks for unsigned */ + +/* src: unsigned, dst: int */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_INT + #define ASSIGN_unsigned_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_INT + #define ASSIGN_unsigned_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_INT */ + #define ASSIGN_unsigned_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: int */ + +/* src: unsigned, dst: uint8_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_UINT8_T + #define ASSIGN_unsigned_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_UINT8_T + #define ASSIGN_unsigned_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_UINT8_T */ + #define ASSIGN_unsigned_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: uint8_t */ + +/* src: unsigned, dst: uint32_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_UINT32_T + #define ASSIGN_unsigned_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_UINT32_T + #define ASSIGN_unsigned_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_UINT32_T */ + #define ASSIGN_unsigned_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: uint32_t */ + +/* src: unsigned, dst: uint64_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_UINT64_T + #define ASSIGN_unsigned_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_UINT64_T + #define ASSIGN_unsigned_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_UINT64_T */ + #define ASSIGN_unsigned_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: uint64_t */ + +/* src: unsigned, dst: size_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_SIZE_T + #define ASSIGN_unsigned_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_SIZE_T + #define ASSIGN_unsigned_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_SIZE_T */ + #define ASSIGN_unsigned_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: size_t */ + +/* src: unsigned, dst: ssize_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_SSIZE_T + #define ASSIGN_unsigned_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_SSIZE_T + #define ASSIGN_unsigned_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_unsigned_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: ssize_t */ + +/* src: unsigned, dst: haddr_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_HADDR_T + #define ASSIGN_unsigned_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_HADDR_T + #define ASSIGN_unsigned_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_HADDR_T */ + #define ASSIGN_unsigned_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: haddr_t */ + +/* src: unsigned, dst: hsize_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_HSIZE_T + #define ASSIGN_unsigned_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_HSIZE_T + #define ASSIGN_unsigned_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_unsigned_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: hsize_t */ + +/* src: unsigned, dst: hssize_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_HSSIZE_T + #define ASSIGN_unsigned_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_HSSIZE_T + #define ASSIGN_unsigned_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_unsigned_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: hssize_t */ + +/* src: unsigned, dst: h5_stat_size_t */ +#if H5_SIZEOF_UNSIGNED < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_unsigned_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UNSIGNED > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_unsigned_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UNSIGNED == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_unsigned_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: unsigned dst: h5_stat_size_t */ + + +/* Assignment checks for int */ + +/* src: int, dst: unsigned */ +#if H5_SIZEOF_INT < H5_SIZEOF_UNSIGNED + #define ASSIGN_int_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_UNSIGNED + #define ASSIGN_int_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_int_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: unsigned */ + +/* src: int, dst: uint8_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_UINT8_T + #define ASSIGN_int_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_UINT8_T + #define ASSIGN_int_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_UINT8_T */ + #define ASSIGN_int_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: uint8_t */ + +/* src: int, dst: uint32_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_UINT32_T + #define ASSIGN_int_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_UINT32_T + #define ASSIGN_int_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_UINT32_T */ + #define ASSIGN_int_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: uint32_t */ + +/* src: int, dst: uint64_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_UINT64_T + #define ASSIGN_int_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_UINT64_T + #define ASSIGN_int_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_UINT64_T */ + #define ASSIGN_int_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: uint64_t */ + +/* src: int, dst: size_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_SIZE_T + #define ASSIGN_int_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_SIZE_T + #define ASSIGN_int_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_SIZE_T */ + #define ASSIGN_int_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: size_t */ + +/* src: int, dst: ssize_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_SSIZE_T + #define ASSIGN_int_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_SSIZE_T + #define ASSIGN_int_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_int_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: ssize_t */ + +/* src: int, dst: haddr_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_HADDR_T + #define ASSIGN_int_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_HADDR_T + #define ASSIGN_int_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_HADDR_T */ + #define ASSIGN_int_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: haddr_t */ + +/* src: int, dst: hsize_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_HSIZE_T + #define ASSIGN_int_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_HSIZE_T + #define ASSIGN_int_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_int_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: hsize_t */ + +/* src: int, dst: hssize_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_HSSIZE_T + #define ASSIGN_int_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_HSSIZE_T + #define ASSIGN_int_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_int_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: hssize_t */ + +/* src: int, dst: h5_stat_size_t */ +#if H5_SIZEOF_INT < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_int_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_INT > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_int_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_INT == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_int_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: int dst: h5_stat_size_t */ + + +/* Assignment checks for uint8_t */ + +/* src: uint8_t, dst: unsigned */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_uint8_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_uint8_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_uint8_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: unsigned */ + +/* src: uint8_t, dst: int */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_INT + #define ASSIGN_uint8_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_INT + #define ASSIGN_uint8_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_INT */ + #define ASSIGN_uint8_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: int */ + +/* src: uint8_t, dst: uint32_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_UINT32_T + #define ASSIGN_uint8_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_UINT32_T + #define ASSIGN_uint8_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_uint8_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: uint32_t */ + +/* src: uint8_t, dst: uint64_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_UINT64_T + #define ASSIGN_uint8_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_UINT64_T + #define ASSIGN_uint8_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_uint8_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: uint64_t */ + +/* src: uint8_t, dst: size_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_SIZE_T + #define ASSIGN_uint8_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_SIZE_T + #define ASSIGN_uint8_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_uint8_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: size_t */ + +/* src: uint8_t, dst: ssize_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_uint8_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_uint8_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_uint8_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: ssize_t */ + +/* src: uint8_t, dst: haddr_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_HADDR_T + #define ASSIGN_uint8_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_HADDR_T + #define ASSIGN_uint8_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_uint8_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: haddr_t */ + +/* src: uint8_t, dst: hsize_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_uint8_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_uint8_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_uint8_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: hsize_t */ + +/* src: uint8_t, dst: hssize_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_uint8_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_uint8_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_uint8_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: hssize_t */ + +/* src: uint8_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_UINT8_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_uint8_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT8_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_uint8_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT8_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_uint8_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint8_t dst: h5_stat_size_t */ + + +/* Assignment checks for uint32_t */ + +/* src: uint32_t, dst: unsigned */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_uint32_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_uint32_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_uint32_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: unsigned */ + +/* src: uint32_t, dst: int */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_INT + #define ASSIGN_uint32_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_INT + #define ASSIGN_uint32_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_INT */ + #define ASSIGN_uint32_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: int */ + +/* src: uint32_t, dst: uint8_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_UINT8_T + #define ASSIGN_uint32_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_UINT8_T + #define ASSIGN_uint32_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_uint32_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: uint8_t */ + +/* src: uint32_t, dst: uint64_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_UINT64_T + #define ASSIGN_uint32_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_UINT64_T + #define ASSIGN_uint32_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_uint32_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: uint64_t */ + +/* src: uint32_t, dst: size_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_SIZE_T + #define ASSIGN_uint32_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_SIZE_T + #define ASSIGN_uint32_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_uint32_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: size_t */ + +/* src: uint32_t, dst: ssize_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_uint32_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_uint32_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_uint32_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: ssize_t */ + +/* src: uint32_t, dst: haddr_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_HADDR_T + #define ASSIGN_uint32_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_HADDR_T + #define ASSIGN_uint32_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_uint32_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: haddr_t */ + +/* src: uint32_t, dst: hsize_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_uint32_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_uint32_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_uint32_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: hsize_t */ + +/* src: uint32_t, dst: hssize_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_uint32_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_uint32_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_uint32_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: hssize_t */ + +/* src: uint32_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_UINT32_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_uint32_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT32_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_uint32_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT32_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_uint32_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint32_t dst: h5_stat_size_t */ + + +/* Assignment checks for uint64_t */ + +/* src: uint64_t, dst: unsigned */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_uint64_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_uint64_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_uint64_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: unsigned */ + +/* src: uint64_t, dst: int */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_INT + #define ASSIGN_uint64_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_INT + #define ASSIGN_uint64_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_INT */ + #define ASSIGN_uint64_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: int */ + +/* src: uint64_t, dst: uint8_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_UINT8_T + #define ASSIGN_uint64_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_UINT8_T + #define ASSIGN_uint64_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_uint64_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: uint8_t */ + +/* src: uint64_t, dst: uint32_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_UINT32_T + #define ASSIGN_uint64_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_UINT32_T + #define ASSIGN_uint64_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_uint64_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: uint32_t */ + +/* src: uint64_t, dst: size_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_SIZE_T + #define ASSIGN_uint64_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_SIZE_T + #define ASSIGN_uint64_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_uint64_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: size_t */ + +/* src: uint64_t, dst: ssize_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_uint64_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_uint64_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_uint64_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: ssize_t */ + +/* src: uint64_t, dst: haddr_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_HADDR_T + #define ASSIGN_uint64_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_HADDR_T + #define ASSIGN_uint64_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_uint64_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: haddr_t */ + +/* src: uint64_t, dst: hsize_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_uint64_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_uint64_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_uint64_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: hsize_t */ + +/* src: uint64_t, dst: hssize_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_uint64_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_uint64_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_uint64_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: hssize_t */ + +/* src: uint64_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_UINT64_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_uint64_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_UINT64_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_uint64_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_UINT64_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_uint64_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: uint64_t dst: h5_stat_size_t */ + + +/* Assignment checks for size_t */ + +/* src: size_t, dst: unsigned */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_size_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_size_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_size_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: unsigned */ + +/* src: size_t, dst: int */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_INT + #define ASSIGN_size_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_INT + #define ASSIGN_size_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_INT */ + #define ASSIGN_size_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: int */ + +/* src: size_t, dst: uint8_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_UINT8_T + #define ASSIGN_size_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_UINT8_T + #define ASSIGN_size_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_size_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: uint8_t */ + +/* src: size_t, dst: uint32_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_UINT32_T + #define ASSIGN_size_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_UINT32_T + #define ASSIGN_size_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_size_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: uint32_t */ + +/* src: size_t, dst: uint64_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_UINT64_T + #define ASSIGN_size_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_UINT64_T + #define ASSIGN_size_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_size_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: uint64_t */ + +/* src: size_t, dst: ssize_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_size_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_size_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_size_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: ssize_t */ + +/* src: size_t, dst: haddr_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_HADDR_T + #define ASSIGN_size_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_HADDR_T + #define ASSIGN_size_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_size_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: haddr_t */ + +/* src: size_t, dst: hsize_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_size_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_size_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_size_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: hsize_t */ + +/* src: size_t, dst: hssize_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_size_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_size_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_size_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: hssize_t */ + +/* src: size_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_SIZE_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_size_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SIZE_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_size_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SIZE_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_size_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: size_t dst: h5_stat_size_t */ + + +/* Assignment checks for ssize_t */ + +/* src: ssize_t, dst: unsigned */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_ssize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_ssize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_ssize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: unsigned */ + +/* src: ssize_t, dst: int */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_INT + #define ASSIGN_ssize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_INT + #define ASSIGN_ssize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_INT */ + #define ASSIGN_ssize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: int */ + +/* src: ssize_t, dst: uint8_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_UINT8_T + #define ASSIGN_ssize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_UINT8_T + #define ASSIGN_ssize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_ssize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: uint8_t */ + +/* src: ssize_t, dst: uint32_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_UINT32_T + #define ASSIGN_ssize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_UINT32_T + #define ASSIGN_ssize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_ssize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: uint32_t */ + +/* src: ssize_t, dst: uint64_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_UINT64_T + #define ASSIGN_ssize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_UINT64_T + #define ASSIGN_ssize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_ssize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: uint64_t */ + +/* src: ssize_t, dst: size_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_SIZE_T + #define ASSIGN_ssize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_SIZE_T + #define ASSIGN_ssize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_ssize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: size_t */ + +/* src: ssize_t, dst: haddr_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_HADDR_T + #define ASSIGN_ssize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_HADDR_T + #define ASSIGN_ssize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_ssize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: haddr_t */ + +/* src: ssize_t, dst: hsize_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_ssize_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_ssize_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_ssize_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: hsize_t */ + +/* src: ssize_t, dst: hssize_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_ssize_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_ssize_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_ssize_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: hssize_t */ + +/* src: ssize_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_SSIZE_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_ssize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_SSIZE_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_ssize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_SSIZE_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_ssize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: ssize_t dst: h5_stat_size_t */ + + +/* Assignment checks for haddr_t */ + +/* src: haddr_t, dst: unsigned */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_haddr_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_haddr_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_haddr_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: unsigned */ + +/* src: haddr_t, dst: int */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_INT + #define ASSIGN_haddr_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_INT + #define ASSIGN_haddr_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_INT */ + #define ASSIGN_haddr_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: int */ + +/* src: haddr_t, dst: uint8_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_UINT8_T + #define ASSIGN_haddr_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_UINT8_T + #define ASSIGN_haddr_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_haddr_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: uint8_t */ + +/* src: haddr_t, dst: uint32_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_UINT32_T + #define ASSIGN_haddr_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_UINT32_T + #define ASSIGN_haddr_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_haddr_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: uint32_t */ + +/* src: haddr_t, dst: uint64_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_UINT64_T + #define ASSIGN_haddr_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_UINT64_T + #define ASSIGN_haddr_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_haddr_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: uint64_t */ + +/* src: haddr_t, dst: size_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_SIZE_T + #define ASSIGN_haddr_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_SIZE_T + #define ASSIGN_haddr_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_haddr_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: size_t */ + +/* src: haddr_t, dst: ssize_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_haddr_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_haddr_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_haddr_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: ssize_t */ + +/* src: haddr_t, dst: hsize_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_haddr_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_haddr_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_haddr_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: hsize_t */ + +/* src: haddr_t, dst: hssize_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_haddr_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_haddr_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_haddr_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: hssize_t */ + +/* src: haddr_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_HADDR_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_haddr_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HADDR_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_haddr_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HADDR_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_haddr_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: haddr_t dst: h5_stat_size_t */ + + +/* Assignment checks for hsize_t */ + +/* src: hsize_t, dst: unsigned */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_hsize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_hsize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_hsize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: unsigned */ + +/* src: hsize_t, dst: int */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_INT + #define ASSIGN_hsize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_INT + #define ASSIGN_hsize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_INT */ + #define ASSIGN_hsize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: int */ + +/* src: hsize_t, dst: uint8_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_UINT8_T + #define ASSIGN_hsize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_UINT8_T + #define ASSIGN_hsize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_hsize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: uint8_t */ + +/* src: hsize_t, dst: uint32_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_UINT32_T + #define ASSIGN_hsize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_UINT32_T + #define ASSIGN_hsize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_hsize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: uint32_t */ + +/* src: hsize_t, dst: uint64_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_UINT64_T + #define ASSIGN_hsize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_UINT64_T + #define ASSIGN_hsize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_hsize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: uint64_t */ + +/* src: hsize_t, dst: size_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_SIZE_T + #define ASSIGN_hsize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_SIZE_T + #define ASSIGN_hsize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_hsize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: size_t */ + +/* src: hsize_t, dst: ssize_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_hsize_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_hsize_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_hsize_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: ssize_t */ + +/* src: hsize_t, dst: haddr_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_HADDR_T + #define ASSIGN_hsize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_HADDR_T + #define ASSIGN_hsize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_hsize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: haddr_t */ + +/* src: hsize_t, dst: hssize_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_hsize_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_hsize_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_hsize_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: hssize_t */ + +/* src: hsize_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_HSIZE_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_hsize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSIZE_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_hsize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSIZE_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_hsize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hsize_t dst: h5_stat_size_t */ + + +/* Assignment checks for hssize_t */ + +/* src: hssize_t, dst: unsigned */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_hssize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_hssize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_hssize_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: unsigned */ + +/* src: hssize_t, dst: int */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_INT + #define ASSIGN_hssize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_INT + #define ASSIGN_hssize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_INT */ + #define ASSIGN_hssize_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: int */ + +/* src: hssize_t, dst: uint8_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_UINT8_T + #define ASSIGN_hssize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_UINT8_T + #define ASSIGN_hssize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_hssize_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: uint8_t */ + +/* src: hssize_t, dst: uint32_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_UINT32_T + #define ASSIGN_hssize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_UINT32_T + #define ASSIGN_hssize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_hssize_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: uint32_t */ + +/* src: hssize_t, dst: uint64_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_UINT64_T + #define ASSIGN_hssize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_UINT64_T + #define ASSIGN_hssize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_hssize_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: uint64_t */ + +/* src: hssize_t, dst: size_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_SIZE_T + #define ASSIGN_hssize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_SIZE_T + #define ASSIGN_hssize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_hssize_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: size_t */ + +/* src: hssize_t, dst: ssize_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_hssize_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_hssize_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_hssize_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: ssize_t */ + +/* src: hssize_t, dst: haddr_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_HADDR_T + #define ASSIGN_hssize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_HADDR_T + #define ASSIGN_hssize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_hssize_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: haddr_t */ + +/* src: hssize_t, dst: hsize_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_hssize_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_hssize_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_hssize_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: hsize_t */ + +/* src: hssize_t, dst: h5_stat_size_t */ +#if H5_SIZEOF_HSSIZE_T < H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_hssize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_HSSIZE_T > H5_SIZEOF_H5_STAT_SIZE_T + #define ASSIGN_hssize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_HSSIZE_T == H5_SIZEOF_H5_STAT_SIZE_T */ + #define ASSIGN_hssize_t_TO_h5_stat_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) +#endif /* src: hssize_t dst: h5_stat_size_t */ + + +/* Assignment checks for h5_stat_size_t */ + +/* src: h5_stat_size_t, dst: unsigned */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_UNSIGNED + #define ASSIGN_h5_stat_size_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_UNSIGNED + #define ASSIGN_h5_stat_size_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_UNSIGNED */ + #define ASSIGN_h5_stat_size_t_TO_unsigned(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: unsigned */ + +/* src: h5_stat_size_t, dst: int */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_INT + #define ASSIGN_h5_stat_size_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_INT + #define ASSIGN_h5_stat_size_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_INT */ + #define ASSIGN_h5_stat_size_t_TO_int(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: int */ + +/* src: h5_stat_size_t, dst: uint8_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_UINT8_T + #define ASSIGN_h5_stat_size_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_UINT8_T + #define ASSIGN_h5_stat_size_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_UINT8_T */ + #define ASSIGN_h5_stat_size_t_TO_uint8_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: uint8_t */ + +/* src: h5_stat_size_t, dst: uint32_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_UINT32_T + #define ASSIGN_h5_stat_size_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_UINT32_T + #define ASSIGN_h5_stat_size_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_UINT32_T */ + #define ASSIGN_h5_stat_size_t_TO_uint32_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: uint32_t */ + +/* src: h5_stat_size_t, dst: uint64_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_UINT64_T + #define ASSIGN_h5_stat_size_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_UINT64_T + #define ASSIGN_h5_stat_size_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_UINT64_T */ + #define ASSIGN_h5_stat_size_t_TO_uint64_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: uint64_t */ + +/* src: h5_stat_size_t, dst: size_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_SIZE_T + #define ASSIGN_h5_stat_size_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_SIZE_T + #define ASSIGN_h5_stat_size_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_SIZE_T */ + #define ASSIGN_h5_stat_size_t_TO_size_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: size_t */ + +/* src: h5_stat_size_t, dst: ssize_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_SSIZE_T + #define ASSIGN_h5_stat_size_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_SSIZE_T + #define ASSIGN_h5_stat_size_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_SSIZE_T */ + #define ASSIGN_h5_stat_size_t_TO_ssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: ssize_t */ + +/* src: h5_stat_size_t, dst: haddr_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_HADDR_T + #define ASSIGN_h5_stat_size_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_HADDR_T + #define ASSIGN_h5_stat_size_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_HADDR_T */ + #define ASSIGN_h5_stat_size_t_TO_haddr_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: haddr_t */ + +/* src: h5_stat_size_t, dst: hsize_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_HSIZE_T + #define ASSIGN_h5_stat_size_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_HSIZE_T + #define ASSIGN_h5_stat_size_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_HSIZE_T */ + #define ASSIGN_h5_stat_size_t_TO_hsize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: hsize_t */ + +/* src: h5_stat_size_t, dst: hssize_t */ +#if H5_SIZEOF_H5_STAT_SIZE_T < H5_SIZEOF_HSSIZE_T + #define ASSIGN_h5_stat_size_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#elif H5_SIZEOF_H5_STAT_SIZE_T > H5_SIZEOF_HSSIZE_T + #define ASSIGN_h5_stat_size_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) +#else /* H5_SIZEOF_H5_STAT_SIZE_T == H5_SIZEOF_HSSIZE_T */ + #define ASSIGN_h5_stat_size_t_TO_hssize_t(dst, dsttype, src, srctype) \ + ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) +#endif /* src: h5_stat_size_t dst: hssize_t */ + +#endif /* H5overflow_H */ + diff --git a/src/H5overflow.txt b/src/H5overflow.txt new file mode 100644 index 0000000..ea62fa0 --- /dev/null +++ b/src/H5overflow.txt @@ -0,0 +1,43 @@ +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# + +# This file is used to generate the headers that is needed for detecting +# overflows between types at run-time +# +# The bin/make_overflow script reads in this file and creates the appropriate +# file in the src/ directory when the generated header is out of date with +# respect to this file. +# +# Blank lines and lines beginning with '#' are ignored +# +# The format of this file is as follows: +# , ; +# +# Where is a valid C type (like 'int8_t', 'hssize_t', etc. and whether +# the type is signed or unsigned follows. +# +# Programmer: Quincey Koziol +# Creation Date: 2009/04/09 + +unsigned, UNSIGNED; +int, SIGNED; +uint8_t, UNSIGNED; +uint32_t, UNSIGNED; +uint64_t, UNSIGNED; +size_t, UNSIGNED; +ssize_t, SIGNED; +haddr_t, UNSIGNED; +hsize_t, UNSIGNED; +hssize_t, SIGNED; +h5_stat_size_t, UNSIGNED; diff --git a/src/H5private.h b/src/H5private.h index 695b015..43b8a95 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -144,6 +144,7 @@ #define VC_EXTRALEAN /*Exclude rarely-used stuff from Windows headers */ #include +#include /* For _getcwd() */ #endif /*_WIN32*/ @@ -438,35 +439,6 @@ #endif /* - * A macro for detecting over/under-flow when casting between types - */ -#ifndef NDEBUG -#define H5_CHECK_OVERFLOW(var, vartype, casttype) \ -{ \ - casttype _tmp_overflow = (casttype)(var); \ - assert((var) == (vartype)_tmp_overflow); \ -} -#else /* NDEBUG */ -#define H5_CHECK_OVERFLOW(var, vartype, casttype) -#endif /* NDEBUG */ - -/* - * A macro for detecting over/under-flow when assigning between types - */ -#ifndef NDEBUG -#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \ -{ \ - srctype _tmp_overflow = (srctype)(src); \ - dsttype _tmp_overflow2 = (dsttype)(_tmp_overflow); \ - assert((dsttype)_tmp_overflow == _tmp_overflow2); \ - (dst) = _tmp_overflow2; \ -} -#else /* NDEBUG */ -#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \ - (dst) = (dsttype)(src); -#endif /* NDEBUG */ - -/* * Data types and functions for timing certain parts of the library. */ typedef struct { @@ -763,6 +735,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #endif /* HDstat */ typedef struct stat64 h5_stat_t; typedef off64_t h5_stat_size_t; + #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF64_T #else /* H5_SIZEOF_OFF_T!=8 && ... */ #ifndef HDfstat #define HDfstat(F,B) fstat(F,B) @@ -772,6 +745,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #endif /* HDstat */ typedef struct stat h5_stat_t; typedef off_t h5_stat_size_t; + #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T #endif /* H5_SIZEOF_OFF_T!=8 && ... */ #endif /* !defined(HDfstat) || !defined(HDstat) */ @@ -1236,6 +1210,9 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #ifndef HDstrtoul #define HDstrtoul(S,R,N) strtoul(S,R,N) #endif /* HDstrtoul */ +#ifndef HDstrtoull + #define HDstrtoull(S,R,N) strtoull(S,R,N) +#endif /* HDstrtoul */ #ifndef HDstrxfrm #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) #endif /* HDstrxfrm */ @@ -1375,6 +1352,78 @@ extern char *strdup(const char *s); #define HDpthread_self_ulong() ((unsigned long)pthread_self()) #endif /* HDpthread_self_ulong */ +/* + * A macro for detecting over/under-flow when casting between types + */ +#ifndef NDEBUG +#define H5_CHECK_OVERFLOW(var, vartype, casttype) \ +{ \ + casttype _tmp_overflow = (casttype)(var); \ + assert((var) == (vartype)_tmp_overflow); \ +} +#else /* NDEBUG */ +#define H5_CHECK_OVERFLOW(var, vartype, casttype) +#endif /* NDEBUG */ + +/* + * A macro for detecting over/under-flow when assigning between types + */ +#ifndef NDEBUG +#define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \ +{ \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + assert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ +} + +#define ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \ + (dst) = (dsttype)(src); + +#define ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ +{ \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + assert(_tmp_src >= 0); \ + assert(_tmp_src == _tmp_dst); \ + (dst) = _tmp_dst; \ +} + +#define ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ + (dst) = (dsttype)(src); + +#define ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \ +{ \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + assert(_tmp_dst >= 0); \ + assert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ +} + +#define ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \ +{ \ + srctype _tmp_src = (srctype)(src); \ + dsttype _tmp_dst = (dsttype)(_tmp_src); \ + assert(_tmp_src >= 0); \ + assert(_tmp_src == (srctype)_tmp_dst); \ + (dst) = _tmp_dst; \ +} + +#define ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \ + (dst) = (dsttype)(src); + +/* Include the generated overflow header file */ +#include "H5overflow.h" + +#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \ + H5_GLUE4(ASSIGN_,srctype,_TO_,dsttype)(dst,dsttype,src,srctype)\ + +#else /* NDEBUG */ +#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \ + (dst) = (dsttype)(src); +#endif /* NDEBUG */ + #if defined(H5_HAVE_WINDOW_PATH) /* directory delimiter for Windows: slash and backslash are acceptable on Windows */ @@ -1692,6 +1741,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_ENTER_COMMON(func_name,asrt) \ static const char FUNC[]=#func_name; \ + hbool_t err_occurred = FALSE; \ FUNC_ENTER_COMMON_NOFUNC(func_name,asrt); /* Threadsafety initialization code for API routines */ @@ -1861,7 +1911,9 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_LEAVE_API(ret_value) \ FINISH_MPE_LOG; \ H5TRACE_RETURN(ret_value); \ - H5_POP_FUNC \ + H5_POP_FUNC \ + if(err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ FUNC_LEAVE_API_THREADSAFE \ return (ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ @@ -1870,6 +1922,8 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_LEAVE_API_NOFS(ret_value) \ FINISH_MPE_LOG; \ H5TRACE_RETURN(ret_value); \ + if(err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ FUNC_LEAVE_API_THREADSAFE \ return (ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ diff --git a/src/H5public.h b/src/H5public.h index ab471b9..4f81141 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -71,10 +71,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 36 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 39 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.36" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.39" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/H5trace.c b/src/H5trace.c index 4a42f0b..6e2578b 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -1978,7 +1978,7 @@ H5_trace (const double *returning, const char *func, const char *type, ...) fprintf(out, "NULL"); } } else { - H5Z_class_t *filter = va_arg (ap, H5Z_class_t*); /*lint !e64 Type mismatch not really occuring */ + H5Z_class2_t *filter = va_arg (ap, H5Z_class2_t*); /*lint !e64 Type mismatch not really occuring */ fprintf (out, "0x%lx", (unsigned long)filter); } break; diff --git a/src/H5vers.txt b/src/H5vers.txt index 00ab84b..18a88d9 100644 --- a/src/H5vers.txt +++ b/src/H5vers.txt @@ -71,4 +71,5 @@ FUNCTION: H5Topen; ; v10, v18 # (although not required, it's easier to compare this file with the headers # generated if the list below is in alphanumeric sort order - QAK) TYPEDEF: H5E_auto; v10, v18 +TYPEDEF: H5Z_class; v16, v18 diff --git a/src/H5version.h b/src/H5version.h index fd9e780..58de2ab 100644 --- a/src/H5version.h +++ b/src/H5version.h @@ -134,6 +134,10 @@ #define H5E_auto_t_vers 1 #endif /* !defined(H5E_auto_t_vers) */ +#if !defined(H5Z_class_t_vers) +#define H5Z_class_t_vers 1 +#endif /* !defined(H5Z_class_t_vers) */ + #endif /* H5_USE_16_API */ @@ -399,5 +403,17 @@ #error "H5E_auto_t_vers set to invalid value" #endif /* H5E_auto_t_vers */ + +#if !defined(H5Z_class_t_vers) || H5Z_class_t_vers == 2 +#ifndef H5Z_class_t_vers +#define H5Z_class_t_vers 2 +#endif /* H5Z_class_t_vers */ +#define H5Z_class_t H5Z_class2_t +#elif H5Z_class_t_vers == 1 +#define H5Z_class_t H5Z_class1_t +#else /* H5Z_class_t_vers */ +#error "H5Z_class_t_vers set to invalid value" +#endif /* H5Z_class_t_vers */ + #endif /* H5version_H */ diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 41e2edd..0cf7172 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -58,6 +58,7 @@ typedef __int64 h5_stat_size_t; #define HDunlink(S) _unlink(S) #define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A) #define HDwrite(F,M,Z) _write(F,M,Z) +#define HDstrtoull(S,R,N) _strtoui64(S,R,N) /* Non-POSIX functions */ diff --git a/src/Makefile.am b/src/Makefile.am index 9ae2252..0cdd5e9 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5G.c H5Gbtree2.c H5Gcache.c \ H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c \ H5Gint.c H5Glink.c \ - H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Gstab.c H5Gtest.c \ + H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Groot.c H5Gstab.c H5Gtest.c \ H5Gtraverse.c \ H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \ H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \ @@ -103,7 +103,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ # Public headers -include_HEADERS = hdf5.h H5api_adpt.h H5pubconf.h H5public.h H5version.h \ +include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5version.h \ H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \ @@ -141,6 +141,10 @@ $(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt $(top_srcdir)/src/H5version.h: $(top_srcdir)/src/H5vers.txt perl $(top_srcdir)/bin/make_vers $? +# Assignment overflow macro generation +$(top_srcdir)/src/H5overflow.h: $(top_srcdir)/src/H5overflow.txt + perl $(top_srcdir)/bin/make_overflow $? + # Add TRACE macros to library source files. This is done via the trace script # in the hdf5/bin directory. If the file contains HDF5 API macros, a "clean" # version of the source file is saved with a tilde (~) after its name and diff --git a/src/Makefile.in b/src/Makefile.in index 650f2bf..0faf5fd 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -97,9 +97,9 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5FScache.lo H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo \ H5G.lo H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \ H5Gdeprec.lo H5Gent.lo H5Gint.lo H5Glink.lo H5Gloc.lo \ - H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Gstab.lo H5Gtest.lo \ - H5Gtraverse.lo H5HF.lo H5HFbtree2.lo H5HFcache.lo H5HFdbg.lo \ - H5HFdblock.lo H5HFdtable.lo H5HFhdr.lo H5HFhuge.lo \ + H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Groot.lo H5Gstab.lo \ + H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFbtree2.lo H5HFcache.lo \ + H5HFdbg.lo H5HFdblock.lo H5HFdtable.lo H5HFhdr.lo H5HFhuge.lo \ H5HFiblock.lo H5HFiter.lo H5HFman.lo H5HFsection.lo \ H5HFspace.lo H5HFstat.lo H5HFtest.lo H5HFtiny.lo H5HG.lo \ H5HGcache.lo H5HGdbg.lo H5HL.lo H5HLcache.lo H5HLdbg.lo \ @@ -409,7 +409,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 26 +LT_VERS_REVISION = 29 LT_VERS_AGE = 0 H5detect_CFLAGS = -g @@ -446,7 +446,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5G.c H5Gbtree2.c H5Gcache.c \ H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c \ H5Gint.c H5Glink.c \ - H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Gstab.c H5Gtest.c \ + H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Groot.c H5Gstab.c H5Gtest.c \ H5Gtraverse.c \ H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \ H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \ @@ -487,7 +487,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ # Public headers -include_HEADERS = hdf5.h H5api_adpt.h H5pubconf.h H5public.h H5version.h \ +include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5version.h \ H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \ @@ -526,8 +526,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -711,6 +711,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gnode.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gobj.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Goh.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Groot.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gstab.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gtest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gtraverse.Plo@am__quote@ @@ -936,7 +937,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -1167,6 +1168,10 @@ $(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt $(top_srcdir)/src/H5version.h: $(top_srcdir)/src/H5vers.txt perl $(top_srcdir)/bin/make_vers $? +# Assignment overflow macro generation +$(top_srcdir)/src/H5overflow.h: $(top_srcdir)/src/H5overflow.txt + perl $(top_srcdir)/bin/make_overflow $? + # Add TRACE macros to library source files. This is done via the trace script # in the hdf5/bin directory. If the file contains HDF5 API macros, a "clean" # version of the source file is saved with a tilde (~) after its name and diff --git a/test/Makefile.am b/test/Makefile.am index 658f7ae..c3bdc35 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -104,11 +104,11 @@ flush2.chkexe_: flush1.chkexe_ # the temporary file name in ways that the makefile is not aware of. CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offset.h5 \ max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \ - huge_chunks.h5 chunk_cache.h5 big_chunk.h5 extend.h5 istore.h5 \ - extlinks*.h5 frspace.h5 links*.h5 \ - tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab.h5 \ - extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2] \ - links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ + huge_chunks.h5 chunk_cache.h5 big_chunk.h5 \ + chunk_expand.h5 extend.h5 istore.h5 extlinks*.h5 frspace.h5 \ + links*.h5 tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \ + stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \ + dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ big.data big[0-9][0-9][0-9][0-9][0-9].h5 \ stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \ tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \ @@ -117,7 +117,8 @@ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offset.h5 \ enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 \ tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \ getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \ - family_file000[0-3][0-9].h5 multi_file-[rs].h5 core_file \ + family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ + multi_file-[rs].h5 core_file \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ diff --git a/test/Makefile.in b/test/Makefile.in index 49674dc..fa06734 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -631,20 +631,21 @@ TRACE = perl $(top_srcdir)/bin/trace CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \ compact_dataset.h5 dataset.h5 dset_offset.h5 \ max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \ - huge_chunks.h5 chunk_cache.h5 big_chunk.h5 extend.h5 istore.h5 \ - extlinks*.h5 frspace.h5 links*.h5 tfile[1-4].h5 th5s[1-3].h5 \ - lheap.h5 fheap.h5 ohdr.h5 stab.h5 extern_[1-3].h5 \ - extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2] links.h5 \ - links[0-6]*.h5 extlinks[0-15].h5 tmp big.data \ - big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \ + huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \ + extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ + tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab.h5 \ + extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \ + dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ + big.data big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \ dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \ unlink.h5 unicode.h5 coord.h5 fillval_[0-9].h5 fillval.raw \ mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \ tvlstr.h5 tvlstr2.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 \ tarray1.h5 tgenprop.h5 tmisc[0-9]*.h5 set_extent[1-5].h5 \ ext[12].bin getname.h5 getname[1-3].h5 sec2_file.h5 \ - direct_file.h5 family_file000[0-3][0-9].h5 multi_file-[rs].h5 \ - core_file new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 \ + direct_file.h5 family_file000[0-3][0-9].h5 \ + new_family_v16_000[0-3][0-9].h5 multi_file-[rs].h5 core_file \ + new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 \ err_compat.h5 dtransform.h5 test_filters.h5 get_file_name.h5 \ tstint[1-2].h5 unlink_chunked.h5 btree2.h5 objcopy_src.h5 \ objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 \ @@ -731,8 +732,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -1090,7 +1091,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/test/big.c b/test/big.c index 8176929..dde9d7a 100644 --- a/test/big.c +++ b/test/big.c @@ -505,7 +505,6 @@ main (int ac, char **av) hid_t fapl=-1; hsize_t family_size; hsize_t family_size_def; /* default family file size */ - double family_size_def_dbl; /* default family file size */ unsigned long seed = 0; /* Random # seed */ int cflag=1; /* check file system before test */ char filename[1024]; @@ -518,11 +517,8 @@ main (int ac, char **av) if (strcmp("-fsize", *av)==0){ /* specify a different family file size */ ac--; av++; - if (ac > 0){ - family_size_def_dbl = atof(*av); - H5_ASSIGN_OVERFLOW(family_size_def,family_size_def_dbl,double,hsize_t); - if (family_size_def <= 0) - family_size_def = (hsize_t)FAMILY_SIZE; + if (ac > 0) { + family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0); } else{ printf("***Missing fsize value***\n"); diff --git a/test/cache.c b/test/cache.c index 65a6719..bacd559 100644 --- a/test/cache.c +++ b/test/cache.c @@ -2727,7 +2727,7 @@ check_insert_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, &is_protected, - &is_pinned); + &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13541,7 +13541,7 @@ check_get_entry_status(void) */ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13565,7 +13565,7 @@ check_get_entry_status(void) if ( pass ) { result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13587,7 +13587,7 @@ check_get_entry_status(void) if ( pass ) { result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13609,7 +13609,7 @@ check_get_entry_status(void) if ( pass ) { result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13631,7 +13631,7 @@ check_get_entry_status(void) if ( pass ) { result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13653,7 +13653,7 @@ check_get_entry_status(void) if ( pass ) { result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13743,7 +13743,7 @@ check_expunge_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, &is_protected, - &is_pinned); + &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13781,7 +13781,7 @@ check_expunge_entry(void) if ( pass ) { result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13821,7 +13821,7 @@ check_expunge_entry(void) */ result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13863,7 +13863,7 @@ check_expunge_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, &is_protected, - &is_pinned); + &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13902,7 +13902,7 @@ check_expunge_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, &is_protected, - &is_pinned); + &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -13943,7 +13943,7 @@ check_expunge_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, &is_protected, - &is_pinned); + &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -14878,7 +14878,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -14948,7 +14948,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15021,7 +15021,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15086,7 +15086,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15147,7 +15147,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15184,7 +15184,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, &is_protected, - &is_pinned); + &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15290,7 +15290,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15362,7 +15362,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15435,7 +15435,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15502,7 +15502,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15563,7 +15563,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + &is_dirty, &is_protected, &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15600,7 +15600,7 @@ check_resize_entry(void) result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, &is_protected, - &is_pinned); + &is_pinned, NULL, NULL); if ( result < 0 ) { @@ -15878,7 +15878,7 @@ check_evictions_enabled(void) entry_ptr = &(base_addr[0]); result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL); + NULL, &in_cache, NULL, NULL, NULL, NULL, NULL); if ( result < 0 ) { @@ -15941,7 +15941,7 @@ check_evictions_enabled(void) entry_ptr = &(base_addr[1]); result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL); + NULL, &in_cache, NULL, NULL, NULL, NULL, NULL); if ( result < 0 ) { @@ -16148,7 +16148,7 @@ check_evictions_enabled(void) entry_ptr = &(base_addr[2]); result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL); + NULL, &in_cache, NULL, NULL, NULL, NULL, NULL); if ( result < 0 ) { @@ -16184,7 +16184,7 @@ check_evictions_enabled(void) entry_ptr = &(base_addr[3]); result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL); + NULL, &in_cache, NULL, NULL, NULL, NULL, NULL); if ( result < 0 ) { @@ -16313,7 +16313,7 @@ check_evictions_enabled(void) entry_ptr = &(base_addr[4]); result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - NULL, &in_cache, NULL, NULL, NULL); + NULL, &in_cache, NULL, NULL, NULL, NULL, NULL); if ( result < 0 ) { @@ -29726,6 +29726,7 @@ static unsigned check_flush_deps(void) { H5C_t * cache_ptr = NULL; /* Metadata cache for this test */ + test_entry_t *base_addr; /* Base address of entries for test */ int entry_type = PICO_ENTRY_TYPE; /* Use very small entry size (size of entries doesn't matter) */ size_t entry_size = PICO_ENTRY_SIZE; /* 1 byte */ unsigned u; /* Local index variable */ @@ -29750,6 +29751,7 @@ check_flush_deps(void) reset_entries(); cache_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + base_addr = entries[entry_type]; if ( !pass ) CACHE_ERROR("setup_cache failed") @@ -29776,12 +29778,47 @@ check_flush_deps(void) /* Create flush dependency between entries 0 (child) & 1 (parent) */ { + hbool_t in_cache, is_flush_dep_parent, is_flush_dep_child; + test_entry_t * entry_ptr; + protect_entry(cache_ptr, entry_type, 1); if ( !pass ) CACHE_ERROR("protect_entry failed") + /* Check the parent's entry status */ + entry_ptr = &(base_addr[1]); + if(H5C_get_entry_status(cache_ptr, entry_ptr->addr, NULL, &in_cache, + NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child) < 0) + CACHE_ERROR("H5C_get_entry_status() failed") + if(!in_cache || is_flush_dep_parent || is_flush_dep_child) + CACHE_ERROR("invalid entry status") + + /* Check the child's entry status */ + entry_ptr = &(base_addr[0]); + if(H5C_get_entry_status(cache_ptr, entry_ptr->addr, NULL, &in_cache, + NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child) < 0) + CACHE_ERROR("H5C_get_entry_status() failed") + if(!in_cache || is_flush_dep_parent || is_flush_dep_child) + CACHE_ERROR("invalid entry status") + create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0); if ( !pass ) CACHE_ERROR("create_flush_dependency failed") + /* Check the parent's entry status */ + entry_ptr = &(base_addr[1]); + if(H5C_get_entry_status(cache_ptr, entry_ptr->addr, NULL, &in_cache, + NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child) < 0) + CACHE_ERROR("H5C_get_entry_status() failed") + if(!in_cache || !is_flush_dep_parent || is_flush_dep_child) + CACHE_ERROR("invalid entry status") + + /* Check the child's entry status */ + entry_ptr = &(base_addr[0]); + if(H5C_get_entry_status(cache_ptr, entry_ptr->addr, NULL, &in_cache, + NULL, NULL, NULL, &is_flush_dep_parent, &is_flush_dep_child) < 0) + CACHE_ERROR("H5C_get_entry_status() failed") + if(!in_cache || is_flush_dep_parent || !is_flush_dep_child) + CACHE_ERROR("invalid entry status") + /* Change expected values, and verify the status of the entries * after creating flush dependency */ @@ -31214,6 +31251,145 @@ check_flush_deps(void) if ( !pass ) CACHE_ERROR("verify_entry_status failed") } +/* Test Case #6a - Make certain that flush dependency relationship with parent + * already pinned works (unpin ater destroying flush dependency) + */ + + /* Create flush dependency between entries 0 (child) & 1 (parent) */ + { + protect_entry(cache_ptr, entry_type, 1); + if ( !pass ) CACHE_ERROR("protect_entry failed") + + pin_entry(cache_ptr, entry_type, 1); + if ( !pass ) CACHE_ERROR("pin_entry failed") + + create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0); + if ( !pass ) CACHE_ERROR("create_flush_dependency failed") + + /* Change expected values, and verify the status of the entries + * after creating flush dependency + */ + expected[0].flush_dep_par_type = entry_type; + expected[0].flush_dep_par_idx = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].child_flush_dep_height_rc[0] = 1; + expected[1].flush_dep_height = 1; + + /* Verify the status */ + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if ( !pass ) CACHE_ERROR("verify_entry_status failed") + } + + /* Unpin entry & destroy flush dependency between entries 0 (child) & 1 (parent) */ + { + destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0); + if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed") + + unpin_entry(cache_ptr, entry_type, 1); + if ( !pass ) CACHE_ERROR("unpin_entry failed") + + unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */ + entry_type, /* int32_t type */ + 1, /* int32_t idx */ + FALSE, /* int32_t dirty */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + if ( !pass ) CACHE_ERROR("unprotect_entry failed") + + /* Change expected values, and verify the status of the entries + * after destroy flush dependency + */ + expected[0].flush_dep_par_type = -1; + expected[0].flush_dep_par_idx = -1; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].child_flush_dep_height_rc[0] = 0; + expected[1].flush_dep_height = 0; + + /* Verify the status */ + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if ( !pass ) CACHE_ERROR("verify_entry_status failed") + } + +/* Test Case #6b - Make certain that flush dependency relationship with parent + * already pinned works (unpin before destroying flush dependency) + */ + + /* Create flush dependency between entries 0 (child) & 1 (parent) */ + { + protect_entry(cache_ptr, entry_type, 1); + if ( !pass ) CACHE_ERROR("protect_entry failed") + + pin_entry(cache_ptr, entry_type, 1); + if ( !pass ) CACHE_ERROR("pin_entry failed") + + create_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0); + if ( !pass ) CACHE_ERROR("create_flush_dependency failed") + + /* Change expected values, and verify the status of the entries + * after creating flush dependency + */ + expected[0].flush_dep_par_type = entry_type; + expected[0].flush_dep_par_idx = 1; + expected[1].is_protected = TRUE; + expected[1].is_pinned = TRUE; + expected[1].child_flush_dep_height_rc[0] = 1; + expected[1].flush_dep_height = 1; + + /* Verify the status */ + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if ( !pass ) CACHE_ERROR("verify_entry_status failed") + } + + /* Unpin entry & destroy flush dependency between entries 0 (child) & 1 (parent) */ + { + unpin_entry(cache_ptr, entry_type, 1); + if ( !pass ) CACHE_ERROR("unpin_entry failed") + + /* Verify the status */ + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if ( !pass ) CACHE_ERROR("verify_entry_status failed") + + destroy_flush_dependency(cache_ptr, entry_type, 1, entry_type, 0); + if ( !pass ) CACHE_ERROR("destroy_flush_dependency failed") + + unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */ + entry_type, /* int32_t type */ + 1, /* int32_t idx */ + FALSE, /* int32_t dirty */ + H5C__NO_FLAGS_SET); /* unsigned int flags */ + if ( !pass ) CACHE_ERROR("unprotect_entry failed") + + /* Change expected values, and verify the status of the entries + * after destroy flush dependency + */ + expected[0].flush_dep_par_type = -1; + expected[0].flush_dep_par_idx = -1; + expected[1].is_protected = FALSE; + expected[1].is_pinned = FALSE; + expected[1].child_flush_dep_height_rc[0] = 0; + expected[1].flush_dep_height = 0; + + /* Verify the status */ + verify_entry_status(cache_ptr, /* H5C_t * cache_ptr */ + (int)0, /* int tag */ + (int)5, /* int num_entries */ + expected); /* struct expected_entry_staus[] */ + if ( !pass ) CACHE_ERROR("verify_entry_status failed") + } + done: if(cache_ptr) @@ -31257,7 +31433,7 @@ check_flush_deps_err(void) /* Loop over test cases, check for various errors in configuring flush * dependencies. Verify that all performs as expected. */ - for(test_count = 0; test_count < 11; test_count++) { + for(test_count = 0; test_count < 9; test_count++) { unsigned u; /* Local index variable */ herr_t result; /* Generic return value */ @@ -31421,36 +31597,14 @@ check_flush_deps_err(void) if ( !pass ) CACHE_ERROR("unprotect_entry failed") break; - /* Verify that parent entry isn't already pinned */ - case 4: - protect_entry(cache_ptr, entry_type, 0); - if ( !pass ) CACHE_ERROR("protect_entry failed") - - pin_entry(cache_ptr, entry_type, 0); - if ( !pass ) CACHE_ERROR("pin_entry failed") - - result = H5C_create_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[1])); - if( result != FAIL ) CACHE_ERROR("Creating dependency when parent is pinned") - - unpin_entry(cache_ptr, entry_type, 0); - if ( !pass ) CACHE_ERROR("unpin_entry failed") - - unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */ - entry_type, /* int32_t type */ - 0, /* int32_t idx */ - FALSE, /* int32_t dirty */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - if ( !pass ) CACHE_ERROR("unprotect_entry failed") - break; - /* Verify that parent entry must be protected */ - case 5: + case 4: result = H5C_destroy_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[1])); if( result != FAIL ) CACHE_ERROR("Destroying [non-existant] dependency when parent isn't protected") break; /* Verify that parent entry has flush dependency */ - case 6: + case 5: protect_entry(cache_ptr, entry_type, 0); if ( !pass ) CACHE_ERROR("protect_entry failed") @@ -31465,30 +31619,8 @@ check_flush_deps_err(void) if ( !pass ) CACHE_ERROR("unprotect_entry failed") break; - /* Verify that parent entry is still pinned */ - case 7: - protect_entry(cache_ptr, entry_type, 0); - if ( !pass ) CACHE_ERROR("protect_entry failed") - - create_flush_dependency(cache_ptr, entry_type, 0, entry_type, 1); - if ( !pass ) CACHE_ERROR("create_flush_dependency failed") - - unpin_entry(cache_ptr, entry_type, 0); - if ( !pass ) CACHE_ERROR("unpin_entry failed") - - result = H5C_destroy_flush_dependency(cache_ptr, &((entries[entry_type])[0]), &((entries[entry_type])[1])); - if( result != FAIL ) CACHE_ERROR("Destroying dependency when parent isn't in relationship") - - unprotect_entry(cache_ptr, /* H5C_t * cache_ptr */ - entry_type, /* int32_t type */ - 0, /* int32_t idx */ - FALSE, /* int32_t dirty */ - H5C__NO_FLAGS_SET); /* unsigned int flags */ - if ( !pass ) CACHE_ERROR("unprotect_entry failed") - break; - /* Verify that child entry is in flush dependency relationship */ - case 8: + case 6: protect_entry(cache_ptr, entry_type, 0); if ( !pass ) CACHE_ERROR("protect_entry failed") @@ -31510,7 +31642,7 @@ check_flush_deps_err(void) break; /* Verify that parent has child entries at this height */ - case 9: + case 7: protect_entry(cache_ptr, entry_type, 0); if ( !pass ) CACHE_ERROR("protect_entry failed") @@ -31565,7 +31697,7 @@ check_flush_deps_err(void) /* Verify that child entry is child of parent */ - case 10: + case 8: protect_entry(cache_ptr, entry_type, 0); if ( !pass ) CACHE_ERROR("protect_entry failed") diff --git a/test/cache_common.c b/test/cache_common.c index 7f8a458..6a9c7e5 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -155,6 +155,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)pico_flush, (H5C_dest_func_t)pico_dest, (H5C_clear_func_t)pico_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)pico_size }, { @@ -163,6 +164,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)nano_flush, (H5C_dest_func_t)nano_dest, (H5C_clear_func_t)nano_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)nano_size }, { @@ -171,6 +173,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)micro_flush, (H5C_dest_func_t)micro_dest, (H5C_clear_func_t)micro_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)micro_size }, { @@ -179,6 +182,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)tiny_flush, (H5C_dest_func_t)tiny_dest, (H5C_clear_func_t)tiny_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)tiny_size }, { @@ -187,6 +191,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)small_flush, (H5C_dest_func_t)small_dest, (H5C_clear_func_t)small_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)small_size }, { @@ -195,6 +200,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)medium_flush, (H5C_dest_func_t)medium_dest, (H5C_clear_func_t)medium_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)medium_size }, { @@ -203,6 +209,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)large_flush, (H5C_dest_func_t)large_dest, (H5C_clear_func_t)large_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)large_size }, { @@ -211,6 +218,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)huge_flush, (H5C_dest_func_t)huge_dest, (H5C_clear_func_t)huge_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)huge_size }, { @@ -219,6 +227,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)monster_flush, (H5C_dest_func_t)monster_dest, (H5C_clear_func_t)monster_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)monster_size }, { @@ -227,6 +236,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)variable_flush, (H5C_dest_func_t)variable_dest, (H5C_clear_func_t)variable_clear, + (H5C_notify_func_t)NULL, (H5C_size_func_t)variable_size } }; @@ -1663,6 +1673,8 @@ reset_entries(void) for ( k = 0; k < H5C__NUM_FLUSH_DEP_HEIGHTS; k++ ) base_addr[j].child_flush_dep_height_rc[k] = 0; base_addr[j].flush_dep_height = 0; + base_addr[j].pinned_from_client = FALSE; + base_addr[j].pinned_from_cache = FALSE; base_addr[j].flush_order = 0; @@ -2279,8 +2291,6 @@ verify_entry_status(H5C_t * cache_ptr, i++; } /* while */ -if(!pass) - HDfprintf(stderr, "failure_mssg = '%s'\n", failure_mssg); return; @@ -2680,14 +2690,15 @@ insert_entry(H5C_t * cache_ptr, if ( insert_pinned ) { HDassert( entry_ptr->header.is_pinned ); - entry_ptr->is_pinned = TRUE; } else { HDassert( ! ( entry_ptr->header.is_pinned ) ); - entry_ptr->is_pinned = FALSE; } + entry_ptr->is_pinned = insert_pinned; + entry_ptr->pinned_from_client = insert_pinned; + HDassert( entry_ptr->header.is_dirty ); HDassert( ((entry_ptr->header).type)->id == type ); } @@ -3201,7 +3212,7 @@ pin_entry(H5C_t * cache_ptr, HDassert( entry_ptr->type == type ); HDassert( entry_ptr == entry_ptr->self ); HDassert( entry_ptr->is_protected ); - HDassert( !(entry_ptr->is_pinned) ); + HDassert( !(entry_ptr->pinned_from_client) ); result = H5C_pin_protected_entry(cache_ptr, (void *)entry_ptr); @@ -3217,7 +3228,9 @@ pin_entry(H5C_t * cache_ptr, } else { + entry_ptr->pinned_from_client = TRUE; entry_ptr->is_pinned = TRUE; + } } /* end if */ @@ -3269,12 +3282,15 @@ unpin_entry(H5C_t * cache_ptr, HDassert( entry_ptr == entry_ptr->self ); HDassert( entry_ptr->cache_ptr == cache_ptr ); HDassert( entry_ptr->header.is_pinned ); + HDassert( entry_ptr->header.pinned_from_client ); HDassert( entry_ptr->is_pinned ); + HDassert( entry_ptr->pinned_from_client ); result = H5C_unpin_entry(cache_ptr, (void *)entry_ptr); if ( ( result < 0 ) || - ( entry_ptr->header.is_pinned ) || + ( entry_ptr->header.pinned_from_client ) || + ( entry_ptr->header.is_pinned && !entry_ptr->header.pinned_from_cache ) || ( entry_ptr->header.type != &(types[type]) ) || ( entry_ptr->size != entry_ptr->header.size ) || ( entry_ptr->addr != entry_ptr->header.addr ) ) { @@ -3284,7 +3300,9 @@ unpin_entry(H5C_t * cache_ptr, } - entry_ptr->is_pinned = FALSE; + entry_ptr->pinned_from_client = FALSE; + + entry_ptr->is_pinned = entry_ptr->pinned_from_cache; HDassert( ((entry_ptr->header).type)->id == type ); @@ -3430,12 +3448,14 @@ unprotect_entry(H5C_t * cache_ptr, if ( pin_flag_set ) { HDassert ( entry_ptr->header.is_pinned ); + entry_ptr->pinned_from_client = TRUE; entry_ptr->is_pinned = TRUE; } else if ( unpin_flag_set ) { - HDassert ( ! ( entry_ptr->header.is_pinned ) ); - entry_ptr->is_pinned = FALSE; + HDassert ( entry_ptr->header.is_pinned == entry_ptr->header.pinned_from_cache ); + entry_ptr->pinned_from_client = FALSE; + entry_ptr->is_pinned = entry_ptr->pinned_from_cache; } } @@ -3592,12 +3612,14 @@ unprotect_entry_with_size_change(H5C_t * cache_ptr, if ( pin_flag_set ) { HDassert ( entry_ptr->header.is_pinned ); + entry_ptr->pinned_from_client = TRUE; entry_ptr->is_pinned = TRUE; } else if ( unpin_flag_set ) { - HDassert ( ! ( entry_ptr->header.is_pinned ) ); - entry_ptr->is_pinned = FALSE; + HDassert ( entry_ptr->header.is_pinned == entry_ptr->header.pinned_from_cache ); + entry_ptr->pinned_from_client = FALSE; + entry_ptr->is_pinned = entry_ptr->pinned_from_cache; } } @@ -4979,6 +5001,7 @@ create_flush_dependency(H5C_t * cache_ptr, chd_entry_ptr->flush_dep_par_type = par_type; chd_entry_ptr->flush_dep_par_idx = par_idx; par_entry_ptr->child_flush_dep_height_rc[chd_entry_ptr->flush_dep_height]++; + par_entry_ptr->pinned_from_cache = TRUE; if( !par_is_pinned ) par_entry_ptr->is_pinned = TRUE; @@ -5051,6 +5074,7 @@ destroy_flush_dependency(H5C_t * cache_ptr, HDassert( par_entry_ptr->index == par_idx ); HDassert( par_entry_ptr->type == par_type ); HDassert( par_entry_ptr->is_pinned ); + HDassert( par_entry_ptr->pinned_from_cache ); HDassert( par_entry_ptr->flush_dep_height > 0 ); HDassert( par_entry_ptr == par_entry_ptr->self ); @@ -5089,8 +5113,10 @@ destroy_flush_dependency(H5C_t * cache_ptr, if((unsigned)(i + 1) < prev_par_flush_dep_height) { par_entry_ptr->flush_dep_height = (unsigned)(i + 1); - if(i < 0) - par_entry_ptr->is_pinned = FALSE; + if(i < 0) { + par_entry_ptr->pinned_from_cache = FALSE; + par_entry_ptr->is_pinned = par_entry_ptr->pinned_from_client; + } /* end if */ /* Check for parent entry being in flush dependency relationship */ if(par_entry_ptr->flush_dep_par_idx >= 0) { diff --git a/test/cache_common.h b/test/cache_common.h index 1284ea3..37e9e0c 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -35,7 +35,7 @@ #include "h5test.h" /* Macro to make error reporting easier */ -#define CACHE_ERROR(s) {failure_mssg = "Line #" H5_TOSTRING(__LINE__) ": " s ; goto done;} +#define CACHE_ERROR(s) {failure_mssg = "Line #" H5_TOSTRING(__LINE__) ": " s ; pass = FALSE; goto done;} #define NO_CHANGE -1 @@ -306,6 +306,8 @@ typedef struct test_entry_t * dependency children */ unsigned flush_dep_height; /* flush dependency height of entry */ + hbool_t pinned_from_client; /* entry was pinned by client call */ + hbool_t pinned_from_cache; /* entry was pinned by cache internally */ unsigned flush_order; /* Order that entry was flushed in */ } test_entry_t; diff --git a/test/dsets.c b/test/dsets.c index 060816d..71324d8 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -45,6 +45,7 @@ const char *FILENAME[] = { "huge_chunks", "chunk_cache", "big_chunk", + "chunk_expand", NULL }; #define FILENAME_BUF_SIZE 1024 @@ -98,6 +99,7 @@ const char *FILENAME[] = { #define DSET_DEPREC_NAME "deprecated" #define DSET_DEPREC_NAME_CHUNKED "deprecated_chunked" #define DSET_DEPREC_NAME_COMPACT "deprecated_compact" +#define DSET_DEPREC_NAME_FILTER "deprecated_filter" #define USER_BLOCK 1024 #define SIXTY_FOUR_KB 65536 @@ -105,7 +107,10 @@ const char *FILENAME[] = { /* Temporary filter IDs used for testing */ #define H5Z_FILTER_BOGUS 305 #define H5Z_FILTER_CORRUPT 306 -#define H5Z_FILTER_BOGUS2 307 +#define H5Z_FILTER_CAN_APPLY_TEST 307 +#define H5Z_FILTER_SET_LOCAL_TEST 308 +#define H5Z_FILTER_DEPREC 309 +#define H5Z_FILTER_EXPAND 310 /* Flags for testing filters */ #define DISABLE_FLETCHER32 0 @@ -186,6 +191,8 @@ static size_t filter_bogus2(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); static size_t filter_corrupt(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_expand(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); /*------------------------------------------------------------------------- @@ -1022,7 +1029,7 @@ test_tconv(hid_t file) } /* This message derives from H5Z */ -const H5Z_class_t H5Z_BOGUS[1] = {{ +const H5Z_class2_t H5Z_BOGUS[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_BOGUS, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ @@ -1114,7 +1121,7 @@ set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id) add_on=(unsigned)H5Tget_size(type_id); /* Get the filter's current parameters */ - if(H5Pget_filter_by_id2(dcpl_id, H5Z_FILTER_BOGUS2, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) + if(H5Pget_filter_by_id2(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) return(FAIL); /* Check that the parameter values were passed along correctly */ @@ -1128,7 +1135,7 @@ set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id) cd_values[3]=add_on; /* Amount the data was modified by */ /* Modify the filter's parameters for this dataset */ - if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_BOGUS2, flags, (size_t)BOGUS2_ALL_NPARMS, + if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, flags, (size_t)BOGUS2_ALL_NPARMS, cd_values) < 0) return(FAIL); @@ -1196,7 +1203,7 @@ filter_bogus2(unsigned int flags, size_t cd_nelmts, } /* This message derives from H5Z */ -const H5Z_class_t H5Z_CORRUPT[1] = {{ +const H5Z_class2_t H5Z_CORRUPT[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_CORRUPT, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ @@ -4793,11 +4800,11 @@ test_types(hid_t file) } /* This message derives from H5Z */ -const H5Z_class_t H5Z_CAN_APPLY_TEST[1] = {{ - H5Z_CLASS_T_VERS, - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, - "bogus", /* Filter name for debugging */ +const H5Z_class2_t H5Z_CAN_APPLY_TEST[1] = {{ + H5Z_CLASS_T_VERS, + H5Z_FILTER_CAN_APPLY_TEST, /* Filter id number */ + 1, 1, + "can_apply_test", /* Filter name for debugging */ can_apply_bogus, /* The "can apply" callback */ NULL, /* The "set local" callback */ filter_bogus, /* The actual filter function */ @@ -4847,7 +4854,7 @@ test_can_apply(hid_t file) printf(" Line %d: Can't register 'can apply' filter\n",__LINE__); goto error; } - if(H5Pset_filter(dcpl, H5Z_FILTER_BOGUS, 0, (size_t)0, NULL) < 0) { + if(H5Pset_filter(dcpl, H5Z_FILTER_CAN_APPLY_TEST, 0, (size_t)0, NULL) < 0) { H5_FAILED(); printf(" Line %d: Can't set bogus filter\n",__LINE__); goto error; @@ -5153,11 +5160,11 @@ error: /* This message derives from H5Z */ -const H5Z_class_t H5Z_SET_LOCAL_TEST[1] = {{ - H5Z_CLASS_T_VERS, - H5Z_FILTER_BOGUS2, /* Filter id number */ - 1, 1, - "bogus2", /* Filter name for debugging */ +const H5Z_class2_t H5Z_SET_LOCAL_TEST[1] = {{ + H5Z_CLASS_T_VERS, + H5Z_FILTER_SET_LOCAL_TEST, /* Filter id number */ + 1, 1, + "set_local_test", /* Filter name for debugging */ NULL, /* The "can apply" callback */ set_local_bogus2, /* The "set local" callback */ filter_bogus2, /* The actual filter function */ @@ -5227,7 +5234,7 @@ test_set_local(hid_t fapl) printf(" Line %d: Can't register 'set local' filter\n",__LINE__); goto error; } - if(H5Pset_filter(dcpl, H5Z_FILTER_BOGUS2, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) { + if(H5Pset_filter(dcpl, H5Z_FILTER_SET_LOCAL_TEST, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) { H5_FAILED(); printf(" Line %d: Can't set bogus2 filter\n",__LINE__); goto error; @@ -5738,7 +5745,6 @@ test_filters_endianess(void) hid_t dsid=-1; /* dataset ID */ hid_t sid=-1; /* dataspace ID */ hid_t dcpl=-1; /* dataset creation property list ID */ - int i; char *srcdir = getenv("srcdir"); /* the source directory */ char data_file[512]=""; /* buffer to hold name of existing file */ @@ -6181,6 +6187,28 @@ error: } /* end test_random_chunks() */ #ifndef H5_NO_DEPRECATED_SYMBOLS +/* Empty can_apply and set_local callbacks */ +static herr_t +can_apply_deprec(hid_t UNUSED dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id) +{ + return 1; +} + +static herr_t +set_local_deprec(hid_t UNUSED dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id) +{ + return(SUCCEED); +} + +/* Old style H5Z_class_t, essentially a copy of the "bogus" filter */ +const H5Z_class1_t H5Z_DEPREC[1] = {{ + H5Z_FILTER_DEPREC, /* Filter id number */ + "deprec", /* Filter name for debugging */ + can_apply_deprec, /* The "can apply" callback */ + set_local_deprec, /* The "set local" callback */ + filter_bogus, /* The actual filter function */ +}}; + /*------------------------------------------------------------------------- * Function: test_deprec @@ -6198,8 +6226,9 @@ error: static herr_t test_deprec(hid_t file) { - hid_t dataset, space, small_space, create_parms; + hid_t dataset, space, small_space, create_parms, dcpl; hsize_t dims[2], small_dims[2]; + hsize_t deprec_size; herr_t status; hsize_t csize[2]; @@ -6353,7 +6382,17 @@ test_deprec(hid_t file) if((dataset = H5Dopen1(file, DSET_DEPREC_NAME_COMPACT)) < 0) goto error; if(H5Dclose(dataset) < 0) goto error; - PASSED(); + /* Test H5Zregister with deprecated H5Z_class1_t */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + if(H5Pset_chunk(dcpl, 2, csize) < 0) goto error; + if(H5Zregister(H5Z_DEPREC) < 0) goto error; + if(H5Pset_filter(dcpl, H5Z_FILTER_DEPREC, 0, (size_t)0, NULL) < 0) goto error; + + puts(""); + if(test_filter_internal(file,DSET_DEPREC_NAME_FILTER,dcpl,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&deprec_size) < 0) goto error; + + if(H5Pclose(dcpl) < 0) goto error; + return 0; error: @@ -6727,7 +6766,7 @@ test_big_chunks_bypass_cache(hid_t fapl) /* Define cache size to be smaller than chunk size */ rdcc_nelmts = BYPASS_CHUNK_DIM/5; rdcc_nbytes = sizeof(int)*BYPASS_CHUNK_DIM/5; - if(H5Pset_cache(fapl_local, 0, rdcc_nelmts, rdcc_nbytes, 0) < 0) FAIL_STACK_ERROR + if(H5Pset_cache(fapl_local, 0, rdcc_nelmts, rdcc_nbytes, (double)0.0) < 0) FAIL_STACK_ERROR /* Create file */ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 0) FAIL_STACK_ERROR @@ -6844,6 +6883,352 @@ error: return -1; } /* end test_big_chunks_bypass_cache() */ +/* This message derives from H5Z */ +const H5Z_class2_t H5Z_EXPAND[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_EXPAND, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "expand", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_expand, /* The actual filter function */ +}}; + +/* Global "expansion factor" for filter_expand() routine */ +static size_t filter_expand_factor_g = 0; + + +/*------------------------------------------------------------------------- + * Function: filter_expand + * + * Purpose: For testing library's behavior when a filter expands a chunk + * too much. + * + * Note: This filter doesn't actually re-allocate the buffer to be + * larger, it just changes the buffer size to a value that's too + * large. The library should throw an error before using the + * incorrect buffer information. + * + * Return: Success: Data chunk size + * Failure: 0 + * + * Programmer: Quincey Koziol + * Mar 31, 2009 + * + *------------------------------------------------------------------------- + */ +static size_t +filter_expand(unsigned int flags, size_t UNUSED cd_nelmts, + const unsigned int UNUSED *cd_values, size_t nbytes, + size_t *buf_size, void UNUSED **buf) +{ + size_t ret_value = 0; + + if(flags & H5Z_FLAG_REVERSE) { + /* Don't do anything when filter is applied in reverse */ + *buf_size = nbytes; + ret_value = nbytes; + } /* end if */ + else { + /* Check for expanding the chunk */ + if(filter_expand_factor_g > 0) { + /* Expand the buffer size beyond what can be encoded */ + *buf_size = nbytes * 256 * 256 * 256 * filter_expand_factor_g; + ret_value = *buf_size; + } /* end if */ + else { + /* Don't expand the chunk's size */ + *buf_size = nbytes; + ret_value = nbytes; + } /* end else */ + } /* end else */ + + return ret_value; +} /* end filter_expand() */ + + +/*------------------------------------------------------------------------- + * Function: test_chunk_expand + * + * Purpose: Tests support for proper error handling when a chunk expands + * too much after a filter is applied + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * Tuesday, March 31, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_chunk_expand(hid_t fapl) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t scalar_sid = -1;/* Scalar dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */ + hsize_t hs_offset; /* Hyperslab offset */ + hsize_t hs_size; /* Hyperslab size */ + H5D_alloc_time_t alloc_time; /* Storage allocation time */ + unsigned write_elem, read_elem; /* Element written/read */ + unsigned u; /* Local index variable */ + herr_t status; /* Generic return value */ + + TESTING("filter expanding chunks too much"); + + h5_fixname(FILENAME[10], fapl, filename, sizeof filename); + + if(sizeof(size_t) <= 4) { + SKIPPED(); + puts(" Current machine can't test for error"); + } /* end if */ + else { + /* Register "expansion" filter */ + if(H5Zregister(H5Z_EXPAND) < 0) FAIL_STACK_ERROR + + /* Check that the filter was registered */ + if(TRUE != H5Zfilter_avail(H5Z_FILTER_EXPAND)) FAIL_STACK_ERROR + + /* Loop over storage allocation time */ + for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + /* Create file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + + /* Create dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + + /* Set chunking */ + chunk_dim = 10; + if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR + + /* Set fill time */ + if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR + + /* Set allocation time */ + if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR + + /* Set "expand" filter */ + if(H5Pset_filter(dcpl, H5Z_FILTER_EXPAND, 0, (size_t)0, NULL) < 0) FAIL_STACK_ERROR + + /* Create scalar dataspace */ + if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + + /* Create 1-D dataspace */ + dim = 100; + max_dim = H5S_UNLIMITED; + if((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) FAIL_STACK_ERROR + + /* Create chunked dataset */ + if(H5D_ALLOC_TIME_EARLY == alloc_time) { + /* Make the expansion factor large enough to cause failure right away */ + filter_expand_factor_g = 8; + + H5E_BEGIN_TRY { + dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + } H5E_END_TRY; + if(dsid >= 0) FAIL_PUTS_ERROR("should fail to create dataset when allocation time is early"); + } /* end if */ + else { + if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Fill elements */ + hs_size = 1; + for(u = 0; u < 100; u++) { + /* Select a single element in the dataset */ + hs_offset = u; + if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR + + /* Read (unwritten) element from dataset */ + read_elem = 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify unwritten element is fill value (0) */ + if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); + + /* Don't expand chunks yet */ + filter_expand_factor_g = 0; + + /* Write element to dataset */ + write_elem = u; + if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR + + /* Read element from dataset */ + read_elem = write_elem + 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify written element is read in */ + if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); + + /* Expand chunks now */ + filter_expand_factor_g = 8; + + /* Write element to dataset */ + write_elem = u; + H5E_BEGIN_TRY { + status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem); + } H5E_END_TRY; + if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); + } /* end for */ + + /* Incrementally extend dataset and verify write/reads */ + while(dim < 1000) { + /* Extend dataset */ + dim += 100; + if(H5Dset_extent(dsid, &dim) < 0) FAIL_STACK_ERROR + + /* Close old dataspace */ + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + + /* Get dataspace for dataset now */ + if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR + + /* Fill new elements */ + hs_size = 1; + for(u = 0; u < 100; u++) { + /* Select a single element in the dataset */ + hs_offset = (dim + u) - 100; + if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR + + /* Read (unwritten) element from dataset */ + read_elem = 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify unwritten element is fill value (0) */ + if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); + + /* Don't expand chunks yet */ + filter_expand_factor_g = 0; + + /* Write element to dataset */ + write_elem = u; + if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR + + /* Read element from dataset */ + read_elem = write_elem + 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify written element is read in */ + if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); + + /* Expand chunks now */ + filter_expand_factor_g = 8; + + /* Write element to dataset */ + write_elem = u; + H5E_BEGIN_TRY { + status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem); + } H5E_END_TRY; + if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); + } /* end for */ + } /* end while */ + + /* Close dataset */ + if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + } /* end else */ + + /* Close everything */ + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + + /* If the dataset was created, do some extra testing */ + if(H5D_ALLOC_TIME_EARLY != alloc_time) { + /* Re-open file & dataset */ + if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + /* Open dataset */ + if((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Create scalar dataspace */ + if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + + /* Get dataspace for dataset now */ + if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR + + /* Read elements */ + hs_size = 1; + for(u = 0; u < 1000; u++) { + /* Select a single element in the dataset */ + hs_offset = u; + if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR + + /* Read element from dataset */ + read_elem = u + 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify unwritten element is proper value */ + if(read_elem != (u % 100)) FAIL_PUTS_ERROR("invalid element read"); + + /* Don't expand chunks yet */ + filter_expand_factor_g = 0; + + /* Write element to dataset */ + write_elem = u % 100; + if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR + + /* Read element from dataset */ + read_elem = write_elem + 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify written element is read in */ + if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); + + /* Expand chunks now */ + filter_expand_factor_g = 8; + + /* Write element to dataset */ + write_elem = u % 100; + H5E_BEGIN_TRY { + status = H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem); + } H5E_END_TRY; + if(status >= 0) FAIL_PUTS_ERROR("should fail to write to dataset when allocation time is not early"); + } /* end for */ + + /* Close everything */ + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR + if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + + /* Re-open file */ + if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + /* Delete dataset */ + if(H5Ldelete(fid, "dset", H5P_DEFAULT) < 0) FAIL_STACK_ERROR + + /* Close everything */ + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + } /* end if */ + } /* end for */ + + /* Unregister "expansion" filter */ + if(H5Zunregister(H5Z_FILTER_EXPAND) < 0) FAIL_STACK_ERROR + + /* Check that the filter was unregistered */ + if(FALSE != H5Zfilter_avail(H5Z_FILTER_EXPAND)) FAIL_STACK_ERROR + + PASSED(); + } /* end else */ + + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dsid); + H5Sclose(sid); + H5Sclose(scalar_sid); + H5Fclose(fid); + } H5E_END_TRY; + return -1; +} /* end test_chunk_expand() */ + /*------------------------------------------------------------------------- * Function: main @@ -6967,6 +7352,7 @@ main(void) nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0); nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); if(H5Fclose(file) < 0) goto error; diff --git a/test/dtransform.c b/test/dtransform.c index 8b5dce0..cb58a6c 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -50,17 +50,17 @@ const float windchillFfloat[ROWS][COLS] = const int transformData[ROWS][COLS] = { {36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63 }, - {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 72 } , - {32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 77 }, - {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 74, 81 }, - {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 78, 84 }, - {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 73, 80, 87 }, - {28, 21, 14, 7, 0, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 76, 82, 89 }, - {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 84, 91 }, - {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72, 79, 86, 93 }, - {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 74, 81, 88, 95}, - {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 75, 82, 89, 97}, - {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 76, 84, 91, 98} + {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 0 } , + {32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 }, + {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9 }, + {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12 }, + {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15 }, + {28, 21, 14, 7, 0, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 }, + {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19 }, + {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 0, 7, 14, 21 }, + {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23}, + {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25}, + {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26} }; #define UCOMPARE(TYPE,VAR1,VAR2,TOL) \ @@ -104,17 +104,25 @@ const int transformData[ROWS][COLS] = /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */ \ const char* utrans = "((x+100)/4)*3"; \ \ - hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset; \ + hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset, dset_nn, dt_nn; \ + H5T_order_t order; \ hsize_t dim[2] = {ROWS, COLS}; \ \ if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR; \ - if((dset = H5Dcreate2(file_id, "/transformtest_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; \ + if((dset = H5Dcreate2(file_id, "/transformtest_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; \ + \ + if((dt_nn = H5Tcopy(HDF_TYPE)) < 0) TEST_ERROR \ + if((order = H5Tget_order(dt_nn)) == H5T_ORDER_ERROR) TEST_ERROR \ + if(H5Tset_order(dt_nn, order == H5T_ORDER_LE ? H5T_ORDER_BE : H5T_ORDER_LE) < 0) TEST_ERROR \ + if((dset_nn = H5Dcreate2(file_id, "/nonnative_transformtest_"TEST_STR, dt_nn, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR \ + if(H5Tclose(dt_nn) < 0) TEST_ERROR \ \ if(SIGNED) \ { \ if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \ if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR; \ if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \ + if(H5Dwrite(dset_nn, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \ if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \ } \ else \ @@ -122,6 +130,7 @@ const int transformData[ROWS][COLS] = if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \ if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR; \ if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \ + if(H5Dwrite(dset_nn, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \ if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \ } \ \ @@ -133,16 +142,21 @@ const int transformData[ROWS][COLS] = COMPARE(TYPE, array, COMPARE_DATA, 2) \ else \ UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + \ + TESTING("contiguous, byte order conversion ("TEST_STR"->"TEST_STR")") \ + \ + if(H5Dread(dset_nn, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \ + if(SIGNED) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ + else \ + UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ \ if(SIGNED) \ { \ TESTING("contiguous, with type conversion (float->"TEST_STR")") \ \ if(H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array) < 0) TEST_ERROR; \ - if(SIGNED) \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - else \ - UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ } \ \ if(H5Dclose(dset) < 0) TEST_ERROR; \ @@ -200,10 +214,7 @@ const int transformData[ROWS][COLS] = TESTING("chunked, with type conversion (float->"TEST_STR")") \ \ if(H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \ - if(SIGNED) \ - COMPARE(TYPE, array, COMPARE_DATA, 2) \ - else \ - UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ + COMPARE(TYPE, array, COMPARE_DATA, 2) \ } \ \ \ @@ -516,7 +527,7 @@ test_getset(const hid_t dxpl_id_c_to_f) float windchillFfloatread[ROWS][COLS]; const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ const char* c_to_f = "(9/5.0)*x + 32"; - char* ptrgetTest = HDmalloc(HDstrlen(simple)+1); + char* ptrgetTest = (char *) HDmalloc(HDstrlen(simple)+1); TESTING("H5Pget_data_transform") H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f)+1); @@ -549,7 +560,7 @@ test_getset(const hid_t dxpl_id_c_to_f) PASSED(); - ptrgetTest = malloc(strlen(simple)+1); + ptrgetTest = (char *) malloc(strlen(simple)+1); HDmemset(ptrgetTest, 0, strlen(simple)+1); TESTING("H5Pget_data_transform, after resetting transform property") @@ -577,7 +588,7 @@ test_set(void) hid_t dxpl_id; H5E_auto2_t func; const char* str = "(9/5.0)*x + 32"; - char* ptrgetTest = malloc(strlen(str)+1); + char* ptrgetTest = (char *) malloc(strlen(str)+1); if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; diff --git a/test/earray.c b/test/earray.c index 7b68e95..5b8ac1a 100644 --- a/test/earray.c +++ b/test/earray.c @@ -312,51 +312,51 @@ check_stats(const H5EA_t *ea, const earray_state_t *state) FAIL_STACK_ERROR /* Compare information */ - if(earray_stats.max_idx_set != state->max_idx_set) { - HDfprintf(stdout, "earray_stats.max_idx_set = %Hu, state->max_idx_set = %Hu\n", earray_stats.max_idx_set, state->max_idx_set); + if(earray_stats.stored.max_idx_set != state->max_idx_set) { + HDfprintf(stdout, "earray_stats.stored.max_idx_set = %Hu, state->max_idx_set = %Hu\n", earray_stats.stored.max_idx_set, state->max_idx_set); TEST_ERROR } /* end if */ - if(earray_stats.nelmts != state->nelmts) { - HDfprintf(stdout, "earray_stats.nelmts = %Hu, state->nelmts = %Hu\n", earray_stats.nelmts, state->nelmts); + if(earray_stats.stored.nelmts != state->nelmts) { + HDfprintf(stdout, "earray_stats.stored.nelmts = %Hu, state->nelmts = %Hu\n", earray_stats.stored.nelmts, state->nelmts); TEST_ERROR } /* end if */ - if(earray_stats.hdr_size != state->hdr_size) { - HDfprintf(stdout, "earray_stats.hdr_size = %Hu, state->hdr_size = %Hu\n", earray_stats.hdr_size, state->hdr_size); + if(earray_stats.computed.hdr_size != state->hdr_size) { + HDfprintf(stdout, "earray_stats.computed.hdr_size = %Hu, state->hdr_size = %Hu\n", earray_stats.computed.hdr_size, state->hdr_size); TEST_ERROR } /* end if */ - if(earray_stats.nindex_blks != state->nindex_blks) { - HDfprintf(stdout, "earray_stats.nindex_blks = %Hu, state->nindex_blks = %Hu\n", earray_stats.nindex_blks, state->nindex_blks); + if(earray_stats.computed.nindex_blks != state->nindex_blks) { + HDfprintf(stdout, "earray_stats.computed.nindex_blks = %Hu, state->nindex_blks = %Hu\n", earray_stats.computed.nindex_blks, state->nindex_blks); TEST_ERROR } /* end if */ - if(earray_stats.index_blk_size != state->index_blk_size) { - HDfprintf(stdout, "earray_stats.index_blk_size = %Hu, state->index_blk_size = %Hu\n", earray_stats.index_blk_size, state->index_blk_size); + if(earray_stats.computed.index_blk_size != state->index_blk_size) { + HDfprintf(stdout, "earray_stats.computed.index_blk_size = %Hu, state->index_blk_size = %Hu\n", earray_stats.computed.index_blk_size, state->index_blk_size); TEST_ERROR } /* end if */ - if(earray_stats.ndata_blks != state->ndata_blks) { - HDfprintf(stdout, "earray_stats.ndata_blks = %Hu, state->ndata_blks = %Hu\n", earray_stats.ndata_blks, state->ndata_blks); + if(earray_stats.stored.ndata_blks != state->ndata_blks) { + HDfprintf(stdout, "earray_stats.stored.ndata_blks = %Hu, state->ndata_blks = %Hu\n", earray_stats.stored.ndata_blks, state->ndata_blks); TEST_ERROR } /* end if */ /* Don't compare this currently, it's very hard to compute */ #ifdef NOT_YET - if(earray_stats.data_blk_size != state->data_blk_size) { - HDfprintf(stdout, "earray_stats.data_blk_size = %Hu, state->data_blk_size = %Hu\n", earray_stats.data_blk_size, state->data_blk_size); + if(earray_stats.stored.data_blk_size != state->data_blk_size) { + HDfprintf(stdout, "earray_stats.stored.data_blk_size = %Hu, state->data_blk_size = %Hu\n", earray_stats.stored.data_blk_size, state->data_blk_size); TEST_ERROR } /* end if */ #endif /* NOT_YET */ - if(earray_stats.nsuper_blks != state->nsuper_blks) { - HDfprintf(stdout, "earray_stats.nsuper_blks = %Hu, state->nsuper_blks = %Hu\n", earray_stats.nsuper_blks, state->nsuper_blks); + if(earray_stats.stored.nsuper_blks != state->nsuper_blks) { + HDfprintf(stdout, "earray_stats.stored.nsuper_blks = %Hu, state->nsuper_blks = %Hu\n", earray_stats.stored.nsuper_blks, state->nsuper_blks); TEST_ERROR } /* end if */ /* Don't compare this currently, it's very hard to compute */ #ifdef NOT_YET - if(earray_stats.super_blk_size != state->super_blk_size) { - HDfprintf(stdout, "earray_stats.super_blk_size = %Hu, state->super_blk_size = %Hu\n", earray_stats.super_blk_size, state->super_blk_size); + if(earray_stats.stored.super_blk_size != state->super_blk_size) { + HDfprintf(stdout, "earray_stats.stored.super_blk_size = %Hu, state->super_blk_size = %Hu\n", earray_stats.stored.super_blk_size, state->super_blk_size); TEST_ERROR } /* end if */ #endif /* NOT_YET */ #ifdef QAK -HDfprintf(stderr, "nelmts = %Hu, total EA size = %Hu\n", earray_stats.nelmts, - (earray_stats.hdr_size + earray_stats.index_blk_size + earray_stats.super_blk_size + earray_stats.data_blk_size)); +HDfprintf(stderr, "nelmts = %Hu, total EA size = %Hu\n", earray_stats.stored.nelmts, + (earray_stats.computed.hdr_size + earray_stats.computed.index_blk_size + earray_stats.stored.super_blk_size + earray_stats.stored.data_blk_size)); #endif /* QAK */ /* All tests passed */ @@ -411,7 +411,7 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* Re-open array, if given */ if(ea) { - if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, ea_cls))) + if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, ea_cls, NULL))) FAIL_STACK_ERROR } /* end if */ } /* end if */ @@ -445,7 +445,7 @@ create_array(H5F_t *f, hid_t dxpl, const H5EA_create_t *cparam, earray_state_t state; /* State of extensible array */ /* Create array */ - if(NULL == (*ea = H5EA_create(f, dxpl, cparam))) + if(NULL == (*ea = H5EA_create(f, dxpl, cparam, NULL))) FAIL_STACK_ERROR /* Check status of array */ @@ -598,7 +598,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.raw_elmt_size = 0; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -613,7 +613,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.max_nelmts_bits = 0; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -627,7 +627,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.max_nelmts_bits = 65; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -642,7 +642,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.sup_blk_min_data_ptrs = 0; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -655,7 +655,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.sup_blk_min_data_ptrs = 1; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -668,7 +668,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.sup_blk_min_data_ptrs = 6; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -683,7 +683,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.data_blk_min_elmts = 0; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -699,7 +699,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.max_dblk_page_nelmts_bits = H5V_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -713,7 +713,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.max_dblk_page_nelmts_bits = 4; /* corresponds to 16 elements in data block page, which is less than the 64 elements for the default settings */ H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -726,7 +726,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tpara HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); test_cparam.max_dblk_page_nelmts_bits = test_cparam.max_nelmts_bits + 1; H5E_BEGIN_TRY { - ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam); + ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; if(ea) { /* Close opened extensible array */ @@ -825,7 +825,7 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TEST_ERROR /* Re-open the array */ - if(NULL == (ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls))) + if(NULL == (ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ @@ -890,7 +890,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TEST_ERROR /* Open the array again, through the first file handle */ - if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls))) + if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ @@ -917,7 +917,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) FAIL_STACK_ERROR /* Open the extensible array through the second file handle */ - if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls))) + if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL))) FAIL_STACK_ERROR /* Verify the creation parameters */ @@ -996,7 +996,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TEST_ERROR /* Open the array again */ - if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls))) + if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL))) FAIL_STACK_ERROR /* Request that the array be deleted */ @@ -1016,7 +1016,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) /* Try re-opening the array again (should fail, as array will be deleted) */ H5E_BEGIN_TRY { - ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls); + ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL); } H5E_END_TRY; if(ea2) { /* Close opened array */ @@ -1037,7 +1037,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) /* Try re-opening the array again (should fail, as array is now deleted) */ H5E_BEGIN_TRY { - ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls); + ea = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, cparam->cls, NULL); } H5E_END_TRY; if(ea) { /* Close opened array */ @@ -1198,7 +1198,7 @@ eiter_fw_state(void *_eiter, const H5EA_create_t *cparam, /* Compute the state of the extensible array */ state->hdr_size = EA_HDR_SIZE; state->nindex_blks = 1; - state->index_blk_size = 298; + state->index_blk_size = EA_IBLOCK_SIZE; state->max_idx_set = idx + 1; if(idx < cparam->idx_blk_elmts) { state->nelmts = (hsize_t)cparam->idx_blk_elmts; @@ -1416,7 +1416,7 @@ eiter_rv_state(void *_eiter, const H5EA_create_t *cparam, /* Compute the state of the extensible array */ state->hdr_size = EA_HDR_SIZE; state->nindex_blks = 1; - state->index_blk_size = 298; + state->index_blk_size = EA_IBLOCK_SIZE; state->max_idx_set = eiter->max + 1; if(eiter->max < cparam->idx_blk_elmts) { state->nelmts = (hsize_t)cparam->idx_blk_elmts; diff --git a/test/family_v16_00000.h5 b/test/family_v16_00000.h5 index 5b69c93..ac75ea9 100644 Binary files a/test/family_v16_00000.h5 and b/test/family_v16_00000.h5 differ diff --git a/test/links.c b/test/links.c index c169670..1d64dd9 100644 --- a/test/links.c +++ b/test/links.c @@ -81,6 +81,7 @@ const char *FILENAME[] = { "extlinks18B", /* 41: */ "extlinks19A", /* 42: */ "extlinks19B", /* 43: */ + "extlinks20", /* 44: */ NULL }; @@ -131,6 +132,7 @@ const char *FILENAME[] = { "extlinks18B", /* 41: */ "extlinks19A", /* 42: */ "extlinks19B", /* 43: */ + "extlinks20", /* 44: */ NULL }; @@ -4218,8 +4220,8 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) if (H5Pset_fapl_family(fam_fapl, op_data.fam_size, op_data.base_fapl) < 0) TEST_ERROR /* Create parent and target files, group, and external link */ - h5_fixname(FILENAME[40], fapl, filename1, sizeof filename1); - h5_fixname(FILENAME[41], fam_fapl, filename2, sizeof filename2); + h5_fixname(FILENAME[42], fapl, filename1, sizeof filename1); + h5_fixname(FILENAME[43], fam_fapl, filename2, sizeof filename2); if ((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR if ((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR if ((group = H5Gcreate2(file1, "group1",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4297,6 +4299,67 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) } /* end external_set_elink_cb() */ +/*------------------------------------------------------------------------- + * Function: external_reset_register + * + * Purpose: Check that external links are registered after the library + * is reset. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Neil Fortner + * Apr. 9, 2009 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +external_reset_register(void) +{ + hid_t file; + char filename[NAME_BUF_SIZE]; + + TESTING("external links are registered after reset") + + /* Create and close file */ + h5_fixname(FILENAME[44], H5P_DEFAULT, filename, sizeof filename); + if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Fclose(file) < 0) TEST_ERROR + + /* Reset the library */ + H5close(); + + /* Re open file */ + if ((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Create an external link */ + if (H5Lcreate_external("some_file", "some_obj", file, "ext_link1", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Close file */ + if (H5Fclose(file) < 0) TEST_ERROR + + /* Try again to make sure the previous H5Lcreate_external call does not + * affect the ability to reset */ + H5close(); + if ((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR + if (H5Lcreate_external("another_file", "another_obj", file, "ext_link2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if (H5Fclose(file) < 0) TEST_ERROR + + if(HDremove(filename) != 0) TEST_ERROR + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + H5Fclose(file); + } H5E_END_TRY; + return -1; +} /* end external_reset_register() */ + + #ifdef H5_HAVE_WINDOW_PATH /*------------------------------------------------------------------------- @@ -7177,6 +7240,14 @@ ud_link_errors(hid_t fapl, hbool_t new_format) if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Gclose(gid) < 0) FAIL_STACK_ERROR + /* Try to create internally defined links with H5Lcreate_ud */ + H5E_BEGIN_TRY { + if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_HARD, NULL, 0, H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR + if(H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_SOFT, "str", 4, H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR + } H5E_END_TRY + /* Create a user-defined link to the group. */ strcpy(group_name, "/group"); if(H5Lcreate_ud(fid, "/ud_link", UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -12753,6 +12824,13 @@ main(void) /* Close 2nd FAPL */ H5Pclose(fapl2); + h5_cleanup(FILENAME, fapl); + + /* Test that external links can be used after a library reset. MUST be + * called last so the reset doesn't interfere with the property lists. This + * routine will delete its own file. */ + nerrors += external_reset_register() < 0 ? 1 : 0; + /* Results */ if(nerrors) { printf("***** %d LINK TEST%s FAILED! *****\n", @@ -12761,8 +12839,6 @@ main(void) } printf("All link tests passed.\n"); - h5_cleanup(FILENAME, fapl); - /* clean up tmp directory created by external link tests */ HDrmdir(TMPDIR); diff --git a/test/mount.c b/test/mount.c index 14ab346..f358634 100644 --- a/test/mount.c +++ b/test/mount.c @@ -502,6 +502,7 @@ test_assoc(hid_t fapl) * of file2. */ if(H5Oget_info_by_name(file1, "/mnt1", &oi2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(oi1.fileno != oi2.fileno || H5F_addr_ne(oi1.addr, oi2.addr)) { H5_FAILED(); puts(" Association failed."); diff --git a/test/objcopy.c b/test/objcopy.c index c2d71c0..4bd4662 100755 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -7451,6 +7451,10 @@ main(void) hid_t fcpl_src; hid_t fcpl_dst; + /* No need to test dense attributes with old format */ + if(!(configuration & CONFIG_NEW_FORMAT) && (configuration & CONFIG_DENSE)) + continue; + /* Test with and without shared messages */ if(configuration & CONFIG_SHARE_SRC) { puts("\nTesting with shared src messages:"); @@ -7473,22 +7477,23 @@ main(void) if(configuration & CONFIG_NEW_FORMAT) { puts("Testing with new group format:"); my_fapl = fapl2; + + /* Test with and without dense attributes */ + if(configuration & CONFIG_DENSE) { + puts("Testing with dense attributes:"); + num_attributes_g = max_compact + 1; + } + else { + puts("Testing without dense attributes:"); + num_attributes_g = MAX(min_dense, 2) - 1; + } } /* end if */ else { puts("Testing with old group format:"); my_fapl = fapl; + num_attributes_g = 4; } /* end else */ - /* Test with and without dense attributes */ - if(configuration & CONFIG_DENSE) { - puts("Testing with dense attributes:"); - num_attributes_g = max_compact + 1; - } - else { - puts("Testing without dense attributes:"); - num_attributes_g = MAX(min_dense, 2) - 1; - } - /* The tests... */ nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, my_fapl); nerrors += test_copy_dataset_simple_samefile(fcpl_src, my_fapl); diff --git a/test/tfile.c b/test/tfile.c index 2afade3..68c7f6b 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -27,6 +27,14 @@ #include "H5Bprivate.h" #include "H5Pprivate.h" +/* + * This file needs to access private information from the H5F package. + * This file also needs to access the file testing code. + */ +#define H5F_PACKAGE +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + #define F1_USERBLOCK_SIZE (hsize_t)0 #define F1_OFFSET_SIZE sizeof(haddr_t) #define F1_LENGTH_SIZE sizeof(hsize_t) @@ -79,6 +87,8 @@ #define TESTA_NX 4 #define TESTA_NY 5 +#define USERBLOCK_SIZE ((hsize_t) 512) + static void create_objects(hid_t, hid_t, hid_t *, hid_t *, hid_t *, hid_t *); static void @@ -1855,6 +1865,168 @@ test_file_double_datatype_open(void) /**************************************************************** ** +** test_userblock_file_size(): low-level file test routine. +** This test checks that the presence of a userblock +** affects the file size in the expected manner, and that +** the filesize is not changed by reopening the file. It +** creates two files which are identical except that one +** contains a userblock, and verifies that their file sizes +** differ exactly by the userblock size. +** +*****************************************************************/ +static void +test_userblock_file_size(void) +{ + hid_t file1_id, file2_id; + hid_t group1_id, group2_id; + hid_t dset1_id, dset2_id; + hid_t space_id; + hid_t fcpl2_id; + hsize_t dims[2] = {3, 4}; + hsize_t filesize1, filesize2, filesize; + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing file size with user block\n")); + + /* Create property list with userblock size set */ + fcpl2_id = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl2_id, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl2_id, USERBLOCK_SIZE); + CHECK(ret, FAIL, "H5Pset_userblock"); + + /* Create files. Onyl file2 with have a userblock. */ + file1_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file1_id, FAIL, "H5Fcreate"); + file2_id = H5Fcreate(FILE2, H5F_ACC_TRUNC, fcpl2_id, H5P_DEFAULT); + CHECK(file2_id, FAIL, "H5Fcreate"); + + /* Create groups */ + group1_id = H5Gcreate2(file1_id, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group1_id, FAIL, "H5Gcreate2"); + group2_id = H5Gcreate2(file2_id, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group2_id, FAIL, "H5Gcreate2"); + + /* Create dataspace */ + space_id = H5Screate_simple(2, dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + + /* Create datasets */ + dset1_id = H5Dcreate2(file1_id, DSET2, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset1_id, FAIL, "H5Dcreate2"); + dset2_id = H5Dcreate2(file2_id, DSET2, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset2_id, FAIL, "H5Dcreate2"); + + /* Close IDs */ + ret = H5Dclose(dset1_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Dclose(dset2_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Gclose(group1_id); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Gclose(group2_id); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Pclose(fcpl2_id); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close files */ + ret = H5Fclose(file1_id); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Fclose(file2_id); + CHECK(ret, FAIL, "H5Fclose"); + + /* Reopen files */ + file1_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(file1_id, FAIL, "H5Fopen"); + file2_id = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(file2_id, FAIL, "H5Fopen"); + + /* Check file sizes */ + ret = H5Fget_filesize(file1_id, &filesize1); + CHECK(ret, FAIL, "H5Fget_filesize"); + ret = H5Fget_filesize(file2_id, &filesize2); + CHECK(ret, FAIL, "H5Fget_filesize"); + + /* Verify that the file sizes differ exactly by the userblock size */ + VERIFY(filesize2, filesize1 + USERBLOCK_SIZE, "H5Fget_filesize"); + + /* Close files */ + ret = H5Fclose(file1_id); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Fclose(file2_id); + CHECK(ret, FAIL, "H5Fclose"); + + /* Reopen files */ + file1_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(file1_id, FAIL, "H5Fopen"); + file2_id = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(file2_id, FAIL, "H5Fopen"); + + /* Verify file sizes did not change */ + ret = H5Fget_filesize(file1_id, &filesize); + CHECK(ret, FAIL, "H5Fget_filesize"); + VERIFY(filesize, filesize1, "H5Fget_filesize"); + ret = H5Fget_filesize(file2_id, &filesize); + CHECK(ret, FAIL, "H5Fget_filesize"); + VERIFY(filesize, filesize2, "H5Fget_filesize"); + + /* Close files */ + ret = H5Fclose(file1_id); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Fclose(file2_id); + CHECK(ret, FAIL, "H5Fclose"); +} /* end test_userblock_file_size() */ + +/**************************************************************** +** +** test_cached_stab_info(): low-level file test routine. +** This test checks that new files are created with cached +** symbol table information in the superblock (when using +** the old format). This is necessary to ensure backwards +** compatibility with versions from 1.3.0 to 1.6.3. +** +*****************************************************************/ +static void +test_cached_stab_info(void) +{ + hid_t file_id; + hid_t group_id; + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing cached symbol table information\n")); + + /* Create file */ + file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file_id, FAIL, "H5Fcreate"); + + /* Create group */ + group_id = H5Gcreate2(file_id, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group_id, FAIL, "H5Gcreate2"); + + /* Close file and group */ + ret = H5Gclose(group_id); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); + + /* Reopen file */ + file_id = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Fopen"); + + /* Verify the cached symbol table information */ + ret = H5F_check_cached_stab_test(file_id); + CHECK(ret, FAIL, "H5F_check_cached_stab_test"); + + /* Close file */ + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); +} /* end test_cached_stab_info() */ + +/**************************************************************** +** ** test_file(): Main low-level file I/O test routine. ** ****************************************************************/ @@ -1884,6 +2056,8 @@ test_file(void) test_file_double_dataset_open(); /* Test opening same dataset from two files works properly */ test_file_double_datatype_open(); /* Test opening same named datatype from two files works properly */ #endif /*H5_CANNOT_OPEN_TWICE*/ + test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */ + test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ } /* test_file() */ @@ -1909,3 +2083,4 @@ cleanup_file(void) HDremove(FILE3); HDremove(FILE4); } + diff --git a/test/tid.c b/test/tid.c index f3c00fc..9bb93e7 100644 --- a/test/tid.c +++ b/test/tid.c @@ -394,7 +394,7 @@ static int test_is_valid(void) /* Check that an id of -1 is invalid */ tri_ret = H5Iis_valid(-1); - VERIFY(tri_ret, FALSE, "H5Iis_valid"); + VERIFY(tri_ret, FALSE, "H4Iis_valid"); if (tri_ret != FALSE) goto out; @@ -408,6 +408,46 @@ out: return -1; } +/* Test the H5Iget_type function */ +static int test_get_type(void) +{ + hid_t dtype; /* datatype id */ + H5I_type_t type_ret; /* return value */ + + /* Create a datatype id */ + dtype = H5Tcopy(H5T_NATIVE_INT); + CHECK(dtype, FAIL, "H5Tcopy"); + if (dtype < 0) + goto out; + + /* Check that the ID is correct */ + type_ret = H5Iget_type(dtype); + VERIFY(type_ret, H5I_DATATYPE, "H5Iget_type"); + if (type_ret == H5I_BADID) + goto out; + + /* Check that the ID is correct */ + type_ret = H5Iget_type(H5T_STRING); + VERIFY(type_ret, H5I_BADID, "H5Iget_type"); + if (type_ret != H5I_BADID) + goto out; + + /* Check that the ID is correct */ + type_ret = H5Iget_type(-1); + VERIFY(type_ret, H5I_BADID, "H5Iget_type"); + if (type_ret != H5I_BADID) + goto out; + + H5Tclose(dtype); + + return 0; + +out: + if(dtype != H5I_INVALID_HID) + H5Tclose(dtype); + + return -1; +} /* Test boundary cases with lots of types */ @@ -498,6 +538,7 @@ void test_ids(void) if (basic_id_test() < 0) TestErrPrintf("Basic ID test failed\n"); if (id_predefined_test() < 0) TestErrPrintf("Predefined ID type test failed\n"); if (test_is_valid() < 0) TestErrPrintf("H5Iis_valid test failed\n"); + if (test_get_type() < 0) TestErrPrintf("H5Iget_type test failed\n"); if (test_id_type_list() < 0) TestErrPrintf("ID type list test failed\n"); } diff --git a/test/tmisc.c b/test/tmisc.c index 4db800c..b646a69 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -3779,6 +3779,7 @@ test_misc23(void) tmp_id=0, create_id=H5P_DEFAULT, access_id=H5P_DEFAULT; char objname[MISC23_NAME_BUF_SIZE]; /* Name of object */ H5O_info_t oinfo; + htri_t tri_status; herr_t status; /* Output message about test being performed */ @@ -4022,6 +4023,87 @@ test_misc23(void) status = H5Pclose(create_id); CHECK(status, FAIL, "H5Pclose"); + /********************************************************************** + * test H5Lcopy() + **********************************************************************/ + + /* Create link creation property list */ + create_id = H5Pcreate(H5P_LINK_CREATE); + CHECK(create_id, FAIL, "H5Pcreate"); + + /* Set flag for intermediate group creation */ + status = H5Pset_create_intermediate_group(create_id, TRUE); + CHECK(status, FAIL, "H5Pset_create_intermediate_group"); + + status = H5Lcopy(file_id, "/A/B01/grp", file_id, "/A/B16/grp", create_id, access_id); + CHECK(status, FAIL, "H5Lcopy"); + + tri_status = H5Lexists(file_id, "/A/B16/grp", access_id); + VERIFY(tri_status, TRUE, "H5Lexists"); + + tri_status = H5Lexists(file_id, "/A/B01/grp", access_id); + VERIFY(tri_status, TRUE, "H5Lexists"); + + /********************************************************************** + * test H5Lmove() + **********************************************************************/ + + status = H5Lmove(file_id, "/A/B16/grp", file_id, "/A/B17/grp", create_id, access_id); + CHECK(status, FAIL, "H5Lmove"); + + tri_status = H5Lexists(file_id, "/A/B17/grp", access_id); + VERIFY(tri_status, TRUE, "H5Lexists"); + + tri_status = H5Lexists(file_id, "/A/B16/grp", access_id); + VERIFY(tri_status, FALSE, "H5Lexists"); + + /********************************************************************** + * test H5Lcreate_hard() + **********************************************************************/ + + status = H5Lcreate_hard(file_id, "/A/B01/grp", file_id, "/A/B18/grp", create_id, access_id); + CHECK(status, FAIL, "H5Lcreate_hard"); + + tri_status = H5Lexists(file_id, "/A/B18/grp", access_id); + VERIFY(tri_status, TRUE, "H5Lexists"); + + /********************************************************************** + * test H5Lcreate_soft() + **********************************************************************/ + + status = H5Lcreate_soft("/A/B01/grp", file_id, "/A/B19/grp", create_id, access_id); + CHECK(status, FAIL, "H5Lcreate_soft"); + + tri_status = H5Lexists(file_id, "/A/B19/grp", access_id); + VERIFY(tri_status, TRUE, "H5Lexists"); + + /********************************************************************** + * test H5Lcreate_external() + **********************************************************************/ + + status = H5Lcreate_external("fake_filename", "fake_path", file_id, "/A/B20/grp", create_id, access_id); + CHECK(status, FAIL, "H5Lcreate_external"); + + tri_status = H5Lexists(file_id, "/A/B20/grp", access_id); + VERIFY(tri_status, TRUE, "H5Lexists"); + + /********************************************************************** + * test H5Lcreate_ud() + **********************************************************************/ + + status = H5Lcreate_ud(file_id, "/A/B21/grp", H5L_TYPE_EXTERNAL, "file\0obj", (size_t) 9, create_id, access_id); + CHECK(status, FAIL, "H5Lcreate_ud"); + + tri_status = H5Lexists(file_id, "/A/B21/grp", access_id); + VERIFY(tri_status, TRUE, "H5Lexists"); + + /********************************************************************** + * close + **********************************************************************/ + + status = H5Pclose(create_id); + CHECK(status, FAIL, "H5Pclose"); + status = H5Gclose(group_id); CHECK(status, FAIL, "H5Gclose"); diff --git a/test/tskiplist.c b/test/tskiplist.c index 289df0b..7b3dcef 100644 --- a/test/tskiplist.c +++ b/test/tskiplist.c @@ -121,7 +121,7 @@ test_skiplist_create(void) MESSAGE(6, ("Testing Creating & Closing Skip Lists\n")); /* Try creating a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Try closing the skip list */ @@ -151,7 +151,7 @@ test_skiplist_insert(void) MESSAGE(7, ("Testing Insertion Into Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -212,7 +212,7 @@ test_skiplist_insert_many(void) MESSAGE(7, ("Testing Insertion of Many Items Into Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -286,7 +286,7 @@ test_skiplist_remove(void) MESSAGE(7, ("Testing Removal From Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -365,7 +365,7 @@ test_skiplist_remove_many(void) MESSAGE(7, ("Testing Removal of Many Items From Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -465,7 +465,7 @@ test_skiplist_firstnext(void) MESSAGE(7, ("Testing Iterating Over Skip List With First/Next\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -558,7 +558,7 @@ test_skiplist_string(void) MESSAGE(7, ("Testing Skip List With String Keys\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_STR); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -620,7 +620,7 @@ test_skiplist_iterate(void) MESSAGE(7, ("Testing Iterating Over Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -670,7 +670,7 @@ test_skiplist_hsize(void) MESSAGE(7, ("Testing Skip List With hsize_t Keys\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_HSIZE, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_HSIZE); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -725,7 +725,7 @@ test_skiplist_unsigned(void) MESSAGE(7, ("Testing Skip List With unsigned Keys\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_UNSIGNED); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -778,7 +778,7 @@ test_skiplist_lastprev(void) MESSAGE(7, ("Testing Iterating Over Skip List With Last/Prev\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -846,7 +846,7 @@ test_skiplist_find(void) MESSAGE(7, ("Testing Skip List 'Find' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_UNSIGNED); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -902,7 +902,7 @@ test_skiplist_add(void) MESSAGE(7, ("Testing Skip List 'Add' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_UNSIGNED); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -964,7 +964,7 @@ test_skiplist_destroy(void) MESSAGE(7, ("Testing Skip List 'Destroy' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1000,7 +1000,7 @@ test_skiplist_free(void) MESSAGE(7, ("Testing Skip List 'Free' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_INT); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1056,7 +1056,7 @@ test_skiplist_less(void) MESSAGE(7, ("Testing Skip List 'Less' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_UNSIGNED); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1120,7 +1120,7 @@ test_skiplist_greater(void) MESSAGE(7, ("Testing Skip List 'Greater' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_UNSIGNED); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1182,10 +1182,10 @@ test_skiplist_below(void) herr_t ret; /* Generic return value */ /* Output message about test being performed */ - MESSAGE(7, ("Testing Skip List 'Less' Operation\n")); + MESSAGE(7, ("Testing Skip List 'Below' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_UNSIGNED); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1261,10 +1261,10 @@ test_skiplist_above(void) herr_t ret; /* Generic return value */ /* Output message about test being performed */ - MESSAGE(7, ("Testing Skip List 'Greater' Operation\n")); + MESSAGE(7, ("Testing Skip List 'Above' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_UNSIGNED); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1338,10 +1338,10 @@ test_skiplist_remove_first(void) herr_t ret; /* Generic return value */ /* Output message about test being performed */ - MESSAGE(7, ("Testing Skip List 'Greater' Operation\n")); + MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED, 0.5, (size_t)16); + slist = H5SL_create(H5SL_TYPE_UNSIGNED); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1368,6 +1368,51 @@ test_skiplist_remove_first(void) /**************************************************************** ** +** test_skiplist_remote_first_many(): Test H5SL (skip list) code. +** Tests 'remove first' operation in large skip lists. +** +****************************************************************/ +static void +test_skiplist_remove_first_many(void) +{ + H5SL_t *slist; /* Skip list created */ + size_t u; /* Local index variable */ + int *found_item; /* Item found in skip list */ + int prev_item = INT_MIN; /* Previously found item in skip list */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n")); + + /* Create a skip list */ + slist = H5SL_create(H5SL_TYPE_INT); + CHECK(slist, NULL, "H5SL_create"); + + /* Insert objects into the skip list */ + for(u = 0; u < NUM_ELEMS; u++) { + ret = H5SL_insert(slist, &rand_num[u], &rand_num[u]); + CHECK(ret, FAIL, "H5SL_insert"); + } /* end for */ + + /* Remove objects from the skip list */ + for(u = 0; u < NUM_ELEMS; u++) { + found_item = (int *)H5SL_remove_first(slist); + VERIFY(*found_item > prev_item, TRUE, "H5SL_remove_first"); + prev_item = *found_item; + } /* end for */ + + /* Check for removing object from empty list */ + found_item = (int *)H5SL_remove_first(slist); + VERIFY(found_item, NULL, "H5SL_remove_first"); + + /* Close the skip list */ + ret = H5SL_close(slist); + CHECK(ret, FAIL, "H5SL_close"); + +} /* end test_skiplist_remove_first() */ + +/**************************************************************** +** ** test_skiplist(): Main H5SL testing routine. ** ****************************************************************/ @@ -1401,6 +1446,7 @@ test_skiplist(void) test_skiplist_below(); /* Test 'below' operation */ test_skiplist_above(); /* Test 'above' operation */ test_skiplist_remove_first(); /* Test 'remove first' operation */ + test_skiplist_remove_first_many(); /* Test 'remove first' operation on large skip lists */ } /* end test_skiplist() */ diff --git a/test/vfd.c b/test/vfd.c index 310b931..c1de28d 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -28,6 +28,7 @@ #define FAMILY_SIZE2 (5*KB) #define MULTI_SIZE 128 #define CORE_INCREMENT (4*KB) +#define FILE_COPY_BUF_SIZE 4096 /*Macros for Direct VFD*/ #define MBOUNDARY 512 @@ -44,6 +45,7 @@ const char *FILENAME[] = { "sec2_file", "core_file", "family_file", + "new_family_v16_", "multi_file", "direct_file", NULL @@ -173,7 +175,7 @@ test_direct(void) fapl = h5_fileaccess(); if(H5Pset_fapl_direct(fapl, MBOUNDARY, FBSIZE, CBSIZE) < 0) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof filename); + h5_fixname(FILENAME[5], fapl, filename, sizeof filename); /* Verify the file access properties */ if(H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0) @@ -802,9 +804,17 @@ static herr_t test_family_compat(void) { hid_t file = (-1), fapl; + hid_t dset; + char dname[]="dataset"; char filename[1024]; - char pathname[1024]; + char pathname[1024], pathname_individual[1024]; + char newname[1024], newname_individual[1024]; char *srcdir = getenv("srcdir"); /*where the src code is located*/ + FILE *tmp_fp, *old_fp; /* Pointers to temp & old files */ + void *copy_buf; /* Pointer to buffer for copying data */ + size_t written; /* Amount of data written to new file */ + size_t read_in; /* Amount of data read in from old file */ + int counter = 0; TESTING("FAMILY file driver backward compatibility"); @@ -815,6 +825,7 @@ test_family_compat(void) TEST_ERROR; h5_fixname(COMPAT_BASENAME, fapl, filename, sizeof filename); + h5_fixname(FILENAME[3], fapl, newname, sizeof newname); pathname[0] = '\0'; /* Generate correct name for test file by prepending the source path */ @@ -824,15 +835,68 @@ test_family_compat(void) } HDstrcat(pathname, filename); - if((file = H5Fopen(pathname, H5F_ACC_RDONLY, fapl)) < 0) + /* The following code makes the copies of the family files in the source directory. + * Since we're going to open the files with write mode, this protects the original + * files. + */ + if(NULL == (copy_buf = HDmalloc((size_t)FILE_COPY_BUF_SIZE))) TEST_ERROR + + sprintf(newname_individual, newname, counter); + sprintf(pathname_individual, pathname, counter); + + /* Open the original files until no more left. Copy the content into the new files. */ + while((old_fp = HDfopen(pathname_individual,"rb"))) { + /* Open the new file */ + if(NULL == (tmp_fp = fopen(newname_individual,"wb"))) TEST_ERROR + + /* Copy data from the old file to the new file */ + while((read_in = HDfread(copy_buf, (size_t)1, (size_t)FILE_COPY_BUF_SIZE, old_fp)) > 0) + /* Write the data to the new file */ + if(read_in != (written = HDfwrite(copy_buf, (size_t)1, read_in, tmp_fp))) TEST_ERROR + + /* Close the old file */ + if(HDfclose(old_fp)) TEST_ERROR + + /* Close the new file */ + if(HDfclose(tmp_fp)) TEST_ERROR + + counter++; + sprintf(newname_individual, newname, counter); + sprintf(pathname_individual, pathname, counter); + } + + /* Free the copy buffer */ + free(copy_buf); + + /* Make sure we can open the file. Use the read and write mode to flush the + * superblock. */ + if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR; + + if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; - if(H5Pclose(fapl) < 0) + /* Open the file again to make sure it isn't corrupted. */ + if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR; + + if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dset) < 0) + TEST_ERROR; + + if(H5Fclose(file) < 0) TEST_ERROR; + h5_cleanup(FILENAME, fapl); + PASSED(); return 0; @@ -840,6 +904,7 @@ test_family_compat(void) error: H5E_BEGIN_TRY { H5Fclose(file); + H5Pclose(fapl); } H5E_END_TRY; return -1; @@ -956,7 +1021,7 @@ test_multi(void) if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) TEST_ERROR; - h5_fixname(FILENAME[3], fapl, filename, sizeof filename); + h5_fixname(FILENAME[4], fapl, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; diff --git a/testpar/Makefile.in b/testpar/Makefile.in index 9a275df..abfdf19 100644 --- a/testpar/Makefile.in +++ b/testpar/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -402,8 +402,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -508,7 +508,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/testpar/t_cache.c b/testpar/t_cache.c index ed3110a..0b94170 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -334,6 +334,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = (H5C_flush_func_t)flush_datum, (H5C_dest_func_t)destroy_datum, (H5C_clear_func_t)clear_datum, + (H5C_notify_func_t)NULL, (H5C_size_func_t)size_datum } }; @@ -2223,7 +2224,7 @@ expunge_entry(H5C_t * cache_ptr, HDassert( ! ((entry_ptr->header).is_dirty) ); result = H5C_get_entry_status(cache_ptr, entry_ptr->base_addr, - NULL, &in_cache, NULL, NULL, NULL); + NULL, &in_cache, NULL, NULL, NULL, NULL, NULL); if ( result < 0 ) { diff --git a/testpar/t_chunk_alloc.c b/testpar/t_chunk_alloc.c index a0cf0e2..4c581f6 100644 --- a/testpar/t_chunk_alloc.c +++ b/testpar/t_chunk_alloc.c @@ -24,9 +24,9 @@ #include "testphdf5.h" static int mpi_size, mpi_rank; -#define DATASETNAME "ExtendibleArray" -#define CHUNKSIZE 1000 /* #elements per chunk */ -#define DSETCHUNKS 20000 +#define DSET_NAME "ExtendibleArray" +#define CHUNK_SIZE 1000 /* #elements per chunk */ +#define CHUNK_FACTOR 200 /* default dataset size in terms of chunks */ #define CLOSE 1 #define NO_CLOSE 0 @@ -78,12 +78,12 @@ typedef enum access_ { /* - * This creates a dataset serially with 'nchunks' chunks, each of CHUNKSIZE + * This creates a dataset serially with chunks, each of CHUNK_SIZE * elements. The allocation time is set to H5D_ALLOC_TIME_EARLY. Another * routine will open this in parallel for extension test. */ static void -create_chunked_dataset(const char *filename, int nchunks, write_type write_pattern) +create_chunked_dataset(const char *filename, int chunk_factor, write_type write_pattern) { hid_t file_id, dataset; /* handles */ hid_t dataspace,memspace; @@ -91,14 +91,14 @@ create_chunked_dataset(const char *filename, int nchunks, write_type write_patte hsize_t dims[1]; hsize_t maxdims[1] = {H5S_UNLIMITED}; - hsize_t chunk_dims[1] ={CHUNKSIZE}; + hsize_t chunk_dims[1] ={CHUNK_SIZE}; hsize_t count[1]; hsize_t stride[1]; hsize_t block[1]; hsize_t offset[1]; /* Selection offset within dataspace */ /* Variables used in reading data back */ - char buffer[CHUNKSIZE]; - + char buffer[CHUNK_SIZE]; + long nchunks; herr_t hrc; MPI_Offset filesize, /* actual file size */ @@ -110,8 +110,8 @@ create_chunked_dataset(const char *filename, int nchunks, write_type write_patte /* Only MAINPROCESS should create the file. Others just wait. */ if (MAINPROCESS){ - - dims[0]=nchunks*CHUNKSIZE; + nchunks=chunk_factor*mpi_size; + dims[0]=nchunks*CHUNK_SIZE; /* Create the data space with unlimited dimensions. */ dataspace = H5Screate_simple (1, dims, maxdims); VRFY((dataspace >= 0), ""); @@ -135,11 +135,11 @@ create_chunked_dataset(const char *filename, int nchunks, write_type write_patte VRFY((hrc >= 0), ""); /* Create a new dataset within the file using cparms creation properties. */ - dataset = H5Dcreate2(file_id, DATASETNAME, H5T_NATIVE_UCHAR, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT); + dataset = H5Dcreate2(file_id, DSET_NAME, H5T_NATIVE_UCHAR, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT); VRFY((dataset >= 0), ""); if(write_pattern == sec_last) { - HDmemset(buffer, 100, CHUNKSIZE); + HDmemset(buffer, 100, CHUNK_SIZE); count[0] = 1; stride[0] = 1; @@ -174,7 +174,7 @@ create_chunked_dataset(const char *filename, int nchunks, write_type write_patte /* verify file size */ filesize = get_filesize(filename); - est_filesize = nchunks * CHUNKSIZE * sizeof(unsigned char); + est_filesize = nchunks * CHUNK_SIZE * sizeof(unsigned char); VRFY((filesize >= est_filesize), "file size check"); } @@ -190,12 +190,12 @@ create_chunked_dataset(const char *filename, int nchunks, write_type write_patte /* * This program performs three different types of parallel access. It writes on - * the entire dataset, it extends the dataset to nchunks*CHUNKSIZE, and it only + * the entire dataset, it extends the dataset to nchunks*CHUNK_SIZE, and it only * opens the dataset. At the end, it verifies the size of the dataset to be - * consistent with argument 'nchunks'. + * consistent with argument 'chunk_factor'. */ static void -parallel_access_dataset(const char *filename, int nchunks, access_type action, hid_t *file_id, hid_t *dataset) +parallel_access_dataset(const char *filename, int chunk_factor, access_type action, hid_t *file_id, hid_t *dataset) { /* HDF5 gubbins */ hid_t memspace, dataspace; /* HDF5 file identifier */ @@ -203,15 +203,18 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h herr_t hrc; /* HDF5 return code */ hsize_t size[1]; - hsize_t chunk_dims[1] ={CHUNKSIZE}; + hsize_t chunk_dims[1] ={CHUNK_SIZE}; hsize_t count[1]; hsize_t stride[1]; hsize_t block[1]; hsize_t offset[1]; /* Selection offset within dataspace */ + hsize_t dims[1]; + hsize_t maxdims[1]; + /* Variables used in reading data back */ - char buffer[CHUNKSIZE]; + char buffer[CHUNK_SIZE]; int i; - + long nchunks; /* MPI Gubbins */ MPI_Offset filesize, /* actual file size */ est_filesize; /* estimated file size */ @@ -220,6 +223,8 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + nchunks=chunk_factor*mpi_size; + /* Set up MPIO file access property lists */ access_plist = H5Pcreate(H5P_FILE_ACCESS); VRFY((access_plist >= 0), ""); @@ -235,7 +240,7 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h /* Open dataset*/ if (*dataset<0){ - *dataset = H5Dopen2(*file_id, DATASETNAME, H5P_DEFAULT); + *dataset = H5Dopen2(*file_id, DSET_NAME, H5P_DEFAULT); VRFY((*dataset >= 0), ""); } @@ -245,19 +250,18 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h dataspace = H5Dget_space(*dataset); VRFY((dataspace >= 0), ""); - size[0] = nchunks*CHUNKSIZE; + size[0] = nchunks*CHUNK_SIZE; switch (action) { /* all chunks are written by all the processes in an interleaved way*/ case write_all: - memset(buffer, mpi_rank+1, CHUNKSIZE); + memset(buffer, mpi_rank+1, CHUNK_SIZE); count[0] = 1; stride[0] = 1; block[0] = chunk_dims[0]; - for (i=0; i<(nchunks+mpi_size-1)/mpi_size; i++){ - if (i*mpi_size+mpi_rank < nchunks){ + for (i=0; i= 0), "H5Dwrite"); - } - } break; /* only extends the dataset */ case extend_only: - /* Extend dataset*/ - hrc = H5Dset_extent(*dataset, size); + /* check if new size is larger than old size */ + hrc = H5Sget_simple_extent_dims(dataspace, dims, maxdims); VRFY((hrc >= 0), ""); + /* Extend dataset*/ + if (size[0] > dims[0]) { + hrc = H5Dset_extent(*dataset, size); + VRFY((hrc >= 0), ""); + } break; - /* only opens the dataset */ + /* only opens the *dataset */ case open_only: break; @@ -292,10 +299,10 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h *dataset = -1; hrc = H5Sclose (dataspace); - VRFY((hrc >= 0), ""); + VRFY((hrc >= 0), ""); - hrc = H5Sclose (memspace); - VRFY((hrc >= 0), ""); + hrc = H5Sclose (memspace); + VRFY((hrc >= 0), ""); hrc = H5Fclose(*file_id); VRFY((hrc >= 0), ""); @@ -303,7 +310,7 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h /* verify file size */ filesize = get_filesize(filename); - est_filesize = nchunks*CHUNKSIZE*sizeof(unsigned char); + est_filesize = nchunks*CHUNK_SIZE*sizeof(unsigned char); VRFY((filesize >= est_filesize), "file size check"); /* Can close some plists */ @@ -326,27 +333,29 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h * interleaved pattern. */ static void -verify_data(const char *filename, int nchunks, write_type write_pattern, int close, hid_t *file_id, hid_t *dataset) +verify_data(const char *filename, int chunk_factor, write_type write_pattern, int close, hid_t *file_id, hid_t *dataset) { /* HDF5 gubbins */ hid_t dataspace, memspace; /* HDF5 file identifier */ hid_t access_plist; /* HDF5 ID for file access property list */ herr_t hrc; /* HDF5 return code */ - hsize_t chunk_dims[1] ={CHUNKSIZE}; + hsize_t chunk_dims[1] ={CHUNK_SIZE}; hsize_t count[1]; hsize_t stride[1]; hsize_t block[1]; hsize_t offset[1]; /* Selection offset within dataspace */ /* Variables used in reading data back */ - char buffer[CHUNKSIZE]; + char buffer[CHUNK_SIZE]; int value, i; int index; - + long nchunks; /* Initialize MPI */ MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + nchunks=chunk_factor*mpi_size; + /* Set up MPIO file access property lists */ access_plist = H5Pcreate(H5P_FILE_ACCESS); VRFY((access_plist >= 0), ""); @@ -362,7 +371,7 @@ verify_data(const char *filename, int nchunks, write_type write_pattern, int clo /* Open dataset*/ if (*dataset<0){ - *dataset = H5Dopen2(*file_id, DATASETNAME, H5P_DEFAULT); + *dataset = H5Dopen2(*file_id, DSET_NAME, H5P_DEFAULT); VRFY((*dataset >= 0), ""); } @@ -378,7 +387,7 @@ verify_data(const char *filename, int nchunks, write_type write_pattern, int clo block[0] = chunk_dims[0]; for (i=0; i\tfilename prefix\n"); printf("\t-2\t\tuse Split-file together with MPIO\n"); printf("\t-p\t\tuse combo MPI-POSIX driver\n"); - printf("\t-d \tdataset dimensions. Defaults (%d,%d)\n", - DIM0, DIM1); + printf("\t-d \tdataset dimensions factors. Defaults (%d,%d)\n", + ROW_FACTOR, COL_FACTOR); printf("\t-c \tdataset chunk dimensions. Defaults (dim0/10,dim1/10)\n"); printf("\n"); } @@ -138,6 +138,7 @@ parse_options(int argc, char **argv) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); /* setup default chunk-size. Make sure sizes are > 0 */ + chunkdim0 = (dim0+9)/10; chunkdim1 = (dim1+9)/10; @@ -184,9 +185,9 @@ parse_options(int argc, char **argv) nerrors++; return(1); } - dim0 = atoi(*(++argv)); + dim0 = atoi(*(++argv))*mpi_size; argc--; - dim1 = atoi(*(++argv)); + dim1 = atoi(*(++argv))*mpi_size; /* set default chunkdim sizes too */ chunkdim0 = (dim0+9)/10; chunkdim1 = (dim1+9)/10; @@ -325,6 +326,9 @@ int main(int argc, char **argv) MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + dim0 = ROW_FACTOR*mpi_size; + dim1 = COL_FACTOR*mpi_size; + if (MAINPROCESS){ printf("===================================\n"); printf("PHDF5 TESTS START\n"); @@ -367,7 +371,6 @@ int main(int argc, char **argv) "extendible dataset independent write #2", PARATESTFILE); AddTest("selnone", none_selection_chunk, NULL, "chunked dataset with none-selection", PARATESTFILE); - AddTest("calloc", test_chunk_alloc, NULL, "parallel extend Chunked allocation on serial file", PARATESTFILE); AddTest("fltread", test_filter_read, NULL, diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h index 81ad0f5..24c4432 100644 --- a/testpar/testphdf5.h +++ b/testpar/testphdf5.h @@ -36,6 +36,8 @@ enum H5TEST_COLL_CHUNK_API {API_NONE=0,API_LINK_HARD, /* Constants definitions */ #define DIM0 600 /* Default dataset sizes. */ #define DIM1 1200 /* Values are from a monitor pixel sizes */ +#define ROW_FACTOR 8 /* Nominal row factor for dataset size */ +#define COL_FACTOR 16 /* Nominal column factor for dataset size */ #define RANK 2 #define DATASETNAME1 "Data1" #define DATASETNAME2 "Data2" diff --git a/tools/Makefile.in b/tools/Makefile.in index 5dc816f..113e752 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -350,8 +350,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -457,7 +457,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/h5copy/Makefile.in b/tools/h5copy/Makefile.in index 3ea702b..958b30f 100644 --- a/tools/h5copy/Makefile.in +++ b/tools/h5copy/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -382,8 +382,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -490,7 +490,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in index bf70681..b83d6ef 100644 --- a/tools/h5diff/Makefile.in +++ b/tools/h5diff/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -398,8 +398,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -511,7 +511,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 181e242..b07c425 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -1,34 +1,36 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include #include "hdf5.h" #include "H5private.h" +#include "h5tools.h" + /*------------------------------------------------------------------------- - * Program: h5diffgentest - * - * Purpose: generate files for h5diff testing - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 12, 2003 - * - *------------------------------------------------------------------------- - */ +* Program: h5diffgentest +* +* Purpose: generate files for h5diff testing +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 12, 2003 +* +*------------------------------------------------------------------------- +*/ #define FILE1 "h5diff_basic1.h5" #define FILE2 "h5diff_basic2.h5" @@ -49,27 +51,27 @@ #define MY_LINKCLASS 187 /* A UD link traversal function. Shouldn't actually be called. */ static hid_t UD_traverse(UNUSED const char * link_name, UNUSED hid_t cur_group, - UNUSED const void * udata, UNUSED size_t udata_size, UNUSED hid_t lapl_id) + UNUSED const void * udata, UNUSED size_t udata_size, UNUSED hid_t lapl_id) { -return -1; + return -1; } const H5L_class_t UD_link_class[1] = {{ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)MY_LINKCLASS, /* Link type id number */ - "UD link class", /* name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ + (H5L_type_t)MY_LINKCLASS, /* Link type id number */ + "UD link class", /* name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ }}; /*------------------------------------------------------------------------- - * prototypes - *------------------------------------------------------------------------- - */ +* prototypes +*------------------------------------------------------------------------- +*/ /* tests called in main() */ static int test_basic(const char *fname1, const char *fname2, const char *fname3); @@ -88,43 +90,43 @@ static int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *name,hid_t /*------------------------------------------------------------------------- - * Function: main - * - * Purpose: main program - * - *------------------------------------------------------------------------- - */ +* Function: main +* +* Purpose: main program +* +*------------------------------------------------------------------------- +*/ int main(void) { test_basic(FILE1, FILE2, FILE11); - + test_types (FILE3); test_datatypes(FILE4); - + /* generate 2 files, the second call creates a similar file with differences */ test_attributes(FILE5,0); test_attributes(FILE6,1); - + /* generate 2 files, the second call creates a similar file with differences */ test_datasets(FILE7,0); test_datasets(FILE8,1); - + /* generate 2 files, the second call creates a similar file with differences */ test_hyperslab(FILE9,0); test_hyperslab(FILE10,1); return 0; - + } /*------------------------------------------------------------------------- - * Function: test_basic - * - * Purpose: Create basic test files, first two contains different data, the - * third one is just an empty file. - * - *------------------------------------------------------------------------- - */ +* Function: test_basic +* +* Purpose: Create basic test files, first two contains different data, the +* third one is just an empty file. +* +*------------------------------------------------------------------------- +*/ static int test_basic(const char *fname1, const char *fname2, const char *fname3) @@ -133,7 +135,7 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) hid_t gid1, gid2, gid3; hsize_t dims1[1] = { 6 }; hsize_t dims2[2] = { 3,2 }; - + /* create the empty file */ if ((fid1=H5Fcreate(fname3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0){ fprintf(stderr, "empty file (%s) creation failed.\n", fname3); @@ -143,26 +145,26 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) fprintf(stderr, "empty file (%s) close failed.\n", fname3); goto out; } - + /*------------------------------------------------------------------------- * create two files *------------------------------------------------------------------------- */ - + if (( fid1 = H5Fcreate (fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) goto out; if (( fid2 = H5Fcreate (fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) goto out; - - /*------------------------------------------------------------------------- - * create groups - *------------------------------------------------------------------------- + + /*------------------------------------------------------------------------- + * create groups + *------------------------------------------------------------------------- */ - + gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid2 = H5Gcreate2(fid2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid3 = H5Gcreate2(fid2, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - + /*------------------------------------------------------------------------- * tests: * # 1.1 normal mode @@ -172,19 +174,19 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) * # 1.5 with -d *------------------------------------------------------------------------- */ - + { double data1[3][2] = {{1,1}, {1,1}, {0,0}}; double data2[3][2] = {{0,1.1},{1.01,1.001},{0,1}}; double data3[3][2] = {{100,100},{100,100},{100,100}}; double data4[3][2] = {{105,120},{160,95},{80,40}}; - + write_dset(gid1,2,dims2,"dset1",H5T_NATIVE_DOUBLE,data1); write_dset(gid2,2,dims2,"dset2",H5T_NATIVE_DOUBLE,data2); write_dset(gid1,2,dims2,"dset3",H5T_NATIVE_DOUBLE,data3); write_dset(gid2,2,dims2,"dset4",H5T_NATIVE_DOUBLE,data4); write_dset(gid2,2,dims2,"dset1",H5T_NATIVE_DOUBLE,data2); - + } /*------------------------------------------------------------------------- * relative error, compare divide by zero, both zero @@ -194,12 +196,12 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) { int data5[3][2] = {{100,100},{100,0},{0,100}}; int data6[3][2] = {{120,80}, {0,100},{0,50}}; - + write_dset(gid1,2,dims2,"dset5",H5T_NATIVE_INT,data5); write_dset(gid1,2,dims2,"dset6",H5T_NATIVE_INT,data6); - + } - + /*------------------------------------------------------------------------- * relative error, compare divide by zero, both zero * # 1.6.2 with -p (unsigned long long) @@ -208,12 +210,12 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) { unsigned long long data7[3][2] = {{100,100},{100,0},{0,100}}; unsigned long long data8[3][2] = {{120,80}, {0,100},{0,50}}; - + write_dset(gid1,2,dims2,"dset7",H5T_NATIVE_ULLONG,data7); write_dset(gid1,2,dims2,"dset8",H5T_NATIVE_ULLONG,data8); - + } - + /*------------------------------------------------------------------------- * relative error, compare divide by zero, both zero * # 1.6.3 with -p (double) @@ -230,13 +232,13 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) { double data9[3][2] = {{100,100},{100,0},{0,100}}; double data10[3][2] ={{120,80}, {0,100},{0,50}}; - + write_dset(gid1,2,dims2,"dset9",H5T_NATIVE_DOUBLE,data9); write_dset(gid1,2,dims2,"dset10",H5T_NATIVE_DOUBLE,data10); - + } - - + + /*------------------------------------------------------------------------- * test floating point comparison *------------------------------------------------------------------------- @@ -247,86 +249,124 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) float data12[3][2] ={{0.00000f,0.00002f},{0.000009f,0.00001f},{0.00000f,0.00001f}}; double data13[3][2] ={{0.000000000,0.000000001},{0.000000001, 0.000000000},{0.000000001,0.000000001}}; double data14[3][2] ={{0.000000000,0.000000002},{0.0000000009,0.000000001},{0.000000000,0.000000001}}; - + write_dset(gid1,2,dims2,"fp1",H5T_NATIVE_FLOAT,data11); write_dset(gid1,2,dims2,"fp2",H5T_NATIVE_FLOAT,data12); write_dset(gid1,2,dims2,"d1",H5T_NATIVE_DOUBLE,data13); write_dset(gid1,2,dims2,"d2",H5T_NATIVE_DOUBLE,data14); - + } - - + + #if H5_SIZEOF_LONG_DOUBLE !=0 { - - /*------------------------------------------------------------------------- - * H5T_NATIVE_LDOUBLE - *------------------------------------------------------------------------- + + /*------------------------------------------------------------------------- + * H5T_NATIVE_LDOUBLE + *------------------------------------------------------------------------- */ - + long double data15[3][2] ={{1,1},{1,1},{1,1}}; - + write_dset(gid1,2,dims2,"ld",H5T_NATIVE_LDOUBLE,data15); - + } #endif - - - + + + /*------------------------------------------------------------------------- * NaNs in H5T_NATIVE_FLOAT *------------------------------------------------------------------------- */ { - + float data15[6]; float data16[6]; - + data15[0] = (float) sqrt( (double)-1 ); data15[1] = 1; data15[2] = (float) sqrt( (double)-1 ); data15[3] = 1; data15[4] = 1; data15[5] = 1; - + data16[0] = (float) sqrt( (double)-1 ); data16[1] = (float) sqrt( (double)-1 ); data16[2] = 1; data16[3] = 1; data16[4] = 1; data16[5] = 1; - + write_dset(gid1,1,dims1,"fp15",H5T_NATIVE_FLOAT,data15); write_dset(gid1,1,dims1,"fp16",H5T_NATIVE_FLOAT,data16); - + } - + /*------------------------------------------------------------------------- * NaNs in H5T_NATIVE_DOUBLE *------------------------------------------------------------------------- */ { - + double data17[6]; double data18[6]; - + data17[0] = sqrt( (double)-1 ); data17[1] = 1; data17[2] = sqrt( (double)-1 ); data17[3] = 1; data17[4] = 1; data17[5] = 1; - + data18[0] = (float) sqrt( (double)-1 ); data18[1] = (float) sqrt( (double)-1 ); data18[2] = 1; data18[3] = 1; data18[4] = 1; data18[5] = 1; - + write_dset(gid1,1,dims1,"fp17",H5T_NATIVE_DOUBLE,data17); write_dset(gid1,1,dims1,"fp18",H5T_NATIVE_DOUBLE,data18); - + + } + + /*------------------------------------------------------------------------- + * NaNs in H5T_NATIVE_DOUBLE and H5T_NATIVE_FLOAT inside H5T_COMPOUND + *------------------------------------------------------------------------- + */ + { + typedef struct cmp1_t + { + double d; + float f; + } cmp1_t; + + cmp1_t buf1[2]; + cmp1_t buf2[2]; + hsize_t dims[1] = {2}; + size_t type_size; + hid_t tid; + + buf1[0].d = sqrt( (double)-1 ); + buf1[0].f = (float) sqrt( (double)-1 ); + buf2[0].d = sqrt( (double)-1 ); + buf2[0].f = (float) sqrt( (double)-1 ); + + buf1[1].d = sqrt( (double)-1 ); + buf1[1].f = (float) sqrt( (double)-1 ); + buf2[1].d = 0; + buf2[1].f = 0; + + type_size = sizeof( cmp1_t ); + tid = H5Tcreate (H5T_COMPOUND, type_size ); + H5Tinsert(tid, "d", HOFFSET( cmp1_t, d ), H5T_NATIVE_DOUBLE ); + H5Tinsert(tid, "f", HOFFSET( cmp1_t, f ), H5T_NATIVE_FLOAT ); + write_dset(gid1,1,dims,"dset11",tid,buf1); + write_dset(gid1,1,dims,"dset12",tid,buf2); + H5Tclose(tid); + + } /* not comparable objects */ @@ -334,19 +374,19 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) typedef struct cmp1_t { - double d; - int i; + double d; + int i; } cmp1_t; typedef struct cmp2_t { - int i; - double d; + int i; + double d; } cmp2_t; typedef struct cmp3_t { - int i; + int i; } cmp3_t; double data2[6] = {0,0,0,0,0,0}; @@ -361,7 +401,7 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) size_t type_size; hid_t tid; - + write_dset(gid3,1,dims1,"dset1",H5T_NATIVE_DOUBLE,NULL); write_dset(gid3,1,dims1,"dset2",H5T_NATIVE_DOUBLE,data2); @@ -391,10 +431,10 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) H5Tinsert(tid, "i", HOFFSET( cmp2_t, i ), H5T_NATIVE_INT ); write_dset(gid3,1,dims4,"dset9",tid,NULL); H5Tclose(tid); - + } - - + + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- @@ -405,21 +445,21 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) H5Fclose(fid1); H5Fclose(fid2); return SUCCEED; - + out: - + return FAIL; } /*------------------------------------------------------------------------- - * Function: test_types - * - * Purpose: Compare different HDF5 object & link types: - * H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK, H5G_UDLINK - * - *------------------------------------------------------------------------- - */ +* Function: test_types +* +* Purpose: Compare different HDF5 object & link types: +* H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK, H5G_UDLINK +* +*------------------------------------------------------------------------- +*/ static int test_types(const char *fname) { @@ -439,19 +479,19 @@ int test_types(const char *fname) { int a; } s2_t; - + /*------------------------------------------------------------------------- * Create one file *------------------------------------------------------------------------- */ fid1 = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - + /*------------------------------------------------------------------------- * H5G_DATASET *------------------------------------------------------------------------- */ write_dset(fid1,1,dims,"dset",H5T_NATIVE_INT,0); - + /*------------------------------------------------------------------------- * H5G_GROUP *------------------------------------------------------------------------- @@ -460,12 +500,12 @@ int test_types(const char *fname) status = H5Gclose(gid1); gid2 = H5Gcreate2(fid1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Gclose(gid2); - + /*------------------------------------------------------------------------- * H5G_TYPE *------------------------------------------------------------------------- */ - + /* create and commit datatype 1 */ tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_INT); @@ -477,15 +517,15 @@ int test_types(const char *fname) H5Tinsert(tid2, "a", HOFFSET(s2_t, a), H5T_NATIVE_INT); H5Tcommit2(fid1, "t2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Tclose(tid2); - + /*------------------------------------------------------------------------- * H5G_LINK *------------------------------------------------------------------------- */ - + status = H5Lcreate_soft("g1", fid1, "l1", H5P_DEFAULT, H5P_DEFAULT); status = H5Lcreate_soft("g2", fid1, "l2", H5P_DEFAULT, H5P_DEFAULT); - + /*------------------------------------------------------------------------- * H5G_UDLINK *------------------------------------------------------------------------- @@ -493,7 +533,7 @@ int test_types(const char *fname) H5Lcreate_external("filename", "objname", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT); H5Lregister(UD_link_class); H5Lcreate_ud(fid1, "ud_link", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); - + /*------------------------------------------------------------------------- * Close *------------------------------------------------------------------------- @@ -542,16 +582,16 @@ TOOLTEST h5diff_28.txt file3.h5 file3.h5 -v l1 l2 */ /*------------------------------------------------------------------------- - * Function: test_datatypes - * - * Purpose: test dataset datatypes - * - *------------------------------------------------------------------------- - */ +* Function: test_datatypes +* +* Purpose: test dataset datatypes +* +*------------------------------------------------------------------------- +*/ static int test_datatypes(const char *fname) { - + hid_t fid1; hsize_t dims[2]={3,2}; herr_t status; @@ -567,114 +607,114 @@ int test_datatypes(const char *fname) float buf5b[3][2] = {{1,1},{3,4},{5,6}}; double buf6a[3][2] = {{1,1},{1,1},{1,1}}; double buf6b[3][2] = {{1,1},{3,4},{5,6}}; - + /*unsigned/signed test signed char -128 to 127 unsigned char 0 to 255 */ char buf7a[3][2] = {{-1,-128},{-1,-1},{-1,-1}}; unsigned char buf7b[3][2] = {{1,128},{1,1},{1,1}}; - + /* long long test */ long long buf8a[3][2] = {{1,1},{1,1},{1,1}}; long long buf8b[3][2] = {{1,1},{3,4},{5,6}}; unsigned long long buf9a[3][2] = {{1,1},{1,1},{1,1}}; unsigned long long buf9b[3][2] = {{1,1},{3,4},{5,6}}; - + unsigned int buf10a[3][2] = {{UIMAX,1},{1,1},{1,1}}; unsigned int buf10b[3][2] = {{UIMAX-1,1},{3,4},{5,6}}; - - + + /*------------------------------------------------------------------------- * Create a file *------------------------------------------------------------------------- */ fid1 = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - + /*------------------------------------------------------------------------- * Check for different storage order. Give a warning if they are different *------------------------------------------------------------------------- */ - + write_dset(fid1,2,dims,"dset0a",H5T_STD_I16LE,buf2a); write_dset(fid1,2,dims,"dset0b",H5T_STD_I32LE,buf3b); - + /*------------------------------------------------------------------------- - * Check H5T_NATIVE_CHAR + * H5T_NATIVE_CHAR *------------------------------------------------------------------------- */ write_dset(fid1,2,dims,"dset1a",H5T_NATIVE_CHAR,buf1a); write_dset(fid1,2,dims,"dset1b",H5T_NATIVE_CHAR,buf1b); - + /*------------------------------------------------------------------------- - * Check H5T_NATIVE_SHORT + * H5T_NATIVE_SHORT *------------------------------------------------------------------------- */ write_dset(fid1,2,dims,"dset2a",H5T_NATIVE_SHORT,buf2a); write_dset(fid1,2,dims,"dset2b",H5T_NATIVE_SHORT,buf2b); - + /*------------------------------------------------------------------------- - * Check H5T_NATIVE_INT + * H5T_NATIVE_INT *------------------------------------------------------------------------- */ write_dset(fid1,2,dims,"dset3a",H5T_NATIVE_INT,buf3a); write_dset(fid1,2,dims,"dset3b",H5T_NATIVE_INT,buf3b); - + /*------------------------------------------------------------------------- - * Check H5T_NATIVE_LONG + * H5T_NATIVE_LONG *------------------------------------------------------------------------- */ write_dset(fid1,2,dims,"dset4a",H5T_NATIVE_LONG,buf4a); write_dset(fid1,2,dims,"dset4b",H5T_NATIVE_LONG,buf4b); - + /*------------------------------------------------------------------------- - * Check H5T_NATIVE_FLOAT + * H5T_NATIVE_FLOAT *------------------------------------------------------------------------- */ write_dset(fid1,2,dims,"dset5a",H5T_NATIVE_FLOAT,buf5a); write_dset(fid1,2,dims,"dset5b",H5T_NATIVE_FLOAT,buf5b); - + /*------------------------------------------------------------------------- - * Check H5T_NATIVE_DOUBLE + * H5T_NATIVE_DOUBLE *------------------------------------------------------------------------- */ - + write_dset(fid1,2,dims,"dset6a",H5T_NATIVE_DOUBLE,buf6a); write_dset(fid1,2,dims,"dset6b",H5T_NATIVE_DOUBLE,buf6b); - + /*------------------------------------------------------------------------- * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR *------------------------------------------------------------------------- */ - + write_dset(fid1,2,dims,"dset7a",H5T_NATIVE_CHAR,buf7a); write_dset(fid1,2,dims,"dset7b",H5T_NATIVE_UCHAR,buf7b); - + /*------------------------------------------------------------------------- * H5T_NATIVE_LLONG *------------------------------------------------------------------------- */ - + write_dset(fid1,2,dims,"dset8a",H5T_NATIVE_LLONG,buf8a); write_dset(fid1,2,dims,"dset8b",H5T_NATIVE_LLONG,buf8b); - + /*------------------------------------------------------------------------- * H5T_NATIVE_ULLONG *------------------------------------------------------------------------- */ - + write_dset(fid1,2,dims,"dset9a",H5T_NATIVE_ULLONG,buf9a); write_dset(fid1,2,dims,"dset9b",H5T_NATIVE_ULLONG,buf9b); - + /*------------------------------------------------------------------------- * H5T_NATIVE_INT *------------------------------------------------------------------------- */ - + write_dset(fid1,2,dims,"dset10a",H5T_NATIVE_UINT,buf10a); write_dset(fid1,2,dims,"dset10b",H5T_NATIVE_UINT,buf10b); - - + + /*------------------------------------------------------------------------- * Close *------------------------------------------------------------------------- @@ -717,12 +757,12 @@ TOOLTEST h5diff_58.txt file7.h5 file8.h5 -v refreg */ /*------------------------------------------------------------------------- - * Function: test_attributes - * - * Purpose: test attributes - * - *------------------------------------------------------------------------- - */ +* Function: test_attributes +* +* Purpose: test attributes +* +*------------------------------------------------------------------------- +*/ static int test_attributes(const char *file, int make_diffs /* flag to modify data buffers */) @@ -734,31 +774,31 @@ int test_attributes(const char *file, hid_t sid; hsize_t dims[1]={2}; herr_t status; - + /* Create a file */ if((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - + /* Create a 1D dataset */ sid = H5Screate_simple(1, dims, NULL); did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Sclose(sid); assert(status >= 0); - + /* Create groups */ gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); root_id = H5Gopen2(fid, "/", H5P_DEFAULT); - + /*------------------------------------------------------------------------- * write a series of attributes on the dataset, group, and root group *------------------------------------------------------------------------- */ - + write_attr_in(did,"dset",fid,make_diffs); write_attr_in(gid,NULL,0,make_diffs); write_attr_in(root_id,NULL,0,make_diffs); - - + + /* Close */ status = H5Dclose(did); assert(status >= 0); @@ -766,7 +806,7 @@ int test_attributes(const char *file, assert(status >= 0); status = H5Gclose(root_id); assert(status >= 0); - + /* Close file */ status = H5Fclose(fid); assert(status >= 0); @@ -775,15 +815,15 @@ int test_attributes(const char *file, /*------------------------------------------------------------------------- - * Function: test_datasets - * - * Purpose: Check all HDF5 classes - * H5T_INTEGER, H5T_FLOAT - * H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_COMPOUND, H5T_REFERENCE, - * H5T_ENUM, H5T_VLEN, H5T_ARRAY - * - *------------------------------------------------------------------------- - */ +* Function: test_datasets +* +* Purpose: Check all HDF5 classes +* H5T_INTEGER, H5T_FLOAT +* H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_COMPOUND, H5T_REFERENCE, +* H5T_ENUM, H5T_VLEN, H5T_ARRAY +* +*------------------------------------------------------------------------- +*/ static int test_datasets(const char *file, int make_diffs /* flag to modify data buffers */) @@ -795,37 +835,37 @@ int test_datasets(const char *file, hsize_t dims[1]={2}; herr_t status; int buf[2]={1,2}; - + if(make_diffs) memset(buf, 0, sizeof buf); - + /* Create a file */ if((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - + /* Create a 1D dataset */ sid = H5Screate_simple(1, dims, NULL); did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); status = H5Sclose(sid); assert(status >= 0); - + /* Create a group */ gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - + /*------------------------------------------------------------------------- * write a series of datasets on the group *------------------------------------------------------------------------- */ - + write_dset_in(gid,"/dset",fid,make_diffs); - + /* close */ status = H5Dclose(did); assert(status >= 0); status = H5Gclose(gid); assert(status >= 0); - + /* close file */ status = H5Fclose(fid); assert(status >= 0); @@ -833,12 +873,12 @@ int test_datasets(const char *file, } /*------------------------------------------------------------------------- - * Function: write_attr_in - * - * Purpose: write attributes in LOC_ID (dataset, group, named datatype) - * - *------------------------------------------------------------------------- - */ +* Function: write_attr_in +* +* Purpose: write attributes in LOC_ID (dataset, group, named datatype) +* +*------------------------------------------------------------------------- +*/ static void write_attr_in(hid_t loc_id, const char* dset_name, /* for saving reference to dataset*/ @@ -851,20 +891,20 @@ void write_attr_in(hid_t loc_id, char a; double b; } s_t; - + typedef enum { RED, - GREEN + GREEN } e_t; - + hid_t aid; hid_t sid; hid_t tid; herr_t status; int val, i, j, k, l, n; float f; - + /* create 1D attributes with dimension [2], 2 elements */ hsize_t dims[1]={2}; char buf1[2][STR_SIZE]= {"ab","de"}; /* string */ @@ -878,7 +918,7 @@ void write_attr_in(hid_t loc_id, int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ int buf7[2]= {1,2}; /* integer */ float buf8[2]= {1,2}; /* float */ - + /* create 2D attributes with dimension [3][2], 6 elements */ hsize_t dims2[2]={3,2}; char buf12[3][2][STR_SIZE]= {{"ab","cd"},{"ef","gh"},{"ij","kl"}}; /* string */ @@ -891,7 +931,7 @@ void write_attr_in(hid_t loc_id, int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ - + /* create 3D attributes with dimension [4][3][2], 24 elements */ hsize_t dims3[3]={4,3,2}; char buf13[4][3][2][STR_SIZE]= {{{"ab","cd"},{"ef","gh"},{"ij","kl"}}, @@ -907,18 +947,18 @@ void write_attr_in(hid_t loc_id, int buf63[24][3]; /* array */ int buf73[4][3][2]; /* integer */ float buf83[4][3][2]; /* float */ - - + + /*------------------------------------------------------------------------- * 1D attributes *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -945,19 +985,19 @@ void write_attr_in(hid_t loc_id, status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id,1,dims,"string",tid,buf1); status = H5Tclose(tid); - + for (i=0; i<2; i++) buf1a[i]=buf1[i]; tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id,1,dims,"VLstring",tid,buf1a); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -974,16 +1014,16 @@ void write_attr_in(hid_t loc_id, [ 0 ] 1 0 1 [ 1 ] 2 0 2 */ - + tid = H5Tcopy(H5T_STD_B8LE); write_attr(loc_id,1,dims,"bitfield",tid,buf2); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - + /* buf2[2]= {1,2}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -995,17 +1035,17 @@ void write_attr_in(hid_t loc_id, [ 0 ] 1 0 1 [ 1 ] 2 0 2 */ - + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id,1,dims,"opaque",tid,buf2); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -1013,7 +1053,7 @@ void write_attr_in(hid_t loc_id, buf3[i].a=0; buf3[i].b=0; } } - + /* buf3[2]= {{1,2},{3,4}}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -1026,13 +1066,13 @@ void write_attr_in(hid_t loc_id, [ 1 ] 3 5 2 [ 1 ] 4 5 1 */ - + tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_attr(loc_id,1,dims,"compound",tid,buf3); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_REFERENCE (H5R_OBJECT object reference) *------------------------------------------------------------------------- @@ -1044,7 +1084,7 @@ void write_attr_in(hid_t loc_id, status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,-1); write_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); } - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- @@ -1071,14 +1111,14 @@ void write_attr_in(hid_t loc_id, H5Tenum_insert(tid, "GREEN", (val = 1, &val)); write_attr(loc_id,1,dims,"enum",tid,buf45); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ - + buf5[0].len = 1; buf5[0].p = malloc( 1 * sizeof(int)); ((int *)buf5[0].p)[0]=1; @@ -1086,7 +1126,7 @@ void write_attr_in(hid_t loc_id, buf5[1].p = malloc( 2 * sizeof(int)); ((int *)buf5[1].p)[0]=2; ((int *)buf5[1].p)[1]=3; - + if (make_diffs) { ((int *)buf5[0].p)[0]=0; @@ -1102,7 +1142,7 @@ void write_attr_in(hid_t loc_id, [ 1 ] 2 0 2 [ 1 ] 3 0 3 */ - + sid = H5Screate_simple(1, dims, NULL); tid = H5Tvlen_create(H5T_NATIVE_INT); aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -1113,12 +1153,12 @@ void write_attr_in(hid_t loc_id, status = H5Aclose(aid); status = H5Tclose(tid); status = H5Sclose(sid); - + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -1144,12 +1184,12 @@ void write_attr_in(hid_t loc_id, tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); write_attr(loc_id, 1, dims, "array", tid, buf6); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -1174,13 +1214,13 @@ void write_attr_in(hid_t loc_id, */ write_attr(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7); write_attr(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8); - - + + /*------------------------------------------------------------------------- * 2D attributes *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- @@ -1192,7 +1232,7 @@ void write_attr_in(hid_t loc_id, for (k=0; k<2; k++) buf12[i][j][k]='z'; } - + /* buf12[6][2]= {"ab","cd","ef","gh","ij","kl"}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -1212,17 +1252,17 @@ void write_attr_in(hid_t loc_id, [ 2 1 ] k z [ 2 1 ] l z */ - + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id,2,dims2,"string2D",tid,buf12); status = H5Tclose(tid); - + for (i=0; i<3; i++) { for (j=0; j<2; j++) { - + buf12a[i][j]=buf12[i][j]; } } @@ -1230,17 +1270,17 @@ void write_attr_in(hid_t loc_id, status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id,2,dims2,"VLstring2D",tid,buf12a); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf22,0,sizeof buf22); } - + /* buf22[3][2]= {{1,2},{3,4},{5,6}}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -1254,17 +1294,17 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - - + + tid = H5Tcopy(H5T_STD_B8LE); write_attr(loc_id,2,dims2,"bitfield2D",tid,buf22); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - + /* buf22[3][2]= {{1,2},{3,4},{5,6}}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -1282,7 +1322,7 @@ void write_attr_in(hid_t loc_id, status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id,2,dims2,"opaque2D",tid,buf22); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- @@ -1291,7 +1331,7 @@ void write_attr_in(hid_t loc_id, { memset(buf32,0,sizeof buf32); } - + /* buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -1305,14 +1345,14 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - - + + tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_attr(loc_id,2,dims2,"compound2D",tid,buf32); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_REFERENCE (H5R_OBJECT object reference) *------------------------------------------------------------------------- @@ -1327,7 +1367,7 @@ void write_attr_in(hid_t loc_id, } write_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); } - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- @@ -1339,7 +1379,7 @@ void write_attr_in(hid_t loc_id, if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=RED; } } - + /* Attribute: and position enum2D of enum2D of difference @@ -1351,18 +1391,18 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] RED GREEN [ 2 1 ] RED GREEN */ - + tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); write_attr(loc_id,2,dims2,"enum2D",tid,buf452); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ n=0; for (i = 0; i < 3; i++) { @@ -1374,7 +1414,7 @@ void write_attr_in(hid_t loc_id, else ((int *)buf52[i][j].p)[l] = n++; } } - + /* position vlen2D of vlen2D of difference ------------------------------------------------------------ @@ -1390,7 +1430,7 @@ void write_attr_in(hid_t loc_id, [ 2 1 ] 10 0 10 [ 2 1 ] 11 0 11 */ - + sid = H5Screate_simple(2, dims2, NULL); tid = H5Tvlen_create(H5T_NATIVE_INT); aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -1401,12 +1441,12 @@ void write_attr_in(hid_t loc_id, status = H5Aclose(aid); status = H5Tclose(tid); status = H5Sclose(sid); - + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf62,0,sizeof buf62); @@ -1440,12 +1480,12 @@ void write_attr_in(hid_t loc_id, tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); write_attr(loc_id, 2, dims2, "array2D", tid, buf62); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf72,0,sizeof buf72); @@ -1472,21 +1512,21 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - + write_attr(loc_id,2,dims2,"integer2D",H5T_NATIVE_INT,buf72); write_attr(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82); - - + + /*------------------------------------------------------------------------- * 3D attributes *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<4; i++) @@ -1495,69 +1535,69 @@ void write_attr_in(hid_t loc_id, for (l=0; l<2; l++) buf13[i][j][k][l]='z'; } - + /* buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq", "rs","tu","vw","xz","AB","CD","EF","GH", "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; - - Attribute: and - position string3D of string3D of difference - ------------------------------------------------------------ - [ 0 0 0 ] a z - [ 0 0 0 ] b z - [ 0 0 1 ] c z - [ 0 0 1 ] d z - [ 0 1 0 ] e z - [ 0 1 0 ] f z - [ 0 1 1 ] g z - [ 0 1 1 ] h z - [ 0 2 0 ] i z - [ 0 2 0 ] j z - [ 0 2 1 ] k z - [ 0 2 1 ] l z - [ 1 0 0 ] m z - [ 1 0 0 ] n z - [ 1 0 1 ] p z - [ 1 0 1 ] q z - [ 1 1 0 ] r z - [ 1 1 0 ] s z - [ 1 1 1 ] t z - [ 1 1 1 ] u z - [ 1 2 0 ] v z - [ 1 2 0 ] w z - [ 1 2 1 ] x z - [ 2 0 0 ] A z - [ 2 0 0 ] B z - [ 2 0 1 ] C z - [ 2 0 1 ] D z - [ 2 1 0 ] E z - [ 2 1 0 ] F z - [ 2 1 1 ] G z - [ 2 1 1 ] H z - [ 2 2 0 ] I z - [ 2 2 0 ] J z - [ 2 2 1 ] K z - [ 2 2 1 ] L z - [ 3 0 0 ] M z - [ 3 0 0 ] N z - [ 3 0 1 ] P z - [ 3 0 1 ] Q z - [ 3 1 0 ] R z - [ 3 1 0 ] S z - [ 3 1 1 ] T z - [ 3 1 1 ] U z - [ 3 2 0 ] V z - [ 3 2 0 ] W z - [ 3 2 1 ] X z - [ 3 2 1 ] Z z - */ - + + Attribute: and + position string3D of string3D of difference + ------------------------------------------------------------ + [ 0 0 0 ] a z + [ 0 0 0 ] b z + [ 0 0 1 ] c z + [ 0 0 1 ] d z + [ 0 1 0 ] e z + [ 0 1 0 ] f z + [ 0 1 1 ] g z + [ 0 1 1 ] h z + [ 0 2 0 ] i z + [ 0 2 0 ] j z + [ 0 2 1 ] k z + [ 0 2 1 ] l z + [ 1 0 0 ] m z + [ 1 0 0 ] n z + [ 1 0 1 ] p z + [ 1 0 1 ] q z + [ 1 1 0 ] r z + [ 1 1 0 ] s z + [ 1 1 1 ] t z + [ 1 1 1 ] u z + [ 1 2 0 ] v z + [ 1 2 0 ] w z + [ 1 2 1 ] x z + [ 2 0 0 ] A z + [ 2 0 0 ] B z + [ 2 0 1 ] C z + [ 2 0 1 ] D z + [ 2 1 0 ] E z + [ 2 1 0 ] F z + [ 2 1 1 ] G z + [ 2 1 1 ] H z + [ 2 2 0 ] I z + [ 2 2 0 ] J z + [ 2 2 1 ] K z + [ 2 2 1 ] L z + [ 3 0 0 ] M z + [ 3 0 0 ] N z + [ 3 0 1 ] P z + [ 3 0 1 ] Q z + [ 3 1 0 ] R z + [ 3 1 0 ] S z + [ 3 1 1 ] T z + [ 3 1 1 ] U z + [ 3 2 0 ] V z + [ 3 2 0 ] W z + [ 3 2 1 ] X z + [ 3 2 1 ] Z z + */ + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id,3,dims3,"string3D",tid,buf13); status = H5Tclose(tid); - + for (i=0; i<4; i++) { for (j=0; j<3; j++) @@ -1572,12 +1612,12 @@ void write_attr_in(hid_t loc_id, status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id,3,dims3,"VLstring3D",tid,buf13a); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - + n=1; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { @@ -1587,7 +1627,7 @@ void write_attr_in(hid_t loc_id, } } } - + /* position bitfield3D of bitfield3D of difference ------------------------------------------------------------ @@ -1616,11 +1656,11 @@ void write_attr_in(hid_t loc_id, [ 3 2 0 ] 23 0 23 [ 3 2 1 ] 24 0 24 */ - + tid = H5Tcopy(H5T_STD_B8LE); write_attr(loc_id,3,dims3,"bitfield3D",tid,buf23); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- @@ -1629,12 +1669,12 @@ void write_attr_in(hid_t loc_id, status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id,3,dims3,"opaque3D",tid,buf23); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - + n=1; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { @@ -1701,13 +1741,13 @@ void write_attr_in(hid_t loc_id, [ 3 2 1 ] 47 0 47 [ 3 2 1 ] 48 0 48 */ - + tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_attr(loc_id,3,dims3,"compound3D",tid,buf33); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_REFERENCE (H5R_OBJECT object reference) *------------------------------------------------------------------------- @@ -1723,12 +1763,12 @@ void write_attr_in(hid_t loc_id, } write_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); } - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- */ - + for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { for (k = 0; k < 2; k++) { @@ -1736,7 +1776,7 @@ void write_attr_in(hid_t loc_id, } } } - + /* position enum3D of enum3D of difference ------------------------------------------------------------ @@ -1765,19 +1805,19 @@ void write_attr_in(hid_t loc_id, [ 3 2 0 ] GREEN RED [ 3 2 1 ] GREEN RED */ - - + + tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); write_attr(loc_id,3,dims3,"enum3D",tid,buf453); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ n=0; for (i = 0; i < 4; i++) { @@ -1816,7 +1856,7 @@ void write_attr_in(hid_t loc_id, status = H5Aclose(aid); status = H5Tclose(tid); status = H5Sclose(sid); - + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- @@ -1840,11 +1880,11 @@ void write_attr_in(hid_t loc_id, [ 0 1 0 ] 7 0 7 etc */ - + tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); write_attr(loc_id, 3, dims3, "array3D", tid, buf63); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- @@ -1864,7 +1904,7 @@ void write_attr_in(hid_t loc_id, } } } - + /* position integer3D of integer3D of difference ------------------------------------------------------------ @@ -1887,12 +1927,12 @@ void write_attr_in(hid_t loc_id, /*------------------------------------------------------------------------- - * Function: write_dset_in - * - * Purpose: write datasets in LOC_ID - * - *------------------------------------------------------------------------- - */ +* Function: write_dset_in +* +* Purpose: write datasets in LOC_ID +* +*------------------------------------------------------------------------- +*/ static void write_dset_in(hid_t loc_id, const char* dset_name, /* for saving reference to dataset*/ @@ -1905,13 +1945,13 @@ void write_dset_in(hid_t loc_id, char a; double b; } s_t; - + typedef enum { RED, - GREEN + GREEN } e_t; - + hid_t did; hid_t sid; hid_t tid; @@ -1921,7 +1961,7 @@ void write_dset_in(hid_t loc_id, float f; int fillvalue=2; int scalar_data = 2; - + /* create 1D attributes with dimension [2], 2 elements */ hsize_t dims[1]={2}; char buf1[2][STR_SIZE]= {"ab","de"}; /* string */ @@ -1935,7 +1975,7 @@ void write_dset_in(hid_t loc_id, int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ int buf7[2]= {1,2}; /* integer */ float buf8[2]= {1,2}; /* float */ - + /* create 2D attributes with dimension [3][2], 6 elements */ hsize_t dims2[2]={3,2}; char buf12[3][2][STR_SIZE]= {{"ab","cd"},{"ef","gh"},{"ij","kl"}}; /* string */ @@ -1947,7 +1987,7 @@ void write_dset_in(hid_t loc_id, int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ - + /* create 3D attributes with dimension [4][3][2], 24 elements */ hsize_t dims3[3]={4,3,2}; char buf13[4][3][2][STR_SIZE]= {{{"ab","cd"},{"ef","gh"},{"ij","kl"}}, @@ -1962,59 +2002,59 @@ void write_dset_in(hid_t loc_id, int buf63[24][3]; /* array */ int buf73[4][3][2]; /* integer */ float buf83[4][3][2]; /* float */ - - + + /*------------------------------------------------------------------------- * H5S_SCALAR *------------------------------------------------------------------------- */ - - - + + + if ( make_diffs ) { - + scalar_data = 1; } - + /* create a space */ sid = H5Screate(H5S_SCALAR); - + /* create a dataset */ did = H5Dcreate2(loc_id, "scalar", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - + /* write */ H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &scalar_data); - + /* close */ H5Dclose(did); H5Sclose(sid); - - + + /*------------------------------------------------------------------------- * 1D *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - - + + if (make_diffs) { for (i=0; i<2; i++) for (j=0; j<2; j++) buf1[i][j]='z'; } - - + + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid,(size_t)STR_SIZE); write_dset(loc_id,1,dims,"string",tid,buf1); status = H5Tclose(tid); - + for (i=0; i<2; i++) { buf1a[i]=buf1[i]; @@ -2023,27 +2063,27 @@ void write_dset_in(hid_t loc_id, status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id,1,dims,"VLstring",tid,buf1a); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) buf2[i]=buf2[1]=0; } - + tid = H5Tcopy(H5T_STD_B8LE); write_dset(loc_id,1,dims,"bitfield",tid,buf2); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -2051,18 +2091,18 @@ void write_dset_in(hid_t loc_id, buf3[i].a=0; buf3[i].b=0; } } - + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id,1,dims,"opaque",tid,buf2); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - - + + if (make_diffs) { for (i=0; i<2; i++) @@ -2070,13 +2110,13 @@ void write_dset_in(hid_t loc_id, buf45[i]=GREEN; } } - + tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_dset(loc_id,1,dims,"compound",tid,buf3); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_REFERENCE (H5R_OBJECT object reference) *------------------------------------------------------------------------- @@ -2088,14 +2128,14 @@ void write_dset_in(hid_t loc_id, status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,-1); write_dset(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); } - + /*------------------------------------------------------------------------- * H5T_REFERENCE (H5R_DATASET_REGION dataset region reference) *------------------------------------------------------------------------- */ - + gen_datareg(fid,make_diffs); - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- @@ -2105,14 +2145,14 @@ void write_dset_in(hid_t loc_id, H5Tenum_insert(tid, "GREEN", (val = 1, &val)); write_dset(loc_id,1,dims,"enum",tid,buf45); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ - + buf5[0].len = 1; buf5[0].p = malloc( 1 * sizeof(int)); ((int *)buf5[0].p)[0]=1; @@ -2120,13 +2160,13 @@ void write_dset_in(hid_t loc_id, buf5[1].p = malloc( 2 * sizeof(int)); ((int *)buf5[1].p)[0]=2; ((int *)buf5[1].p)[1]=3; - + if(make_diffs) { ((int *)buf5[0].p)[0] = 0; ((int *)buf5[1].p)[0] = 0; ((int *)buf5[1].p)[1]=0; } - + sid = H5Screate_simple(1, dims, NULL); tid = H5Tvlen_create(H5T_NATIVE_INT); did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -2137,12 +2177,12 @@ void write_dset_in(hid_t loc_id, status = H5Dclose(did); status = H5Tclose(tid); status = H5Sclose(sid); - + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -2151,16 +2191,56 @@ void write_dset_in(hid_t loc_id, buf6[i][j]=0; } } - + tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); write_dset(loc_id, 1, dims, "array", tid, buf6); status = H5Tclose(tid); - + + { + + double *dbuf; /* information to write */ + hid_t did; /* dataset ID */ + hid_t sid; /* dataspace ID */ + hid_t tid; /* datatype ID */ + size_t size; + hsize_t sdims[] = {1}; + hsize_t tdims[] = {H5TOOLS_MALLOCSIZE / sizeof(double) + 1}; + int j; + + /* allocate and initialize array data to write */ + size = ( H5TOOLS_MALLOCSIZE / sizeof(double) + 1 ) * sizeof(double); + dbuf = malloc( size ); + + for( j = 0; j < H5TOOLS_MALLOCSIZE / sizeof(double) + 1; j++) + dbuf[j] = j; + + if (make_diffs) + { + dbuf[5] = 0; + dbuf[6] = 0; + } + + /* create a type larger than H5TOOLS_MALLOCSIZE */ + tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims); + size = H5Tget_size(tid); + sid = H5Screate_simple(1, sdims, NULL); + did = H5Dcreate2(loc_id, "arrayd", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); +#if defined(WRITE_ARRAY) + H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); +#endif + + /* close */ + H5Dclose(did); + H5Tclose(tid); + H5Sclose(sid); + free( dbuf ); + } + /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -2169,21 +2249,21 @@ void write_dset_in(hid_t loc_id, buf8[i]=0; } } - + write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7); write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8); - - + + /*------------------------------------------------------------------------- * 2D *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<3; i++) @@ -2191,13 +2271,13 @@ void write_dset_in(hid_t loc_id, for (k=0; k<2; k++) buf12[i][j][k]='z'; } - - + + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid,(size_t)STR_SIZE); write_dset(loc_id,2,dims2,"string2D",tid,buf12); status = H5Tclose(tid); - + for (i=0; i<3; i++) { for (j=0; j<2; j++) @@ -2209,22 +2289,22 @@ void write_dset_in(hid_t loc_id, status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id,2,dims2,"VLstring2D",tid,buf12a); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - - + + if (make_diffs) { memset(buf22,0,sizeof buf22); } - + tid = H5Tcopy(H5T_STD_B8LE); write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- @@ -2233,23 +2313,23 @@ void write_dset_in(hid_t loc_id, status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id,2,dims2,"opaque2D",tid,buf22); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf32,0,sizeof buf32); } - + tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_dset(loc_id,2,dims2,"compound2D",tid,buf32); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_REFERENCE (H5R_OBJECT object reference) *------------------------------------------------------------------------- @@ -2264,23 +2344,23 @@ void write_dset_in(hid_t loc_id, } write_dset(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); } - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- */ - + tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); write_dset(loc_id,2,dims2,"enum2D",tid,0); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ n = 0; for(i = 0; i < 3; i++) @@ -2298,7 +2378,7 @@ void write_dset_in(hid_t loc_id, } } } - + sid = H5Screate_simple(2, dims2, NULL); tid = H5Tvlen_create(H5T_NATIVE_INT); did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -2309,35 +2389,35 @@ void write_dset_in(hid_t loc_id, status = H5Dclose(did); status = H5Tclose(tid); status = H5Sclose(sid); - + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf62,0,sizeof buf62); } - - + + tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); write_dset(loc_id, 2, dims2, "array2D", tid, buf62); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_INTEGER, write a fill value *------------------------------------------------------------------------- */ - - + + if (make_diffs) { memset(buf72, 0, sizeof buf72); memset(buf82, 0, sizeof buf82); } - - + + dcpl = H5Pcreate(H5P_DATASET_CREATE); status = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue); sid = H5Screate_simple(2, dims2, NULL); @@ -2346,25 +2426,25 @@ void write_dset_in(hid_t loc_id, status = H5Pclose(dcpl); status = H5Dclose(did); status = H5Sclose(sid); - + /*------------------------------------------------------------------------- * H5T_FLOAT *------------------------------------------------------------------------- */ - + write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82); - - + + /*------------------------------------------------------------------------- * 3D *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<4; i++) @@ -2373,12 +2453,12 @@ void write_dset_in(hid_t loc_id, for (l=0; l<2; l++) buf13[i][j][k][l]='z'; } - + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid,(size_t)STR_SIZE); write_dset(loc_id,3,dims3,"string3D",tid,buf13); status = H5Tclose(tid); - + for (i=0; i<4; i++) { for (j=0; j<3; j++) @@ -2393,13 +2473,13 @@ void write_dset_in(hid_t loc_id, status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id,3,dims3,"VLstring3D",tid,buf13a); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - - + + n=1; for (i = 0; i < 4; i++) { @@ -2413,12 +2493,12 @@ void write_dset_in(hid_t loc_id, } } } - - + + tid = H5Tcopy(H5T_STD_B8LE); write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- @@ -2427,12 +2507,12 @@ void write_dset_in(hid_t loc_id, status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id,3,dims3,"opaque3D",tid,buf23); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - + n=1; for (i = 0; i < 4; i++) { @@ -2452,14 +2532,14 @@ void write_dset_in(hid_t loc_id, } } } - - + + tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_dset(loc_id,3,dims3,"compound3D",tid,buf33); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_REFERENCE (H5R_OBJECT object reference) *------------------------------------------------------------------------- @@ -2475,23 +2555,23 @@ void write_dset_in(hid_t loc_id, } write_dset(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); } - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- */ - + tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); write_dset(loc_id,3,dims3,"enum3D",tid,0); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ n=0; for(i = 0; i < 4; i++) @@ -2512,7 +2592,7 @@ void write_dset_in(hid_t loc_id, } } } - + sid = H5Screate_simple(3, dims3, NULL); tid = H5Tvlen_create(H5T_NATIVE_INT); did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -2523,13 +2603,13 @@ void write_dset_in(hid_t loc_id, status = H5Dclose(did); status = H5Tclose(tid); status = H5Sclose(sid); - + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- */ - - + + n=1; for (i = 0; i < 24; i++) { for (j = 0; j < (int)dimarray[0]; j++) { @@ -2537,11 +2617,11 @@ void write_dset_in(hid_t loc_id, else buf63[i][j]=n++; } } - + tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); write_dset(loc_id, 3, dims3, "array3D", tid, buf63); status = H5Tclose(tid); - + /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- @@ -2566,14 +2646,14 @@ void write_dset_in(hid_t loc_id, } /*------------------------------------------------------------------------- - * Function: gen_datareg - * - * Purpose: generate a dataset region and its reference - * - * Date: April 19, 2006 - * - *------------------------------------------------------------------------- - */ +* Function: gen_datareg +* +* Purpose: generate a dataset region and its reference +* +* Date: April 19, 2006 +* +*------------------------------------------------------------------------- +*/ static void gen_datareg(hid_t fid, @@ -2594,44 +2674,44 @@ void gen_datareg(hid_t fid, hsize_t coord[5][2]; /* coordinates for point selection */ herr_t status; int i; - + /* allocate the buffer for write the references */ rbuf = calloc((size_t)2, sizeof(hdset_reg_ref_t)); - + /* allocate the buffer for write the data dataset */ buf = malloc(10 * 10 * sizeof(int)); - + for(i = 0; i < 10 * 10; i++) buf[i] = i; - + /* create the data dataset */ sid1 = H5Screate_simple(2, dims1, NULL); did1 = H5Dcreate2(fid, "dsetref", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); assert(status >= 0); - + /* create the reference dataset */ sid2 = H5Screate_simple(1, dims2, NULL); did2 = H5Dcreate2(fid, "refreg", H5T_STD_REF_DSETREG, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - + /* create the references */ /* select hyperslab for first reference */ - + start[0] = 2; start[1] = 2; count[0] = 6; count[1] = 6; if(make_diffs) { start[0] = 0; start[1] = 0; count[0] = 3; count[1] = 3; } - + status = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL); assert(status >= 0); H5Sget_select_npoints(sid1); - + /* store first dataset region */ status = H5Rcreate(&rbuf[0], fid, "dsetref", H5R_DATASET_REGION, sid1); assert(status >= 0); - + /* select sequence of five points for second reference */ coord[0][0]=6; coord[0][1]=9; coord[1][0]=2; coord[1][1]=2; @@ -2646,14 +2726,14 @@ void gen_datareg(hid_t fid, } H5Sselect_elements(sid1,H5S_SELECT_SET,(size_t)5,(const hsize_t *)coord); H5Sget_select_npoints(sid1); - + /* store second dataset region */ H5Rcreate(&rbuf[1],fid,"dsetref",H5R_DATASET_REGION,sid1); - + /* write */ status = H5Dwrite(did2,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,rbuf); assert(status >= 0); - + /* close, free memory buffers */ status = H5Dclose(did1); assert(status >= 0); @@ -2670,13 +2750,13 @@ void gen_datareg(hid_t fid, /*------------------------------------------------------------------------- - * Function: test_hyperslab - * - * Purpose: test diff by hyperslabs. create a dataset with 1GB dimensions - * by iterating trough 1KB hyperslabs - * - *------------------------------------------------------------------------- - */ +* Function: test_hyperslab +* +* Purpose: test diff by hyperslabs. create a dataset with 1GB dimensions +* by iterating trough 1KB hyperslabs +* +*------------------------------------------------------------------------- +*/ static int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buffers */) @@ -2697,7 +2777,7 @@ int test_hyperslab(const char *fname, char *buf=NULL; int i, j, s; char c; - + /* create */ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -2716,7 +2796,7 @@ int test_hyperslab(const char *fname, goto out; if((size = H5Tget_size(tid)) <= 0) goto out; - + /* create a evenly divided buffer from 0 to 127 */ buf = (char *)HDmalloc((size_t)(nelmts * size)); s = 1024 * 1024 / 127; @@ -2725,29 +2805,29 @@ int test_hyperslab(const char *fname, c++; j = 0; } - + /* set the hyperslab values */ HDmemset(buf, c, nelmts); - + /* make a different hyperslab at this position */ if(make_diffs && i == 512 * 512) HDmemset(buf, 0, nelmts); - + hs_start[0] = i * GBLL/(1024*1024); if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size, NULL) < 0) goto out; - + /* write only one hyperslab */ if ( i==512*512) { if (H5Dwrite (did,H5T_NATIVE_CHAR,m_sid,f_sid,H5P_DEFAULT,buf) < 0) goto out; } - + } free(buf); buf=NULL; - + /* close */ if(H5Sclose(f_sid) < 0) goto out; @@ -2758,9 +2838,9 @@ int test_hyperslab(const char *fname, if(H5Dclose(did) < 0) goto out; H5Fclose(fid); - + return 0; - + out: H5E_BEGIN_TRY { H5Pclose(dcpl); @@ -2770,17 +2850,17 @@ out: H5Fclose(fid); } H5E_END_TRY; return -1; - + } /*------------------------------------------------------------------------- - * Function: write_attr - * - * Purpose: utility function to write an attribute in LOC_ID - * - *------------------------------------------------------------------------- - */ +* Function: write_attr +* +* Purpose: utility function to write an attribute in LOC_ID +* +*------------------------------------------------------------------------- +*/ static int write_attr(hid_t loc_id, int rank, @@ -2821,19 +2901,19 @@ out: } /*------------------------------------------------------------------------- - * Function: write_dset - * - * Purpose: utility function to create and write a dataset in LOC_ID - * - *------------------------------------------------------------------------- - */ +* Function: write_dset +* +* Purpose: utility function to create and write a dataset in LOC_ID +* +*------------------------------------------------------------------------- +*/ static int write_dset( hid_t loc_id, - int rank, - hsize_t *dims, - const char *name, - hid_t tid, - void *buf ) + int rank, + hsize_t *dims, + const char *name, + hid_t tid, + void *buf ) { hid_t did=-1; hid_t sid=-1; diff --git a/tools/h5diff/testfiles/h5diff_201.txt b/tools/h5diff/testfiles/h5diff_201.txt index 599cc2b..a212444 100644 --- a/tools/h5diff/testfiles/h5diff_201.txt +++ b/tools/h5diff/testfiles/h5diff_201.txt @@ -1 +1 @@ - or are empty datasets +Not comparable: or are empty datasets diff --git a/tools/h5diff/testfiles/h5diff_202.txt b/tools/h5diff/testfiles/h5diff_202.txt index a881cf5..ee240c2 100644 --- a/tools/h5diff/testfiles/h5diff_202.txt +++ b/tools/h5diff/testfiles/h5diff_202.txt @@ -1,2 +1,2 @@ is of class H5T_FLOAT and is of class H5T_INTEGER - has sign H5T_SGN_ERROR and has sign H5T_SGN_2 +Not comparable: has sign H5T_SGN_ERROR and has sign H5T_SGN_2 diff --git a/tools/h5diff/testfiles/h5diff_203.txt b/tools/h5diff/testfiles/h5diff_203.txt index aea1891..49ee21c 100644 --- a/tools/h5diff/testfiles/h5diff_203.txt +++ b/tools/h5diff/testfiles/h5diff_203.txt @@ -1,2 +1,2 @@ - has rank 1, dimensions [6], max dimensions [6] +Not comparable: has rank 1, dimensions [6], max dimensions [6] has rank 2, dimensions [3x2], max dimensions [3x2] diff --git a/tools/h5diff/testfiles/h5diff_204.txt b/tools/h5diff/testfiles/h5diff_204.txt index 66b9e63..5a3d87f 100644 --- a/tools/h5diff/testfiles/h5diff_204.txt +++ b/tools/h5diff/testfiles/h5diff_204.txt @@ -1,2 +1,2 @@ - has rank 2, dimensions [3x2], max dimensions [3x2] +Not comparable: has rank 2, dimensions [3x2], max dimensions [3x2] has rank 2, dimensions [2x2], max dimensions [2x2] diff --git a/tools/h5diff/testfiles/h5diff_205.txt b/tools/h5diff/testfiles/h5diff_205.txt index f7360ab..81298af 100644 --- a/tools/h5diff/testfiles/h5diff_205.txt +++ b/tools/h5diff/testfiles/h5diff_205.txt @@ -1,3 +1,3 @@ - has rank 2, dimensions [2x2], max dimensions [2x2] +Not comparable: has rank 2, dimensions [2x2], max dimensions [2x2] has rank 2, dimensions [3x2], max dimensions [3x2] - has sign H5T_SGN_2 and has sign H5T_SGN_NONE +Not comparable: has sign H5T_SGN_2 and has sign H5T_SGN_NONE diff --git a/tools/h5diff/testfiles/h5diff_206.txt b/tools/h5diff/testfiles/h5diff_206.txt index 8bbbb9a..164aed9 100644 --- a/tools/h5diff/testfiles/h5diff_206.txt +++ b/tools/h5diff/testfiles/h5diff_206.txt @@ -1 +1 @@ - has a class H5T_FLOAT and has a class H5T_INTEGER +Not comparable: has a class H5T_FLOAT and has a class H5T_INTEGER diff --git a/tools/h5diff/testfiles/h5diff_207.txt b/tools/h5diff/testfiles/h5diff_207.txt index 833afe8..f8152f8 100644 --- a/tools/h5diff/testfiles/h5diff_207.txt +++ b/tools/h5diff/testfiles/h5diff_207.txt @@ -1,2 +1,2 @@ - or are empty datasets - has 2 members has 1 members +Not comparable: or are empty datasets +Not comparable: has 2 members has 1 members diff --git a/tools/h5diff/testfiles/h5diff_57.txt b/tools/h5diff/testfiles/h5diff_57.txt index c1a0d64..a026077 100644 --- a/tools/h5diff/testfiles/h5diff_57.txt +++ b/tools/h5diff/testfiles/h5diff_57.txt @@ -2,7 +2,7 @@ dataset: and Warning: different storage datatype has file datatype H5T_STD_I8LE has file datatype H5T_STD_U8LE - has sign H5T_SGN_2 and has sign H5T_SGN_NONE +Not comparable: has sign H5T_SGN_2 and has sign H5T_SGN_NONE 0 differences found -------------------------------- Some objects are not comparable diff --git a/tools/h5diff/testfiles/h5diff_70.txt b/tools/h5diff/testfiles/h5diff_70.txt index 42fe6fc..b42cacd 100644 --- a/tools/h5diff/testfiles/h5diff_70.txt +++ b/tools/h5diff/testfiles/h5diff_70.txt @@ -677,7 +677,7 @@ position float3D of float3D of difference [ 3 2 1 ] 24 0 24 24 differences found dataset: and - or are empty datasets +Not comparable: or are empty datasets attribute: > and > size: [2] [2] position string of string of difference diff --git a/tools/h5diff/testfiles/h5diff_80.txt b/tools/h5diff/testfiles/h5diff_80.txt index dcabf10..c8ec309 100644 --- a/tools/h5diff/testfiles/h5diff_80.txt +++ b/tools/h5diff/testfiles/h5diff_80.txt @@ -11,6 +11,7 @@ file1 file2 x x /g1/array x x /g1/array2D x x /g1/array3D + x x /g1/arrayd x x /g1/bitfield x x /g1/bitfield2D x x /g1/bitfield3D @@ -243,6 +244,9 @@ position array3D array3D difference [ 3 2 1 ] 71 0 71 [ 3 2 1 ] 72 0 72 72 differences found +dataset: and +Not comparable: or are empty datasets +0 differences found dataset: and size: [2] [2] position bitfield bitfield difference @@ -376,10 +380,10 @@ position enum enum difference [ 0 ] RED GREEN 1 differences found dataset: and - or are empty datasets +Not comparable: or are empty datasets 0 differences found dataset: and - or are empty datasets +Not comparable: or are empty datasets 0 differences found dataset: and size: [2] [2] diff --git a/tools/h5diff/testfiles/h5diff_90.txt b/tools/h5diff/testfiles/h5diff_90.txt index 71b960e..a513ffa 100644 --- a/tools/h5diff/testfiles/h5diff_90.txt +++ b/tools/h5diff/testfiles/h5diff_90.txt @@ -30,7 +30,7 @@ dataset: and group : and 0 differences found dataset: and - or are empty datasets +Not comparable: or are empty datasets 0 differences found dataset: and 0 differences found @@ -47,7 +47,7 @@ dataset: and dataset: and 0 differences found dataset: and - or are empty datasets +Not comparable: or are empty datasets 0 differences found -------------------------------- Some objects are not comparable diff --git a/tools/h5diff/testfiles/h5diff_dset1.h5 b/tools/h5diff/testfiles/h5diff_dset1.h5 index d1ceb9d..123e141 100644 Binary files a/tools/h5diff/testfiles/h5diff_dset1.h5 and b/tools/h5diff/testfiles/h5diff_dset1.h5 differ diff --git a/tools/h5diff/testfiles/h5diff_dset2.h5 b/tools/h5diff/testfiles/h5diff_dset2.h5 index d1370d9..3ae6993 100644 Binary files a/tools/h5diff/testfiles/h5diff_dset2.h5 and b/tools/h5diff/testfiles/h5diff_dset2.h5 differ diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in index 9bf42b7..0d77850 100644 --- a/tools/h5dump/Makefile.in +++ b/tools/h5dump/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -385,8 +385,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -501,7 +501,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index f116e89..6868332 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -105,8 +105,8 @@ static H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | d **/ /* module-scoped variables for XML option */ -#define DEFAULT_XSD "http://hdfgroup.org/DTDs/HDF5-File.xsd" -#define DEFAULT_DTD "http://hdfgroup.org/DTDs/HDF5-File.dtd" +#define DEFAULT_XSD "http://www.hdfgroup.org/DTDs/HDF5-File.xsd" +#define DEFAULT_DTD "http://www.hdfgroup.org/DTDs/HDF5-File.dtd" static int doxml = 0; static int useschema = 1; @@ -4396,8 +4396,8 @@ main(int argc, const char *argv[]) printf("<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/DTDs/HDF5-File\" " "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " - "xsi:schemaLocation=\"http://hdfgroup.org/DTDs/HDF5File " - "http://hdfgroup.org/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns); + "xsi:schemaLocation=\"http://hdfgroup.org/DTDs/HDF5-File " + "http://www.hdfgroup.org/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns); } } else { printf("\n", diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index fc75681..c7e1445 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -91,6 +91,7 @@ #define FILE61 "textlinksrc.h5" #define FILE62 "textlinktar.h5" #define FILE63 "textlinkfar.h5" +#define FILE64 "tarray8.h5" @@ -121,7 +122,7 @@ set_local_myfilter(hid_t dcpl_id, hid_t tid, hid_t UNUSED sid); #define MYFILTER_ID 405 /* This message derives from H5Z */ -const H5Z_class_t H5Z_MYFILTER[1] = {{ +const H5Z_class2_t H5Z_MYFILTER[1] = {{ H5Z_CLASS_T_VERS, MYFILTER_ID, /* Filter id number */ 1, 1, @@ -2812,6 +2813,50 @@ static void gent_array7(void) assert(ret >= 0); } +static void gent_array8(void) +{ + int *buf; /* information to write */ + hid_t fid; /* HDF5 File ID */ + hid_t did; /* dataset ID */ + hid_t sid; /* dataspace ID */ + hid_t tid; /* datatype ID */ + size_t size; + hsize_t sdims[] = {1}; + hsize_t tdims[] = {H5TOOLS_BUFSIZE / sizeof(int) + 1}; + int i; + herr_t ret; + + size = ( H5TOOLS_BUFSIZE / sizeof(int) + 1 ) * sizeof(int); + buf = malloc( size ); + + for( i = 0; i < H5TOOLS_BUFSIZE / sizeof(int) + 1; i++) + buf[i] = i; + + /* create file */ + fid = H5Fcreate(FILE64, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* create a type larger than H5TOOLS_BUFSIZE */ + tid = H5Tarray_create2(H5T_NATIVE_INT, 1, tdims); + size = H5Tget_size(tid); + sid = H5Screate_simple(1, sdims, NULL); + did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + assert(ret >= 0); + + + /* close */ + ret = H5Dclose(did); + assert(ret >= 0); + ret = H5Tclose(tid); + assert(ret >= 0); + ret = H5Sclose(sid); + assert(ret >= 0); + + ret = H5Fclose(fid); + assert(ret >= 0); + free( buf ); +} + static void gent_empty(void) { typedef struct { diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 9718bfc..080726f 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -514,6 +514,7 @@ TOOLTEST textlinkfar.ddl textlinkfar.h5 + if test $nerrors -eq 0 ; then echo "All $DUMPER tests passed." fi diff --git a/tools/h5import/Makefile.in b/tools/h5import/Makefile.in index 65cefc8..9314d90 100755 --- a/tools/h5import/Makefile.in +++ b/tools/h5import/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -376,8 +376,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -484,7 +484,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/h5jam/Makefile.in b/tools/h5jam/Makefile.in index 32a6c2f..87d1c6b 100644 --- a/tools/h5jam/Makefile.in +++ b/tools/h5jam/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -388,8 +388,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -510,7 +510,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/h5ls/Makefile.in b/tools/h5ls/Makefile.in index bfc0e78..72fc0bf 100644 --- a/tools/h5ls/Makefile.in +++ b/tools/h5ls/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -369,8 +369,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -468,7 +468,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/h5repack/Makefile.am b/tools/h5repack/Makefile.am index f677de0..2c0c0c2 100644 --- a/tools/h5repack/Makefile.am +++ b/tools/h5repack/Makefile.am @@ -50,6 +50,9 @@ h5repacktst_SOURCES=$(COMMON_SOURCES) h5repacktst.c testh5repack_detect_szip_SOURCES=testh5repack_detect_szip.c +# The h5repack.sh script needs h5repacktst to run first. +h5repack.sh.chkexe_: h5repacktst.chkexe_ + # Temporary files. *.h5 are generated by h5repack. They should # copied to the testfiles/ directory if update is required. CHECK_CLEANFILES+=*.h5 *.bin diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in index 1a5990d..9b559ad 100644 --- a/tools/h5repack/Makefile.in +++ b/tools/h5repack/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -403,8 +403,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -531,7 +531,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -722,6 +722,9 @@ uninstall-am: uninstall-binPROGRAMS help: @$(top_srcdir)/bin/makehelp +# The h5repack.sh script needs h5repacktst to run first. +h5repack.sh.chkexe_: h5repacktst.chkexe_ + # lib/progs/tests targets recurse into subdirectories. build-* targets # build files in this directory. build-lib: $(LIB) diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 92db049..d8a503c 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -27,10 +27,10 @@ extern char *progname; /*------------------------------------------------------------------------- - * File: h5repack.c - * Purpose: Public API functions - *------------------------------------------------------------------------- - */ +* File: h5repack.c +* Purpose: Public API functions +*------------------------------------------------------------------------- +*/ static int check_options(pack_opt_t *options); static int check_objects(const char* fname, pack_opt_t *options); @@ -40,24 +40,24 @@ static int have_request(pack_opt_t *options); /*------------------------------------------------------------------------- - * Function: h5repack - * - * Purpose: locate all high-level HDF5 objects in the file - * and compress/chunk them using options - * - * Algorithm: 2 traversals are made to the file; the 1st builds a list of - * the objects, the 2nd makes a copy of them, using the options; - * the reason for the 1st traversal is to check for invalid - * object name requests - * - * Return: 0, ok, -1, fail - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: September, 22, 2003 - * - *------------------------------------------------------------------------- - */ +* Function: h5repack +* +* Purpose: locate all high-level HDF5 objects in the file +* and compress/chunk them using options +* +* Algorithm: 2 traversals are made to the file; the 1st builds a list of +* the objects, the 2nd makes a copy of them, using the options; +* the reason for the 1st traversal is to check for invalid +* object name requests +* +* Return: 0, ok, -1, fail +* +* Programmer: pvn@ncsa.uiuc.edu +* +* Date: September, 22, 2003 +* +*------------------------------------------------------------------------- +*/ int h5repack(const char* infile, const char* outfile, pack_opt_t *options) @@ -81,14 +81,14 @@ int h5repack(const char* infile, /*------------------------------------------------------------------------- - * Function: h5repack_init - * - * Purpose: initialize options - * - * Return: 0, ok, -1, fail - * - *------------------------------------------------------------------------- - */ +* Function: h5repack_init +* +* Purpose: initialize options +* +* Return: 0, ok, -1, fail +* +*------------------------------------------------------------------------- +*/ int h5repack_init (pack_opt_t *options, int verbose) @@ -110,12 +110,12 @@ int h5repack_init (pack_opt_t *options, } /*------------------------------------------------------------------------- - * Function: h5repack_end - * - * Purpose: free options table - * - *------------------------------------------------------------------------- - */ +* Function: h5repack_end +* +* Purpose: free options table +* +*------------------------------------------------------------------------- +*/ int h5repack_end (pack_opt_t *options) { @@ -123,15 +123,15 @@ int h5repack_end (pack_opt_t *options) } /*------------------------------------------------------------------------- - * Function: h5repack_addfilter - * - * Purpose: add a compression -f option to table - * Example: -f dset:GZIP=6 - * - * Return: 0, ok, -1, fail - * - *------------------------------------------------------------------------- - */ +* Function: h5repack_addfilter +* +* Purpose: add a compression -f option to table +* Example: -f dset:GZIP=6 +* +* Return: 0, ok, -1, fail +* +*------------------------------------------------------------------------- +*/ int h5repack_addfilter(const char* str, pack_opt_t *options) @@ -177,14 +177,14 @@ int h5repack_addfilter(const char* str, /*------------------------------------------------------------------------- - * Function: h5repack_addlayout - * - * Purpose: add a layout option - * - * Return: 0, ok, -1, fail - * - *------------------------------------------------------------------------- - */ +* Function: h5repack_addlayout +* +* Purpose: add a layout option +* +* Return: 0, ok, -1, fail +* +*------------------------------------------------------------------------- +*/ int h5repack_addlayout(const char* str, @@ -199,9 +199,9 @@ int h5repack_addlayout(const char* str, init_packobject(&pack); if (options->all_layout==1){ - error_msg(progname, "invalid layout input: 'all' option \ - is present with other objects <%s>\n",str); - return -1; + error_msg(progname, "invalid layout input: 'all' option \ + is present with other objects <%s>\n",str); + return -1; } /* parse the layout option */ @@ -215,7 +215,7 @@ int h5repack_addlayout(const char* str, options->layout_g=pack.layout; if (pack.layout==H5D_CHUNKED) { - /* -2 means the NONE option, remove chunking + /* -2 means the NONE option, remove chunking and set the global layout to contiguous */ if (pack.chunk.rank==-2) { @@ -243,22 +243,22 @@ int h5repack_addlayout(const char* str, /*------------------------------------------------------------------------- - * Function: check_options - * - * Purpose: print options, checks for invalid options - * - * Return: void, return -1 on error - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: September, 22, 2003 - * - * Modification: - * Peter Cao, July 9, 2007 - * Add "-L, --latest" and other options to pack a file with the latest file format - * - *------------------------------------------------------------------------- - */ +* Function: check_options +* +* Purpose: print options, checks for invalid options +* +* Return: void, return -1 on error +* +* Programmer: pvn@ncsa.uiuc.edu +* +* Date: September, 22, 2003 +* +* Modification: +* Peter Cao, July 9, 2007 +* Add "-L, --latest" and other options to pack a file with the latest file format +* +*------------------------------------------------------------------------- +*/ static int check_options(pack_opt_t *options) { unsigned int i; @@ -272,7 +272,8 @@ static int check_options(pack_opt_t *options) if (options->verbose && have_request(options) /* only print if requested */) { printf("Objects to modify layout are...\n"); - if (options->all_layout==1) { + if (options->all_layout==1) + { switch (options->layout_g) { case H5D_COMPACT: @@ -284,12 +285,17 @@ static int check_options(pack_opt_t *options) case H5D_CHUNKED: strcpy(slayout,"chunked"); break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + error_msg(progname, "invalid layout\n"); + return -1; default: - strcpy(slayout,"unknown"); - break; + strcpy(slayout,"invalid layout\n"); + return -1; } printf(" Apply %s layout to all\n", slayout); - if (H5D_CHUNKED==options->layout_g) { + if (H5D_CHUNKED==options->layout_g) + { printf("with dimension ["); for ( j = 0; j < options->chunk_g.rank; j++) printf("%d ",(int)options->chunk_g.chunk_lengths[j]); @@ -322,9 +328,9 @@ static int check_options(pack_opt_t *options) if (options->all_layout==1 && has_ck) { - error_msg(progname, "invalid chunking input: 'all' option\ - is present with other objects\n"); - return -1; + error_msg(progname, "invalid chunking input: 'all' option\ + is present with other objects\n"); + return -1; } /*------------------------------------------------------------------------- @@ -356,6 +362,8 @@ static int check_options(pack_opt_t *options) get_sfilter(filtn), options->filter_g[k].cd_values[0]); break; + default: + break; } /* k */ }; } @@ -382,9 +390,9 @@ static int check_options(pack_opt_t *options) if (options->all_filter==1 && has_cp) { - error_msg(progname, "invalid compression input: 'all' option\ - is present with other objects\n"); - return -1; + error_msg(progname, "invalid compression input: 'all' option\ + is present with other objects\n"); + return -1; } /*------------------------------------------------------------------------- @@ -455,19 +463,19 @@ static int check_options(pack_opt_t *options) /*------------------------------------------------------------------------- - * Function: check_objects - * - * Purpose: locate all HDF5 objects in the file and compare with user - * supplied list - * - * Return: 0, ok, -1 no - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: September, 23, 2003 - * - *------------------------------------------------------------------------- - */ +* Function: check_objects +* +* Purpose: locate all HDF5 objects in the file and compare with user +* supplied list +* +* Return: 0, ok, -1 no +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: September, 23, 2003 +* +*------------------------------------------------------------------------- +*/ static int check_objects(const char* fname, pack_opt_t *options) { @@ -480,9 +488,9 @@ static int check_objects(const char* fname, return 0; /*------------------------------------------------------------------------- - * open the file - *------------------------------------------------------------------------- - */ + * open the file + *------------------------------------------------------------------------- + */ if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) { printf("<%s>: %s\n", fname, H5FOPENERROR ); @@ -490,9 +498,9 @@ static int check_objects(const char* fname, } /*------------------------------------------------------------------------- - * get the list of objects in the file - *------------------------------------------------------------------------- - */ + * get the list of objects in the file + *------------------------------------------------------------------------- + */ /* init table */ trav_table_init(&travt); @@ -502,9 +510,9 @@ static int check_objects(const char* fname, goto out; /*------------------------------------------------------------------------- - * compare with user supplied list - *------------------------------------------------------------------------- - */ + * compare with user supplied list + *------------------------------------------------------------------------- + */ if(options->verbose) printf("Opening file <%s>. Searching for objects to modify...\n", fname); @@ -529,7 +537,7 @@ static int check_objects(const char* fname, switch(options->op_tbl->objs[i].filter->filtn) { /* chunk size must be smaller than pixels per block */ - case H5Z_FILTER_SZIP: + case H5Z_FILTER_SZIP: { int j; hsize_t csize = 1; @@ -568,10 +576,12 @@ static int check_objects(const char* fname, } } break; + default: + break; } } /* i */ - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ @@ -590,16 +600,16 @@ out: /*------------------------------------------------------------------------- - * Function: have_request - * - * Purpose: check if a filter or layout was requested - * - * Return: 1 yes, 0 no - * - * Date: May, 24, 2007 - * - *------------------------------------------------------------------------- - */ +* Function: have_request +* +* Purpose: check if a filter or layout was requested +* +* Return: 1 yes, 0 no +* +* Date: May, 24, 2007 +* +*------------------------------------------------------------------------- +*/ static int have_request(pack_opt_t *options) { @@ -612,14 +622,14 @@ static int have_request(pack_opt_t *options) /*------------------------------------------------------------------------- - * Function: get_sfilter - * - * Purpose: return the filter as a string name - * - * Return: name of filter, exit on error - * - *------------------------------------------------------------------------- - */ +* Function: get_sfilter +* +* Purpose: return the filter as a string name +* +* Return: name of filter, exit on error +* +*------------------------------------------------------------------------- +*/ static const char* get_sfilter(H5Z_filter_t filtn) { @@ -641,6 +651,5 @@ static const char* get_sfilter(H5Z_filter_t filtn) error_msg(progname, "input error in filter type\n"); exit(1); } - return NULL; } diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index b63102b..cb3d75a 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -131,7 +131,7 @@ int h5repack_addlayout (const char* str, pack_opt_t *options); int h5repack_init (pack_opt_t *options, int verbose); int h5repack_end (pack_opt_t *options); int h5repack_verify (const char *fname,pack_opt_t *options); -int h5repack_cmpdcpl (const char *fname1, +int h5repack_cmp_pl (const char *fname1, const char *fname2); diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index ba3bdfe..a09e8b9 100755 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.sh.in @@ -53,6 +53,7 @@ FILE12=h5repack_nbit.h5 FILE13=h5repack_soffset.h5 FILE14=h5repack_layouto.h5 # A file with an older version of the layout message # (copy of test/tlayouto.h5) +FILE15=h5repack_named_dtypes.h5 nerrors=0 @@ -455,7 +456,10 @@ TOOLTEST $FILE4 -l dset_chunk:CONTI TOOLTEST $FILE4 -l dset_chunk:CHUNK=18x13 # Native option -TOOLTEST $FILE1 -n +# Do not use FILE1, as the named dtype will be converted to native, and h5diff will +# report a difference. +TOOLTEST $FILE0 -n +TOOLTEST $FILE2 -n # latest file format with long switches. use FILE4=h5repack_layout.h5 (no filters) @@ -504,6 +508,12 @@ TOOLTEST $arg # to new version and be readable, etc.) TOOLTEST $FILE14 +# test for datum size > H5TOOLS_MALLOCSIZE +TOOLTEST $FILE1 -f GZIP=1 + +# Check repacking file with committed datatypes in odd configurations +TOOLTEST $FILE15 + if test $nerrors -eq 0 ; then echo "All $H5REPACK tests passed." fi diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index b165dc7..73f57e3 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include @@ -21,50 +21,67 @@ #include "h5tools.h" #include "h5tools_utils.h" -extern char *progname; +/*------------------------------------------------------------------------- +* typedefs +*------------------------------------------------------------------------- +*/ +typedef struct named_dt_t { + haddr_t addr_in; /* Address of the named dtype in the in file */ + hid_t id_out; /* Open identifier for the dtype in the out file */ + struct named_dt_t *next; /* Next dtype */ +} named_dt_t; +/*------------------------------------------------------------------------- +* globals +*------------------------------------------------------------------------- +*/ +extern char *progname; /*------------------------------------------------------------------------- - * macros - *------------------------------------------------------------------------- - */ +* macros +*------------------------------------------------------------------------- +*/ #define USERBLOCK_XFER_SIZE 512 /* size of buffer/# of bytes to xfer at a time when copying userblock */ /*------------------------------------------------------------------------- - * local functions - *------------------------------------------------------------------------- - */ +* local functions +*------------------------------------------------------------------------- +*/ static void print_dataset_info(hid_t dcpl_id,char *objname,double per, int pr); static int do_copy_objects(hid_t fidin,hid_t fidout,trav_table_t *travt,pack_opt_t *options); -static int copy_attr(hid_t loc_in,hid_t loc_out,pack_opt_t *options); +static int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, + trav_table_t *travt, pack_opt_t *options); +static hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, + trav_table_t *travt, pack_opt_t *options); +static int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err); static int copy_user_block(const char *infile, const char *outfile, hsize_t size); #if defined (H5REPACK_DEBUG_USER_BLOCK) static void print_user_block(const char *filename, hid_t fid); #endif /*------------------------------------------------------------------------- - * Function: copy_objects - * - * Purpose: duplicate all HDF5 objects in the file - * - * Return: 0, ok, -1 no - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October, 23, 2003 - * - * Modification: - * Peter Cao, June 13, 2007 - * Add "-L, --latest" and other options to pack a file with the latest file format - * - * Peter Cao, September 25, 2007 - * Copy user block when repacking a file - * - * Pedro Vicente, August 20, 2008 - * Add a user block to file if requested - * - *------------------------------------------------------------------------- - */ +* Function: copy_objects +* +* Purpose: duplicate all HDF5 objects in the file +* +* Return: 0, ok, -1 no +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: October, 23, 2003 +* +* Modification: +* Peter Cao, June 13, 2007 +* Add "-L, --latest" and other options to pack a file with the latest file format +* +* Peter Cao, September 25, 2007 +* Copy user block when repacking a file +* +* Pedro Vicente, August 20, 2008 +* Add a user block to file if requested +* +*------------------------------------------------------------------------- +*/ int copy_objects(const char* fnamein, const char* fnameout, @@ -90,19 +107,19 @@ int copy_objects(const char* fnamein, /* get user block size */ { hid_t fcpl_in; /* file creation property list ID for input file */ - + if((fcpl_in = H5Fget_create_plist(fidin)) < 0) { error_msg(progname, "failed to retrieve file creation property list\n"); goto out; } - + if(H5Pget_userblock(fcpl_in, &ub_size) < 0) { error_msg(progname, "failed to retrieve userblock size\n"); goto out; } - + if(H5Pclose(fcpl_in) < 0) { error_msg(progname, "failed to close property list\n"); @@ -147,25 +164,27 @@ int copy_objects(const char* fnamein, { switch(i) { - case 0: - mesg_type_flags[nindex] = H5O_SHMESG_SDSPACE_FLAG; - break; - - case 1: - mesg_type_flags[nindex] = H5O_SHMESG_DTYPE_FLAG; - break; - - case 2: - mesg_type_flags[nindex] = H5O_SHMESG_FILL_FLAG; - break; - - case 3: - mesg_type_flags[nindex] = H5O_SHMESG_PLINE_FLAG; - break; - - case 4: - mesg_type_flags[nindex] = H5O_SHMESG_ATTR_FLAG; - break; + case 0: + mesg_type_flags[nindex] = H5O_SHMESG_SDSPACE_FLAG; + break; + + case 1: + mesg_type_flags[nindex] = H5O_SHMESG_DTYPE_FLAG; + break; + + case 2: + mesg_type_flags[nindex] = H5O_SHMESG_FILL_FLAG; + break; + + case 3: + mesg_type_flags[nindex] = H5O_SHMESG_PLINE_FLAG; + break; + + case 4: + mesg_type_flags[nindex] = H5O_SHMESG_ATTR_FLAG; + break; + default: + break; } /* end switch */ min_mesg_sizes[nindex] = (unsigned)options->msg_size[i]; @@ -205,8 +224,8 @@ int copy_objects(const char* fnamein, } /* end if */ } /* end if */ } /* end if */ - - + + #if defined (H5REPACK_DEBUG_USER_BLOCK) @@ -230,30 +249,30 @@ int copy_objects(const char* fnamein, error_msg(progname, "failed to set userblock size\n"); goto out; } - + } - + else { - + /* create a file creation property list */ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { error_msg(progname, "fail to create a file creation property list\n"); goto out; } - + /* set user block size */ if(H5Pset_userblock(fcpl, options->ublock_size) < 0) { error_msg(progname, "failed to set userblock size\n"); goto out; } - + } - - - + + + } @@ -262,39 +281,39 @@ int copy_objects(const char* fnamein, *------------------------------------------------------------------------- */ - + if ( options->alignment > 0 ) { /* either use the FAPL already created or create a new one */ if (fapl != H5P_DEFAULT) { - + if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) { error_msg(progname, "failed to set alignment\n"); goto out; } - + } - + else { - + /* create a file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { error_msg(progname, "Could not create file access property list\n"); goto out; } - + if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) { error_msg(progname, "failed to set alignment\n"); goto out; } - + } - + } @@ -303,18 +322,18 @@ int copy_objects(const char* fnamein, *------------------------------------------------------------------------- */ - + if(options->verbose) printf("Making file <%s>...\n",fnameout); - - + + if((fidout = H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl)) < 0) { error_msg(progname, "<%s>: Could not create file\n", fnameout ); goto out; } - + /*------------------------------------------------------------------------- * write a new user block if requested *------------------------------------------------------------------------- @@ -325,11 +344,11 @@ int copy_objects(const char* fnamein, { error_msg(progname, "Could not copy user block. Exiting...\n"); goto out; - + } } - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * get list of objects *------------------------------------------------------------------------- */ @@ -375,7 +394,7 @@ int copy_objects(const char* fnamein, H5Fclose(fidin); H5Fclose(fidout); - + /* free table */ trav_table_free(travt); travt = NULL; @@ -391,7 +410,7 @@ int copy_objects(const char* fnamein, { error_msg(progname, "Could not copy user block. Exiting...\n"); goto out; - + } } @@ -417,74 +436,74 @@ out: } /*------------------------------------------------------------------------- - * Function: do_copy_objects - * - * Purpose: duplicate all HDF5 objects in the file - * - * Return: 0, ok, -1 no - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October, 23, 2003 - * - * Modifications: - * - * July 2004: Introduced the extra EC or NN option for SZIP - * - * December 2004: Added a check for H5Dcreate; if the dataset cannot be created - * with the requested filter, use the input one - * - * October 2006: Read/write using the file type by default. - * - * October 2006: Read by hyperslabs for big datasets. - * - * A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done - * i.e., if the memory needed to read a dataset is greater than this limit, - * then hyperslab I/O is done instead of one operation I/O - * For each dataset, the memory needed is calculated according to - * - * memory needed = number of elements * size of each element - * - * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations - * are done - * - * H5Dread( input_dataset1 ) - * H5Dread( input_dataset2 ) - * - * with all elements in the datasets selected. If the memory needed is greater than - * H5TOOLS_MALLOCSIZE, then the following operations are done instead: - * - * a strip mine is defined for each dimension k (a strip mine is defined as a - * hyperslab whose size is memory manageable) according to the formula - * - * (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type) - * - * where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures - * that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip - * mine size k is simply defined as its dimension k, but for larger datasets the - * hyperslab size is still memory manageable. - * a cycle is done until the number of elements in the dataset is reached. In each - * iteration, two parameters are defined for the function H5Sselect_hyperslab, - * the start and size of each hyperslab, according to - * - * (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k]) - * - * where hyperslab_offset [k] is initially set to zero, and later incremented in - * hyperslab_size[k] offsets. The reason for the operation - * - * dimension[k] - hyperslab_offset[k] - * - * in (2) is that, when using the strip mine size, it assures that the "remaining" part - * of the dataset that does not fill an entire strip mine is processed. - * - * November 2006: Use H5Ocopy in the copy of objects. The logic for using - * H5Ocopy or not is if a change of filters or layout is requested by the user - * then use read/write else use H5Ocopy. - * - * May, 1, 2008: Add a printing of the compression ratio of old size / new size - * - *------------------------------------------------------------------------- - */ +* Function: do_copy_objects +* +* Purpose: duplicate all HDF5 objects in the file +* +* Return: 0, ok, -1 no +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: October, 23, 2003 +* +* Modifications: +* +* July 2004: Introduced the extra EC or NN option for SZIP +* +* December 2004: Added a check for H5Dcreate; if the dataset cannot be created +* with the requested filter, use the input one +* +* October 2006: Read/write using the file type by default. +* +* October 2006: Read by hyperslabs for big datasets. +* +* A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done +* i.e., if the memory needed to read a dataset is greater than this limit, +* then hyperslab I/O is done instead of one operation I/O +* For each dataset, the memory needed is calculated according to +* +* memory needed = number of elements * size of each element +* +* if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations +* are done +* +* H5Dread( input_dataset1 ) +* H5Dread( input_dataset2 ) +* +* with all elements in the datasets selected. If the memory needed is greater than +* H5TOOLS_MALLOCSIZE, then the following operations are done instead: +* +* a strip mine is defined for each dimension k (a strip mine is defined as a +* hyperslab whose size is memory manageable) according to the formula +* +* (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type) +* +* where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures +* that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip +* mine size k is simply defined as its dimension k, but for larger datasets the +* hyperslab size is still memory manageable. +* a cycle is done until the number of elements in the dataset is reached. In each +* iteration, two parameters are defined for the function H5Sselect_hyperslab, +* the start and size of each hyperslab, according to +* +* (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k]) +* +* where hyperslab_offset [k] is initially set to zero, and later incremented in +* hyperslab_size[k] offsets. The reason for the operation +* +* dimension[k] - hyperslab_offset[k] +* +* in (2) is that, when using the strip mine size, it assures that the "remaining" part +* of the dataset that does not fill an entire strip mine is processed. +* +* November 2006: Use H5Ocopy in the copy of objects. The logic for using +* H5Ocopy or not is if a change of filters or layout is requested by the user +* then use read/write else use H5Ocopy. +* +* May, 1, 2008: Add a printing of the compression ratio of old size / new size +* +*------------------------------------------------------------------------- +*/ int do_copy_objects(hid_t fidin, hid_t fidout, @@ -495,7 +514,8 @@ int do_copy_objects(hid_t fidin, hid_t grp_out=-1; /* group ID */ hid_t dset_in=-1; /* read dataset ID */ hid_t dset_out=-1; /* write dataset ID */ - hid_t gcpl_id=-1; /* group creation property list */ + hid_t gcpl_in=-1; /* group creation property list */ + hid_t gcpl_out=-1; /* group creation property list */ hid_t type_in=-1; /* named type ID */ hid_t type_out=-1; /* named type ID */ hid_t dcpl_id=-1; /* dataset creation property list ID */ @@ -503,6 +523,7 @@ int do_copy_objects(hid_t fidin, hid_t f_space_id=-1; /* file space ID */ hid_t ftype_id=-1; /* file type ID */ hid_t wtype_id=-1; /* read/write type ID */ + named_dt_t *named_dt_head=NULL; /* Pointer to the stack of named datatypes copied */ size_t msize; /* size of type */ hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ @@ -515,9 +536,11 @@ int do_copy_objects(hid_t fidin, void *sm_buf=NULL; /* buffer for raw data */ int has_filter; /* current object has a filter */ int req_filter; /* there was a request for a filter */ + unsigned crt_order_flags; /* group creation order flag */ unsigned i; unsigned u; int is_ref=0; + htri_t is_named; /*------------------------------------------------------------------------- * copy the suppplied object list @@ -537,506 +560,548 @@ int do_copy_objects(hid_t fidin, buf = NULL; switch ( travt->objs[i].type ) { + + case H5TRAV_TYPE_UNKNOWN: + assert(0); + break; /*------------------------------------------------------------------------- - * H5TRAV_TYPE_GROUP - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_GROUP: - if (options->verbose) - printf(FORMAT_OBJ,"group",travt->objs[i].name ); + * H5TRAV_TYPE_GROUP + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_GROUP: - /*------------------------------------------------------------------------- - * the root is a special case, we get an ID for the root group - * and copy its attributes using that ID - *------------------------------------------------------------------------- - */ - if(HDstrcmp(travt->objs[i].name, "/") == 0) - { - if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0) - goto error; - } - else if (options->grp_compact>0 || options->grp_indexed>0) - { - /* Set up group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) - goto error; + if (options->verbose) + { + printf(FORMAT_OBJ,"group",travt->objs[i].name ); + } - if(H5Pset_link_phase_change(gcpl_id, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0) - goto error; + /* open input group */ + if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + goto error; - if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto error; - } - else - { - if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - } + /* get input group creation property list */ + if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) + goto error; - if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + /* query and set the group creation properties */ + if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) + goto error; - /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ - if(copy_attr(grp_in,grp_out,options) < 0) + /* set up group creation property list */ + if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0) + goto error; + + if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0) + goto error; + + + /*------------------------------------------------------------------------- + * the root is a special case, we get an ID for the root group + * and copy its attributes using that ID + *------------------------------------------------------------------------- + */ + if(HDstrcmp(travt->objs[i].name, "/") == 0) + { + if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0) goto error; + } + + else + { - if(gcpl_id > 0) { - if(H5Pclose(gcpl_id) < 0) + if (options->grp_compact>0 || options->grp_indexed>0) + { + if(H5Pset_link_phase_change(gcpl_out, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0) goto error; } - if(H5Gclose(grp_out) < 0) - goto error; - if(H5Gclose(grp_in) < 0) + + if((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0) goto error; - break; + } + + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if(copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0) + goto error; + + + if(H5Pclose(gcpl_out) < 0) + goto error; + if(H5Pclose(gcpl_in) < 0) + goto error; + if(H5Gclose(grp_out) < 0) + goto error; + if(H5Gclose(grp_in) < 0) + goto error; + + break; /*------------------------------------------------------------------------- - * H5TRAV_TYPE_DATASET - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_DATASET: + * H5TRAV_TYPE_DATASET + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_DATASET: + + has_filter = 0; + req_filter = 0; - has_filter = 0; - req_filter = 0; + /* check if global filters were requested */ + if ( options->n_filter_g ) + req_filter = 1; - /* check if global filters were requested */ - if ( options->n_filter_g ) - req_filter = 1; + /* check if filters were requested for individual objects */ + for( u = 0; u < options->op_tbl->nelems; u++) + { + int k; - /* check if filters were requested for individual objects */ - for( u = 0; u < options->op_tbl->nelems; u++) + for( k = 0; k < options->op_tbl->objs[u].nfilters; k++) { - int k; - - for( k = 0; k < options->op_tbl->objs[u].nfilters; k++) + if ( options->op_tbl->objs[u].filter->filtn > 0 ) { - if ( options->op_tbl->objs[u].filter->filtn > 0 ) - { - - req_filter = 1; - - } - + + req_filter = 1; + } + } + } + + /* early detection of references */ + if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + goto error; + if((ftype_id = H5Dget_type(dset_in)) < 0) + goto error; + if(H5T_REFERENCE == H5Tget_class(ftype_id)) + is_ref = 1; + + /* Check if the datatype is committed */ + if((is_named = H5Tcommitted(ftype_id)) < 0) + goto error; + if(is_named) + if((wtype_id = copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0) + goto error; + + if(H5Tclose(ftype_id) < 0) + goto error; + if(H5Dclose(dset_in) < 0) + goto error; + + + /*------------------------------------------------------------------------- + * check if we should use H5Ocopy or not + * if there is a request for filters/layout, we read/write the object + * otherwise we do a copy using H5Ocopy + *------------------------------------------------------------------------- + */ + if ( options->op_tbl->nelems || + options->all_filter == 1 || + options->all_layout == 1 || + is_ref || + is_named) + { + + int j; - /* early detection of references */ if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) goto error; + if((f_space_id = H5Dget_space(dset_in)) < 0) + goto error; if((ftype_id = H5Dget_type(dset_in)) < 0) goto error; - if(H5T_REFERENCE == H5Tget_class(ftype_id)) - is_ref = 1; - if(H5Tclose(ftype_id) < 0) + if((dcpl_id = H5Dget_create_plist(dset_in)) < 0) goto error; - if(H5Dclose(dset_in) < 0) + if((dcpl_out = H5Pcopy(dcpl_id)) < 0) goto error; - - - /*------------------------------------------------------------------------- - * check if we should use H5Ocopy or not - * if there is a request for filters/layout, we read/write the object - * otherwise we do a copy using H5Ocopy - *------------------------------------------------------------------------- - */ - if ( options->op_tbl->nelems || - options->all_filter == 1 || - options->all_layout == 1 || - is_ref) + if((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) + goto error; + HDmemset(dims, 0, sizeof dims); + if(H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) + goto error; + nelmts = 1; + for ( j = 0; j < rank; j++) { - - int j; - - if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; - if((f_space_id = H5Dget_space(dset_in)) < 0) - goto error; - if((ftype_id = H5Dget_type(dset_in)) < 0) - goto error; - if((dcpl_id = H5Dget_create_plist(dset_in)) < 0) - goto error; - if((dcpl_out = H5Pcopy(dcpl_id)) < 0) - goto error; - if((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) - goto error; - HDmemset(dims, 0, sizeof dims); - if(H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) - goto error; - nelmts = 1; - for ( j = 0; j < rank; j++) - { - nelmts *= dims[j]; - } + nelmts *= dims[j]; + } + /* wtype_id will have already been set if using a named dtype */ + if(!is_named) { if(options->use_native == 1) wtype_id = h5tools_get_native_type(ftype_id); else - wtype_id = H5Tcopy(ftype_id); + wtype_id = H5Tcopy(ftype_id); + } /* end if */ + + if((msize = H5Tget_size(wtype_id)) == 0) + goto error; + + /*------------------------------------------------------------------------- + * check if the dataset creation property list has filters that + * are not registered in the current configuration + * 1) the external filters GZIP and SZIP might not be available + * 2) the internal filters might be turned off + *------------------------------------------------------------------------- + */ + if (h5tools_canreadf((travt->objs[i].name),dcpl_id)==1) + { + apply_s=1; + apply_f=1; - if((msize = H5Tget_size(wtype_id)) == 0) - goto error; - /*------------------------------------------------------------------------- - * check if the dataset creation property list has filters that - * are not registered in the current configuration - * 1) the external filters GZIP and SZIP might not be available - * 2) the internal filters might be turned off - *------------------------------------------------------------------------- - */ - if (h5tools_canreadf((travt->objs[i].name),dcpl_id)==1) + * references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + * in a second traversal of the output file + *------------------------------------------------------------------------- + */ + if (H5T_REFERENCE!=H5Tget_class(wtype_id)) { - apply_s=1; - apply_f=1; + /* get the storage size of the input dataset */ + dsize_in=H5Dget_storage_size(dset_in); + + /* check for datasets too small */ + if (nelmts*msize < options->min_comp ) + apply_s=0; + + /* apply the filter */ + if (apply_s) + { + if (apply_filters(travt->objs[i].name, + rank, + dims, + msize, + dcpl_out, + options, + &has_filter) < 0) + goto error; + } /*------------------------------------------------------------------------- - * references are a special case - * we cannot just copy the buffers, but instead we recreate the reference - * in a second traversal of the output file + * create the output dataset; + * disable error checking in case the dataset cannot be created with the + * modified dcpl; in that case use the original instead *------------------------------------------------------------------------- */ - if (H5T_REFERENCE!=H5Tget_class(wtype_id)) + H5E_BEGIN_TRY { + dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); + } H5E_END_TRY; + + if(dset_out == FAIL) { - /* get the storage size of the input dataset */ - dsize_in=H5Dget_storage_size(dset_in); + if(options->verbose) + printf(" warning: could not create dataset <%s>. Applying original settings\n", + travt->objs[i].name); - /* check for datasets too small */ - if (nelmts*msize < options->min_comp ) - apply_s=0; + if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + goto error; + apply_f = 0; + } - /* apply the filter */ - if (apply_s) - { - if (apply_filters(travt->objs[i].name, - rank, - dims, - msize, - dcpl_out, - options, - &has_filter) < 0) - goto error; - } + /*------------------------------------------------------------------------- + * read/write + *------------------------------------------------------------------------- + */ + if (nelmts) + { + size_t need = (size_t)(nelmts*msize); /* bytes needed */ + if ( need < H5TOOLS_MALLOCSIZE ) + buf = HDmalloc(need); - /*------------------------------------------------------------------------- - * create the output dataset; - * disable error checking in case the dataset cannot be created with the - * modified dcpl; in that case use the original instead - *------------------------------------------------------------------------- - */ - H5E_BEGIN_TRY { - dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); - } H5E_END_TRY; - - if(dset_out == FAIL) + if (buf != NULL ) { - if(options->verbose) - printf(" warning: could not create dataset <%s>. Applying original settings\n", - travt->objs[i].name); - - if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + if (H5Dread(dset_in,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) goto error; - apply_f = 0; - } + if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) + goto error; + } - /*------------------------------------------------------------------------- - * read/write - *------------------------------------------------------------------------- - */ - if (nelmts) + else /* possibly not enough memory, read/write by hyperslabs */ { - size_t need = (size_t)(nelmts*msize); /* bytes needed */ - if ( need < H5TOOLS_MALLOCSIZE ) - buf = HDmalloc(need); + size_t p_type_nbytes = msize; /*size of memory type */ + hsize_t p_nelmts = nelmts; /*total selected elmts */ + hsize_t elmtno; /*counter */ + int carry; /*counter carry value */ + unsigned int vl_data = 0; /*contains VL datatypes */ + + /* stripmine info */ + hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ + hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nelmts; /*elements per stripmine*/ + hid_t sm_space; /*stripmine data space */ + + /* hyperslab info */ + hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ + hsize_t hs_nelmts; /*elements in request */ + hsize_t zero[8]; /*vector of zeros */ + int k; + + /* check if we have VL data in the dataset's datatype */ + if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE) + vl_data = TRUE; + + /* + * determine the strip mine size and allocate a buffer. The strip mine is + * a hyperslab whose size is manageable. + */ + sm_nbytes = p_type_nbytes; - if (buf != NULL ) + for (k = rank; k > 0; --k) { - if (H5Dread(dset_in,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) - goto error; - if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) - goto error; - } + hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; + if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ + size = 1; + sm_size[k - 1] = MIN(dims[k - 1], size); + sm_nbytes *= sm_size[k - 1]; + assert(sm_nbytes > 0); + } + sm_buf = HDmalloc((size_t)sm_nbytes); + + sm_nelmts = sm_nbytes / p_type_nbytes; + sm_space = H5Screate_simple(1, &sm_nelmts, NULL); + + /* the stripmine loop */ + memset(hs_offset, 0, sizeof hs_offset); + memset(zero, 0, sizeof zero); - else /* possibly not enough memory, read/write by hyperslabs */ + for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { - size_t p_type_nbytes = msize; /*size of memory type */ - hsize_t p_nelmts = nelmts; /*total selected elmts */ - hsize_t elmtno; /*counter */ - int carry; /*counter carry value */ - unsigned int vl_data = 0; /*contains VL datatypes */ - - /* stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ - hsize_t sm_nelmts; /*elements per stripmine*/ - hid_t sm_space; /*stripmine data space */ - - /* hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ - hsize_t hs_nelmts; /*elements in request */ - hsize_t zero[8]; /*vector of zeros */ - int k; - - /* check if we have VL data in the dataset's datatype */ - if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE) - vl_data = TRUE; - - /* - * determine the strip mine size and allocate a buffer. The strip mine is - * a hyperslab whose size is manageable. - */ - sm_nbytes = p_type_nbytes; - - for (k = rank; k > 0; --k) { - sm_size[k - 1] = MIN(dims[k - 1], H5TOOLS_BUFSIZE / sm_nbytes); - sm_nbytes *= sm_size[k - 1]; - assert(sm_nbytes > 0); - } - sm_buf = HDmalloc((size_t)sm_nbytes); - - sm_nelmts = sm_nbytes / p_type_nbytes; - sm_space = H5Screate_simple(1, &sm_nelmts, NULL); - - /* the stripmine loop */ - memset(hs_offset, 0, sizeof hs_offset); - memset(zero, 0, sizeof zero); - - for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) + /* calculate the hyperslab size */ + if (rank > 0) { - /* calculate the hyperslab size */ - if (rank > 0) + for (k = 0, hs_nelmts = 1; k < rank; k++) { - for (k = 0, hs_nelmts = 1; k < rank; k++) - { - hs_size[k] = MIN(dims[k] - hs_offset[k], sm_size[k]); - hs_nelmts *= hs_size[k]; - } - - if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - goto error; - if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) - goto error; - } - else - { - H5Sselect_all(f_space_id); - H5Sselect_all(sm_space); - hs_nelmts = 1; - } /* rank */ + hs_size[k] = MIN(dims[k] - hs_offset[k], sm_size[k]); + hs_nelmts *= hs_size[k]; + } - /* read/write */ - if (H5Dread(dset_in, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0) + if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) goto error; - if (H5Dwrite(dset_out, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0) + if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) goto error; + } + else + { + H5Sselect_all(f_space_id); + H5Sselect_all(sm_space); + hs_nelmts = 1; + } /* rank */ + + /* read/write */ + if (H5Dread(dset_in, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0) + goto error; + if (H5Dwrite(dset_out, wtype_id, sm_space, f_space_id, H5P_DEFAULT, sm_buf) < 0) + goto error; - /* reclaim any VL memory, if necessary */ - if(vl_data) - H5Dvlen_reclaim(wtype_id, sm_space, H5P_DEFAULT, sm_buf); + /* reclaim any VL memory, if necessary */ + if(vl_data) + H5Dvlen_reclaim(wtype_id, sm_space, H5P_DEFAULT, sm_buf); - /* calculate the next hyperslab offset */ - for (k = rank, carry = 1; k > 0 && carry; --k) - { - hs_offset[k - 1] += hs_size[k - 1]; - if (hs_offset[k - 1] == dims[k - 1]) - hs_offset[k - 1] = 0; - else - carry = 0; - } /* k */ - } /* elmtno */ - - H5Sclose(sm_space); - /* free */ - if (sm_buf!=NULL) + /* calculate the next hyperslab offset */ + for (k = rank, carry = 1; k > 0 && carry; --k) { - HDfree(sm_buf); - sm_buf=NULL; - } - } /* hyperslab read */ - }/*nelmts*/ - - /*------------------------------------------------------------------------- - * amount of compression used - *------------------------------------------------------------------------- - */ - if (options->verbose) + hs_offset[k - 1] += hs_size[k - 1]; + if (hs_offset[k - 1] == dims[k - 1]) + hs_offset[k - 1] = 0; + else + carry = 0; + } /* k */ + } /* elmtno */ + + H5Sclose(sm_space); + /* free */ + if (sm_buf!=NULL) + { + HDfree(sm_buf); + sm_buf=NULL; + } + } /* hyperslab read */ + }/*nelmts*/ + + /*------------------------------------------------------------------------- + * amount of compression used + *------------------------------------------------------------------------- + */ + if (options->verbose) + { + double ratio=0; + + /* only print the compression ration if there was a filter request */ + if (apply_s && apply_f && req_filter) { - double ratio=0; + hssize_t a, b; - /* only print the compression ration if there was a filter request */ - if (apply_s && apply_f && req_filter) - { - hssize_t a, b; + /* get the storage size of the output dataset */ + dsize_out=H5Dget_storage_size(dset_out); - /* get the storage size of the output dataset */ - dsize_out=H5Dget_storage_size(dset_out); + /* compression ratio = uncompressed size / compressed size */ - /* compression ratio = uncompressed size / compressed size */ + a = dsize_in; b = dsize_out; + if (b!=0) + ratio = (double) a / (double) b; - a = dsize_in; b = dsize_out; - if (b!=0) - ratio = (double) a / (double) b; - - print_dataset_info(dcpl_out,travt->objs[i].name,ratio,1); - } - else - print_dataset_info(dcpl_id,travt->objs[i].name,ratio,0); + print_dataset_info(dcpl_out,travt->objs[i].name,ratio,1); + } + else + print_dataset_info(dcpl_id,travt->objs[i].name,ratio,0); - /* print a message that the filter was not applied - (in case there was a filter) - */ - if ( has_filter && apply_s == 0 ) - printf(" \n", - travt->objs[i].name, - (int)options->min_comp); - - if ( has_filter && apply_f == 0 ) - printf(" \n", - travt->objs[i].name); - - } /* verbose */ - - /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ - if (copy_attr(dset_in,dset_out,options) < 0) - goto error; + /* print a message that the filter was not applied + (in case there was a filter) + */ + if ( has_filter && apply_s == 0 ) + printf(" \n", + travt->objs[i].name, + (int)options->min_comp); - /*close */ - if (H5Dclose(dset_out) < 0) - goto error; + if ( has_filter && apply_f == 0 ) + printf(" \n", + travt->objs[i].name); - }/*!H5T_REFERENCE*/ - }/*h5tools_canreadf*/ + } /* verbose */ + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + goto error; + + /*close */ + if (H5Dclose(dset_out) < 0) + goto error; + + }/*!H5T_REFERENCE*/ + }/*h5tools_canreadf*/ - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if (H5Tclose(ftype_id) < 0) - goto error; - if (H5Tclose(wtype_id) < 0) - goto error; - if (H5Pclose(dcpl_id) < 0) - goto error; - if (H5Pclose(dcpl_out) < 0) - goto error; - if (H5Sclose(f_space_id) < 0) - goto error; - if (H5Dclose(dset_in) < 0) - goto error; - } /*------------------------------------------------------------------------- - * we do not have request for filter/chunking use H5Ocopy instead - *------------------------------------------------------------------------- - */ - else - { - hid_t pid; + * close + *------------------------------------------------------------------------- + */ + if (H5Tclose(ftype_id) < 0) + goto error; + if (H5Tclose(wtype_id) < 0) + goto error; + if (H5Pclose(dcpl_id) < 0) + goto error; + if (H5Pclose(dcpl_out) < 0) + goto error; + if (H5Sclose(f_space_id) < 0) + goto error; + if (H5Dclose(dset_in) < 0) + goto error; - /* create property to pass copy options */ - if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) - goto error; + } + /*------------------------------------------------------------------------- + * we do not have request for filter/chunking use H5Ocopy instead + *------------------------------------------------------------------------- + */ + else + { + hid_t pid; - /* set options for object copy */ - if(H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) - goto error; + /* create property to pass copy options */ + if ( (pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + goto error; - /*------------------------------------------------------------------------- - * do the copy - *------------------------------------------------------------------------- - */ - - if(H5Ocopy(fidin, /* Source file or group identifier */ - travt->objs[i].name, /* Name of the source object to be copied */ - fidout, /* Destination file or group identifier */ - travt->objs[i].name, /* Name of the destination object */ - pid, /* Properties which apply to the copy */ - H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ - goto error; + /* set options for object copy */ + if(H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) + goto error; - /* close property */ - if(H5Pclose(pid) < 0) - goto error; + /*------------------------------------------------------------------------- + * do the copy + *------------------------------------------------------------------------- + */ + + if(H5Ocopy(fidin, /* Source file or group identifier */ + travt->objs[i].name, /* Name of the source object to be copied */ + fidout, /* Destination file or group identifier */ + travt->objs[i].name, /* Name of the destination object */ + pid, /* Properties which apply to the copy */ + H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ + goto error; + /* close property */ + if(H5Pclose(pid) < 0) + goto error; + + + /*------------------------------------------------------------------------- + * copy attrs manually + *------------------------------------------------------------------------- + */ + if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + goto error; + if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + goto error; + if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + goto error; + if(H5Dclose(dset_in) < 0) + goto error; + if(H5Dclose(dset_out) < 0) + goto error; - /*------------------------------------------------------------------------- - * copy attrs manually - *------------------------------------------------------------------------- - */ - if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; - if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; - if(copy_attr(dset_in, dset_out, options) < 0) - goto error; - if(H5Dclose(dset_in) < 0) - goto error; - if(H5Dclose(dset_out) < 0) - goto error; + if (options->verbose) + printf(FORMAT_OBJ,"dset",travt->objs[i].name ); - if (options->verbose) - printf(FORMAT_OBJ,"dset",travt->objs[i].name ); - - } /* end do we have request for filter/chunking */ + } /* end do we have request for filter/chunking */ - break; + break; /*------------------------------------------------------------------------- - * H5TRAV_TYPE_NAMED_DATATYPE - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_NAMED_DATATYPE: + * H5TRAV_TYPE_NAMED_DATATYPE + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_NAMED_DATATYPE: - if(options->verbose) - printf(FORMAT_OBJ, "type", travt->objs[i].name); + if(options->verbose) + printf(FORMAT_OBJ, "type", travt->objs[i].name); - if((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + if((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + goto error; - if((type_out = H5Tcopy(type_in)) < 0) - goto error; + /* Copy the datatype anonymously */ + if((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, + travt, options)) < 0) + goto error; - if((H5Tcommit2(fidout, travt->objs[i].name, type_out, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + /* Link in to group structure */ + if(H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, + H5P_DEFAULT, H5P_DEFAULT) < 0) + goto error; - /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ - if(copy_attr(type_in, type_out, options) < 0) - goto error; + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if(copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0) + goto error; - if(H5Tclose(type_in) < 0) - goto error; - if(H5Tclose(type_out) < 0) - goto error; + if(H5Tclose(type_in) < 0) + goto error; + if(H5Tclose(type_out) < 0) + goto error; - - break; + + break; /*------------------------------------------------------------------------- - * H5TRAV_TYPE_LINK - * H5TRAV_TYPE_UDLINK - * - * Only handles external links; H5Lcopy will fail for other UD link types - * since we don't have creation or copy callbacks for them. - *------------------------------------------------------------------------- - */ - - case H5TRAV_TYPE_LINK: - case H5TRAV_TYPE_UDLINK: + * H5TRAV_TYPE_LINK + * H5TRAV_TYPE_UDLINK + * + * Only handles external links; H5Lcopy will fail for other UD link types + * since we don't have creation or copy callbacks for them. + *------------------------------------------------------------------------- + */ + + case H5TRAV_TYPE_LINK: + case H5TRAV_TYPE_UDLINK: { if(options->verbose) @@ -1051,8 +1116,8 @@ int do_copy_objects(hid_t fidin, } break; - default: - goto error; + default: + goto error; } /* switch */ /* free */ @@ -1064,6 +1129,9 @@ int do_copy_objects(hid_t fidin, } /* i */ + /* Finalize (link) the stack of named datatypes (if any) */ + named_datatype_free(&named_dt_head, 0); + return 0; error: @@ -1071,7 +1139,8 @@ error: H5Gclose(grp_in); H5Gclose(grp_out); H5Pclose(dcpl_id); - H5Pclose(gcpl_id); + H5Pclose(gcpl_in); + H5Pclose(gcpl_out); H5Sclose(f_space_id); H5Dclose(dset_in); H5Dclose(dset_out); @@ -1079,6 +1148,7 @@ error: H5Tclose(wtype_id); H5Tclose(type_in); H5Tclose(type_out); + named_datatype_free(&named_dt_head, 1); } H5E_END_TRY; /* free */ if (buf!=NULL) @@ -1090,24 +1160,26 @@ error: /*------------------------------------------------------------------------- - * Function: copy_attr - * - * Purpose: copy attributes located in LOC_IN, which is obtained either from - * loc_id = H5Gopen2( fid, name); - * loc_id = H5Dopen2( fid, name); - * loc_id = H5Topen2( fid, name); - * - * Return: 0, ok, -1 no - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October, 28, 2003 - * - *------------------------------------------------------------------------- - */ +* Function: copy_attr +* +* Purpose: copy attributes located in LOC_IN, which is obtained either from +* loc_id = H5Gopen2( fid, name); +* loc_id = H5Dopen2( fid, name); +* loc_id = H5Topen2( fid, name); +* +* Return: 0, ok, -1 no +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: October, 28, 2003 +* +*------------------------------------------------------------------------- +*/ int copy_attr(hid_t loc_in, hid_t loc_out, + named_dt_t **named_dt_head_p, + trav_table_t *travt, pack_opt_t *options ) { @@ -1120,76 +1192,101 @@ int copy_attr(hid_t loc_in, void *buf=NULL; /* data buffer */ hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ + htri_t is_named; /* Whether the datatype is named */ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ char name[255]; H5O_info_t oinfo; /* object info */ int j; unsigned u; - + if(H5Oget_info(loc_in, &oinfo) < 0) goto error; - - /*------------------------------------------------------------------------- + + /*------------------------------------------------------------------------- * copy all attributes *------------------------------------------------------------------------- */ - + for ( u = 0; u < (unsigned)oinfo.num_attrs; u++) { - + buf=NULL; - + /* open attribute */ if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - + /* get name */ if (H5Aget_name( attr_id, (size_t)255, name ) < 0) goto error; - + /* get the file datatype */ if ((ftype_id = H5Aget_type( attr_id )) < 0 ) goto error; - + + /* Check if the datatype is committed */ + if((is_named = H5Tcommitted(ftype_id)) < 0) + goto error; + if(is_named) { + hid_t fidout; + + /* Create out file id */ + if((fidout = H5Iget_file_id(loc_out)) < 0) + goto error; + + /* Copy named dt */ + if((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, + travt, options)) < 0) { + H5Fclose(fidout); + goto error; + } /* end if */ + + if(H5Fclose(fidout) < 0) + goto error; + } /* end if */ + /* get the dataspace handle */ if ((space_id = H5Aget_space( attr_id )) < 0 ) goto error; - + /* get dimensions */ if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 ) goto error; - + nelmts=1; for (j=0; juse_native==1) - wtype_id = h5tools_get_native_type(ftype_id); - else - wtype_id = H5Tcopy(ftype_id); - + + /* wtype_id will have already been set if using a named dtype */ + if(!is_named) { + if (options->use_native==1) + wtype_id = h5tools_get_native_type(ftype_id); + else + wtype_id = H5Tcopy(ftype_id); + } /* end if */ + if ((msize=H5Tget_size(wtype_id))==0) goto error; - - /*------------------------------------------------------------------------- + + /*------------------------------------------------------------------------- * object references are a special case * we cannot just copy the buffers, but instead we recreate the reference * this is done on a second sweep of the file that just copies * the referenced objects *------------------------------------------------------------------------- */ - + if (H5T_REFERENCE==H5Tget_class(wtype_id)) { ; } else { - /*------------------------------------------------------------------------- - * read to memory - *------------------------------------------------------------------------- - */ - + /*------------------------------------------------------------------------- + * read to memory + *------------------------------------------------------------------------- + */ + buf = (void *)HDmalloc((size_t)(nelmts * msize)); if(buf == NULL) { error_msg(progname, "cannot read into memory\n" ); @@ -1197,46 +1294,46 @@ int copy_attr(hid_t loc_in, } if(H5Aread(attr_id, wtype_id, buf) < 0) goto error; - - /*------------------------------------------------------------------------- + + /*------------------------------------------------------------------------- * copy *------------------------------------------------------------------------- */ - - if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + + if((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; if(H5Awrite(attr_out, wtype_id, buf) < 0) goto error; - + /*close*/ if(H5Aclose(attr_out) < 0) goto error; - - + + if(buf) free(buf); - + } /*H5T_REFERENCE*/ - - + + if(options->verbose) printf(FORMAT_OBJ_ATTR, "attr", name); - + /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - + * close + *------------------------------------------------------------------------- + */ + if (H5Tclose(ftype_id) < 0) goto error; if (H5Tclose(wtype_id) < 0) goto error; if (H5Sclose(space_id) < 0) goto error; if (H5Aclose(attr_id) < 0) goto error; - + } /* u */ - - + + return 0; - + error: H5E_BEGIN_TRY { H5Tclose(ftype_id); @@ -1251,15 +1348,13 @@ error: } - - /*------------------------------------------------------------------------- - * Function: print_dataset_info - * - * Purpose: print name, filters, percentage compression of a dataset - * - *------------------------------------------------------------------------- - */ +* Function: print_dataset_info +* +* Purpose: print name, filters, percentage compression of a dataset +* +*------------------------------------------------------------------------- +*/ static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, @@ -1276,27 +1371,27 @@ static void print_dataset_info(hid_t dcpl_id, size_t cd_nelmts; /* filter client number of values */ char f_objname[256]; /* filter objname */ int i; - - + + strcpy(strfilter,"\0"); - + /* get information about input filters */ if((nfilters = H5Pget_nfilters(dcpl_id)) < 0) return; - + for(i = 0; i < nfilters; i++) { cd_nelmts = NELMTS(cd_values); - + filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_objname), f_objname, NULL); - + switch(filtn) { default: break; - + case H5Z_FILTER_DEFLATE: strcat(strfilter,"GZIP "); - + #if defined (PRINT_DEBUG) { unsigned level=cd_values[0]; @@ -1305,10 +1400,10 @@ static void print_dataset_info(hid_t dcpl_id, } #endif break; - + case H5Z_FILTER_SZIP: strcat(strfilter,"SZIP "); - + #if defined (PRINT_DEBUG) { unsigned options_mask=cd_values[0]; /* from dcpl, not filt*/ @@ -1321,29 +1416,29 @@ static void print_dataset_info(hid_t dcpl_id, strcpy(temp,"NN) "); } strcat(strfilter,temp); - + #endif - + break; - + case H5Z_FILTER_SHUFFLE: strcat(strfilter,"SHUF "); break; - + case H5Z_FILTER_FLETCHER32: strcat(strfilter,"FLET "); break; - + case H5Z_FILTER_NBIT: strcat(strfilter,"NBIT "); break; - + case H5Z_FILTER_SCALEOFFSET: strcat(strfilter,"SCALEOFFSET "); break; } /* switch */ }/*i*/ - + if(!pr) printf(FORMAT_OBJ,"dset",objname ); else @@ -1357,19 +1452,152 @@ static void print_dataset_info(hid_t dcpl_id, } } + /*------------------------------------------------------------------------- - * Function: copy_user_block - * - * Purpose: copy user block from one file to another - * - * Return: 0, ok, -1 no - * - * Programmer: Peter Cao - * - * Date: October, 25, 2007 - * - *------------------------------------------------------------------------- - */ +* Function: copy_named_datatype +* +* Purpose: Copies the specified datatype anonymously, and returns an open +* id for that datatype in the output file. The first time this +* is called it scans every named datatype in travt into a +* private stack, afterwards it simply scans that stack. The id +* returned must be closed after it is no longer needed. +* named_datatype_free must be called before the program exits +* to free the stack. +* +* Programmer: Neil Fortner +* +* Date: April 14, 2009 +* +*------------------------------------------------------------------------- +*/ +static hid_t +copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) +{ + named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ + named_dt_t *dt_ret = NULL; /* Datatype to return */ + H5O_info_t oinfo; /* Object info of input dtype */ + hid_t ret_value = -1; /* The identifier of the named dtype in the out file */ + + if(H5Oget_info(type_in, &oinfo) < 0) + goto error; + + if(*named_dt_head_p) { + /* Stack already exists, search for the datatype */ + while(dt && dt->addr_in != oinfo.addr) + dt = dt->next; + + dt_ret = dt; + } else { + /* Create the stack */ + size_t i; + + for(i=0; inobjs; i++) + if(travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) { + /* Push onto the stack */ + if(NULL == (dt = (named_dt_t *) HDmalloc(sizeof(named_dt_t)))) + goto error; + dt->next = *named_dt_head_p; + *named_dt_head_p = dt; + + /* Update the address and id */ + dt->addr_in = travt->objs[i].objno; + dt->id_out = -1; + + /* Check if this type is the one requested */ + if(oinfo.addr == dt->addr_in) { + HDassert(!dt_ret); + dt_ret = dt; + } /* end if */ + } /* end if */ + } /* end else */ + + /* Handle the case that the requested datatype was not found. This is + * possible if the datatype was committed anonymously in the input file. */ + if(!dt_ret) { + /* Push the new datatype onto the stack */ + if(NULL == (dt_ret = (named_dt_t *) HDmalloc(sizeof(named_dt_t)))) + goto error; + dt_ret->next = *named_dt_head_p; + *named_dt_head_p = dt_ret; + + /* Update the address and id */ + dt_ret->addr_in = oinfo.addr; + dt_ret->id_out = -1; + } /* end if */ + + /* If the requested datatype does not yet exist in the output file, copy it + * anonymously */ + if(dt_ret->id_out < 0) { + if (options->use_native==1) + dt_ret->id_out = h5tools_get_native_type(type_in); + else + dt_ret->id_out = H5Tcopy(type_in); + if(dt_ret->id_out < 0) + goto error; + if(H5Tcommit_anon(fidout, dt_ret->id_out, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto error; + } /* end if */ + + /* Set return value */ + ret_value = dt_ret->id_out; + + /* Increment the ref count on id_out, because the calling function will try + * to close it */ + if(H5Iinc_ref(ret_value) < 0) + goto error; + + return(ret_value); + +error: + return(-1); +} /* end copy_named_datatype */ + + +/*------------------------------------------------------------------------- +* Function: named_datatype_free +* +* Purpose: Frees the stack of named datatypes. +* +* Programmer: Neil Fortner +* +* Date: April 14, 2009 +* +*------------------------------------------------------------------------- +*/ +static int +named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) +{ + named_dt_t *dt = *named_dt_head_p; + + while(dt) { + /* Pop the datatype off the stack and free it */ + if(H5Tclose(dt->id_out) < 0 && !ignore_err) + goto error; + dt = dt->next; + HDfree(*named_dt_head_p); + *named_dt_head_p = dt; + } /* end while */ + + return 0; + +error: + return -1; +} /* end named_datatype_free */ + + +/*------------------------------------------------------------------------- +* Function: copy_user_block +* +* Purpose: copy user block from one file to another +* +* Return: 0, ok, -1 no +* +* Programmer: Peter Cao +* +* Date: October, 25, 2007 +* +*------------------------------------------------------------------------- +*/ static int copy_user_block(const char *infile, const char *outfile, hsize_t size) { @@ -1444,18 +1672,18 @@ done: /*------------------------------------------------------------------------- - * Function: print_user_block - * - * Purpose: print user block - * - * Return: 0, ok, -1 no - * - * Programmer: Pedro Vicente - * - * Date: August, 20, 2008 - * - *------------------------------------------------------------------------- - */ +* Function: print_user_block +* +* Purpose: print user block +* +* Return: 0, ok, -1 no +* +* Programmer: Pedro Vicente +* +* Date: August, 20, 2008 +* +*------------------------------------------------------------------------- +*/ #if defined (H5REPACK_DEBUG_USER_BLOCK) static void print_user_block(const char *filename, hid_t fid) @@ -1472,25 +1700,25 @@ void print_user_block(const char *filename, hid_t fid) error_msg(progname, "failed to retrieve file creation property list\n"); goto done; } - + if(H5Pget_userblock(fcpl, &ub_size) < 0) { error_msg(progname, "failed to retrieve userblock size\n"); goto done; } - + if(H5Pclose(fcpl) < 0) { error_msg(progname, "failed to close property list\n"); goto done; } - + /* open file */ if((fh = HDopen(filename, O_RDONLY, 0)) < 0) { goto done; } - + size = ub_size; /* read file */ @@ -1518,7 +1746,7 @@ void print_user_block(const char *filename, hid_t fid) goto done; } - + /* update size of userblock left to transfer */ size -= nread; } @@ -1526,7 +1754,7 @@ void print_user_block(const char *filename, hid_t fid) done: if(fh > 0) HDclose(fh); - + return; } diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 5038cbb..00d7c66 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.c @@ -98,6 +98,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis for ( i=0; ichunk_g.chunk_lengths[i]; break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_NLAYOUTS: + break; default: break; }/*switch*/ @@ -112,6 +117,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis for ( i=0; iop_tbl->objs[idx].chunk.chunk_lengths[i]; break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_NLAYOUTS: + break; default: break; }/*switch*/ @@ -163,6 +173,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis for ( i=0; ichunk_g.chunk_lengths[i]; break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_NLAYOUTS: + break; default: break; }/*switch*/ @@ -296,14 +311,19 @@ int apply_filters(const char* name, /* object name from traverse list */ * determine the strip mine size. The strip mine is * a hyperslab whose size is manageable. */ + + sm_nbytes = msize; for ( i = rank; i > 0; --i) { - sm_size[i - 1] = MIN(dims[i - 1], H5TOOLS_BUFSIZE / sm_nbytes); + hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; + if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ + size = 1; + sm_size[i - 1] = MIN(dims[i - 1], size); sm_nbytes *= sm_size[i - 1]; assert(sm_nbytes > 0); - + } for ( i = 0; i < rank; i++) diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index d684da8..154d6e5 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -95,7 +95,7 @@ obj_list_t* parse_filter(const char *str, } n++; - obj_list = malloc(n*sizeof(obj_list_t)); + obj_list = (obj_list_t*) malloc(n*sizeof(obj_list_t)); if (obj_list==NULL) { error_msg(progname, "could not allocate object list\n"); @@ -446,6 +446,8 @@ obj_list_t* parse_filter(const char *str, exit(1); } break; + default: + break; }; @@ -514,7 +516,7 @@ obj_list_t* parse_layout(const char *str, } n++; - obj_list=malloc(n*sizeof(obj_list_t)); + obj_list = (obj_list_t*) malloc(n*sizeof(obj_list_t)); if (obj_list==NULL) { error_msg(progname, "could not allocate object list\n"); diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index 82e8250..cd725cd 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -74,7 +74,8 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ for(i = 0; i < travt->nobjs; i++) { - switch(travt->objs[i].type) { + switch(travt->objs[i].type) + { /*------------------------------------------------------------------------- * H5TRAV_TYPE_GROUP *------------------------------------------------------------------------- @@ -165,7 +166,7 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if(nelmts) { - buf = (void *)HDmalloc((unsigned)(nelmts * msize)); + buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); if(buf==NULL) { printf("cannot read into memory\n" ); goto error; @@ -173,7 +174,7 @@ int do_copy_refobjs(hid_t fidin, if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; - refbuf = HDcalloc((unsigned)nelmts, msize); + refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize); if(refbuf == NULL){ printf("cannot allocate memory\n" ); goto error; @@ -237,7 +238,7 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if(nelmts) { - buf = (void *)HDmalloc((unsigned)(nelmts * msize)); + buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize)); if(buf == NULL) { printf("cannot read into memory\n"); goto error; @@ -249,7 +250,7 @@ int do_copy_refobjs(hid_t fidin, * create output *------------------------------------------------------------------------- */ - refbuf = HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ + refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ if(refbuf == NULL) { printf("cannot allocate memory\n"); goto error; @@ -370,6 +371,10 @@ int do_copy_refobjs(hid_t fidin, /*nothing to do */ break; + case H5TRAV_TYPE_UNKNOWN: + case H5TRAV_TYPE_UDLINK: + goto error; + default: break; } /* end switch */ @@ -436,7 +441,8 @@ static int copy_refs_attr(hid_t loc_in, if(H5Oget_info(loc_in, &oinfo) < 0) goto error; - for(u = 0; u < (unsigned)oinfo.num_attrs; u++) { + for(u = 0; u < (unsigned)oinfo.num_attrs; u++) + { /*------------------------------------------------------------------------- * open *------------------------------------------------------------------------- @@ -482,7 +488,8 @@ static int copy_refs_attr(hid_t loc_in, * we cannot just copy the buffers, but instead we recreate the reference *------------------------------------------------------------------------- */ - if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { + if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) + { hid_t refobj_id; hobj_ref_t *refbuf = NULL; unsigned k; @@ -494,23 +501,28 @@ static int copy_refs_attr(hid_t loc_in, *------------------------------------------------------------------------- */ - if (nelmts) { - buf = (void *)HDmalloc((unsigned)(nelmts * msize)); - if(buf == NULL) { + if (nelmts) + { + buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); + if(buf == NULL) + { printf("cannot read into memory\n"); goto error; } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) goto error; - refbuf = HDcalloc((unsigned)nelmts, msize); - if(refbuf == NULL) { + refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize); + if(refbuf == NULL) + { printf( "cannot allocate memory\n" ); goto error; } /* end if */ - for(k = 0; k < nelmts; k++) { - H5E_BEGIN_TRY { + for(k = 0; k < nelmts; k++) + { + H5E_BEGIN_TRY + { if((refobj_id = H5Rdereference(attr_id, H5R_OBJECT, &buf[k])) < 0) goto error; } H5E_END_TRY; @@ -518,7 +530,8 @@ static int copy_refs_attr(hid_t loc_in, /* get the name. a valid name could only occur in the * second traversal of the file */ - if((refname = MapIdToName(refobj_id, travt)) != NULL) { + if((refname = MapIdToName(refobj_id, travt)) != NULL) + { /* create the reference */ if(H5Rcreate(&refbuf[k], fidout, refname, H5R_OBJECT, -1) < 0) goto error; @@ -552,7 +565,8 @@ static int copy_refs_attr(hid_t loc_in, * dataset region references *------------------------------------------------------------------------- */ - else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { + else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) + { hid_t refobj_id; hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ hdset_reg_ref_t *buf = NULL; /* output buffer */ @@ -563,9 +577,11 @@ static int copy_refs_attr(hid_t loc_in, * read input to memory *------------------------------------------------------------------------- */ - if(nelmts) { - buf = (void *)HDmalloc((unsigned)(nelmts * msize)); - if(buf == NULL) { + if(nelmts) + { + buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize)); + if(buf == NULL) + { printf( "cannot read into memory\n" ); goto error; } /* end if */ @@ -576,14 +592,17 @@ static int copy_refs_attr(hid_t loc_in, * create output *------------------------------------------------------------------------- */ - refbuf = HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ - if(refbuf == NULL) { + refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ + if(refbuf == NULL) + { printf( "cannot allocate memory\n" ); goto error; } /* end if */ - for(k = 0; k < nelmts; k++) { - H5E_BEGIN_TRY { + for(k = 0; k < nelmts; k++) + { + H5E_BEGIN_TRY + { if((refobj_id = H5Rdereference(attr_id, H5R_DATASET_REGION, &buf[k])) < 0) continue; } H5E_END_TRY; @@ -591,7 +610,8 @@ static int copy_refs_attr(hid_t loc_in, /* get the name. a valid name could only occur in the * second traversal of the file */ - if((refname = MapIdToName(refobj_id, travt)) != NULL) { + if((refname = MapIdToName(refobj_id, travt)) != NULL) + { hid_t region_id; /* region id of the referenced dataset */ if((region_id = H5Rget_region(attr_id, H5R_DATASET_REGION, &buf[k])) < 0) @@ -616,8 +636,10 @@ static int copy_refs_attr(hid_t loc_in, if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; if(nelmts) + { if(H5Awrite(attr_out, mtype_id, refbuf) < 0) goto error; + } if(H5Aclose(attr_out) < 0) goto error; @@ -670,8 +692,10 @@ static const char* MapIdToName(hid_t refobj_id, unsigned int i; /* linear search */ - for(i = 0; i < travt->nobjs; i++) { - if(travt->objs[i].type == H5O_TYPE_DATASET) { + for(i = 0; i < travt->nobjs; i++) + { + if(travt->objs[i].type == H5O_TYPE_DATASET) + { H5O_info_t ref_oinfo; /* Stat for the refobj id */ /* obtain information to identify the referenced object uniquely */ diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index a7454d6..92d758e 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -275,7 +275,7 @@ int has_layout(hid_t pid, } /*------------------------------------------------------------------------- - * Function: h5repack_cmpdcpl + * Function: h5repack_cmp_pl * * Purpose: compare 2 files for identical property lists of all objects * @@ -288,17 +288,20 @@ int has_layout(hid_t pid, *------------------------------------------------------------------------- */ -int h5repack_cmpdcpl(const char *fname1, +int h5repack_cmp_pl(const char *fname1, const char *fname2) { - hid_t fid1=-1; /* file ID */ - hid_t fid2=-1; /* file ID */ - hid_t dset1=-1; /* dataset ID */ - hid_t dset2=-1; /* dataset ID */ - hid_t dcpl1=-1; /* dataset creation property list ID */ - hid_t dcpl2=-1; /* dataset creation property list ID */ - trav_table_t *travt1=NULL; - trav_table_t *travt2=NULL; + hid_t fid1=-1; /* file ID */ + hid_t fid2=-1; /* file ID */ + hid_t dset1=-1; /* dataset ID */ + hid_t dset2=-1; /* dataset ID */ + hid_t gid=-1; /* group ID */ + hid_t dcpl1=-1; /* dataset creation property list ID */ + hid_t dcpl2=-1; /* dataset creation property list ID */ + hid_t gcplid=-1; /* group creation property list */ + unsigned crt_order_flag1; /* group creation order flag */ + unsigned crt_order_flag2; /* group creation order flag */ + trav_table_t *trav=NULL; int ret=1; unsigned int i; @@ -330,26 +333,57 @@ int h5repack_cmpdcpl(const char *fname1, * get file table list of objects *------------------------------------------------------------------------- */ - trav_table_init(&travt1); - trav_table_init(&travt2); - if(h5trav_gettable(fid1, travt1) < 0) + trav_table_init(&trav); + if(h5trav_gettable(fid1, trav) < 0) goto error; - if(h5trav_gettable(fid2, travt2) < 0) - goto error; - - + /*------------------------------------------------------------------------- * traverse the suppplied object list *------------------------------------------------------------------------- */ - - for(i = 0; i < travt1->nobjs; i++) + for(i = 0; i < trav->nobjs; i++) { - if(travt1->objs[i].type == H5TRAV_TYPE_DATASET) + + if(trav->objs[i].type == H5TRAV_TYPE_GROUP) + { + + if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) + goto error; + if ((gcplid = H5Gget_create_plist(gid)) < 0) + goto error; + if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0) + goto error; + if (H5Pclose(gcplid) < 0) + goto error; + if (H5Gclose(gid) < 0) + goto error; + + if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) + goto error; + if ((gcplid = H5Gget_create_plist(gid)) < 0) + goto error; + if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0) + goto error; + if (H5Pclose(gcplid) < 0) + goto error; + if (H5Gclose(gid) < 0) + goto error; + + if ( crt_order_flag1 != crt_order_flag2 ) + { + error_msg(progname, "property lists for <%s> are different\n",trav->objs[i].name); + goto error; + } + + } + + + + else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) { - if((dset1 = H5Dopen2(fid1, travt1->objs[i].name, H5P_DEFAULT)) < 0) + if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) goto error; - if((dset2 = H5Dopen2(fid2, travt1->objs[i].name, H5P_DEFAULT)) < 0) + if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) goto error; if((dcpl1 = H5Dget_create_plist(dset1)) < 0) goto error; @@ -365,7 +399,7 @@ int h5repack_cmpdcpl(const char *fname1, if(ret == 0) { - error_msg(progname, "property lists for <%s> are different\n",travt1->objs[i].name); + error_msg(progname, "property lists for <%s> are different\n",trav->objs[i].name); goto error; } @@ -389,8 +423,7 @@ int h5repack_cmpdcpl(const char *fname1, *------------------------------------------------------------------------- */ - trav_table_free(travt1); - trav_table_free(travt2); + trav_table_free(trav); /*------------------------------------------------------------------------- * close @@ -415,8 +448,9 @@ error: H5Dclose(dset2); H5Fclose(fid1); H5Fclose(fid2); - trav_table_free(travt1); - trav_table_free(travt2); + H5Pclose(gcplid); + H5Gclose(gid); + trav_table_free(trav); } H5E_END_TRY; return -1; diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 1a9422e..af4d671 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -1,17 +1,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +* Copyright by The HDF Group. * +* Copyright by the Board of Trustees of the University of Illinois. * +* All rights reserved. * +* * +* This file is part of HDF5. The full HDF5 copyright notice, including * +* terms governing use, modification, and redistribution, is contained in * +* the files COPYING and Copyright.html. COPYING can be found at the root * +* of the source code distribution tree; Copyright.html can be found at the * +* root level of an installed copy of the electronic HDF5 document set and * +* is linked from the top-level documents page. It can also be found at * +* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * +* access to either file, you may request a copy from help@hdfgroup.org. * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "h5repack.h" #include "h5test.h" @@ -40,9 +40,11 @@ #define FNAME5 "h5repack_early.h5" #define FNAME5OUT "h5repack_early_out.h5" #define FNAME6 "h5repack_early2.h5" +#ifdef H5_HAVE_FILTER_SZIP /* SZIP filter */ #define FNAME7 "h5repack_szip.h5" #define FNAME7OUT "h5repack_szip_out.h5" +#endif /* GZIP filter */ #define FNAME8 "h5repack_deflate.h5" #define FNAME8OUT "h5repack_deflate_out.h5" @@ -70,13 +72,16 @@ /* File w/userblock */ #define FNAME16 "h5repack_ub.h5" #define FNAME16OUT "h5repack_ub_out.h5" +/* Named datatypes */ +#define FNAME17 "h5repack_named_dtypes.h5" +#define FNAME17OUT "h5repack_named_dtypes_out.h5" #define FNAME_UB "ublock.bin" const char *H5REPACK_FILENAMES[] = { - "h5repack_big_out", + "h5repack_big_out", NULL }; @@ -92,57 +97,57 @@ int d_status = EXIT_SUCCESS; #define CDIM1 DIM1/2 #define CDIM2 DIM2/2 #define RANK 2 -#define GBLL ((unsigned long long) 1024*1024*1024) /* Size of userblock (for userblock test) */ #define USERBLOCK_SIZE 2048 /*------------------------------------------------------------------------- - * prototypes - *------------------------------------------------------------------------- - */ -int make_all_objects(hid_t loc_id); -int make_attributes(hid_t loc_id); -int make_hlinks(hid_t loc_id); -int make_early(void); -int make_layout(hid_t loc_id); +* prototypes +*------------------------------------------------------------------------- +*/ +static int make_all_objects(hid_t loc_id); +static int make_attributes(hid_t loc_id); +static int make_hlinks(hid_t loc_id); +static int make_early(void); +static int make_layout(hid_t loc_id); #ifdef H5_HAVE_FILTER_SZIP -int make_szip(hid_t loc_id); +static int make_szip(hid_t loc_id); #endif /* H5_HAVE_FILTER_SZIP */ -int make_deflate(hid_t loc_id); -int make_shuffle(hid_t loc_id); -int make_fletcher32(hid_t loc_id); -int make_nbit(hid_t loc_id); -int make_scaleoffset(hid_t loc_id); -int make_all(hid_t loc_id); -int make_fill(hid_t loc_id); -int make_big(hid_t loc_id); -int make_testfiles(void); -void write_dset_in(hid_t loc_id,const char* dset_name,hid_t file_id,int make_diffs ); -void write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs ); -int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *dset_name,hid_t type_id,void *buf ); -int make_dset(hid_t loc_id,const char *name,hid_t sid,hid_t dcpl,void *buf); -int make_attr(hid_t loc_id,int rank,hsize_t *dims,const char *attr_name,hid_t type_id,void *buf); -void make_dset_reg_ref(hid_t loc_id); -int make_external(hid_t loc_id); +static int make_deflate(hid_t loc_id); +static int make_shuffle(hid_t loc_id); +static int make_fletcher32(hid_t loc_id); +static int make_nbit(hid_t loc_id); +static int make_scaleoffset(hid_t loc_id); +static int make_all_filters(hid_t loc_id); +static int make_fill(hid_t loc_id); +static int make_big(hid_t loc_id); +static int make_testfiles(void); +static int write_dset_in(hid_t loc_id,const char* dset_name,hid_t file_id,int make_diffs ); +static int write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs ); +static int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *dset_name,hid_t tid,void *buf ); +static int make_dset(hid_t loc_id,const char *name,hid_t sid,hid_t dcpl,void *buf); +static int make_attr(hid_t loc_id,int rank,hsize_t *dims,const char *attr_name,hid_t tid,void *buf); +static int make_dset_reg_ref(hid_t loc_id); +static int make_external(hid_t loc_id); static int make_userblock(void); static int verify_userblock( const char* filename); static int make_userblock_file(void); +static int make_named_dtype(hid_t loc_id); /*------------------------------------------------------------------------- - * Function: main - * - * Purpose: Executes h5repack tests - * - * Return: Success: zero - * Failure: 1 - * - * Programmer: Pedro Vicente - * January, 6, 2004 - * - *------------------------------------------------------------------------- - */ +* Function: main +* +* Purpose: Executes h5repack tests +* +* Return: Success: zero +* Failure: 1 +* +* Programmer: Pedro Vicente +* January, 6, 2004 +* +*------------------------------------------------------------------------- +*/ int main (void) { @@ -151,20 +156,20 @@ int main (void) #if defined (H5_HAVE_FILTER_SZIP) int szip_can_encode = 0; #endif - + /* initialize */ memset(&diff_options, 0, sizeof (diff_opt_t)); memset(&pack_options, 0, sizeof (pack_opt_t)); - + /* run tests */ puts("Testing h5repack:"); - + /* make the test files */ TESTING(" generating datasets"); if (make_testfiles() < 0) GOERROR; PASSED(); - + /*------------------------------------------------------------------------- * Format of the tests: * @@ -177,7 +182,7 @@ int main (void) * file with fill values *------------------------------------------------------------------------- */ - + TESTING(" copy of datasets (fill values)"); if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -187,7 +192,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME0OUT,&pack_options)<=0) GOERROR; - if (h5repack_cmpdcpl(FNAME0,FNAME0OUT)<=0) + if (h5repack_cmp_pl(FNAME0,FNAME0OUT)<=0) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; @@ -207,13 +212,13 @@ int main (void) GOERROR; if (h5repack_verify(FNAME1OUT,&pack_options)<=0) GOERROR; - if (h5repack_cmpdcpl(FNAME1,FNAME1OUT)<=0) + if (h5repack_cmp_pl(FNAME1,FNAME1OUT)<=0) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - - + + /*------------------------------------------------------------------------- * file with attributes *------------------------------------------------------------------------- @@ -227,12 +232,12 @@ int main (void) GOERROR; if (h5repack_verify(FNAME2OUT,&pack_options)<=0) GOERROR; - if (h5repack_cmpdcpl(FNAME2,FNAME2OUT)<=0) + if (h5repack_cmp_pl(FNAME2,FNAME2OUT)<=0) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + /*------------------------------------------------------------------------- * file with hardlinks *------------------------------------------------------------------------- @@ -246,13 +251,13 @@ int main (void) GOERROR; if (h5repack_verify(FNAME3OUT,&pack_options)<=0) GOERROR; - if (h5repack_cmpdcpl(FNAME3,FNAME3OUT)<=0) + if (h5repack_cmp_pl(FNAME3,FNAME3OUT)<=0) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); - + /*------------------------------------------------------------------------- * alloc early test *------------------------------------------------------------------------- @@ -269,25 +274,25 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + /*------------------------------------------------------------------------- * the remaining files differ in the dcpl's *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * deflate *------------------------------------------------------------------------- */ TESTING(" adding deflate filter"); - + #ifdef H5_HAVE_FILTER_DEFLATE - + /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- */ - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addfilter("dset1:GZIP=9",&pack_options) < 0) @@ -306,16 +311,16 @@ int main (void) #else SKIPPED(); #endif - + /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- */ - + TESTING(" adding deflate filter to all"); - + #ifdef H5_HAVE_FILTER_DEFLATE - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addfilter("GZIP=1",&pack_options) < 0) @@ -330,29 +335,29 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + /*------------------------------------------------------------------------- * SZIP *------------------------------------------------------------------------- */ - + TESTING(" adding szip filter"); - + #if defined (H5_HAVE_FILTER_SZIP) if (h5tools_can_encode(H5Z_FILTER_SZIP) >0) { szip_can_encode = 1; } - + /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- */ - + if (szip_can_encode) { if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -368,7 +373,7 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); } else { SKIPPED(); @@ -376,14 +381,14 @@ int main (void) #else SKIPPED(); #endif - - + + /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- */ TESTING(" adding szip filter to all"); - + #if defined (H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init (&pack_options, 0) < 0) @@ -398,7 +403,7 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); } else { SKIPPED(); @@ -406,17 +411,17 @@ int main (void) #else SKIPPED(); #endif - - + + TESTING(" addding shuffle filter"); - + #ifdef H5_HAVE_FILTER_SHUFFLE - + /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- */ - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addfilter("dset1:SHUF",&pack_options) < 0) @@ -431,21 +436,21 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- */ - + TESTING(" addding shuffle filter to all"); - + #ifdef H5_HAVE_FILTER_SHUFFLE - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addfilter("SHUF",&pack_options) < 0) @@ -460,21 +465,21 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + TESTING(" adding checksum filter"); - + #ifdef H5_HAVE_FILTER_FLETCHER32 - + /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- */ - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addfilter("dset1:FLET",&pack_options) < 0) @@ -489,22 +494,22 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- */ - - + + TESTING(" adding checksum filter to all"); - + #ifdef H5_HAVE_FILTER_FLETCHER32 - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addfilter("FLET",&pack_options) < 0) @@ -519,47 +524,47 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - + + TESTING(" filter queue fletcher, shuffle, deflate, szip"); - + /*------------------------------------------------------------------------- * add some filters *------------------------------------------------------------------------- */ - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addlayout("dset1:CHUNK 20x10",&pack_options) < 0) GOERROR; - + #if defined (H5_HAVE_FILTER_FLETCHER32) if (h5repack_addfilter("dset1:FLET",&pack_options) < 0) GOERROR; #endif - + #ifdef H5_HAVE_FILTER_SHUFFLE if (h5repack_addfilter("dset1:SHUF",&pack_options) < 0) GOERROR; #endif - + #if defined (H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_addfilter("dset1:SZIP=8,NN",&pack_options) < 0) GOERROR; } #endif - + #ifdef H5_HAVE_FILTER_DEFLATE if (h5repack_addfilter("dset1:GZIP=1",&pack_options) < 0) GOERROR; #endif - + if (h5repack(FNAME4,FNAME4OUT,&pack_options) < 0) GOERROR; if (h5diff(FNAME4,FNAME4OUT,NULL,NULL,&diff_options) >0) @@ -568,17 +573,17 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); - - + + TESTING(" adding layout chunked"); - + /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- */ - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addlayout("dset1:CHUNK=20x10",&pack_options) < 0) @@ -592,13 +597,13 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- */ TESTING(" adding layout chunked to all"); - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addlayout("CHUNK=20x10",&pack_options) < 0) @@ -611,11 +616,11 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); - + TESTING(" adding layout contiguous"); - + /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- @@ -632,11 +637,11 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); - + TESTING(" adding layout contiguous to all"); - + /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- @@ -653,16 +658,16 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); - + TESTING(" adding layout compact"); - + /*------------------------------------------------------------------------- * test an individual object option *------------------------------------------------------------------------- */ - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addlayout("dset1:COMPA",&pack_options) < 0) @@ -676,14 +681,14 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" adding layout compact to all"); - + /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- */ - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addlayout("COMPA",&pack_options) < 0) @@ -696,12 +701,12 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); - - + + TESTING(" layout compact to contiguous conversion"); - + /*------------------------------------------------------------------------- * layout compact to contiguous conversion *------------------------------------------------------------------------- @@ -719,9 +724,9 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" layout compact to chunk conversion"); - + /*------------------------------------------------------------------------- * layout compact to chunk conversion *------------------------------------------------------------------------- @@ -739,9 +744,9 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" layout compact to compact conversion"); - + /*------------------------------------------------------------------------- * layout compact to compact conversion *------------------------------------------------------------------------- @@ -759,7 +764,7 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" layout contiguous to compact conversion"); /*------------------------------------------------------------------------- * layout contiguous to compact conversion @@ -778,7 +783,7 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" layout contiguous to chunk conversion"); /*------------------------------------------------------------------------- * layout contiguous to chunk conversion @@ -797,9 +802,9 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" layout contiguous to contiguous conversion"); - + /*------------------------------------------------------------------------- * layout contiguous to contiguous conversion *------------------------------------------------------------------------- @@ -817,7 +822,7 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" layout chunked to compact conversion"); /*------------------------------------------------------------------------- * layout chunked to compact conversion @@ -836,9 +841,9 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" layout chunked to contiguous conversion"); - + /*------------------------------------------------------------------------- * layout chunked to contiguous conversion *------------------------------------------------------------------------- @@ -856,7 +861,7 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + TESTING(" layout chunked to chunk conversion"); /*------------------------------------------------------------------------- * layout chunked to chunked conversion @@ -875,8 +880,8 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - - + + /*------------------------------------------------------------------------- * the following tests assume the input files have filters * FNAME7 @@ -886,10 +891,10 @@ int main (void) * FNAME11 *------------------------------------------------------------------------- */ - - + + TESTING(" copy of szip filter"); - + #if defined (H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init (&pack_options, 0) < 0) @@ -900,11 +905,11 @@ int main (void) GOERROR; if (h5repack_verify(FNAME7OUT,&pack_options)<=0) GOERROR; - if (h5repack_cmpdcpl(FNAME7,FNAME7OUT)<=0) + if (h5repack_cmp_pl(FNAME7,FNAME7OUT)<=0) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); } else { SKIPPED(); @@ -912,9 +917,9 @@ int main (void) #else SKIPPED(); #endif - + TESTING(" removing szip filter"); - + #if defined (H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init (&pack_options, 0) < 0) @@ -929,7 +934,7 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); } else { SKIPPED(); @@ -937,10 +942,10 @@ int main (void) #else SKIPPED(); #endif - - + + TESTING(" copy of deflate filter"); - + #ifdef H5_HAVE_FILTER_DEFLATE if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -952,15 +957,15 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - + + TESTING(" removing deflate filter"); - + #ifdef H5_HAVE_FILTER_DEFLATE if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -974,16 +979,16 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - - + + + TESTING(" copy of shuffle filter"); - + #ifdef H5_HAVE_FILTER_SHUFFLE if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -995,14 +1000,14 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + TESTING(" removing shuffle filter"); - + #ifdef H5_HAVE_FILTER_SHUFFLE if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1016,14 +1021,14 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + TESTING(" copy of fletcher filter"); - + #ifdef H5_HAVE_FILTER_FLETCHER32 if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1035,14 +1040,14 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + TESTING(" removing fletcher filter"); - + #ifdef H5_HAVE_FILTER_FLETCHER32 if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1056,15 +1061,15 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - + + TESTING(" copy of nbit filter"); - + #ifdef H5_HAVE_FILTER_NBIT if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1076,14 +1081,14 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + TESTING(" removing nbit filter"); - + #ifdef H5_HAVE_FILTER_NBIT if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1097,15 +1102,15 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - + + TESTING(" adding nbit filter"); - + #ifdef H5_HAVE_FILTER_NBIT if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1119,15 +1124,15 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - + + TESTING(" copy of scaleoffset filter"); - + #ifdef H5_HAVE_FILTER_SCALEOFFSET if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1139,14 +1144,14 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + TESTING(" removing scaleoffset filter"); - + #ifdef H5_HAVE_FILTER_SCALEOFFSET if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1160,15 +1165,15 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - + + TESTING(" adding scaleoffset filter"); - + #ifdef H5_HAVE_FILTER_SCALEOFFSET if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1182,14 +1187,14 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - - + + + /*------------------------------------------------------------------------- * file with all filters * dset_all @@ -1199,14 +1204,14 @@ int main (void) * dset_fletcher32 *------------------------------------------------------------------------- */ - - + + TESTING(" filter conversion from deflate to szip"); - + #if defined (H5_HAVE_FILTER_SZIP) \ && defined (H5_HAVE_FILTER_DEFLATE) \ && defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE) - + if (szip_can_encode) { if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1220,7 +1225,7 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); } else { SKIPPED(); @@ -1228,13 +1233,13 @@ int main (void) #else SKIPPED(); #endif - + TESTING(" filter conversion from szip to deflate"); - + #if defined (H5_HAVE_FILTER_SZIP) \ && defined (H5_HAVE_FILTER_DEFLATE) \ && defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE) - + if (szip_can_encode) { if (h5repack_init (&pack_options, 0) < 0) GOERROR; @@ -1248,7 +1253,7 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); } else { SKIPPED(); @@ -1256,18 +1261,18 @@ int main (void) #else SKIPPED(); #endif - - + + /*------------------------------------------------------------------------- * test the NONE global option *------------------------------------------------------------------------- */ - + TESTING(" removing all filters"); - + #if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) \ && defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE) - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addfilter("NONE",&pack_options) < 0) @@ -1280,12 +1285,12 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - + /*------------------------------------------------------------------------- * test a big file *------------------------------------------------------------------------- @@ -1302,7 +1307,7 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + /*------------------------------------------------------------------------- * test external dataset *------------------------------------------------------------------------- @@ -1319,7 +1324,7 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - + /*------------------------------------------------------------------------- * test file with userblock *------------------------------------------------------------------------- @@ -1338,7 +1343,7 @@ int main (void) if(h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - + /*------------------------------------------------------------------------- * test --latest options *------------------------------------------------------------------------- @@ -1363,17 +1368,17 @@ int main (void) if (h5repack_end (&pack_options) < 0) GOERROR; PASSED(); - - + + /*------------------------------------------------------------------------- * test several global filters *------------------------------------------------------------------------- */ - + TESTING(" several global filters"); - + #if defined (H5_HAVE_FILTER_DEFLATE) && defined (H5_HAVE_FILTER_SHUFFLE) - + if (h5repack_init (&pack_options, 0) < 0) GOERROR; if (h5repack_addfilter("GZIP=1",&pack_options) < 0) @@ -1388,28 +1393,28 @@ int main (void) GOERROR; if (h5repack_end (&pack_options) < 0) GOERROR; - + PASSED(); #else SKIPPED(); #endif - - + + /*------------------------------------------------------------------------- * test file with userblock *------------------------------------------------------------------------- */ TESTING(" file with added userblock"); - + #ifdef H5_HAVE_FILTER_DEFLATE - + if(h5repack_init(&pack_options, 0) < 0) GOERROR; - + /* add the options for a user block size and user block filename */ pack_options.ublock_size = USERBLOCK_SIZE; pack_options.ublock_filename = FNAME_UB; - + if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) GOERROR; if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) @@ -1420,44 +1425,44 @@ int main (void) GOERROR; if(h5repack_end(&pack_options) < 0) GOERROR; - - + + PASSED(); #else SKIPPED(); #endif - - + + /*------------------------------------------------------------------------- * test file with aligment *------------------------------------------------------------------------- */ TESTING(" file with aligment"); - + #ifdef H5_HAVE_FILTER_DEFLATE - + if(h5repack_init(&pack_options, 0) < 0) GOERROR; - + /* add the options for aligment */ pack_options.alignment = 1; pack_options.threshold = 1; - + if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) GOERROR; if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) GOERROR; if(h5repack_verify(FNAME8OUT, &pack_options) <= 0) GOERROR; - - + + /* verify aligment */ { hsize_t threshold; hsize_t alignment; hid_t fapl; hid_t fid; - + if (( fid = H5Fopen(FNAME8OUT, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) GOERROR; if ((fapl = H5Fget_access_plist(fid)) < 0) @@ -1472,264 +1477,297 @@ int main (void) GOERROR; if (H5Fclose(fid) < 0) GOERROR; - + } - - + + if(h5repack_end(&pack_options) < 0) GOERROR; - - + + PASSED(); #else SKIPPED(); #endif - - - - - + + + /*------------------------------------------------------------------------- + * test file with userblock + *------------------------------------------------------------------------- + */ + TESTING(" file with committed datatypes"); + + if(h5repack_init(&pack_options, 0) < 0) + GOERROR; + + if(h5repack(FNAME17, FNAME17OUT, &pack_options) < 0) + GOERROR; + if(h5diff(FNAME17, FNAME17OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if(h5repack_verify(FNAME17OUT, &pack_options) <= 0) + GOERROR; + if(h5repack_end(&pack_options) < 0) + GOERROR; + + + PASSED(); + + + /*------------------------------------------------------------------------- * clean temporary test files *------------------------------------------------------------------------- */ { hid_t fapl; - + /* setup */ h5_reset(); fapl = h5_fileaccess(); h5_cleanup(H5REPACK_FILENAMES, fapl); - + } - + puts("All h5repack tests passed."); - + return 0; - + error: puts("***** H5REPACK TESTS FAILED *****"); return 1; - + } /*------------------------------------------------------------------------- - * Function: make_testfiles - * - * Purpose: make a test file with all types of HDF5 objects, - * datatypes and filters - * - *------------------------------------------------------------------------- - */ +* Function: make_testfiles +* +* Purpose: make a test file with all types of HDF5 objects, +* datatypes and filters +* +*------------------------------------------------------------------------- +*/ +static int make_testfiles(void) { - hid_t loc_id; - - + hid_t fid; + /*------------------------------------------------------------------------- * create a file for general copy test *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME0,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME0,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_fill(loc_id) < 0) + if (make_fill(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create another file for general copy test (all datatypes) *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_all_objects(loc_id) < 0) + if (make_all_objects(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file for attributes copy test *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_attributes(loc_id) < 0) + if (make_attributes(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file for hard links test *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_hlinks(loc_id) < 0) + if (make_hlinks(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file for layouts test *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_layout(loc_id) < 0) + if (make_layout(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file for the H5D_ALLOC_TIME_EARLY test *------------------------------------------------------------------------- */ if (make_early() < 0) goto out; - + /*------------------------------------------------------------------------- * create a file with the SZIP filter *------------------------------------------------------------------------- */ #ifdef H5_HAVE_FILTER_SZIP - if((loc_id = H5Fcreate(FNAME7,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME7,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_szip(loc_id) < 0) + if (make_szip(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; #endif /* H5_HAVE_FILTER_SZIP */ - - + + /*------------------------------------------------------------------------- * create a file with the deflate filter *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME8,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME8,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_deflate(loc_id) < 0) + if (make_deflate(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file with the shuffle filter *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME9,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME9,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_shuffle(loc_id) < 0) + if (make_shuffle(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file with the fletcher32 filter *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME10,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME10,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_fletcher32(loc_id) < 0) + if (make_fletcher32(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file with all the filters *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME11,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME11,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_all(loc_id) < 0) + if (make_all_filters(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file with the nbit filter *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME12,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME12,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_nbit(loc_id) < 0) + if (make_nbit(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file with the scaleoffset filter *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME13,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME13,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_scaleoffset(loc_id) < 0) + if (make_scaleoffset(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a big dataset *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME14,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME14,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_big(loc_id) < 0) + if (make_big(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file with external dataset *------------------------------------------------------------------------- */ - if((loc_id = H5Fcreate(FNAME15,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + if((fid = H5Fcreate(FNAME15,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; - if (make_external(loc_id) < 0) + if (make_external(fid) < 0) goto out; - if(H5Fclose(loc_id) < 0) + if(H5Fclose(fid) < 0) return -1; - + /*------------------------------------------------------------------------- * create a file with userblock *------------------------------------------------------------------------- */ if(make_userblock() < 0) goto out; - + /*------------------------------------------------------------------------- * create a userblock file *------------------------------------------------------------------------- */ if(make_userblock_file() < 0) goto out; - + + /*------------------------------------------------------------------------- + * create a file with named datatypes + *------------------------------------------------------------------------- + */ + if((fid = H5Fcreate(FNAME17,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + return -1; + if (make_named_dtype(fid) < 0) + goto out; + if(H5Fclose(fid) < 0) + return -1; + return 0; - + out: - H5Fclose(loc_id); + H5Fclose(fid); return -1; } /*------------------------------------------------------------------------- - * Function: make_all_objects - * - * Purpose: make a test file with all types of HDF5 objects - * - *------------------------------------------------------------------------- - */ +* Function: make_all_objects +* +* Purpose: make a test file with all types of HDF5 objects +* +*------------------------------------------------------------------------- +*/ +static int make_all_objects(hid_t loc_id) { - hid_t dset_id; - hid_t group_id; - hid_t type_id; - hid_t root_id; - hid_t space_id; + hid_t did=-1; + hid_t gid=-1; + hid_t tid=-1; + hid_t rid=-1; + hid_t sid=-1; + hid_t gcplid=-1; hsize_t dims[1]={2}; - /* Compound datatype */ + /* compound datatype */ typedef struct s_t { int a; @@ -1737,124 +1775,186 @@ int make_all_objects(hid_t loc_id) } s_t; /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - space_id = H5Screate_simple(1, dims, NULL); - dset_id = H5Dcreate2(loc_id, "dset_referenced", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Sclose(space_id); - - /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - group_id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - root_id = H5Gopen2(loc_id, "/", H5P_DEFAULT); + * H5G_DATASET + *------------------------------------------------------------------------- + */ + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + goto out; + if ((did = H5Dcreate2(loc_id, "dset_referenced", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ - - /* Create a memory compound datatype */ - type_id = H5Tcreate(H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_INT); - H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_FLOAT); + * H5G_GROUP + *------------------------------------------------------------------------- + */ + if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if (H5Gclose(gid) < 0) + goto out; - /* Commit compound datatype and close it */ - H5Tcommit2(loc_id, "type", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Tclose(type_id); + /* create a group "g2" with H5P_CRT_ORDER_TRACKED set */ + if ((gcplid = H5Pcreate(H5P_GROUP_CREATE)) < 0) + goto out; + if (H5Pset_link_creation_order(gcplid, H5P_CRT_ORDER_TRACKED) < 0) + goto out; + if ((gid = H5Gcreate2(loc_id, "g2", H5P_DEFAULT, gcplid, H5P_DEFAULT)) < 0) + goto out; + if (H5Gclose(gid) < 0) + goto out; /*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ + * H5G_TYPE + *------------------------------------------------------------------------- + */ + + /* create a compound datatype */ + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) + goto out; + if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_INT) < 0) + goto out; + if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_FLOAT) < 0) + goto out; + if (H5Tcommit2(loc_id, "type", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5G_LINK + *------------------------------------------------------------------------- + */ - H5Lcreate_soft("dset", loc_id, "link", H5P_DEFAULT, H5P_DEFAULT); + if (H5Lcreate_soft("dset", loc_id, "link", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; /*------------------------------------------------------------------------- - * H5G_UDLINK - *------------------------------------------------------------------------- - */ + * H5G_UDLINK + *------------------------------------------------------------------------- + */ /* Create an external link. Other UD links are not supported by h5repack */ - H5Lcreate_external("file", "path", loc_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT); + if (H5Lcreate_external("file", "path", loc_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; /*------------------------------------------------------------------------- - * write a series of datasetes - *------------------------------------------------------------------------- - */ + * write a series of datasetes at root + *------------------------------------------------------------------------- + */ - write_dset_in(root_id,"dset_referenced",loc_id,0); + if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) + goto out; + if (write_dset_in(rid,"dset_referenced",loc_id,0) < 0) + goto out; + if (H5Gclose(rid) < 0) + goto out; - /* Close */ - H5Dclose(dset_id); - H5Gclose(group_id); - H5Gclose(root_id); + /* close */ + if (H5Dclose(did) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + if (H5Pclose(gcplid) < 0) + goto out; return 0; + +out: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Gclose(gid); + H5Gclose(rid); + H5Sclose(sid); + H5Tclose(tid); + H5Pclose(gcplid); + } H5E_END_TRY; + return -1; } /*------------------------------------------------------------------------- - * Function: make_attributes - * - * Purpose: make a test file with all types of attributes - * - *------------------------------------------------------------------------- - */ +* Function: make_attributes +* +* Purpose: make a test file with all types of attributes +* +*------------------------------------------------------------------------- +*/ +static int make_attributes(hid_t loc_id) { - hid_t dset_id; - hid_t group_id; - hid_t root_id; - hid_t space_id; + hid_t did=-1; + hid_t gid=-1; + hid_t rid=-1; + hid_t sid=-1; hsize_t dims[1]={2}; /*------------------------------------------------------------------------- * H5G_DATASET *------------------------------------------------------------------------- */ - - space_id = H5Screate_simple(1, dims, NULL); - dset_id = H5Dcreate2(loc_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Sclose(space_id); + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + goto out; + if ((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; /*------------------------------------------------------------------------- * H5G_GROUP *------------------------------------------------------------------------- */ - group_id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - root_id = H5Gopen2(loc_id, "/", H5P_DEFAULT); + if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) + goto out; /*------------------------------------------------------------------------- * write a series of attributes on the dataset, group, and root group *------------------------------------------------------------------------- */ - write_attr_in(dset_id,"dset",loc_id,0); - write_attr_in(group_id,"dset",loc_id,0); - write_attr_in(root_id,"dset",loc_id,0); - - /* Close */ - H5Dclose(dset_id); - H5Gclose(group_id); - H5Gclose(root_id); + if ( write_attr_in(did,"dset",loc_id,0) < 0) + goto out; + if (write_attr_in(gid,"dset",loc_id,0) < 0) + goto out; + if (write_attr_in(rid,"dset",loc_id,0) < 0) + goto out; + /* close */ + if (H5Dclose(did) < 0) + goto out; + if (H5Gclose(gid) < 0) + goto out; + if (H5Gclose(rid) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + return 0; + +out: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Gclose(gid); + H5Gclose(rid); + H5Sclose(sid); + } H5E_END_TRY; + return -1; + } /*------------------------------------------------------------------------- - * Function: make_hlinks - * - * Purpose: make a test file with hard links - * - *------------------------------------------------------------------------- - */ +* Function: make_hlinks +* +* Purpose: make a test file with hard links +* +*------------------------------------------------------------------------- +*/ +static int make_hlinks(hid_t loc_id) { - hid_t group1_id; - hid_t group2_id; - hid_t group3_id; + hid_t g1id=-1; + hid_t g2id=-1; + hid_t g3id=-1; hsize_t dims[2]={3,2}; int buf[3][2]= {{1,1},{1,2},{2,2}}; @@ -1872,40 +1972,55 @@ int make_hlinks(hid_t loc_id) if(H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link3 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) return -1; - /*------------------------------------------------------------------------- * create a group and some hard links to it *------------------------------------------------------------------------- */ - if((group1_id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - if((group2_id = H5Gcreate2(group1_id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - if((group3_id = H5Gcreate2(group2_id, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; + if((g1id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if((g2id = H5Gcreate2(g1id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if((g3id = H5Gcreate2(g2id, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; - if(H5Lcreate_hard(loc_id, "g1", group2_id, "link1 to g1", H5P_DEFAULT, H5P_DEFAULT) < 0) - return -1; - if(H5Lcreate_hard(group1_id, "g2", group3_id, "link1 to g2", H5P_DEFAULT, H5P_DEFAULT) < 0) - return -1; + if(H5Lcreate_hard(loc_id, "g1", g2id, "link1 to g1", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + if(H5Lcreate_hard(g1id, "g2", g3id, "link1 to g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; - H5Gclose(group1_id); - H5Gclose(group2_id); - H5Gclose(group3_id); + /* close */ + if (H5Gclose(g1id) < 0) + goto out; + if (H5Gclose(g2id) < 0) + goto out; + if (H5Gclose(g3id) < 0) + goto out; + return 0; + +out: + H5E_BEGIN_TRY + { + H5Gclose(g1id); + H5Gclose(g2id); + H5Gclose(g3id); + } H5E_END_TRY; + return -1; + } /*------------------------------------------------------------------------- - * Function: make_szip - * - * Purpose: make a dataset with the SZIP filter - * - *------------------------------------------------------------------------- - */ +* Function: make_szip +* +* Purpose: make a dataset with the SZIP filter +* +*------------------------------------------------------------------------- +*/ #ifdef H5_HAVE_FILTER_SZIP +static int make_szip(hid_t loc_id) { hid_t dcpl; /* dataset creation property list */ @@ -1916,8 +2031,8 @@ int make_szip(hid_t loc_id) hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; int buf[DIM1][DIM2]; int i, j, n; - int szip_can_encode = 0; - + int szip_can_encode = 0; + for (i=n=0; i= 0); - status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf5); - assert(status >= 0); - status = H5Dclose(dset_id); - status = H5Tclose(type_id); - status = H5Sclose(space_id); - + + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + goto out; + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + goto out; + if ((did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5) < 0) + goto out; + if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -3333,16 +3499,59 @@ void write_dset_in(hid_t loc_id, buf6[i][j]=0; } } - - type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_dset(loc_id, 1, dims, "array", type_id, buf6); - status = H5Tclose(type_id); - + + if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) + goto out; + if (write_dset(loc_id, 1, dims, "array", tid, buf6) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + + { + + double *dbuf; /* information to write */ + size_t size; + hsize_t sdims[] = {1}; + hsize_t tdims[] = {H5TOOLS_MALLOCSIZE / sizeof(double) + 1}; + unsigned u; + + /* allocate and initialize array data to write */ + size = ( H5TOOLS_MALLOCSIZE / sizeof(double) + 1 ) * sizeof(double); + dbuf = (double*)malloc( size ); + + for( u = 0; u < H5TOOLS_MALLOCSIZE / sizeof(double) + 1; u++) + dbuf[u] = u; + + if (make_diffs) + { + dbuf[5] = 0; + dbuf[6] = 0; + } + + /* create a type larger than H5TOOLS_MALLOCSIZE */ + if ((tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims)) < 0) + goto out; + size = H5Tget_size(tid); + if ((sid = H5Screate_simple(1, sdims, NULL)) < 0) + goto out; + if ((did = H5Dcreate2(loc_id, "arrayd", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; +#if defined(WRITE_ARRAY) + H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); +#endif + + /* close */ + H5Dclose(did); + H5Tclose(tid); + H5Sclose(sid); + free( dbuf ); + } + /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -3351,72 +3560,90 @@ void write_dset_in(hid_t loc_id, buf8[i]=0; } } - - write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7); - write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8); - - + + if (write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7) < 0) + goto out; + if (write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8) < 0) + goto out; + + /*------------------------------------------------------------------------- * 2D *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf12, 'z', sizeof buf12); } - - - type_id = H5Tcopy(H5T_C_S1); - status = H5Tset_size(type_id, (size_t)2); - write_dset(loc_id,2,dims2,"string2D",type_id,buf12); - status = H5Tclose(type_id); - + + + if ((tid = H5Tcopy(H5T_C_S1)) < 0) + goto out; + if (H5Tset_size(tid, (size_t)2) < 0) + goto out; + if (write_dset(loc_id,2,dims2,"string2D",tid,buf12) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - - + + if (make_diffs) { memset(buf22,0,sizeof buf22); } - - type_id = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,2,dims2,"bitfield2D",type_id,buf22); - status = H5Tclose(type_id); - + + if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) + goto out; + if (write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - type_id = H5Tcreate(H5T_OPAQUE, (size_t)1); - status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,2,dims2,"opaque2D",type_id,buf22); - status = H5Tclose(type_id); - + if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) + goto out; + if (H5Tset_tag(tid, "1-byte opaque type") < 0) + goto out; + if (write_dset(loc_id,2,dims2,"opaque2D",tid,buf22) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf32,0,sizeof buf32); } - - type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,2,dims2,"compound2D",type_id,buf32); - status = H5Tclose(type_id); - + + if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + goto out; + if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) + goto out; + if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) + goto out; + if (write_dset(loc_id,2,dims2,"compound2D",tid,buf32) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_REFERENCE *------------------------------------------------------------------------- @@ -3424,373 +3651,478 @@ void write_dset_in(hid_t loc_id, /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf42[0][0], file_id, dset_name, H5R_OBJECT, -1); - write_dset(loc_id, 2, dims2r, "refobj2D", H5T_STD_REF_OBJ, buf42); + if (H5Rcreate(&buf42[0][0], file_id, dset_name, H5R_OBJECT, -1) < 0) + goto out; + if (write_dset(loc_id, 2, dims2r, "refobj2D", H5T_STD_REF_OBJ, buf42) < 0) + goto out; } - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- */ - - type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(type_id, "RED", (val = 0, &val)); - H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); - write_dset(loc_id,2,dims2,"enum2D",type_id,0); - status = H5Tclose(type_id); - + + if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) + goto out; + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + goto out; + if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) + goto out; + if (write_dset(loc_id,2,dims2,"enum2D",tid,0) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ n = 0; for(i = 0; i < 3; i++) - for(j = 0; j < 2; j++) { + { + for(j = 0; j < 2; j++) + { int l; - + buf52[i][j].p = malloc((i + 1) * sizeof(int)); buf52[i][j].len = i + 1; for(l = 0; l < i + 1; l++) + { if(make_diffs) ((int *)buf52[i][j].p)[l] = 0; else ((int *)buf52[i][j].p)[l] = n++; - } - - space_id = H5Screate_simple(2, dims2, NULL); - type_id = H5Tvlen_create(H5T_NATIVE_INT); - dset_id = H5Dcreate2(loc_id, "vlen2D", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52); - assert(status >= 0); - status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf52); - assert(status >= 0); - status = H5Dclose(dset_id); - status = H5Tclose(type_id); - status = H5Sclose(space_id); - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - - if (make_diffs) - { - memset(buf62,0,sizeof buf62); - } - - - type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_dset(loc_id, 2, dims2, "array2D", type_id, buf62); - status = H5Tclose(type_id); - - /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ - - - if(make_diffs) { - memset(buf72, 0, sizeof buf72); - memset(buf82, 0, sizeof buf82); - } - - - plist_id = H5Pcreate(H5P_DATASET_CREATE); - space_id = H5Screate_simple(2, dims2, NULL); - dset_id = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT); - status = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); - status = H5Pclose(plist_id); - status = H5Dclose(dset_id); - status = H5Sclose(space_id); - - /*------------------------------------------------------------------------- - * H5T_FLOAT - *------------------------------------------------------------------------- - */ - - write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82); - - - /*------------------------------------------------------------------------- - * 3D - *------------------------------------------------------------------------- - */ - - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - - if (make_diffs) - { - memset(buf13,'z',sizeof buf13); - } - - type_id = H5Tcopy(H5T_C_S1); - status = H5Tset_size(type_id, (size_t)2); - write_dset(loc_id,3,dims3,"string3D",type_id,buf13); - status = H5Tclose(type_id); - - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - - - n=1; - for (i = 0; i < 4; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 2; k++) { - if (make_diffs) buf23[i][j][k]=0; - else buf23[i][j][k]=n++; - } - } - } - - - type_id = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,3,dims3,"bitfield3D",type_id,buf23); - status = H5Tclose(type_id); - - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - type_id = H5Tcreate(H5T_OPAQUE, (size_t)1); - status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,3,dims3,"opaque3D",type_id,buf23); - status = H5Tclose(type_id); - - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - - n=1; - for (i = 0; i < 4; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 2; k++) { - if (make_diffs) { - buf33[i][j][k].a=0; - buf33[i][j][k].b=0; - } - else { - buf33[i][j][k].a=n++; - buf33[i][j][k].b=n++; - } - } } } - - - type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,3,dims3,"compound3D",type_id,buf33); - status = H5Tclose(type_id); - - /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ - /* Create references to dataset */ - if (dset_name) - { - status = H5Rcreate(&buf43[0][0][0], file_id, dset_name, H5R_OBJECT, -1); - write_dset(loc_id, 3, dims3r, "refobj3D", H5T_STD_REF_OBJ, buf43); - } - - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - - type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(type_id, "RED", (val = 0, &val)); - H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); - write_dset(loc_id,3,dims3,"enum3D",type_id,0); - status = H5Tclose(type_id); - - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - - /* Allocate and initialize VL dataset to write */ - n = 0; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) { - int l; - - buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); - buf53[i][j][k].len = i + 1; - for(l = 0; l < i + 1; l++) - if(make_diffs) - ((int *)buf53[i][j][k].p)[l] = 0; - else - ((int *)buf53[i][j][k].p)[l] = n++; - } - - space_id = H5Screate_simple(3, dims3, NULL); - type_id = H5Tvlen_create(H5T_NATIVE_INT); - dset_id = H5Dcreate2(loc_id, "vlen3D", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53); - assert(status >= 0); - status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf53); - assert(status >= 0); - status = H5Dclose(dset_id); - status = H5Tclose(type_id); - status = H5Sclose(space_id); - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - - - n = 1; - for(i = 0; i < 24; i++) - for(j = 0; j < (int)dimarray[0]; j++) - if(make_diffs) - buf63[i][j] = 0; - else - buf63[i][j] = n++; - - type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_dset(loc_id, 3, dims3, "array3D", type_id, buf63); - status = H5Tclose(type_id); - - /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - n=1; f=1; - for (i = 0; i < 4; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 2; k++) { - if (make_diffs) { - buf73[i][j][k]=0; - buf83[i][j][k]=0; - } - else { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; - } - } - } - } - write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); - write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); -} - - - -/*------------------------------------------------------------------------- - * Function: make_dset_reg_ref - * - * Purpose: write dataset region references - * - *------------------------------------------------------------------------- - */ + } -#define SPACE1_RANK 1 -#define SPACE1_DIM1 1 -#define SPACE2_RANK 2 + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) + goto out; + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + goto out; + if ((did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52) < 0) + goto out; + if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + memset(buf62,0,sizeof buf62); + } + + + if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) + goto out; + if (write_dset(loc_id, 2, dims2, "array2D", tid, buf62) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ + + + if(make_diffs) { + memset(buf72, 0, sizeof buf72); + memset(buf82, 0, sizeof buf82); + } + + + if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto out; + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) + goto out; + if ((did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) + goto out; + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72) < 0) + goto out; + if (H5Pclose(pid) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_FLOAT + *------------------------------------------------------------------------- + */ + + if (write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82) < 0) + goto out; + + + /*------------------------------------------------------------------------- + * 3D + *------------------------------------------------------------------------- + */ + + /*------------------------------------------------------------------------- + * H5T_STRING + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + memset(buf13,'z',sizeof buf13); + } + + if ((tid = H5Tcopy(H5T_C_S1)) < 0) + goto out; + if (H5Tset_size(tid, (size_t)2) < 0) + goto out; + if (write_dset(loc_id,3,dims3,"string3D",tid,buf13) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ + + + n=1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) buf23[i][j][k]=0; + else buf23[i][j][k]=n++; + } + } + } + + + if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) + goto out; + if (write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) + goto out; + if (H5Tset_tag(tid, "1-byte opaque type") < 0) + goto out; + if (write_dset(loc_id,3,dims3,"opaque3D",tid,buf23) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + + n=1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { + buf33[i][j][k].a=0; + buf33[i][j][k].b=0; + } + else { + buf33[i][j][k].a=n++; + buf33[i][j][k].b=n++; + } + } + } + } + + + if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + goto out; + if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) + goto out; + if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) + goto out; + if (write_dset(loc_id,3,dims3,"compound3D",tid,buf33) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ + /* Create references to dataset */ + if (dset_name) + { + if (H5Rcreate(&buf43[0][0][0], file_id, dset_name, H5R_OBJECT, -1) < 0) + goto out; + if (write_dset(loc_id, 3, dims3r, "refobj3D", H5T_STD_REF_OBJ, buf43) < 0) + goto out; + } + + /*------------------------------------------------------------------------- + * H5T_ENUM + *------------------------------------------------------------------------- + */ + + if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) + goto out; + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + goto out; + if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) + goto out; + if (write_dset(loc_id,3,dims3,"enum3D",tid,0) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_VLEN + *------------------------------------------------------------------------- + */ + + /* Allocate and initialize VL dataset to write */ + n = 0; + for(i = 0; i < 4; i++) + { + for(j = 0; j < 3; j++) + { + for(k = 0; k < 2; k++) + { + int l; + + buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); + buf53[i][j][k].len = i + 1; + for(l = 0; l < i + 1; l++) + { + if(make_diffs) + ((int *)buf53[i][j][k].p)[l] = 0; + else + ((int *)buf53[i][j][k].p)[l] = n++; + } + } + } + } + + if ((sid = H5Screate_simple(3, dims3, NULL)) < 0) + goto out; + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + goto out; + if ((did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53) < 0) + goto out; + + if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53) < 0) + goto out; + + if (H5Dclose(did) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + + + n = 1; + for(i = 0; i < 24; i++) + { + for(j = 0; j < (int)dimarray[0]; j++) + { + if(make_diffs) + buf63[i][j] = 0; + else + buf63[i][j] = n++; + } + } + + if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) + goto out; + if (write_dset(loc_id, 3, dims3, "array3D", tid, buf63) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + + /*------------------------------------------------------------------------- + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ + n=1; f=1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { + buf73[i][j][k]=0; + buf83[i][j][k]=0; + } + else { + buf73[i][j][k]=n++; + buf83[i][j][k]=f++; + } + } + } + } + if (write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73) < 0) + goto out; + if (write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0) + goto out; + + + return 0; + + +out: + H5E_BEGIN_TRY + { + H5Pclose(pid); + H5Sclose(sid); + H5Dclose(did); + H5Tclose(tid); + } H5E_END_TRY; + return -1; +} + + + +/*------------------------------------------------------------------------- +* Function: make_dset_reg_ref +* +* Purpose: write dataset region references +* +*------------------------------------------------------------------------- +*/ + +#define SPACE1_RANK 1 +#define SPACE1_DIM1 1 +#define SPACE2_RANK 2 #define SPACE2_DIM1 10 #define SPACE2_DIM2 10 -#define NPOINTS 10 - -void make_dset_reg_ref(hid_t loc_id) +static +int make_dset_reg_ref(hid_t loc_id) { - hid_t dset1; /* Dataset ID */ - hid_t dset2; /* Dereferenced dataset ID */ - hid_t sid1; /* Dataspace ID #1 */ - hid_t sid2; /* Dataspace ID #2 */ + hid_t did1=-1; /* Dataset ID */ + hid_t did2=-1; /* Dereferenced dataset ID */ + hid_t sid1=-1; /* Dataspace ID #1 */ + hid_t sid2=-1; /* Dataspace ID #2 */ hsize_t dims1[] = {SPACE1_DIM1}; hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hdset_reg_ref_t *wbuf; /* buffer to write to disk */ - int *dwbuf; /* Buffer for writing numeric data to disk */ + hdset_reg_ref_t *wbuf=NULL; /* buffer to write to disk */ + int *dwbuf=NULL; /* Buffer for writing numeric data to disk */ int i; /* counting variables */ - herr_t ret; /* Generic return value */ - + /* Allocate write & read buffers */ wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); dwbuf = (int *)malloc(sizeof(int) * SPACE2_DIM1 * SPACE2_DIM2); - + /* Create dataspace for datasets */ - sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); - + if ((sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL)) < 0) + goto out; + /* Create a dataset */ - dset2 = H5Dcreate2(loc_id, "dsetreg", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) + if ((did2 = H5Dcreate2(loc_id, "dsetreg", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + + for (i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) dwbuf[i] = i * 3; - + /* Write selection to disk */ - ret = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf); - assert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dset2); - assert(ret >= 0); - + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf) < 0) + goto out; + /* Create dataspace for the reference dataset */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - + if ((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) + goto out; + /* Create a dataset */ - dset1 = H5Dcreate2(loc_id, "refreg", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Create references */ - + if ((did1 = H5Dcreate2(loc_id, "refreg", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + /* Select 6x6 hyperslab for first reference */ start[0] = 2; start[1] = 2; stride[0] = 1; stride[1] = 1; count[0] = 6; count[1] = 6; block[0] = 1; block[1] = 1; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); - assert(ret >= 0); - + if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0) + goto out; + + /* Store dataset region */ - ret = H5Rcreate(&wbuf[0], loc_id, "dsetreg", H5R_DATASET_REGION, sid2); - assert(ret >= 0); - + if (H5Rcreate(&wbuf[0], loc_id, "dsetreg", H5R_DATASET_REGION, sid2) < 0) + goto out; + /* Write selection to disk */ - ret=H5Dwrite(dset1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf); - assert(ret >= 0); - + if (H5Dwrite(did1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf) < 0) + goto out; + /* Close all objects */ - ret = H5Sclose(sid1); - assert(ret >= 0); - ret = H5Dclose(dset1); - assert(ret >= 0); - ret = H5Sclose(sid2); - assert(ret >= 0); - - free(wbuf); - free(dwbuf); + if (H5Sclose(sid1) < 0) + goto out; + if (H5Dclose(did1) < 0) + goto out; + if (H5Sclose(sid2) < 0) + goto out; + if (H5Dclose(did2) < 0) + goto out; + + if (wbuf) + free(wbuf); + if (dwbuf) + free(dwbuf); + + return 0; + +out: + H5E_BEGIN_TRY + { + + H5Sclose(sid1); + H5Sclose(sid2); + H5Dclose(did1); + H5Dclose(did2); + + } H5E_END_TRY; + return -1; } /*------------------------------------------------------------------------- - * Function: write_attr_in - * - * Purpose: write attributes in LOC_ID (dataset, group, named datatype) - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 12, 2003 - * - *------------------------------------------------------------------------- - */ - - -void write_attr_in(hid_t loc_id, +* Function: write_attr_in +* +* Purpose: write attributes in LOC_ID (dataset, group, named datatype) +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 12, 2003 +* +*------------------------------------------------------------------------- +*/ + +static +int write_attr_in(hid_t loc_id, const char* dset_name, /* for saving reference to dataset*/ hid_t fid, /* for reference create */ int make_diffs /* flag to modify data buffers */) @@ -3801,20 +4133,19 @@ void write_attr_in(hid_t loc_id, char a; double b; } s_t; - + typedef enum { RED, - GREEN + GREEN } e_t; - - hid_t attr_id; - hid_t space_id; - hid_t type_id; - herr_t status; + + hid_t aid; + hid_t sid; + hid_t tid; int val, i, j, k, n; float f; - + /* create 1D attributes with dimension [2], 2 elements */ hsize_t dims[1]={2}; char buf1[2][2]= {"ab","de"}; /* string */ @@ -3827,7 +4158,7 @@ void write_attr_in(hid_t loc_id, int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ int buf7[2]= {1,2}; /* integer */ float buf8[2]= {1,2}; /* float */ - + /* create 2D attributes with dimension [3][2], 6 elements */ hsize_t dims2[2]={3,2}; char buf12[6][2]= {"ab","cd","ef","gh","ij","kl"}; /* string */ @@ -3839,7 +4170,7 @@ void write_attr_in(hid_t loc_id, int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ - + /* create 3D attributes with dimension [4][3][2], 24 elements */ hsize_t dims3[3]={4,3,2}; char buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq", @@ -3853,18 +4184,18 @@ void write_attr_in(hid_t loc_id, int buf63[24][3]; /* array */ int buf73[4][3][2]; /* integer */ float buf83[4][3][2]; /* float */ - - + + /*------------------------------------------------------------------------- * 1D attributes *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -3885,16 +4216,20 @@ void write_attr_in(hid_t loc_id, [ 1 ] d z [ 1 ] e z */ - type_id = H5Tcopy(H5T_C_S1); - status = H5Tset_size(type_id, (size_t)2); - make_attr(loc_id,1,dims,"string",type_id,buf1); - status = H5Tclose(type_id); + if ((tid = H5Tcopy(H5T_C_S1)) < 0) + goto out; + if (H5Tset_size(tid, (size_t)2) < 0) + goto out; + if (make_attr(loc_id,1,dims,"string",tid,buf1) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -3912,15 +4247,18 @@ void write_attr_in(hid_t loc_id, [ 1 ] 2 0 2 */ - type_id = H5Tcopy(H5T_STD_B8LE); - make_attr(loc_id,1,dims,"bitfield",type_id,buf2); - status = H5Tclose(type_id); - + if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) + goto out; + if (make_attr(loc_id,1,dims,"bitfield",tid,buf2) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - + /* buf2[2]= {1,2}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -3932,17 +4270,21 @@ void write_attr_in(hid_t loc_id, [ 0 ] 1 0 1 [ 1 ] 2 0 2 */ - - type_id = H5Tcreate(H5T_OPAQUE, (size_t)1); - status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */ - make_attr(loc_id,1,dims,"opaque",type_id,buf2); - status = H5Tclose(type_id); - + + if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) + goto out; + if (H5Tset_tag(tid, "1-byte opaque type") < 0) + goto out; + if (make_attr(loc_id,1,dims,"opaque",tid,buf2) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -3950,7 +4292,7 @@ void write_attr_in(hid_t loc_id, buf3[i].a=0; buf3[i].b=0; } } - + /* buf3[2]= {{1,2},{3,4}}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -3963,13 +4305,18 @@ void write_attr_in(hid_t loc_id, [ 1 ] 3 5 2 [ 1 ] 4 5 1 */ - - type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - make_attr(loc_id,1,dims,"compound",type_id,buf3); - status = H5Tclose(type_id); - + + if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + goto out; + if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) + goto out; + if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) + goto out; + if (make_attr(loc_id,1,dims,"compound",tid,buf3) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_REFERENCE *------------------------------------------------------------------------- @@ -3977,12 +4324,15 @@ void write_attr_in(hid_t loc_id, /* object references ( H5R_OBJECT */ if (dset_name) { - status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,-1); - status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,-1); - make_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); + if (H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,-1) < 0) + goto out; + if (H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,-1) < 0) + goto out; + if (make_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4) < 0) + goto out; } - - + + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- @@ -4004,19 +4354,24 @@ void write_attr_in(hid_t loc_id, [ 0 ] RED GREEN [ 1 ] RED GREEN */ - type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(type_id, "RED", (val = 0, &val)); - H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); - make_attr(loc_id,1,dims,"enum",type_id,buf45); - status = H5Tclose(type_id); + if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) + goto out; + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + goto out; + if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) + goto out; + if (make_attr(loc_id,1,dims,"enum",tid,buf45) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ - + buf5[0].len = 1; buf5[0].p = malloc( 1 * sizeof(int)); ((int *)buf5[0].p)[0]=1; @@ -4024,7 +4379,7 @@ void write_attr_in(hid_t loc_id, buf5[1].p = malloc(2 * sizeof(int)); ((int *)buf5[1].p)[0] = 2; ((int *)buf5[1].p)[1] = 3; - + if(make_diffs) { ((int *)buf5[0].p)[0] = 0; @@ -4040,23 +4395,29 @@ void write_attr_in(hid_t loc_id, [ 1 ] 2 0 2 [ 1 ] 3 0 3 */ - - space_id = H5Screate_simple(1, dims, NULL); - type_id = H5Tvlen_create(H5T_NATIVE_INT); - attr_id = H5Acreate2(loc_id, "vlen", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite(attr_id, type_id, buf5); - assert(status >= 0); - status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf5); - assert(status >= 0); - status = H5Aclose(attr_id); - status = H5Tclose(type_id); - status = H5Sclose(space_id); - + + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + goto out; + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + goto out; + if ((aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if (H5Awrite(aid, tid, buf5) < 0) + goto out; + if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5) < 0) + goto out; + if (H5Aclose(aid) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) @@ -4079,15 +4440,18 @@ void write_attr_in(hid_t loc_id, [ 1 ] 5 0 5 [ 1 ] 6 0 6 */ - type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - make_attr(loc_id, 1, dims, "array", type_id, buf6); - status = H5Tclose(type_id); + if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) + goto out; + if (make_attr(loc_id, 1, dims, "array", tid, buf6) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - + if(make_diffs) { for(i = 0; i < 2; i++) @@ -4096,7 +4460,7 @@ void write_attr_in(hid_t loc_id, buf8[i]=0; } } - + /* buf7[2]= {1,2}; buf8[2]= {1,2}; @@ -4111,15 +4475,17 @@ void write_attr_in(hid_t loc_id, [ 0 ] 1 0 1 [ 1 ] 2 0 2 */ - make_attr(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7); - make_attr(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8); + if (make_attr(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7) < 0) + goto out; + if (make_attr(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8) < 0) + goto out; + - /*------------------------------------------------------------------------- * 2D attributes *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- @@ -4128,7 +4494,7 @@ void write_attr_in(hid_t loc_id, { memset(buf12, 'z', sizeof buf12); } - + /* buf12[6][2]= {"ab","cd","ef","gh","ij","kl"}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -4148,22 +4514,26 @@ void write_attr_in(hid_t loc_id, [ 2 1 ] k z [ 2 1 ] l z */ - - type_id = H5Tcopy(H5T_C_S1); - status = H5Tset_size(type_id, (size_t)2); - make_attr(loc_id,2,dims2,"string2D",type_id,buf12); - status = H5Tclose(type_id); - + + if ((tid = H5Tcopy(H5T_C_S1)) < 0) + goto out; + if (H5Tset_size(tid, (size_t)2) < 0) + goto out; + if (make_attr(loc_id,2,dims2,"string2D",tid,buf12) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf22,0,sizeof buf22); } - + /* buf22[3][2]= {{1,2},{3,4},{5,6}}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -4177,17 +4547,20 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - - - type_id = H5Tcopy(H5T_STD_B8LE); - make_attr(loc_id,2,dims2,"bitfield2D",type_id,buf22); - status = H5Tclose(type_id); - + + + if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) + goto out; + if (make_attr(loc_id,2,dims2,"bitfield2D",tid,buf22) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - + /* buf22[3][2]= {{1,2},{3,4},{5,6}}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -4201,11 +4574,15 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - type_id = H5Tcreate(H5T_OPAQUE, (size_t)1); - status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */ - make_attr(loc_id,2,dims2,"opaque2D",type_id,buf22); - status = H5Tclose(type_id); - + if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) + goto out; + if (H5Tset_tag(tid, "1-byte opaque type") < 0) + goto out; + if (make_attr(loc_id,2,dims2,"opaque2D",tid,buf22) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- @@ -4214,7 +4591,7 @@ void write_attr_in(hid_t loc_id, { memset(buf32,0,sizeof buf32); } - + /* buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; $h5diff file7.h5 file6.h5 g1 g1 -v @@ -4228,14 +4605,19 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - - - type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - make_attr(loc_id,2,dims2,"compound2D",type_id,buf32); - status = H5Tclose(type_id); - + + + if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + goto out; + if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) + goto out; + if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) + goto out; + if (make_attr(loc_id,2,dims2,"compound2D",tid,buf32) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_REFERENCE *------------------------------------------------------------------------- @@ -4247,12 +4629,14 @@ void write_attr_in(hid_t loc_id, { for (j = 0; j < 2; j++) { - status=H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,-1); + if (H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,-1) < 0) + goto out; } } - make_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); + if (make_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42) < 0) + goto out; } - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- @@ -4264,7 +4648,7 @@ void write_attr_in(hid_t loc_id, if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=RED; } } - + /* Attribute: and position enum2D of enum2D of difference @@ -4276,18 +4660,23 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] RED GREEN [ 2 1 ] RED GREEN */ - - type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(type_id, "RED", (val = 0, &val)); - H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); - make_attr(loc_id,2,dims2,"enum2D",type_id,buf452); - status = H5Tclose(type_id); - + + if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) + goto out; + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + goto out; + if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) + goto out; + if (make_attr(loc_id,2,dims2,"enum2D",tid,buf452) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ n=0; for (i = 0; i < 3; i++) @@ -4302,7 +4691,7 @@ void write_attr_in(hid_t loc_id, else ((int *)buf52[i][j].p)[l] = n++; } } - + /* position vlen2D of vlen2D of difference ------------------------------------------------------------ @@ -4318,23 +4707,29 @@ void write_attr_in(hid_t loc_id, [ 2 1 ] 10 0 10 [ 2 1 ] 11 0 11 */ - - space_id = H5Screate_simple(2, dims2, NULL); - type_id = H5Tvlen_create(H5T_NATIVE_INT); - attr_id = H5Acreate2(loc_id, "vlen2D", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite(attr_id, type_id, buf52); - assert(status >= 0); - status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf52); - assert(status >= 0); - status = H5Aclose(attr_id); - status = H5Tclose(type_id); - status = H5Sclose(space_id); - + + if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) + goto out; + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + goto out; + if ((aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if (H5Awrite(aid, tid, buf52) < 0) + goto out; + if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52) < 0) + goto out; + if (H5Aclose(aid) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf62,0,sizeof buf62); @@ -4365,15 +4760,18 @@ void write_attr_in(hid_t loc_id, [ 2 1 ] 17 0 17 [ 2 1 ] 18 0 18 */ - type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - make_attr(loc_id, 2, dims2, "array2D", type_id, buf62); - status = H5Tclose(type_id); - + if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) + goto out; + if (make_attr(loc_id, 2, dims2, "array2D", tid, buf62) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- */ - + if(make_diffs) { HDmemset(buf72, 0, sizeof buf72); @@ -4400,93 +4798,99 @@ void write_attr_in(hid_t loc_id, [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - - make_attr(loc_id,2,dims2,"integer2D",H5T_NATIVE_INT,buf72); - make_attr(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82); - - + + if (make_attr(loc_id,2,dims2,"integer2D",H5T_NATIVE_INT,buf72) < 0) + goto out; + if (make_attr(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82) < 0) + goto out; + + /*------------------------------------------------------------------------- * 3D attributes *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf13,'z',sizeof buf13); } - + /* buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq", "rs","tu","vw","xz","AB","CD","EF","GH", "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; - - Attribute: and - position string3D of string3D of difference - ------------------------------------------------------------ - [ 0 0 0 ] a z - [ 0 0 0 ] b z - [ 0 0 1 ] c z - [ 0 0 1 ] d z - [ 0 1 0 ] e z - [ 0 1 0 ] f z - [ 0 1 1 ] g z - [ 0 1 1 ] h z - [ 0 2 0 ] i z - [ 0 2 0 ] j z - [ 0 2 1 ] k z - [ 0 2 1 ] l z - [ 1 0 0 ] m z - [ 1 0 0 ] n z - [ 1 0 1 ] p z - [ 1 0 1 ] q z - [ 1 1 0 ] r z - [ 1 1 0 ] s z - [ 1 1 1 ] t z - [ 1 1 1 ] u z - [ 1 2 0 ] v z - [ 1 2 0 ] w z - [ 1 2 1 ] x z - [ 2 0 0 ] A z - [ 2 0 0 ] B z - [ 2 0 1 ] C z - [ 2 0 1 ] D z - [ 2 1 0 ] E z - [ 2 1 0 ] F z - [ 2 1 1 ] G z - [ 2 1 1 ] H z - [ 2 2 0 ] I z - [ 2 2 0 ] J z - [ 2 2 1 ] K z - [ 2 2 1 ] L z - [ 3 0 0 ] M z - [ 3 0 0 ] N z - [ 3 0 1 ] P z - [ 3 0 1 ] Q z - [ 3 1 0 ] R z - [ 3 1 0 ] S z - [ 3 1 1 ] T z - [ 3 1 1 ] U z - [ 3 2 0 ] V z - [ 3 2 0 ] W z - [ 3 2 1 ] X z - [ 3 2 1 ] Z z - */ - - type_id = H5Tcopy(H5T_C_S1); - status = H5Tset_size(type_id, (size_t)2); - make_attr(loc_id,3,dims3,"string3D",type_id,buf13); - status = H5Tclose(type_id); - + + Attribute: and + position string3D of string3D of difference + ------------------------------------------------------------ + [ 0 0 0 ] a z + [ 0 0 0 ] b z + [ 0 0 1 ] c z + [ 0 0 1 ] d z + [ 0 1 0 ] e z + [ 0 1 0 ] f z + [ 0 1 1 ] g z + [ 0 1 1 ] h z + [ 0 2 0 ] i z + [ 0 2 0 ] j z + [ 0 2 1 ] k z + [ 0 2 1 ] l z + [ 1 0 0 ] m z + [ 1 0 0 ] n z + [ 1 0 1 ] p z + [ 1 0 1 ] q z + [ 1 1 0 ] r z + [ 1 1 0 ] s z + [ 1 1 1 ] t z + [ 1 1 1 ] u z + [ 1 2 0 ] v z + [ 1 2 0 ] w z + [ 1 2 1 ] x z + [ 2 0 0 ] A z + [ 2 0 0 ] B z + [ 2 0 1 ] C z + [ 2 0 1 ] D z + [ 2 1 0 ] E z + [ 2 1 0 ] F z + [ 2 1 1 ] G z + [ 2 1 1 ] H z + [ 2 2 0 ] I z + [ 2 2 0 ] J z + [ 2 2 1 ] K z + [ 2 2 1 ] L z + [ 3 0 0 ] M z + [ 3 0 0 ] N z + [ 3 0 1 ] P z + [ 3 0 1 ] Q z + [ 3 1 0 ] R z + [ 3 1 0 ] S z + [ 3 1 1 ] T z + [ 3 1 1 ] U z + [ 3 2 0 ] V z + [ 3 2 0 ] W z + [ 3 2 1 ] X z + [ 3 2 1 ] Z z + */ + + if ((tid = H5Tcopy(H5T_C_S1)) < 0) + goto out; + if (H5Tset_size(tid, (size_t)2) < 0) + goto out; + if (make_attr(loc_id,3,dims3,"string3D",tid,buf13) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_BITFIELD *------------------------------------------------------------------------- */ - + n=1; for (i = 0; i < 4; i++) { @@ -4499,7 +4903,7 @@ void write_attr_in(hid_t loc_id, } } } - + /* position bitfield3D of bitfield3D of difference ------------------------------------------------------------ @@ -4528,25 +4932,32 @@ void write_attr_in(hid_t loc_id, [ 3 2 0 ] 23 0 23 [ 3 2 1 ] 24 0 24 */ - - type_id = H5Tcopy(H5T_STD_B8LE); - make_attr(loc_id,3,dims3,"bitfield3D",type_id,buf23); - status = H5Tclose(type_id); - + + if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) + goto out; + if (make_attr(loc_id,3,dims3,"bitfield3D",tid,buf23) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_OPAQUE *------------------------------------------------------------------------- */ - type_id = H5Tcreate(H5T_OPAQUE, (size_t)1); - status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */ - make_attr(loc_id,3,dims3,"opaque3D",type_id,buf23); - status = H5Tclose(type_id); - + if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) + goto out; + if (H5Tset_tag(tid, "1-byte opaque type") < 0) + goto out; + if (make_attr(loc_id,3,dims3,"opaque3D",tid,buf23) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_COMPOUND *------------------------------------------------------------------------- */ - + n=1; for (i = 0; i < 4; i++) { @@ -4618,15 +5029,20 @@ void write_attr_in(hid_t loc_id, [ 3 2 1 ] 47 0 47 [ 3 2 1 ] 48 0 48 */ - - - - type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - make_attr(loc_id,3,dims3,"compound3D",type_id,buf33); - status = H5Tclose(type_id); - + + + + if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + goto out; + if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) + goto out; + if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) + goto out; + if (make_attr(loc_id,3,dims3,"compound3D",tid,buf33) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_REFERENCE *------------------------------------------------------------------------- @@ -4639,17 +5055,19 @@ void write_attr_in(hid_t loc_id, for (j = 0; j < 3; j++) { for (k = 0; k < 2; k++) - status=H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,-1); + if (H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,-1) < 0) + goto out; } } - make_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); + if (make_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43) < 0) + goto out; } - + /*------------------------------------------------------------------------- * H5T_ENUM *------------------------------------------------------------------------- */ - + for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) @@ -4667,7 +5085,7 @@ void write_attr_in(hid_t loc_id, } } } - + /* position enum3D of enum3D of difference ------------------------------------------------------------ @@ -4696,19 +5114,24 @@ void write_attr_in(hid_t loc_id, [ 3 2 0 ] GREEN RED [ 3 2 1 ] GREEN RED */ - - - type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(type_id, "RED", (val = 0, &val)); - H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); - make_attr(loc_id,3,dims3,"enum3D",type_id,buf453); - status = H5Tclose(type_id); - + + + if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) + goto out; + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + goto out; + if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) + goto out; + if (make_attr(loc_id,3,dims3,"enum3D",tid,buf453) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ n=0; for (i = 0; i < 4; i++) @@ -4745,17 +5168,23 @@ void write_attr_in(hid_t loc_id, [ 1 1 0 ] 10 0 10 etc */ - space_id = H5Screate_simple(3, dims3, NULL); - type_id = H5Tvlen_create(H5T_NATIVE_INT); - attr_id = H5Acreate2(loc_id, "vlen3D", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite(attr_id, type_id, buf53); - assert(status >= 0); - status = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, buf53); - assert(status >= 0); - status = H5Aclose(attr_id); - status = H5Tclose(type_id); - status = H5Sclose(space_id); - + if ((sid = H5Screate_simple(3, dims3, NULL)) < 0) + goto out; + if ((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) + goto out; + if ((aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if (H5Awrite(aid, tid, buf53) < 0) + goto out; + if (H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53) < 0) + goto out; + if (H5Aclose(aid) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_ARRAY *------------------------------------------------------------------------- @@ -4781,11 +5210,14 @@ void write_attr_in(hid_t loc_id, [ 0 1 0 ] 7 0 7 etc */ - - type_id = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - make_attr(loc_id, 3, dims3, "array3D", type_id, buf63); - status = H5Tclose(type_id); - + + if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) + goto out; + if (make_attr(loc_id, 3, dims3, "array3D", tid, buf63) < 0) + goto out; + if (H5Tclose(tid) < 0) + goto out; + /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT *------------------------------------------------------------------------- @@ -4810,7 +5242,7 @@ void write_attr_in(hid_t loc_id, } } } - + /* position integer3D of integer3D of difference ------------------------------------------------------------ @@ -4826,145 +5258,279 @@ void write_attr_in(hid_t loc_id, [ 1 1 1 ] 10 0 10 etc */ - make_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); - make_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); + if (make_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73) < 0) + goto out; + if (make_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0) + goto out; + + + return 0; + +out: + H5E_BEGIN_TRY + { + H5Aclose(aid); + H5Sclose(sid); + H5Tclose(tid); + } H5E_END_TRY; + return -1; } + /*------------------------------------------------------------------------- - * Function: make_dset - * - * Purpose: utility function to create and write a dataset in LOC_ID - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 12, 2003 - * - *------------------------------------------------------------------------- - */ +* Function: make_dset +* +* Purpose: utility function to create and write a dataset in LOC_ID +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 12, 2003 +* +*------------------------------------------------------------------------- +*/ +static int make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t dcpl, void *buf) { - hid_t dsid; + hid_t did=-1; - /* create the dataset */ - if((dsid = H5Dcreate2(loc_id, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; - - /* write */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; - - /* close */ - if(H5Dclose(dsid) < 0) + if (H5Dclose(did) < 0) return -1; - return 0; out: H5E_BEGIN_TRY { - H5Dclose(dsid); + H5Dclose(did); } H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- - * Function: write_dset - * - * Purpose: utility function to create and write a dataset in LOC_ID - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 12, 2003 - * - *------------------------------------------------------------------------- - */ - +* Function: write_dset +* +* Purpose: utility function to create and write a dataset in LOC_ID +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 12, 2003 +* +*------------------------------------------------------------------------- +*/ +static int write_dset( hid_t loc_id, - int rank, - hsize_t *dims, - const char *dset_name, - hid_t type_id, - void *buf ) + int rank, + hsize_t *dims, + const char *dset_name, + hid_t tid, + void *buf ) { - hid_t dset_id; - hid_t space_id; + hid_t did=-1; + hid_t sid=-1; - /* Create a buf space */ - if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; + if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if (buf) + { + if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + goto out; + } + if (H5Dclose(did) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; - /* Create a dataset */ - if((dset_id = H5Dcreate2(loc_id, dset_name, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; + return 0; + +out: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Sclose(sid); + } H5E_END_TRY; + return -1; +} - /* Write the buf */ - if(buf) - if(H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - return -1; - /* Close */ - if(H5Dclose(dset_id) < 0) - return -1; - if(H5Sclose(space_id) < 0) - return -1; +/*------------------------------------------------------------------------- +* Function: make_attr +* +* Purpose: utility function to write an attribute in LOC_ID +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: November 12, 2003 +* +*------------------------------------------------------------------------- +*/ +static +int make_attr(hid_t loc_id, + int rank, + hsize_t *dims, + const char *attr_name, + hid_t tid, + void *buf) +{ + hid_t aid; + hid_t sid; + + if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) + return -1; + if ((aid = H5Acreate2(loc_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(buf) + { + if(H5Awrite(aid, tid, buf) < 0) + goto out; + } + if (H5Aclose(aid) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; return 0; + +out: + H5E_BEGIN_TRY { + H5Aclose(aid); + H5Sclose(sid); + } H5E_END_TRY; + return -1; } /*------------------------------------------------------------------------- - * Function: write_attr - * - * Purpose: utility function to write an attribute in LOC_ID - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 12, 2003 - * - *------------------------------------------------------------------------- - */ - -int make_attr(hid_t loc_id, - int rank, - hsize_t *dims, - const char *attr_name, - hid_t type_id, - void *buf) +* Function: make_named_dtype +* +* Purpose: create a file with named datatypes in various configurations +* +*------------------------------------------------------------------------- +*/ +static +int make_named_dtype(hid_t loc_id) { - hid_t attr_id; - hid_t space_id; + hsize_t dims[1] ={3}; + hid_t did=-1; + hid_t aid=-1; + hid_t sid=-1; + hid_t tid=-1; + hid_t gid=-1; - /* create a space */ - if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) - return -1; + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + goto out; - /* create the attribute */ - if((attr_id = H5Acreate2(loc_id, attr_name, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; + /* Create a dataset with an anonymous committed datatype as the first thing + * h5repack sees */ + if((tid = H5Tcopy(H5T_STD_I16LE)) < 0) + goto out; + if(H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + if ((did = H5Dcreate2(loc_id, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Tclose(tid) < 0) + goto out; - /* write the buffer */ - if(buf) - if(H5Awrite(attr_id, type_id, buf) < 0) - goto out; + /* Create an attribute on that dataset that uses a committed datatype in + * a remote group */ + if((gid = H5Gcreate2(loc_id, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Gclose(gid) < 0) + goto out; + if((gid = H5Gcreate2(loc_id, "M/M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Gclose(gid) < 0) + goto out; + if((tid = H5Tcopy(H5T_STD_I16BE)) < 0) + goto out; + if(H5Tcommit2(loc_id, "/M/M/A", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + if((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Aclose(aid) < 0) + goto out; + if(H5Tclose(tid) < 0) + goto out; + if(H5Dclose(did) < 0) + goto out; - /* close */ - H5Aclose(attr_id); - H5Sclose(space_id); - return 0; + /* Create a dataset in the remote group that uses a committed datatype in + * the root group */ + if((tid = H5Tcopy(H5T_STD_I32LE)) < 0) + goto out; + if(H5Tcommit2(loc_id, "N", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + if((did = H5Dcreate2(loc_id, "M/M/B", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Tclose(tid) < 0) + goto out; -out: - H5E_BEGIN_TRY { - H5Aclose(attr_id); - H5Sclose(space_id); - } H5E_END_TRY; - return -1; -} + /* Create an attribute on the remote dataset that uses an anonymous + * committed datatype */ + if((tid = H5Tcopy(H5T_STD_I32BE)) < 0) + goto out; + if(H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto out; + if((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Aclose(aid) < 0) + goto out; + + /* Create another attribute that uses the same anonymous datatype */ + if((aid = H5Acreate2(did, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Aclose(aid) < 0) + goto out; + if(H5Tclose(tid) < 0) + goto out; + if(H5Dclose(did) < 0) + goto out; + + /* Create a dataset in the root group that uses the committed datatype in + * the root group */ + if((tid = H5Topen2(loc_id, "N", H5P_DEFAULT)) < 0) + goto out; + if((did = H5Dcreate2(loc_id, "O", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Dclose(did) < 0) + goto out; + + /* Create 2 attributes on the committed datatype that use that datatype */ + if((aid = H5Acreate2(tid, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Aclose(aid) < 0) + goto out; + if((aid = H5Acreate2(tid, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + if(H5Aclose(aid) < 0) + goto out; + if(H5Tclose(tid) < 0) + goto out; + + /* Close */ + if (H5Sclose(sid) < 0) + goto out; + return 0; +out: + H5E_BEGIN_TRY + { + H5Tclose(tid); + H5Aclose(aid); + H5Sclose(sid); + H5Dclose(did); + H5Gclose(gid); + } H5E_END_TRY; + return -1; +} /* end make_named_dtype() */ diff --git a/tools/h5repack/testfiles/h5repack_named_dtypes.h5 b/tools/h5repack/testfiles/h5repack_named_dtypes.h5 new file mode 100644 index 0000000..108bb9f Binary files /dev/null and b/tools/h5repack/testfiles/h5repack_named_dtypes.h5 differ diff --git a/tools/h5repack/testfiles/h5repack_objs.h5 b/tools/h5repack/testfiles/h5repack_objs.h5 index 0a0c041..16d55da 100644 Binary files a/tools/h5repack/testfiles/h5repack_objs.h5 and b/tools/h5repack/testfiles/h5repack_objs.h5 differ diff --git a/tools/h5stat/Makefile.in b/tools/h5stat/Makefile.in index 3bcdd8c..48957c9 100644 --- a/tools/h5stat/Makefile.in +++ b/tools/h5stat/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -391,8 +391,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -520,7 +520,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in index 3f29521..669917c 100644 --- a/tools/lib/Makefile.in +++ b/tools/lib/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -380,8 +380,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -479,7 +479,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index ebf541e..5d026ea 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -273,12 +273,10 @@ hsize_t diff_array( void *_mem1, nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); - #if H5_SIZEOF_LONG_DOUBLE !=0 else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE)) nfound=diff_ldouble(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); -#endif - +#endif break; case H5T_INTEGER: @@ -1842,7 +1840,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { if (ABS(temp1_float-temp2_float) > options->delta) @@ -1856,7 +1855,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } } /*------------------------------------------------------------------------- * !-d and -p @@ -1875,7 +1886,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_float,temp2_float); @@ -1906,7 +1918,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } } /*------------------------------------------------------------------------- @@ -1927,7 +1951,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_float,temp2_float); @@ -1959,7 +1984,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } } /*------------------------------------------------------------------------- @@ -1991,7 +2028,6 @@ hsize_t diff_datum(void *_mem1, int isnan1=0; int isnan2=0; - assert(type_size==sizeof(double)); memcpy(&temp1_double, mem1, sizeof(double)); @@ -2016,7 +2052,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { if (ABS(temp1_double-temp2_double) > options->delta) @@ -2030,8 +2067,20 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ - } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } + } /* options->d && !options->p */ /*------------------------------------------------------------------------- * !-d and -p @@ -2050,7 +2099,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_double,temp2_double); @@ -2082,7 +2132,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } } /*------------------------------------------------------------------------- @@ -2102,7 +2164,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_double,temp2_double); @@ -2135,7 +2198,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } } /*------------------------------------------------------------------------- @@ -2194,7 +2269,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { if (ABS(temp1_double-temp2_double) > options->delta) @@ -2228,7 +2304,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_double,temp2_double); @@ -2280,7 +2357,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_double,temp2_double); @@ -2791,7 +2869,8 @@ hsize_t diff_float(unsigned char *mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { if (ABS(temp1_float-temp2_float) > options->delta) { @@ -2803,7 +2882,19 @@ hsize_t diff_float(unsigned char *mem1, } nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } mem1+=sizeof(float); mem2+=sizeof(float); if (options->n && nfound>=options->count) @@ -2831,8 +2922,8 @@ hsize_t diff_float(unsigned char *mem1, isnan1 = my_isnan(FLT_FLOAT,&temp1_float); isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_float,temp2_float); @@ -2863,7 +2954,19 @@ hsize_t diff_float(unsigned char *mem1, } nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } mem1+=sizeof(float); mem2+=sizeof(float); if (options->n && nfound>=options->count) @@ -2893,7 +2996,8 @@ hsize_t diff_float(unsigned char *mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_float,temp2_float); @@ -2925,7 +3029,19 @@ hsize_t diff_float(unsigned char *mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } mem1+=sizeof(float); mem2+=sizeof(float); if (options->n && nfound>=options->count) @@ -2976,7 +3092,6 @@ hsize_t diff_float(unsigned char *mem1, } - /*------------------------------------------------------------------------- * Function: diff_double * @@ -2987,17 +3102,17 @@ hsize_t diff_float(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_double(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { hsize_t nfound=0; /* number of differences found */ @@ -3006,18 +3121,48 @@ hsize_t diff_double(unsigned char *mem1, hsize_t i; double per; int both_zero; + int isnan1=0; + int isnan2=0; - /* -d and !-p */ + /*------------------------------------------------------------------------- + * -d and !-p + *------------------------------------------------------------------------- + */ + if (options->d && !options->p) { - for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(double)); memcpy(&temp2_double, mem2, sizeof(double)); - if (ABS(temp1_double-temp2_double) > options->delta) + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) + { + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); + } + + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { + if (ABS(temp1_double-temp2_double) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) { if ( print_data(options) ) { @@ -3026,59 +3171,91 @@ hsize_t diff_double(unsigned char *mem1, parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); } nfound++; + } mem1+=sizeof(double); mem2+=sizeof(double); if (options->n && nfound>=options->count) return nfound; - } + } /* i */ } - /* !-d and -p */ + /*------------------------------------------------------------------------- + * !-d and -p + *------------------------------------------------------------------------- + */ else if (!options->d && options->p) { - for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(double)); memcpy(&temp2_double, mem2, sizeof(double)); - PER(temp1_double,temp2_double); - - if (not_comparable && !both_zero) /* not comparable */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) { - if ( print_data(options) ) - { - print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, - ABS(temp1_double-temp2_double)); - } - nfound++; + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { - else + PER(temp1_double,temp2_double); - if ( per > options->percent ) + if (not_comparable && !both_zero) /* not comparable */ { if ( print_data(options) ) { print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); parallel_print(SPACES); - parallel_print(F_FORMAT_P,temp1_double,temp2_double, - ABS(temp1_double-temp2_double), - ABS(1-temp2_double/temp1_double)); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, + ABS(temp1_double-temp2_double)); } nfound++; } - mem1+=sizeof(double); - mem2+=sizeof(double); - if (options->n && nfound>=options->count) - return nfound; - } + + else + + if ( per > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT_P,temp1_double,temp2_double, + ABS(temp1_double-temp2_double), + ABS(1-temp2_double/temp1_double)); + } + nfound++; + } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } + mem1+=sizeof(double); + mem2+=sizeof(double); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } - /* -d and -p */ + /*------------------------------------------------------------------------- + * -d and -p + *------------------------------------------------------------------------- + */ else if ( options->d && options->p) { @@ -3087,48 +3264,84 @@ hsize_t diff_double(unsigned char *mem1, memcpy(&temp1_double, mem1, sizeof(double)); memcpy(&temp2_double, mem2, sizeof(double)); - PER(temp1_double,temp2_double); - - if (not_comparable && !both_zero) /* not comparable */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) { - if ( print_data(options) ) - { - print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, - ABS(temp1_double-temp2_double)); - } - nfound++; + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } - else + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { + + PER(temp1_double,temp2_double); - if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta ) + if (not_comparable && !both_zero) /* not comparable */ { if ( print_data(options) ) { print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); parallel_print(SPACES); - parallel_print(F_FORMAT_P,temp1_double,temp2_double, - ABS(temp1_double-temp2_double), - ABS(1-temp2_double/temp1_double)); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, + ABS(temp1_double-temp2_double)); } nfound++; } - mem1+=sizeof(double); - mem2+=sizeof(double); - if (options->n && nfound>=options->count) - return nfound; - } + + else + + if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta ) + { + if ( print_data(options) ) + { + print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT_P,temp1_double,temp2_double, + ABS(temp1_double-temp2_double), + ABS(1-temp2_double/temp1_double)); + } + nfound++; + } + + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } + mem1+=sizeof(double); + mem2+=sizeof(double); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } + + /*------------------------------------------------------------------------- + * no -d and -p + *------------------------------------------------------------------------- + */ else { + + for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(double)); memcpy(&temp2_double, mem2, sizeof(double)); + if (equal_double(temp1_double,temp2_double,options)==FALSE) { if ( print_data(options) ) @@ -3144,14 +3357,22 @@ hsize_t diff_double(unsigned char *mem1, mem2+=sizeof(double); if (options->n && nfound>=options->count) return nfound; + } /* nelmts */ + + + + } return nfound; } + + + /*------------------------------------------------------------------------- * Function: diff_ldouble * @@ -3162,19 +3383,19 @@ hsize_t diff_double(unsigned char *mem1, *------------------------------------------------------------------------- */ #if H5_SIZEOF_LONG_DOUBLE !=0 - + hsize_t diff_ldouble(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { hsize_t nfound=0; /* number of differences found */ @@ -3183,79 +3404,141 @@ hsize_t diff_ldouble(unsigned char *mem1, hsize_t i; double per; int both_zero; + int isnan1=0; + int isnan2=0; - /* -d and !-p */ + /*------------------------------------------------------------------------- + * -d and !-p + *------------------------------------------------------------------------- + */ + if (options->d && !options->p) { - for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(long double)); memcpy(&temp2_double, mem2, sizeof(long double)); - if (ABS(temp1_double-temp2_double) > options->delta) + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) + { + isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); + } + + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { + if (ABS(temp1_double-temp2_double) > options->delta) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) { if ( print_data(options) ) { print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); parallel_print(SPACES); - parallel_print(LD_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); } nfound++; + } mem1+=sizeof(long double); mem2+=sizeof(long double); if (options->n && nfound>=options->count) return nfound; - } + } /* i */ } - /* !-d and -p */ + /*------------------------------------------------------------------------- + * !-d and -p + *------------------------------------------------------------------------- + */ else if (!options->d && options->p) { - for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(long double)); memcpy(&temp2_double, mem2, sizeof(long double)); - PER(temp1_double,temp2_double); - - if (not_comparable && !both_zero) /* not comparable */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) { - if ( print_data(options) ) - { - print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT_P_NOTCOMP,temp1_double,temp2_double, - ABS(temp1_double-temp2_double)); - } - nfound++; + isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { - else + PER(temp1_double,temp2_double); - if ( per > options->percent ) + if (not_comparable && !both_zero) /* not comparable */ { if ( print_data(options) ) { print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); parallel_print(SPACES); - parallel_print(LD_FORMAT_P,temp1_double,temp2_double, - ABS(temp1_double-temp2_double), - ABS(1-temp2_double/temp1_double)); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, + ABS(temp1_double-temp2_double)); } nfound++; } - mem1+=sizeof(long double); - mem2+=sizeof(long double); - if (options->n && nfound>=options->count) - return nfound; - } + + else + + if ( per > options->percent ) + { + if ( print_data(options) ) + { + print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT_P,temp1_double,temp2_double, + ABS(temp1_double-temp2_double), + ABS(1-temp2_double/temp1_double)); + } + nfound++; + } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } + mem1+=sizeof(long double); + mem2+=sizeof(long double); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } - /* -d and -p */ + /*------------------------------------------------------------------------- + * -d and -p + *------------------------------------------------------------------------- + */ else if ( options->d && options->p) { @@ -3264,55 +3547,91 @@ hsize_t diff_ldouble(unsigned char *mem1, memcpy(&temp1_double, mem1, sizeof(long double)); memcpy(&temp2_double, mem2, sizeof(long double)); - PER(temp1_double,temp2_double); - - if (not_comparable && !both_zero) /* not comparable */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) { - if ( print_data(options) ) - { - print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT_P_NOTCOMP,temp1_double,temp2_double, - ABS(temp1_double-temp2_double)); - } - nfound++; + isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } - else + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { + + PER(temp1_double,temp2_double); - if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta ) + if (not_comparable && !both_zero) /* not comparable */ { if ( print_data(options) ) { print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); parallel_print(SPACES); - parallel_print(LD_FORMAT_P,temp1_double,temp2_double, - ABS(temp1_double-temp2_double), - ABS(1-temp2_double/temp1_double)); + parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double, + ABS(temp1_double-temp2_double)); } nfound++; } - mem1+=sizeof(long double); - mem2+=sizeof(long double); - if (options->n && nfound>=options->count) - return nfound; - } + + else + + if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta ) + { + if ( print_data(options) ) + { + print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT_P,temp1_double,temp2_double, + ABS(temp1_double-temp2_double), + ABS(1-temp2_double/temp1_double)); + } + nfound++; + } + + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } + mem1+=sizeof(long double); + mem2+=sizeof(long double); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } + + /*------------------------------------------------------------------------- + * no -d and -p + *------------------------------------------------------------------------- + */ else { + + for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(long double)); memcpy(&temp2_double, mem2, sizeof(long double)); + if (equal_ldouble(temp1_double,temp2_double,options)==FALSE) { if ( print_data(options) ) { print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); parallel_print(SPACES); - parallel_print(LD_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); } nfound++; } @@ -3321,15 +3640,24 @@ hsize_t diff_ldouble(unsigned char *mem1, mem2+=sizeof(long double); if (options->n && nfound>=options->count) return nfound; + } /* nelmts */ + + + + } return nfound; } - #endif /* H5_SIZEOF_LONG_DOUBLE */ + + + + + /*------------------------------------------------------------------------- * Function: diff_schar * @@ -5208,12 +5536,7 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options) if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } - - /*------------------------------------------------------------------------- - * both are not NaNs, compare - *------------------------------------------------------------------------- - */ + } } BOTH_ZERO(value,expected) @@ -5274,13 +5597,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } - - /*------------------------------------------------------------------------- - * both are not NaNs, compare - *------------------------------------------------------------------------- - */ - + } } BOTH_ZERO(value,expected) @@ -5344,13 +5661,7 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options) if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } - - /*------------------------------------------------------------------------- - * both are not NaNs, compare - *------------------------------------------------------------------------- - */ - + } } BOTH_ZERO(value,expected) diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 4826a7f..0f53192 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -267,7 +267,7 @@ hsize_t diff_datasetid( hid_t did1, if (storage_size1==0 || storage_size2==0) { if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) - parallel_print("<%s> or <%s> are empty datasets\n", obj1_name, obj2_name); + parallel_print("Not comparable: <%s> or <%s> are empty datasets\n", obj1_name, obj2_name); can_compare=0; options->not_cmp=1; } @@ -317,7 +317,7 @@ hsize_t diff_datasetid( hid_t did1, { if ((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) { - parallel_print("<%s> has sign %s ", obj1_name, get_sign(sign1)); + parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1)); parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2)); } @@ -452,8 +452,12 @@ hsize_t diff_datasetid( hid_t did1, */ sm_nbytes = p_type_nbytes; - for (i = rank1; i > 0; --i) { - sm_size[i - 1] = MIN(dims1[i - 1], H5TOOLS_BUFSIZE / sm_nbytes); + for (i = rank1; i > 0; --i) + { + hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; + if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ + size = 1; + sm_size[i - 1] = MIN(dims1[i - 1], size); sm_nbytes *= sm_size[i - 1]; assert(sm_nbytes > 0); } @@ -694,7 +698,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( is_compound ) { - parallel_print("<%s> has a class %s and <%s> has a class %s\n", + parallel_print("Not comparable: <%s> has a class %s and <%s> has a class %s\n", obj1_name, get_class(tclass1), obj2_name, get_class(tclass2) ); @@ -744,7 +748,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) { - parallel_print("<%s> and <%s> are of class %s\n", + parallel_print("Not comparable: <%s> and <%s> are of class %s\n", obj1_name,obj2_name,get_class(tclass2) ); } can_compare = 0; @@ -789,7 +793,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) { - parallel_print("<%s> has rank %d, dimensions ", obj1_name, rank1); + parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1); print_dimensions(rank1,dims1); parallel_print(", max dimensions "); print_dimensions(rank1,maxdim1); @@ -832,7 +836,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ { if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) { - parallel_print("<%s> has rank %d, dimensions ", obj1_name, rank1); + parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1); print_dimensions(rank1,dims1); if (maxdim1 && maxdim2) { @@ -891,7 +895,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) { - parallel_print("<%s> has %d members ", obj1_name, nmembs1); + parallel_print("Not comparable: <%s> has %d members ", obj1_name, nmembs1); parallel_print("<%s> has %d members ", obj2_name, nmembs2); parallel_print("\n"); } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 6d3b0df..f28d9c5 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1651,9 +1651,12 @@ static herr_t h5tools_dump_simple_subset(FILE *stream, sm_nbytes = p_type_nbytes = H5Tget_size(p_type); if (ctx.ndims > 0) - for (i = ctx.ndims; i > 0; --i) { - sm_size[i - 1] = MIN(total_size[i - 1], H5TOOLS_BUFSIZE - / sm_nbytes); + for (i = ctx.ndims; i > 0; --i) + { + hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; + if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ + size = 1; + sm_size[i - 1] = MIN(total_size[i - 1], size); sm_nbytes *= sm_size[i - 1]; assert(sm_nbytes > 0); } diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index de1e2c3..03e6efd 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -117,7 +117,7 @@ init_ref_path_table(void) HDassert(thefile > 0); /* Create skip list to store reference path information */ - if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL) + if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR))==NULL) return (-1); /* Iterate over objects in this file */ diff --git a/tools/misc/Makefile.in b/tools/misc/Makefile.in index 98f2d1d..4e95b43 100644 --- a/tools/misc/Makefile.in +++ b/tools/misc/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -411,8 +411,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -554,7 +554,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/tools/testfiles/tall-2A.h5.xml b/tools/testfiles/tall-2A.h5.xml index 314ab4e..ce9df3a 100644 --- a/tools/testfiles/tall-2A.h5.xml +++ b/tools/testfiles/tall-2A.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml -A tall.h5' ############################# - + diff --git a/tools/testfiles/tall.h5.xml b/tools/testfiles/tall.h5.xml index 3747193..e8d39a4 100644 --- a/tools/testfiles/tall.h5.xml +++ b/tools/testfiles/tall.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tall.h5' ############################# - + diff --git a/tools/testfiles/tarray1.h5.xml b/tools/testfiles/tarray1.h5.xml index 8e68659..cff79e3 100644 --- a/tools/testfiles/tarray1.h5.xml +++ b/tools/testfiles/tarray1.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tarray1.h5' ############################# - + diff --git a/tools/testfiles/tarray2.h5.xml b/tools/testfiles/tarray2.h5.xml index b03f44b..f851c18 100644 --- a/tools/testfiles/tarray2.h5.xml +++ b/tools/testfiles/tarray2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tarray2.h5' ############################# - + diff --git a/tools/testfiles/tarray3.h5.xml b/tools/testfiles/tarray3.h5.xml index 5f0959e..a620a5e 100644 --- a/tools/testfiles/tarray3.h5.xml +++ b/tools/testfiles/tarray3.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tarray3.h5' ############################# - + diff --git a/tools/testfiles/tarray6.h5.xml b/tools/testfiles/tarray6.h5.xml index 2b32f99..5be8371 100644 --- a/tools/testfiles/tarray6.h5.xml +++ b/tools/testfiles/tarray6.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tarray6.h5' ############################# - + diff --git a/tools/testfiles/tarray7.h5.xml b/tools/testfiles/tarray7.h5.xml index c7aa380..4fb02c4 100644 --- a/tools/testfiles/tarray7.h5.xml +++ b/tools/testfiles/tarray7.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tarray7.h5' ############################# - + diff --git a/tools/testfiles/tattr.h5.xml b/tools/testfiles/tattr.h5.xml index d5ad730..bfde477 100644 --- a/tools/testfiles/tattr.h5.xml +++ b/tools/testfiles/tattr.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tattr.h5' ############################# - + diff --git a/tools/testfiles/tbitfields.h5.xml b/tools/testfiles/tbitfields.h5.xml index 56c4cd0..28da284 100644 --- a/tools/testfiles/tbitfields.h5.xml +++ b/tools/testfiles/tbitfields.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tbitfields.h5' ############################# - + diff --git a/tools/testfiles/tcompound.h5.xml b/tools/testfiles/tcompound.h5.xml index c6de351..ed255e7 100644 --- a/tools/testfiles/tcompound.h5.xml +++ b/tools/testfiles/tcompound.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tcompound.h5' ############################# - + diff --git a/tools/testfiles/tcompound2.h5.xml b/tools/testfiles/tcompound2.h5.xml index e0b087c..53e9312 100644 --- a/tools/testfiles/tcompound2.h5.xml +++ b/tools/testfiles/tcompound2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tcompound2.h5' ############################# - + diff --git a/tools/testfiles/tcompound_complex.h5.xml b/tools/testfiles/tcompound_complex.h5.xml index 693a5b8..99c1bff 100644 --- a/tools/testfiles/tcompound_complex.h5.xml +++ b/tools/testfiles/tcompound_complex.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tcompound_complex.h5' ############################# - + diff --git a/tools/testfiles/tdatareg.h5.xml b/tools/testfiles/tdatareg.h5.xml index b488409..d7dfad8 100644 --- a/tools/testfiles/tdatareg.h5.xml +++ b/tools/testfiles/tdatareg.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tdatareg.h5' ############################# - + diff --git a/tools/testfiles/tdset.h5.xml b/tools/testfiles/tdset.h5.xml index 990e788..7aedaf5 100644 --- a/tools/testfiles/tdset.h5.xml +++ b/tools/testfiles/tdset.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tdset.h5' ############################# - + diff --git a/tools/testfiles/tdset2.h5.xml b/tools/testfiles/tdset2.h5.xml index 33686e3..3bcaef0 100644 --- a/tools/testfiles/tdset2.h5.xml +++ b/tools/testfiles/tdset2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tdset2.h5' ############################# - + diff --git a/tools/testfiles/tempty-dtd-2.h5.xml b/tools/testfiles/tempty-dtd-2.h5.xml index 70f2567..bf5a5d2 100644 --- a/tools/testfiles/tempty-dtd-2.h5.xml +++ b/tools/testfiles/tempty-dtd-2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml -u tempty.h5' ############################# - + diff --git a/tools/testfiles/tempty-dtd.h5.xml b/tools/testfiles/tempty-dtd.h5.xml index a9bf259..8d15505 100644 --- a/tools/testfiles/tempty-dtd.h5.xml +++ b/tools/testfiles/tempty-dtd.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml --use-dtd tempty.h5' ############################# - + diff --git a/tools/testfiles/tempty-nons-2.h5.xml b/tools/testfiles/tempty-nons-2.h5.xml index 94239b4..c9dc971 100644 --- a/tools/testfiles/tempty-nons-2.h5.xml +++ b/tools/testfiles/tempty-nons-2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml --xml-ns=: tempty.h5' ############################# - + diff --git a/tools/testfiles/tempty-nons.h5.xml b/tools/testfiles/tempty-nons.h5.xml index 2a4d9ab..25536d9 100644 --- a/tools/testfiles/tempty-nons.h5.xml +++ b/tools/testfiles/tempty-nons.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml -X : tempty.h5' ############################# - + diff --git a/tools/testfiles/tempty-ns-2.h5.xml b/tools/testfiles/tempty-ns-2.h5.xml index 6102b39..4851e5c 100644 --- a/tools/testfiles/tempty-ns-2.h5.xml +++ b/tools/testfiles/tempty-ns-2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml --xml-ns=thing: tempty.h5' ############################# - + diff --git a/tools/testfiles/tempty-ns.h5.xml b/tools/testfiles/tempty-ns.h5.xml index 9a1ba94..01ae896 100644 --- a/tools/testfiles/tempty-ns.h5.xml +++ b/tools/testfiles/tempty-ns.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml -X thing: tempty.h5' ############################# - + diff --git a/tools/testfiles/tempty.h5.xml b/tools/testfiles/tempty.h5.xml index 5c642d6..4ff8c95 100644 --- a/tools/testfiles/tempty.h5.xml +++ b/tools/testfiles/tempty.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tempty.h5' ############################# - + diff --git a/tools/testfiles/tenum.h5.xml b/tools/testfiles/tenum.h5.xml index d3e01e5..d8adc1b 100644 --- a/tools/testfiles/tenum.h5.xml +++ b/tools/testfiles/tenum.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tenum.h5' ############################# - + diff --git a/tools/testfiles/textlink.h5.xml b/tools/testfiles/textlink.h5.xml index 0ea7084..f6666a8 100644 --- a/tools/testfiles/textlink.h5.xml +++ b/tools/testfiles/textlink.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml textlink.h5' ############################# - + diff --git a/tools/testfiles/tgroup.h5.xml b/tools/testfiles/tgroup.h5.xml index 4df9638..00f5a0b 100644 --- a/tools/testfiles/tgroup.h5.xml +++ b/tools/testfiles/tgroup.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tgroup.h5' ############################# - + diff --git a/tools/testfiles/thlink.h5.xml b/tools/testfiles/thlink.h5.xml index c2737b9..19bc816 100644 --- a/tools/testfiles/thlink.h5.xml +++ b/tools/testfiles/thlink.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml thlink.h5' ############################# - + diff --git a/tools/testfiles/tloop.h5.xml b/tools/testfiles/tloop.h5.xml index eba827e..d8a5080 100644 --- a/tools/testfiles/tloop.h5.xml +++ b/tools/testfiles/tloop.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tloop.h5' ############################# - + diff --git a/tools/testfiles/tloop2.h5.xml b/tools/testfiles/tloop2.h5.xml index 2eb8e29..73ac4e0 100644 --- a/tools/testfiles/tloop2.h5.xml +++ b/tools/testfiles/tloop2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tloop2.h5' ############################# - + diff --git a/tools/testfiles/tmany.h5.xml b/tools/testfiles/tmany.h5.xml index 93a0610..59b856f 100644 --- a/tools/testfiles/tmany.h5.xml +++ b/tools/testfiles/tmany.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tmany.h5' ############################# - + diff --git a/tools/testfiles/tname-amp.h5.xml b/tools/testfiles/tname-amp.h5.xml index 26df9f5..b443f22 100644 --- a/tools/testfiles/tname-amp.h5.xml +++ b/tools/testfiles/tname-amp.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tname-amp.h5' ############################# - + diff --git a/tools/testfiles/tname-apos.h5.xml b/tools/testfiles/tname-apos.h5.xml index 34fca8b..f60fa48 100644 --- a/tools/testfiles/tname-apos.h5.xml +++ b/tools/testfiles/tname-apos.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tname-apos.h5' ############################# - + diff --git a/tools/testfiles/tname-gt.h5.xml b/tools/testfiles/tname-gt.h5.xml index a30a30c..43d9a50 100644 --- a/tools/testfiles/tname-gt.h5.xml +++ b/tools/testfiles/tname-gt.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tname-gt.h5' ############################# - + diff --git a/tools/testfiles/tname-lt.h5.xml b/tools/testfiles/tname-lt.h5.xml index 4be63e1..4e948c9 100644 --- a/tools/testfiles/tname-lt.h5.xml +++ b/tools/testfiles/tname-lt.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tname-lt.h5' ############################# - + diff --git a/tools/testfiles/tname-quot.h5.xml b/tools/testfiles/tname-quot.h5.xml index 65e46ef..e148630 100644 --- a/tools/testfiles/tname-quot.h5.xml +++ b/tools/testfiles/tname-quot.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tname-quot.h5' ############################# - + diff --git a/tools/testfiles/tname-sp.h5.xml b/tools/testfiles/tname-sp.h5.xml index fbc790c..231d0d5 100644 --- a/tools/testfiles/tname-sp.h5.xml +++ b/tools/testfiles/tname-sp.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tname-sp.h5' ############################# - + diff --git a/tools/testfiles/tnamed_dtype_attr.h5.xml b/tools/testfiles/tnamed_dtype_attr.h5.xml index 2e3cfa3..ebba88b 100644 --- a/tools/testfiles/tnamed_dtype_attr.h5.xml +++ b/tools/testfiles/tnamed_dtype_attr.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tnamed_dtype_attr.h5' ############################# - + diff --git a/tools/testfiles/tnestedcomp.h5.xml b/tools/testfiles/tnestedcomp.h5.xml index 30ee392..a2f928b 100644 --- a/tools/testfiles/tnestedcomp.h5.xml +++ b/tools/testfiles/tnestedcomp.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tnestedcomp.h5' ############################# - + diff --git a/tools/testfiles/tnodata.h5.xml b/tools/testfiles/tnodata.h5.xml index 8b9b3a1..762475e 100644 --- a/tools/testfiles/tnodata.h5.xml +++ b/tools/testfiles/tnodata.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tnodata.h5' ############################# - + diff --git a/tools/testfiles/tobjref.h5.xml b/tools/testfiles/tobjref.h5.xml index 327291e..825cb27 100644 --- a/tools/testfiles/tobjref.h5.xml +++ b/tools/testfiles/tobjref.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tobjref.h5' ############################# - + diff --git a/tools/testfiles/topaque.h5.xml b/tools/testfiles/topaque.h5.xml index 0889251..3f44ace 100644 --- a/tools/testfiles/topaque.h5.xml +++ b/tools/testfiles/topaque.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml topaque.h5' ############################# - + diff --git a/tools/testfiles/torderattr1.h5.xml b/tools/testfiles/torderattr1.h5.xml index fcbe444..15481fc 100644 --- a/tools/testfiles/torderattr1.h5.xml +++ b/tools/testfiles/torderattr1.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml -H --sort_by=name --sort_order=ascending torderattr.h5' ############################# - + diff --git a/tools/testfiles/torderattr2.h5.xml b/tools/testfiles/torderattr2.h5.xml index 5f2b434..ef28140 100644 --- a/tools/testfiles/torderattr2.h5.xml +++ b/tools/testfiles/torderattr2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml -H --sort_by=name --sort_order=descending torderattr.h5' ############################# - + diff --git a/tools/testfiles/torderattr3.h5.xml b/tools/testfiles/torderattr3.h5.xml index 6488711..e9e131a 100644 --- a/tools/testfiles/torderattr3.h5.xml +++ b/tools/testfiles/torderattr3.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml -H --sort_by=creation_order --sort_order=ascending torderattr.h5' ############################# - + diff --git a/tools/testfiles/torderattr4.h5.xml b/tools/testfiles/torderattr4.h5.xml index c6fa0ad..2f4a2ed 100644 --- a/tools/testfiles/torderattr4.h5.xml +++ b/tools/testfiles/torderattr4.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml -H --sort_by=creation_order --sort_order=descending torderattr.h5' ############################# - + diff --git a/tools/testfiles/tref-escapes-at.h5.xml b/tools/testfiles/tref-escapes-at.h5.xml index b7a1158..6d683f1 100644 --- a/tools/testfiles/tref-escapes-at.h5.xml +++ b/tools/testfiles/tref-escapes-at.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tref-escapes-at.h5' ############################# - + diff --git a/tools/testfiles/tref-escapes.h5.xml b/tools/testfiles/tref-escapes.h5.xml index de42418..6d43069 100644 --- a/tools/testfiles/tref-escapes.h5.xml +++ b/tools/testfiles/tref-escapes.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tref-escapes.h5' ############################# - + diff --git a/tools/testfiles/tref.h5.xml b/tools/testfiles/tref.h5.xml index 6b093de..8a39acf 100644 --- a/tools/testfiles/tref.h5.xml +++ b/tools/testfiles/tref.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tref.h5' ############################# - + diff --git a/tools/testfiles/tsaf.h5.xml b/tools/testfiles/tsaf.h5.xml index 3f4ef38..11808e3 100644 --- a/tools/testfiles/tsaf.h5.xml +++ b/tools/testfiles/tsaf.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tsaf.h5' ############################# - + diff --git a/tools/testfiles/tslink.h5.xml b/tools/testfiles/tslink.h5.xml index 97d49d6..f31f425 100644 --- a/tools/testfiles/tslink.h5.xml +++ b/tools/testfiles/tslink.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tslink.h5' ############################# - + diff --git a/tools/testfiles/tstr.h5.xml b/tools/testfiles/tstr.h5.xml index 4ee36db..aa429a8 100644 --- a/tools/testfiles/tstr.h5.xml +++ b/tools/testfiles/tstr.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tstr.h5' ############################# - + diff --git a/tools/testfiles/tstr2.h5.xml b/tools/testfiles/tstr2.h5.xml index 277d9ae..62283be 100644 --- a/tools/testfiles/tstr2.h5.xml +++ b/tools/testfiles/tstr2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tstr2.h5' ############################# - + diff --git a/tools/testfiles/tstring-at.h5.xml b/tools/testfiles/tstring-at.h5.xml index bd6e412..29e2b90 100644 --- a/tools/testfiles/tstring-at.h5.xml +++ b/tools/testfiles/tstring-at.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tstring-at.h5' ############################# - + diff --git a/tools/testfiles/tstring.h5.xml b/tools/testfiles/tstring.h5.xml index 945f61a..d83ea0e 100644 --- a/tools/testfiles/tstring.h5.xml +++ b/tools/testfiles/tstring.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tstring.h5' ############################# - + diff --git a/tools/testfiles/tudlink.h5.xml b/tools/testfiles/tudlink.h5.xml index 43bf34e..bc55a83 100644 --- a/tools/testfiles/tudlink.h5.xml +++ b/tools/testfiles/tudlink.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tudlink.h5' ############################# - + diff --git a/tools/testfiles/tvldtypes1.h5.xml b/tools/testfiles/tvldtypes1.h5.xml index 8facbec..34eb276 100644 --- a/tools/testfiles/tvldtypes1.h5.xml +++ b/tools/testfiles/tvldtypes1.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tvldtypes1.h5' ############################# - + diff --git a/tools/testfiles/tvldtypes2.h5.xml b/tools/testfiles/tvldtypes2.h5.xml index c741845..d7e644c 100644 --- a/tools/testfiles/tvldtypes2.h5.xml +++ b/tools/testfiles/tvldtypes2.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tvldtypes2.h5' ############################# - + diff --git a/tools/testfiles/tvldtypes3.h5.xml b/tools/testfiles/tvldtypes3.h5.xml index d1122ad..627b2ca 100644 --- a/tools/testfiles/tvldtypes3.h5.xml +++ b/tools/testfiles/tvldtypes3.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tvldtypes3.h5' ############################# - + diff --git a/tools/testfiles/tvldtypes4.h5.xml b/tools/testfiles/tvldtypes4.h5.xml index 8433f48..de2a476 100644 --- a/tools/testfiles/tvldtypes4.h5.xml +++ b/tools/testfiles/tvldtypes4.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tvldtypes4.h5' ############################# - + diff --git a/tools/testfiles/tvldtypes5.h5.xml b/tools/testfiles/tvldtypes5.h5.xml index c4f1eb1..92d5f0c 100644 --- a/tools/testfiles/tvldtypes5.h5.xml +++ b/tools/testfiles/tvldtypes5.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tvldtypes5.h5' ############################# - + diff --git a/tools/testfiles/tvlstr.h5.xml b/tools/testfiles/tvlstr.h5.xml index 98a3b30..5999abd 100644 --- a/tools/testfiles/tvlstr.h5.xml +++ b/tools/testfiles/tvlstr.h5.xml @@ -2,7 +2,7 @@ Expected output for 'h5dump --xml tvlstr.h5' ############################# - + diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index d79c993..238c655 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -480,13 +480,13 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.36" +#define H5_PACKAGE_STRING "HDF5 1.9.39" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.36" +#define H5_PACKAGE_VERSION "1.9.39" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "ll" @@ -639,7 +639,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.36" +#define H5_VERSION "1.9.39" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ diff --git a/vms/src/make.com b/vms/src/make.com index 3dcecf1..9ebc858 100644 --- a/vms/src/make.com +++ b/vms/src/make.com @@ -40,7 +40,7 @@ $ cobj= "H5, H5checksum, H5dbg, H5system, H5timer, H5trace,"+- "H5Ffake, H5Fio, H5FL, H5Fmount, H5Fmpi, H5FO, H5Fquery, H5FS, H5FScache, H5FSdbg, H5Fsfile,"+- "H5FSsection, H5FSstat, H5FStest, H5Fsuper, H5Ftest,"+- "H5Gbtree2, H5G, H5Gcache, H5Gcompact, H5Gdense, H5Gdeprec, H5Gent, H5Gint, H5Glink, H5Gloc,"+- - "H5Gname, H5Gnode, H5Gobj, H5Goh, H5Gstab, H5Gtest, H5Gtraverse,"+- + "H5Gname, H5Gnode, H5Gobj, H5Goh, H5Groot, H5Gstab, H5Gtest, H5Gtraverse,"+- "H5HFbtree2, H5HF, H5HFcache, H5HFdbg, H5HFdblock, H5HFdtable, H5HFhdr, H5HFhuge, H5HFiblock,"+- "H5HFiter, H5HFman, H5HFsection, H5HFspace, H5HFstat, H5HFtest, H5HFtiny,"+- "H5HG, H5HGcache, H5HGdbg, H5HL, H5HLcache, H5HLdbg, H5HP, H5I, H5L, H5Lexternal" diff --git a/vms/test/check.com b/vms/test/check.com index 402f17a..1a833dc 100644 --- a/vms/test/check.com +++ b/vms/test/check.com @@ -216,11 +216,6 @@ $ run set_extent $ type sys$input $ type sys$input -------- Running space_overflow ------- -$ run space_overflow -$ type sys$input - -$ type sys$input ------- Running stab ------- $ run stab $ type sys$input diff --git a/vms/test/make.com b/vms/test/make.com index 998b6f8..e4adac9 100644 --- a/vms/test/make.com +++ b/vms/test/make.com @@ -288,12 +288,6 @@ $ link set_extent, - libh5test.olb/lib,[-.src]hdf5.olb/lib,zlib_dir:libz.olb/lib $! $ type sys$input - Creating space_overflow test -$ ccc space_overflow -$ link space_overflow, - - libh5test.olb/lib,[-.src]hdf5.olb/lib,zlib_dir:libz.olb/lib -$! -$ type sys$input Creating stab test $ ccc stab $ link stab, - diff --git a/vms/tools/h5repack/check_h5repack.com b/vms/tools/h5repack/check_h5repack.com index 207951e..34c122c 100644 --- a/vms/tools/h5repack/check_h5repack.com +++ b/vms/tools/h5repack/check_h5repack.com @@ -48,6 +48,9 @@ $ CALL TOOLTEST "" h5repack_attr.h5 $ CALL TOOLTEST "" h5repack_hlink.h5 $ CALL TOOLTEST "" h5repack_layout.h5 $ CALL TOOLTEST "" h5repack_early.h5 + +$! Check repacking file with committed datatypes in odd configurations +$ CALL TOOLTEST "" h5repack_named_dtypes.h5 $ $! # use h5repack_layout.h5 to write some filters (this file has no filters) $ diff --git a/windows/copy_hdf.bat b/windows/copy_hdf.bat index c9b2957..63ca620 100755 --- a/windows/copy_hdf.bat +++ b/windows/copy_hdf.bat @@ -21,7 +21,6 @@ rem Last Update : November 17, 2007 by Scott Wegner pushd %~dp0 -copy /y src\H5Tinit.c ..\src > nul copy /y src\H5pubconf.h ..\src > nul copy /y fortran\src\H5f90i_gen.h ..\fortran\src > nul copy /y fortran\src\H5fortran_types.f90 ..\fortran\src > nul diff --git a/windows/proj/hdf5/hdf5.vcproj b/windows/proj/hdf5/hdf5.vcproj index cf1b353..37fe50d 100644 --- a/windows/proj/hdf5/hdf5.vcproj +++ b/windows/proj/hdf5/hdf5.vcproj @@ -3511,6 +3511,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + H5TOOLS_MALLOCSIZE + set arg=%file1% -f GZIP=1 + call :tooltest %arg% + + rem Check repacking file with committed datatypes in odd configurations + call :tooltest %file15% + if %nerrors% equ 0 ( echo.All %h5repack% tests passed. diff --git a/windows/tools/testfiles/h5difftst/h5difftst.vcproj b/windows/tools/testfiles/h5difftst/h5difftst.vcproj index 98de07a..61f46cd 100644 --- a/windows/tools/testfiles/h5difftst/h5difftst.vcproj +++ b/windows/tools/testfiles/h5difftst/h5difftst.vcproj @@ -48,7 +48,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\..\src" + AdditionalIncludeDirectories="..\..\..\..\src,..\..\..\..\tools\lib" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" StringPooling="true" RuntimeLibrary="0" @@ -141,7 +141,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\..\src" + AdditionalIncludeDirectories="..\..\..\..\src,..\..\..\..\tools\lib" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" StringPooling="true" RuntimeLibrary="0" @@ -232,7 +232,7 @@ + + + + + + + + + + + + + + + + diff --git a/windows_vnet/proj/hdf5dll/hdf5dll.vcproj b/windows_vnet/proj/hdf5dll/hdf5dll.vcproj index 5177f9f..b18db22 100644 --- a/windows_vnet/proj/hdf5dll/hdf5dll.vcproj +++ b/windows_vnet/proj/hdf5dll/hdf5dll.vcproj @@ -2971,6 +2971,40 @@ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_HDF5DLL_;ZLIB_DLL;_SZDLL_;$(NoInherit)"/> + + + + + + + + + + + + + +