From 2daa28652dc7823eac6a6fd2d7ad02d391585174 Mon Sep 17 00:00:00 2001 From: Scot Breitenfeld Date: Tue, 23 Nov 2021 13:15:30 -0600 Subject: subfiling with selection IO (#1219) Merged branch 'selection_io' into subfiling branch. --- CMakeLists.txt | 8 +- MANIFEST | 23 +- bin/trace | 2 +- c++/src/H5PredType.cpp | 46 +- c++/test/CMakeVFDTests.cmake | 34 +- config/cmake/ConfigureChecks.cmake | 11 +- config/cmake/H5pubconf.h.in | 3 + config/cmake/HDF5Macros.cmake | 41 + config/cmake/HDF5UseFortran.cmake | 71 +- config/cmake/HDF5_Examples.cmake.in | 2 + config/cmake/HDFCXXCompilerFlags.cmake | 4 +- config/cmake/HDFFortranCompilerFlags.cmake | 10 +- config/cmake/jrunTest.cmake | 7 +- config/cmake/jvolTest.cmake | 301 -------- config/cmake/libhdf5.settings.cmake.in | 51 +- config/gnu-cxxflags | 4 +- config/gnu-fflags | 8 +- config/gnu-warnings/cxx-developer-4.8 | 16 + config/gnu-warnings/developer-gfort-5 | 1 + config/gnu-warnings/error-5 | 1 + config/gnu-warnings/error-8 | 5 +- config/gnu-warnings/error-general | 1 + config/gnu-warnings/gfort-5 | 1 - config/gnu-warnings/no-cxx-developer-4.8 | 9 + configure.ac | 34 + doc/library-init-shutdown.md | 56 ++ fortran/src/H5_f.c | 8 - fortran/test/tH5A.F90 | 4 +- hl/CMakeLists.txt | 8 + hl/fortran/src/H5LTfc.c | 4 - hl/src/H5DS.c | 900 +++++++++++++++------- hl/src/H5DSprivate.h | 8 +- hl/src/H5DSpublic.h | 2 + hl/src/H5LT.c | 64 +- hl/test/CMakeTests.cmake | 2 + hl/test/gen_test_ds.c | 6 +- hl/test/test_ds.c | 71 +- hl/test/test_ds_be_new_ref-32bit.h5 | Bin 0 -> 13480 bytes hl/test/test_ds_be_new_ref.h5 | Bin 0 -> 16040 bytes hl/test/test_ds_le_new_ref.h5 | Bin 0 -> 16040 bytes hl/test/test_packet_vlen.c | 4 +- hl/tools/h5watch/CMakeLists.txt | 23 - hl/tools/h5watch/CMakeTests.cmake | 68 +- hl/tools/h5watch/Makefile.am | 3 +- hl/tools/h5watch/swmr_check_compat_vfd.c | 55 -- hl/tools/h5watch/testh5watch.sh.in | 8 +- java/src/hdf/hdf5lib/CMakeLists.txt | 22 +- java/src/hdf/hdf5lib/H5.java | 51 +- java/src/hdf/hdf5lib/callbacks/package-info.java | 27 + java/src/hdf/hdf5lib/exceptions/package-info.java | 31 + java/src/hdf/hdf5lib/package-info.java | 174 +++++ java/src/hdf/hdf5lib/structs/package-info.java | 17 + java/src/jni/h5util.c | 4 +- java/test/CMakeLists.txt | 22 +- m4/aclocal_fc.f90 | 21 +- m4/aclocal_fc.m4 | 150 ++-- release_docs/RELEASE.txt | 70 +- src/CMakeLists.txt | 1 + src/H5.c | 305 ++++---- src/H5AC.c | 35 +- src/H5ACproxy_entry.c | 3 +- src/H5Aint.c | 76 +- src/H5B.c | 3 - src/H5B2.c | 3 - src/H5B2int.c | 33 +- src/H5B2pkg.h | 12 +- src/H5C.c | 3 - src/H5CX.c | 70 +- src/H5CXprivate.h | 2 + src/H5D.c | 3 - src/H5Dchunk.c | 78 +- src/H5Dcompact.c | 23 +- src/H5Dcontig.c | 31 +- src/H5Defl.c | 22 +- src/H5Dfill.c | 2 +- src/H5Dint.c | 110 +-- src/H5Dio.c | 6 +- src/H5Dpkg.h | 32 +- src/H5Dscatgath.c | 4 +- src/H5Dselect.c | 12 +- src/H5Dvirtual.c | 52 +- src/H5E.c | 145 ++-- src/H5EA.c | 3 - src/H5ESint.c | 30 +- src/H5ESprivate.h | 1 + src/H5ESpublic.h | 10 +- src/H5Eint.c | 3 +- src/H5FA.c | 3 - src/H5FD.c | 55 +- src/H5FDcore.c | 60 +- src/H5FDcore.h | 2 +- src/H5FDdevelop.h | 1 + src/H5FDdirect.c | 48 +- src/H5FDdirect.h | 2 +- src/H5FDfamily.c | 31 +- src/H5FDfamily.h | 2 +- src/H5FDhdfs.c | 23 - src/H5FDhdfs.h | 2 +- src/H5FDint.c | 7 +- src/H5FDlog.c | 48 +- src/H5FDlog.h | 2 +- src/H5FDmirror.c | 24 - src/H5FDmirror.h | 2 +- src/H5FDmpio.c | 35 +- src/H5FDmpio.h | 2 +- src/H5FDmulti.h | 2 +- src/H5FDperform.c | 58 ++ src/H5FDprivate.h | 1 + src/H5FDros3.c | 25 - src/H5FDros3.h | 2 +- src/H5FDsec2.c | 48 +- src/H5FDsec2.h | 2 +- src/H5FDsplitter.c | 27 +- src/H5FDsplitter.h | 2 +- src/H5FDstdio.h | 2 +- src/H5FL.c | 24 +- src/H5FS.c | 3 - src/H5FSint.c | 25 - src/H5FSprivate.h | 3 - src/H5Fcwfs.c | 6 +- src/H5Fint.c | 54 +- src/H5Gint.c | 72 +- src/H5HF.c | 22 +- src/H5HFcache.c | 12 +- src/H5HFman.c | 10 +- src/H5HG.c | 3 - src/H5HGprivate.h | 2 +- src/H5HL.c | 3 - src/H5Iint.c | 41 +- src/H5Lint.c | 47 +- src/H5M.c | 68 +- src/H5MF.c | 3 - src/H5MP.c | 3 - src/H5Oint.c | 27 +- src/H5P.c | 3 - src/H5PB.c | 3 - src/H5PLint.c | 48 +- src/H5PLprivate.h | 1 + src/H5Pdxpl.c | 14 +- src/H5Pfapl.c | 8 +- src/H5Pint.c | 343 +++++---- src/H5RS.c | 15 +- src/H5Rint.c | 126 +-- src/H5Rpkg.h | 2 +- src/H5Rprivate.h | 2 + src/H5S.c | 83 +- src/H5SL.c | 736 ++++++------------ src/H5SLprivate.h | 5 +- src/H5SM.c | 3 - src/H5Sall.c | 34 +- src/H5Shyper.c | 69 +- src/H5Snone.c | 34 +- src/H5Spkg.h | 18 +- src/H5Spoint.c | 34 +- src/H5Sprivate.h | 62 +- src/H5Sselect.c | 28 +- src/H5T.c | 613 +++++++-------- src/H5Tconv.c | 8 - src/H5Tnative.c | 23 +- src/H5Tpkg.h | 6 - src/H5Tpublic.h | 4 - src/H5Tref.c | 24 +- src/H5VL.c | 33 + src/H5VLint.c | 126 ++- src/H5VLpublic.h | 13 + src/H5Z.c | 144 ++-- src/H5Zscaleoffset.c | 66 +- src/H5Ztrans.c | 64 -- src/H5detect.c | 2 +- src/H5private.h | 113 +-- src/H5trace.c | 2 - src/Makefile.am | 2 +- src/libhdf5.settings.in | 51 +- src/uthash.h | 30 +- test/CMakeLists.txt | 83 +- test/CMakeTests.cmake | 2 - test/CMakeVFDTests.cmake | 35 +- test/Makefile.am | 14 +- test/ShellTests.cmake | 9 +- test/cork.c | 137 ++-- test/dt_arith.c | 160 +--- test/dtransform.c | 4 - test/dtypes.c | 2 - test/null_vfd_plugin.c | 31 + test/swmr.c | 4 +- test/swmr_check_compat_vfd.c | 53 -- test/tconfig.c | 16 - test/test_usecases.sh.in | 32 +- test/testflushrefresh.sh.in | 24 +- test/testmeta.c | 2 +- test/testswmr.sh.in | 38 +- test/testvdsswmr.sh.in | 12 +- test/tskiplist.c | 208 ----- test/tvlstr.c | 6 +- testpar/CMakeVFDTests.cmake | 35 +- tools/lib/h5diff_array.c | 43 +- tools/lib/h5diff_util.c | 2 - tools/lib/h5tools_str.c | 2 - tools/src/h5import/h5import.c | 38 +- tools/src/h5repack/h5repack.c | 88 ++- tools/src/h5repack/h5repack.h | 6 + tools/src/h5repack/h5repack_copy.c | 99 ++- tools/src/h5repack/h5repack_main.c | 14 +- tools/src/h5repack/h5repack_refs.c | 9 +- tools/test/h5diff/h5diffgentest.c | 2 - tools/test/h5dump/CMakeVFDTests.cmake | 20 +- tools/test/h5import/h5importtest.c | 28 +- tools/test/h5repack/CMakeTests.cmake | 6 +- tools/test/h5repack/CMakeVFDTests.cmake | 33 +- tools/test/h5repack/h5repack.sh.in | 17 +- tools/test/h5repack/testfiles/h5repack-help.txt | 3 +- utils/CMakeLists.txt | 9 +- utils/Makefile.am | 14 +- utils/test/CMakeLists.txt | 35 + utils/test/Makefile.am | 34 + utils/test/swmr_check_compat_vfd.c | 53 ++ 216 files changed, 4063 insertions(+), 5030 deletions(-) delete mode 100644 config/cmake/jvolTest.cmake create mode 100644 config/gnu-warnings/cxx-developer-4.8 create mode 100644 config/gnu-warnings/developer-gfort-5 delete mode 100644 config/gnu-warnings/gfort-5 create mode 100644 config/gnu-warnings/no-cxx-developer-4.8 create mode 100644 doc/library-init-shutdown.md create mode 100644 hl/test/test_ds_be_new_ref-32bit.h5 create mode 100644 hl/test/test_ds_be_new_ref.h5 create mode 100644 hl/test/test_ds_le_new_ref.h5 delete mode 100644 hl/tools/h5watch/swmr_check_compat_vfd.c create mode 100644 java/src/hdf/hdf5lib/callbacks/package-info.java create mode 100644 java/src/hdf/hdf5lib/exceptions/package-info.java create mode 100644 java/src/hdf/hdf5lib/package-info.java create mode 100644 java/src/hdf/hdf5lib/structs/package-info.java create mode 100644 src/H5FDperform.c delete mode 100644 test/swmr_check_compat_vfd.c create mode 100644 utils/test/CMakeLists.txt create mode 100644 utils/test/Makefile.am create mode 100644 utils/test/swmr_check_compat_vfd.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dc93c6..250898c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -956,6 +956,9 @@ if (BUILD_TESTING) if (HDF5_TEST_VFD) option (HDF5_TEST_FHEAP_VFD "Execute tests with different VFDs" ON) mark_as_advanced (HDF5_TEST_FHEAP_VFD) + + # Initialize the list of VFDs to be used for testing and create a test folder for each VFD + H5_SET_VFD_LIST() endif () option (HDF5_TEST_PASSTHROUGH_VOL "Execute tests with different passthrough VOL connectors" OFF) @@ -1014,10 +1017,7 @@ endif () # Option to build HDF5 Utilities #----------------------------------------------------------------------------- if (EXISTS "${HDF5_SOURCE_DIR}/utils" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/utils") - option (HDF5_BUILD_UTILS "Build HDF5 Utils" ON) - if (HDF5_BUILD_UTILS) - add_subdirectory (utils) - endif () + add_subdirectory (utils) endif () #----------------------------------------------------------------------------- diff --git a/MANIFEST b/MANIFEST index c9dc837..03da027 100644 --- a/MANIFEST +++ b/MANIFEST @@ -173,6 +173,7 @@ ./config/gnu-warnings/cxx-4.9 ./config/gnu-warnings/cxx-5 ./config/gnu-warnings/cxx-9 +./config/gnu-warnings/cxx-developer-4.8 ./config/gnu-warnings/cxx-error-5 ./config/gnu-warnings/cxx-error-general ./config/gnu-warnings/developer-4.8 @@ -186,9 +187,10 @@ ./config/gnu-warnings/general ./config/gnu-warnings/gfort-general ./config/gnu-warnings/gfort-4.8 -./config/gnu-warnings/gfort-5 +./config/gnu-warnings/developer-gfort-5 ./config/gnu-warnings/gfort-6 ./config/gnu-warnings/gfort-8 +./config/gnu-warnings/no-cxx-developer-4.8 ./config/gnu-warnings/no-developer-4.8 ./config/gnu-warnings/no-developer-8 ./config/gnu-warnings/no-developer-general @@ -205,6 +207,7 @@ ./doc/branches-explained.md ./doc/code-conventions.md ./doc/contributing.md +./doc/library-init-shutdown.md ./doxygen/aliases ./doxygen/CMakeLists.txt ./doxygen/Doxyfile.in @@ -808,6 +811,7 @@ ./src/H5FDmpio.h ./src/H5FDmulti.c ./src/H5FDmulti.h +./src/H5FDperform.c ./src/H5FDros3.c ./src/H5FDros3.h ./src/H5FDpkg.h @@ -1309,7 +1313,6 @@ ./test/stab.c ./test/swmr.c ./test/swmr_addrem_writer.c -./test/swmr_check_compat_vfd.c ./test/swmr_common.c ./test/swmr_common.h ./test/swmr_generator.c @@ -2998,6 +3001,10 @@ ./utils/mirror_vfd/mirror_server_stop.c ./utils/mirror_vfd/mirror_writer.c +# test utilities +./utils/test/Makefile.am +./utils/test/swmr_check_compat_vfd.c + # high level libraries ./hl/Makefile.am ./hl/examples/Makefile.am @@ -3071,7 +3078,10 @@ ./hl/test/sepia.pal ./hl/test/test_ds.c ./hl/test/test_ds_be.h5 +./hl/test/test_ds_be_new_ref.h5 +./hl/test/test_ds_be_new_ref-32bit.h5 ./hl/test/test_ds_le.h5 +./hl/test/test_ds_le_new_ref.h5 ./hl/test/test_dset_append.c ./hl/test/test_file_image.c ./hl/test/test_h5do_compat.c @@ -3109,7 +3119,6 @@ ./hl/tools/h5watch/extend_dset.c ./hl/tools/h5watch/h5watch.c ./hl/tools/h5watch/h5watchgentest.c -./hl/tools/h5watch/swmr_check_compat_vfd.c ./hl/tools/h5watch/testh5watch.sh.in # expected test output from testing h5watch @@ -3294,6 +3303,7 @@ ./java/src/hdf/hdf5lib/callbacks/H5P_prp_set_func_cb.java ./java/src/hdf/hdf5lib/callbacks/H5P_iterate_cb.java ./java/src/hdf/hdf5lib/callbacks/H5P_iterate_t.java +./java/src/hdf/hdf5lib/callbacks/package-info.java ./java/src/hdf/hdf5lib/exceptions/HDF5AttributeException.java ./java/src/hdf/hdf5lib/exceptions/HDF5BtreeException.java @@ -3319,6 +3329,7 @@ ./java/src/hdf/hdf5lib/exceptions/HDF5ReferenceException.java ./java/src/hdf/hdf5lib/exceptions/HDF5ResourceUnavailableException.java ./java/src/hdf/hdf5lib/exceptions/HDF5SymbolTableException.java +./java/src/hdf/hdf5lib/exceptions/package-info.java ./java/src/hdf/hdf5lib/structs/H5_ih_info_t.java ./java/src/hdf/hdf5lib/structs/H5A_info_t.java @@ -3333,12 +3344,14 @@ ./java/src/hdf/hdf5lib/structs/H5O_info_t.java ./java/src/hdf/hdf5lib/structs/H5O_native_info_t.java ./java/src/hdf/hdf5lib/structs/H5O_token_t.java +./java/src/hdf/hdf5lib/structs/package-info.java ./java/src/hdf/hdf5lib/H5.java ./java/src/hdf/hdf5lib/HDF5Constants.java ./java/src/hdf/hdf5lib/HDF5GroupInfo.java ./java/src/hdf/hdf5lib/HDFArray.java ./java/src/hdf/hdf5lib/HDFNativeData.java +./java/src/hdf/hdf5lib/package-info.java ./java/examples/Makefile.am ./java/examples/CMakeLists.txt @@ -3589,7 +3602,6 @@ ./config/cmake/HDF5UseFortran.cmake ./config/cmake/javaTargets.cmake.in ./config/cmake/jrunTest.cmake -./config/cmake/jvolTest.cmake ./config/cmake/libh5cc.in ./config/cmake/libhdf5.settings.cmake.in ./config/cmake/mccacheinit.cmake @@ -3734,7 +3746,9 @@ ./tools/test/misc/vds/CMakeLists.txt ./tools/test/perform/CMakeLists.txt ./tools/test/perform/CMakeTests.cmake + ./utils/CMakeLists.txt +./utils/test/CMakeLists.txt ./utils/mirror_vfd/CMakeLists.txt # CMake-specific User Scripts @@ -3850,3 +3864,4 @@ ./tools/test/perform/Makefile.in ./utils/Makefile.in ./utils/mirror_vfd/Makefile.in +./utils/test/Makefile.in diff --git a/bin/trace b/bin/trace index 71bcc56..e2a791e 100755 --- a/bin/trace +++ b/bin/trace @@ -500,7 +500,7 @@ for $file (@ARGV) { $file_args = 0; # Ignore some files that do not need tracing macros - unless ($file eq "H5FDmulti.c" or $file eq "src/H5FDmulti.c" or $file eq "H5FDstdio.c" or $file eq "src/H5FDstdio.c" or $file eq "src/H5TS.c") { + unless ($file eq "H5FDmulti.c" or $file eq "src/H5FDmulti.c" or $file eq "H5FDstdio.c" or $file eq "src/H5FDstdio.c" or $file eq "src/H5TS.c" or $file eq "src/H5FDperform.c") { # Snarf up the entire file open SOURCE, $file or die "$file: $!\n"; diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 72d560d..c407c33 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -406,31 +406,29 @@ PredType::makePredTypes() MIPS_F32_ = new PredType(H5T_MIPS_F32); MIPS_F64_ = new PredType(H5T_MIPS_F64); - NATIVE_CHAR_ = new PredType(H5T_NATIVE_CHAR); - NATIVE_INT_ = new PredType(H5T_NATIVE_INT); - NATIVE_FLOAT_ = new PredType(H5T_NATIVE_FLOAT); - NATIVE_SCHAR_ = new PredType(H5T_NATIVE_SCHAR); - NATIVE_UCHAR_ = new PredType(H5T_NATIVE_UCHAR); - NATIVE_SHORT_ = new PredType(H5T_NATIVE_SHORT); - NATIVE_USHORT_ = new PredType(H5T_NATIVE_USHORT); - NATIVE_UINT_ = new PredType(H5T_NATIVE_UINT); - NATIVE_LONG_ = new PredType(H5T_NATIVE_LONG); - NATIVE_ULONG_ = new PredType(H5T_NATIVE_ULONG); - NATIVE_LLONG_ = new PredType(H5T_NATIVE_LLONG); - NATIVE_ULLONG_ = new PredType(H5T_NATIVE_ULLONG); - NATIVE_DOUBLE_ = new PredType(H5T_NATIVE_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE != 0 + NATIVE_CHAR_ = new PredType(H5T_NATIVE_CHAR); + NATIVE_INT_ = new PredType(H5T_NATIVE_INT); + NATIVE_FLOAT_ = new PredType(H5T_NATIVE_FLOAT); + NATIVE_SCHAR_ = new PredType(H5T_NATIVE_SCHAR); + NATIVE_UCHAR_ = new PredType(H5T_NATIVE_UCHAR); + NATIVE_SHORT_ = new PredType(H5T_NATIVE_SHORT); + NATIVE_USHORT_ = new PredType(H5T_NATIVE_USHORT); + NATIVE_UINT_ = new PredType(H5T_NATIVE_UINT); + NATIVE_LONG_ = new PredType(H5T_NATIVE_LONG); + NATIVE_ULONG_ = new PredType(H5T_NATIVE_ULONG); + NATIVE_LLONG_ = new PredType(H5T_NATIVE_LLONG); + NATIVE_ULLONG_ = new PredType(H5T_NATIVE_ULLONG); + NATIVE_DOUBLE_ = new PredType(H5T_NATIVE_DOUBLE); NATIVE_LDOUBLE_ = new PredType(H5T_NATIVE_LDOUBLE); -#endif - NATIVE_B8_ = new PredType(H5T_NATIVE_B8); - NATIVE_B16_ = new PredType(H5T_NATIVE_B16); - NATIVE_B32_ = new PredType(H5T_NATIVE_B32); - NATIVE_B64_ = new PredType(H5T_NATIVE_B64); - NATIVE_OPAQUE_ = new PredType(H5T_NATIVE_OPAQUE); - NATIVE_HSIZE_ = new PredType(H5T_NATIVE_HSIZE); - NATIVE_HSSIZE_ = new PredType(H5T_NATIVE_HSSIZE); - NATIVE_HERR_ = new PredType(H5T_NATIVE_HERR); - NATIVE_HBOOL_ = new PredType(H5T_NATIVE_HBOOL); + NATIVE_B8_ = new PredType(H5T_NATIVE_B8); + NATIVE_B16_ = new PredType(H5T_NATIVE_B16); + NATIVE_B32_ = new PredType(H5T_NATIVE_B32); + NATIVE_B64_ = new PredType(H5T_NATIVE_B64); + NATIVE_OPAQUE_ = new PredType(H5T_NATIVE_OPAQUE); + NATIVE_HSIZE_ = new PredType(H5T_NATIVE_HSIZE); + NATIVE_HSSIZE_ = new PredType(H5T_NATIVE_HSSIZE); + NATIVE_HERR_ = new PredType(H5T_NATIVE_HERR); + NATIVE_HBOOL_ = new PredType(H5T_NATIVE_HBOOL); NATIVE_INT8_ = new PredType(H5T_NATIVE_INT8); NATIVE_UINT8_ = new PredType(H5T_NATIVE_UINT8); diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake index 6a74244..ced9b0c 100644 --- a/c++/test/CMakeVFDTests.cmake +++ b/c++/test/CMakeVFDTests.cmake @@ -15,38 +15,7 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - -set (VFD_LIST - sec2 - stdio - core - core_paged - split - multi - family - splitter - #log - log VFD currently has file space allocation bugs -) - -if (H5_HAVE_DIRECT) - set (VFD_LIST ${VFD_LIST} direct) -endif () -if (H5_HAVE_PARALLEL) - # MPI I/O VFD is currently incompatible with too many tests in the VFD test set - # set (VFD_LIST ${VFD_LIST} mpio) -endif () -if (H5_HAVE_MIRROR_VFD) - set (VFD_LIST ${VFD_LIST} mirror) -endif () -if (H5_HAVE_ROS3_VFD) - set (VFD_LIST ${VFD_LIST} ros3) -endif () -if (H5_HAVE_LIBHDFS) - set (VFD_LIST ${VFD_LIST} hdfs) -endif () -if (H5_HAVE_WINDOWS) - set (VFD_LIST ${VFD_LIST} windows) -endif () +H5_CREATE_VFD_DIR() ############################################################################## ############################################################################## @@ -56,7 +25,6 @@ endif () macro (ADD_VFD_TEST vfdname resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") add_test ( NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects COMMAND ${CMAKE_COMMAND} -E remove diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 263cedf..483e551 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -195,7 +195,7 @@ endif () # Header-check flags set in config/cmake_ext_mod/ConfigureChecks.cmake # ---------------------------------------------------------------------- option (HDF5_ENABLE_MIRROR_VFD "Build the Mirror Virtual File Driver" OFF) -if (H5FD_ENABLE_MIRROR_VFD) +if (HDF5_ENABLE_MIRROR_VFD) if ( ${HDF_PREFIX}_HAVE_NETINET_IN_H AND ${HDF_PREFIX}_HAVE_NETDB_H AND ${HDF_PREFIX}_HAVE_ARPA_INET_H AND @@ -232,7 +232,7 @@ endif () # so this one is used. #----------------------------------------------------------------------------- set (RUN_OUTPUT_PATH_DEFAULT ${CMAKE_BINARY_DIR}) -macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR) +macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR RETURN_OUTPUT_VAR) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") message (VERBOSE "Detecting C ${FUNCTION_NAME}") endif () @@ -248,7 +248,7 @@ macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR) RUN_OUTPUT_VARIABLE OUTPUT_VAR ) - set (${RETURN_VAR} ${OUTPUT_VAR}) + set (${RETURN_OUTPUT_VAR} ${OUTPUT_VAR}) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") message (VERBOSE "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") @@ -304,12 +304,11 @@ set (PROG_SRC #define C_LDBL_DIG DECIMAL_DIG\n\ #else\n\ #define C_LDBL_DIG LDBL_DIG\n\ -#endif\n\nint main() {\nFILE *pFile = fopen(\"pac_Cconftest.out\",\"w\")\\\;\nfprintf(pFile, \"\\%d\\\;\\%d\\\;\", C_LDBL_DIG, C_FLT128_DIG)\\\;\n\nreturn 0\\\;\n}\n +#endif\n\nint main() {\nprintf(\"\\%d\\\;\\%d\\\;\", C_LDBL_DIG, C_FLT128_DIG)\\\;\n\nreturn 0\\\;\n}\n " ) -C_RUN ("maximum decimal precision for C" ${PROG_SRC} PROG_RES) -file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_Cconftest.out" PROG_OUTPUT4) +C_RUN ("maximum decimal precision for C" ${PROG_SRC} PROG_RES PROG_OUTPUT4) message (STATUS "Testing maximum decimal precision for C - ${PROG_OUTPUT4}") # dnl The output from the above program will be: diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 04c0c9f..1a1c03a 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -406,6 +406,9 @@ /* Define if the high-level library headers should be included in hdf5.h */ #cmakedefine H5_INCLUDE_HL @H5_INCLUDE_HL@ +/* Define if new-style references should be used with dimension scales */ +#cmakedefine H5_DIMENSION_SCALES_WITH_NEW_REF @H5_DIMENSION_SCALES_WITH_NEW_REF@ + /* Define if your system can convert long double to (unsigned) long long values correctly. */ #cmakedefine H5_LDOUBLE_TO_LLONG_ACCURATE @H5_LDOUBLE_TO_LLONG_ACCURATE@ diff --git a/config/cmake/HDF5Macros.cmake b/config/cmake/HDF5Macros.cmake index 090524a..8b8b334 100644 --- a/config/cmake/HDF5Macros.cmake +++ b/config/cmake/HDF5Macros.cmake @@ -58,5 +58,46 @@ macro (H5_SET_LIB_OPTIONS libtarget libname libtype libpackage) endif () endif () endif () +endmacro () + +# Initialize the list of VFDs to be used for testing and create a test folder for each VFD +macro (H5_SET_VFD_LIST) + set (VFD_LIST + sec2 + stdio + core + core_paged + split + multi + family + splitter + #log - log VFD currently has file space allocation bugs + ) + + if (H5_HAVE_DIRECT) + set (VFD_LIST ${VFD_LIST} direct) + endif () + if (H5_HAVE_PARALLEL) + # MPI I/O VFD is currently incompatible with too many tests in the VFD test set + # set (VFD_LIST ${VFD_LIST} mpio) + endif () + if (H5_HAVE_MIRROR_VFD) + set (VFD_LIST ${VFD_LIST} mirror) + endif () + if (H5_HAVE_ROS3_VFD) + set (VFD_LIST ${VFD_LIST} ros3) + endif () + if (H5_HAVE_LIBHDFS) + set (VFD_LIST ${VFD_LIST} hdfs) + endif () + if (H5_HAVE_WINDOWS) + set (VFD_LIST ${VFD_LIST} windows) + endif () +endmacro () +# Initialize the list of VFDs to be used for testing and create a test folder for each VFD +macro (H5_CREATE_VFD_DIR) + foreach (vfdtest ${VFD_LIST}) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}") + endforeach () endmacro () diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index e192ec4..40027ea 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -32,15 +32,10 @@ macro (READ_SOURCE SOURCE_START SOURCE_END RETURN_VAR) endmacro () set (RUN_OUTPUT_PATH_DEFAULT ${CMAKE_BINARY_DIR}) -if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - if (HDF5_REQUIRED_LIBRARIES) - set (CMAKE_REQUIRED_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}") - endif () -else () # The provided CMake Fortran macros don't provide a general compile/run function # so this one is used. #----------------------------------------------------------------------------- -macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 RETURN_VAR) +macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 RETURN_VAR RETURN_OUTPUT_VAR) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") message (VERBOSE "Detecting Fortran ${FUNCTION_NAME}") endif () @@ -52,7 +47,9 @@ macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90 LINK_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}" + RUN_OUTPUT_VARIABLE OUTPUT_VAR ) + set (${RETURN_OUTPUT_VAR} ${OUTPUT_VAR}) if (${COMPILE_RESULT_VAR}) set(${RETURN_VAR} ${RUN_RESULT_VAR}) @@ -81,7 +78,6 @@ macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 set(${RETURN_VAR} ${COMPILE_RESULT_VAR}) endif () endmacro () -endif () #----------------------------------------------------------------------------- # Check to see C_LONG_DOUBLE is available @@ -130,25 +126,20 @@ endif () #----------------------------------------------------------------------------- READ_SOURCE ("PROGRAM FC_AVAIL_KINDS" "END PROGRAM FC_AVAIL_KINDS" SOURCE_CODE) -if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_fortran_source_runs (${SOURCE_CODE} FC_AVAIL_KINDS_RESULT SRC_EXT f90) -else () FORTRAN_RUN ("REAL and INTEGER KINDs" "${SOURCE_CODE}" XX YY FC_AVAIL_KINDS_RESULT + PROG_OUTPUT ) -endif () - # dnl The output from the above program will be: # dnl -- LINE 1 -- valid integer kinds (comma seperated list) # dnl -- LINE 2 -- valid real kinds (comma seperated list) # dnl -- LINE 3 -- max decimal precision for reals # dnl -- LINE 4 -- number of valid integer kinds # dnl -- LINE 5 -- number of valid real kinds - -file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_fconftest.out" PROG_OUTPUT) +# # Convert the string to a list of strings by replacing the carriage return with a semicolon string (REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}") @@ -196,20 +187,14 @@ foreach (KIND ${VAR}) " PROGRAM main USE ISO_C_BINDING + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : stderr=>ERROR_UNIT IMPLICIT NONE INTEGER (KIND=${KIND}) a - OPEN(8,FILE='pac_validIntKinds.${KIND}.out',FORM='formatted') - WRITE(8,'(I0)') ${FC_SIZEOF_A} - CLOSE(8) + WRITE(stderr,'(I0)') ${FC_SIZEOF_A} END " ) - if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_fortran_source_runs (${PROG_SRC_${KIND}} VALIDINTKINDS_RESULT_${KIND} SRC_EXT f90) - else () - FORTRAN_RUN("INTEGER KIND SIZEOF" ${PROG_SRC_${KIND}} XX YY VALIDINTKINDS_RESULT_${KIND}) - endif () - file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validIntKinds.${KIND}.out" PROG_OUTPUT1) + FORTRAN_RUN("INTEGER KIND SIZEOF" ${PROG_SRC_${KIND}} XX YY VALIDINTKINDS_RESULT_${KIND} PROG_OUTPUT1) string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") set (pack_int_sizeof "${pack_int_sizeof} ${PROG_OUTPUT1},") endforeach () @@ -245,22 +230,16 @@ foreach (KIND ${VAR} ) " PROGRAM main USE ISO_C_BINDING + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : stderr=>ERROR_UNIT IMPLICIT NONE REAL (KIND=${KIND}) a - OPEN(8,FILE='pac_validRealKinds.${KIND}.out',FORM='formatted') - WRITE(8,'(I0)') ${FC_SIZEOF_A} - CLOSE(8) + WRITE(stderr,'(I0)') ${FC_SIZEOF_A} END " ) - if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_fortran_source_runs (${PROG_SRC2_${KIND}} VALIDREALKINDS_RESULT_${KIND} SRC_EXT f90) - else () - FORTRAN_RUN ("REAL KIND SIZEOF" ${PROG_SRC2_${KIND}} XX YY VALIDREALKINDS_RESULT_${KIND}) - endif () - file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_validRealKinds.${KIND}.out" PROG_OUTPUT1) - string (REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") - set (pack_real_sizeof "${pack_real_sizeof} ${PROG_OUTPUT1},") + FORTRAN_RUN ("REAL KIND SIZEOF" ${PROG_SRC2_${KIND}} XX YY VALIDREALKINDS_RESULT_${KIND} PROG_OUTPUT2) + string (REGEX REPLACE "\n" "" PROG_OUTPUT2 "${PROG_OUTPUT2}") + set (pack_real_sizeof "${pack_real_sizeof} ${PROG_OUTPUT2},") endforeach () if (pack_real_sizeof STREQUAL "") @@ -293,27 +272,21 @@ set (PROG_SRC3 " PROGRAM main USE ISO_C_BINDING + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : stderr=>ERROR_UNIT IMPLICIT NONE INTEGER a REAL b DOUBLE PRECISION c - OPEN(8,FILE='pac_sizeof_native_kinds.out',FORM='formatted') - WRITE(8,*) ${FC_SIZEOF_A} - WRITE(8,*) kind(a) - WRITE(8,*) ${FC_SIZEOF_B} - WRITE(8,*) kind(b) - WRITE(8,*) ${FC_SIZEOF_C} - WRITE(8,*) kind(c) - CLOSE(8) + WRITE(stderr,*) ${FC_SIZEOF_A} + WRITE(stderr,*) kind(a) + WRITE(stderr,*) ${FC_SIZEOF_B} + WRITE(stderr,*) kind(b) + WRITE(stderr,*) ${FC_SIZEOF_C} + WRITE(stderr,*) kind(c) END " ) -if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") - check_fortran_source_runs (${PROG_SRC3} PAC_SIZEOF_NATIVE_KINDS_RESULT SRC_EXT f90) -else () - FORTRAN_RUN ("SIZEOF NATIVE KINDs" ${PROG_SRC3} XX YY PAC_SIZEOF_NATIVE_KINDS_RESULT) -endif () -file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_sizeof_native_kinds.out" PROG_OUTPUT3) +FORTRAN_RUN ("SIZEOF NATIVE KINDs" ${PROG_SRC3} XX YY PAC_SIZEOF_NATIVE_KINDS_RESULT PROG_OUTPUT3) # dnl The output from the above program will be: # dnl -- LINE 1 -- sizeof INTEGER # dnl -- LINE 2 -- kind of INTEGER @@ -321,7 +294,7 @@ file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_sizeof_native_kinds.out" PROG_OUTPUT3 # dnl -- LINE 4 -- kind of REAL # dnl -- LINE 5 -- sizeof DOUBLE PRECISION # dnl -- LINE 6 -- kind of DOUBLE PRECISION - +# # Convert the string to a list of strings by replacing the carriage return with a semicolon string (REGEX REPLACE "\n" ";" PROG_OUTPUT3 "${PROG_OUTPUT3}") diff --git a/config/cmake/HDF5_Examples.cmake.in b/config/cmake/HDF5_Examples.cmake.in index 5b7262e..db638fd 100644 --- a/config/cmake/HDF5_Examples.cmake.in +++ b/config/cmake/HDF5_Examples.cmake.in @@ -94,6 +94,8 @@ else() set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") endif() +### default HDF5_PLUGIN_PATH to where the filter libraries are located +set(ENV{HDF5_PLUGIN_PATH} "${INSTALLDIR}/lib/plugin") if(${CDASH_LOCAL}) set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCDASH_LOCAL:BOOL=ON") endif() diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 7bfd0bd..a5af43c 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -181,9 +181,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-4.8") if (HDF5_ENABLE_DEV_WARNINGS) # Use the C warnings as CXX warnings are the same - ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-developer-4.8") else () - ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8") + ADD_H5_FLAGS (H5_CXXFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-cxx-developer-4.8") endif () endif () diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 94c40aa..754259e 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -79,7 +79,6 @@ if (NOT MSVC AND NOT MINGW) endif () if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - # Append more extra warning flags that only gcc 4.8+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") @@ -91,10 +90,11 @@ if (NOT MSVC AND NOT MINGW) #endif () # Append more extra warning flags that only gcc 5.x+ knows about - # do not include -Wuse-without-only - #if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) - # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") - #endif () + if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) + if (HDF5_ENABLE_DEV_WARNINGS) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-gfort-5") + endif () + endif () # Append more extra warning flags that only gcc 6.x+ knows about if (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) diff --git a/config/cmake/jrunTest.cmake b/config/cmake/jrunTest.cmake index 2ca1b75..13e50dd 100644 --- a/config/cmake/jrunTest.cmake +++ b/config/cmake/jrunTest.cmake @@ -47,7 +47,12 @@ else () set (LOG_LEVEL "${TEST_LOG_LEVEL}") endif () -message (STATUS "COMMAND: ${TEST_TESTER} -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=${LOG_LEVEL} -Djava.library.path=\"${TEST_LIBRARY_DIRECTORY}\" -cp \"${TEST_CLASSPATH}\" ${TEST_ARGS} ${TEST_PROGRAM} ${ARGN}") +if (NOT TEST_VOL) + message (STATUS "COMMAND: ${TEST_TESTER} -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=${LOG_LEVEL} -Djava.library.path=\"${TEST_LIBRARY_DIRECTORY}\" -cp \"${TEST_CLASSPATH}\" ${TEST_ARGS} ${TEST_PROGRAM} ${ARGN}") +else () + message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_TESTER} -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=${LOG_LEVEL} -Djava.library.path=\"${TEST_LIBRARY_DIRECTORY}\" -cp \"${TEST_CLASSPATH}\" ${TEST_ARGS} ${TEST_PROGRAM} ${ARGN}") + set (ENV{HDF5_VOL_CONNECTOR} "${TEST_VOL}") +endif () if (WIN32) set (ENV{PATH} "$ENV{PATH}\\;${TEST_LIBRARY_DIRECTORY}") diff --git a/config/cmake/jvolTest.cmake b/config/cmake/jvolTest.cmake deleted file mode 100644 index b12c358..0000000 --- a/config/cmake/jvolTest.cmake +++ /dev/null @@ -1,301 +0,0 @@ -# -# Copyright by The HDF Group. -# 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 COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# jrunTest.cmake executes a command and captures the output in a file. File is then compared -# against a reference file. Exit status of command can also be compared. -cmake_policy(SET CMP0007 NEW) - -# arguments checking -if (NOT TEST_TESTER) - message (FATAL_ERROR "Require TEST_TESTER to be defined") -endif () -if (NOT TEST_PROGRAM) - message (FATAL_ERROR "Require TEST_PROGRAM to be defined") -endif () -if (NOT TEST_LIBRARY_DIRECTORY) - message (STATUS "Require TEST_LIBRARY_DIRECTORY to be defined") -endif () -if (NOT TEST_FOLDER) - message (FATAL_ERROR "Require TEST_FOLDER to be defined") -endif () -if (NOT TEST_OUTPUT) - message (FATAL_ERROR "Require TEST_OUTPUT to be defined") -endif () -if (NOT TEST_CLASSPATH) - message (STATUS "Require TEST_CLASSPATH to be defined") -endif () -if (NOT TEST_VOL) - message (FATAL_ERROR "Require TEST_VOL to be defined") -endif () - -if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}") - file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}) -endif () - -if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err") - file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) -endif () - -if (NOT TEST_LOG_LEVEL) - set (LOG_LEVEL "info") -else () - set (LOG_LEVEL "${TEST_LOG_LEVEL}") -endif () - -message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_TESTER} -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=${LOG_LEVEL} -Djava.library.path=\"${TEST_LIBRARY_DIRECTORY}\" -cp \"${TEST_CLASSPATH}\" ${TEST_ARGS} ${TEST_PROGRAM} ${ARGN}") - -set (ENV{HDF5_VOL_CONNECTOR} "${TEST_VOL}") - -if (WIN32) - set (ENV{PATH} "$ENV{PATH}\\;${TEST_LIBRARY_DIRECTORY}") -else () - set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}") -endif () - -# run the test program, capture the stdout/stderr and the result var -execute_process ( - COMMAND ${TEST_TESTER} -Xmx1024M - -Dorg.slf4j.simpleLogger.defaultLogLevel=${LOG_LEVEL} - -Djava.library.path=${TEST_LIBRARY_DIRECTORY} - -cp "${TEST_CLASSPATH}" ${TEST_ARGS} ${TEST_PROGRAM} - ${ARGN} - WORKING_DIRECTORY ${TEST_FOLDER} - RESULT_VARIABLE TEST_RESULT - OUTPUT_FILE ${TEST_OUTPUT} - ERROR_FILE ${TEST_OUTPUT}.err - OUTPUT_VARIABLE TEST_OUT - ERROR_VARIABLE TEST_ERROR -) - -message (STATUS "COMMAND Result: ${TEST_RESULT}") - -# if the .err file exists and ERRROR_APPEND is enabled -if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err") - file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) - list(LENGTH TEST_STREAM test_len) - if (test_len GREATER 0) - if (TEST_MASK_FILE) - STRING(REGEX REPLACE "CurrentDir is [^\n]+\n" "CurrentDir is (dir name)\n" TEST_STREAM "${TEST_STREAM}") - endif () - - if (NOT ERROR_APPEND) - # write back to original .err file - file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}") - else () - # append error output to the stdout output file - file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") - endif () - endif () -endif () - -# if the output file or the .err file needs to mask out error stack info -if (TEST_MASK_ERROR) - if (NOT TEST_ERRREF) - # the error stack has been appended to the output file - file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) - else () - # the error stack remains in the .err file - file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) - endif () - string (REGEX REPLACE "Time:[^\n]+\n" "Time: XXXX\n" TEST_STREAM "${TEST_STREAM}") - string (REGEX REPLACE "thread [0-9]*:" "thread (IDs):" TEST_STREAM "${TEST_STREAM}") - string (REGEX REPLACE ": ([^\n]*)[.]c " ": (file name) " TEST_STREAM "${TEST_STREAM}") - string (REGEX REPLACE " line [0-9]*" " line (number)" TEST_STREAM "${TEST_STREAM}") - #string (REGEX REPLACE "v[1-9]*[.][0-9]*[.]" "version (number)." TEST_STREAM "${TEST_STREAM}") - string (REGEX REPLACE "HDF5 .[1-9]*[.][0-9]*[.][0-9]*[^)]*" "HDF5 (version (number)" TEST_STREAM "${TEST_STREAM}") - string (REGEX REPLACE "H5Eget_auto[1-2]*" "H5Eget_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}") - string (REGEX REPLACE "H5Eset_auto[1-2]*" "H5Eset_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}") - # write back the changes to the original files - if (NOT TEST_ERRREF) - file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") - else () - file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}") - endif () -endif () - -# if the return value is !=expected bail out -if (NOT TEST_RESULT EQUAL TEST_EXPECT) - message (STATUS "ERROR OUTPUT: ${TEST_STREAM}") - message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != 0.\n${TEST_ERROR}") -endif () - -message (STATUS "COMMAND Error: ${TEST_ERROR}") - -# compare output files to references unless this must be skipped -set (TEST_COMPARE_RESULT 0) -if (NOT TEST_SKIP_COMPARE) - if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}") - file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) - list(LENGTH TEST_STREAM test_len) - if (test_len GREATER 0) - if (WIN32) - configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF) - if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}.tmp") - file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE}) - endif () - #file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) - #file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") - endif () - - if (NOT TEST_SORT_COMPARE) - # now compare the output with the reference - execute_process ( - COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE} - RESULT_VARIABLE TEST_COMPARE_RESULT - ) - else () - file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} v1) - file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} v2) - list (SORT v1) - list (SORT v2) - if (NOT v1 STREQUAL v2) - set(TEST_COMPARE_RESULT 1) - endif () - endif () - - if (TEST_COMPARE_RESULT) - set (TEST_COMPARE_RESULT 0) - file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) - list (LENGTH test_act len_act) - file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref) - list (LENGTH test_ref len_ref) - if (len_act GREATER 0 AND len_ref GREATER 0) - math (EXPR _FP_LEN "${len_ref} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET test_act ${line} str_act) - list (GET test_ref ${line} str_ref) - if (NOT str_act STREQUAL str_ref) - if (str_act) - set (TEST_COMPARE_RESULT 1) - message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") - endif () - endif () - endforeach () - else () - if (len_act EQUAL 0) - message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty") - endif () - if (len_ref EQUAL 0) - message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty") - endif () - endif () - if (NOT len_act EQUAL len_ref) - set (TEST_COMPARE_RESULT 1) - endif () - endif () - endif () - - message (STATUS "COMPARE Result: ${TEST_COMPARE_RESULT}") - - # again, if return value is !=0 scream and shout - if (TEST_COMPARE_RESULT) - message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}") - endif () - endif () - - # now compare the .err file with the error reference, if supplied - set (TEST_ERRREF_RESULT 0) - if (TEST_ERRREF) - file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) - list(LENGTH TEST_STREAM test_len) - if (test_len GREATER 0) - if (WIN32) - configure_file(${TEST_FOLDER}/${TEST_ERRREF} ${TEST_FOLDER}/${TEST_ERRREF}.tmp NEWLINE_STYLE CRLF) - if (EXISTS "${TEST_FOLDER}/${TEST_ERRREF}.tmp") - file(RENAME ${TEST_FOLDER}/${TEST_ERRREF}.tmp ${TEST_FOLDER}/${TEST_ERRREF}) - endif () - #file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) - #file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") - endif () - - # now compare the error output with the error reference - execute_process ( - COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT}.err ${TEST_FOLDER}/${TEST_ERRREF} - RESULT_VARIABLE TEST_ERRREF_RESULT - ) - if (TEST_ERRREF_RESULT) - set (TEST_ERRREF_RESULT 0) - file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT}.err test_act) - list (LENGTH test_act len_act) - file (STRINGS ${TEST_FOLDER}/${TEST_ERRREF} test_ref) - list (LENGTH test_ref len_ref) - math (EXPR _FP_LEN "${len_ref} - 1") - if (len_act GREATER 0 AND len_ref GREATER 0) - math (EXPR _FP_LEN "${len_ref} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET test_act ${line} str_act) - list (GET test_ref ${line} str_ref) - if (NOT str_act STREQUAL str_ref) - if (str_act) - set (TEST_ERRREF_RESULT 1) - message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") - endif () - endif () - endforeach () - else () - if (len_act EQUAL 0) - message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT}.err is empty") - endif () - if (len_ref EQUAL 0) - message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_ERRREF} is empty") - endif () - endif () - if (NOT len_act EQUAL len_ref) - set (TEST_ERRREF_RESULT 1) - endif () - endif () - endif () - - message (STATUS "COMPARE Result: ${TEST_ERRREF_RESULT}") - - # again, if return value is !=0 scream and shout - if (TEST_ERRREF_RESULT) - message (FATAL_ERROR "Failed: The error output of ${TEST_OUTPUT}.err did not match ${TEST_ERRREF}") - endif () - endif () -endif () - -set (TEST_GREP_RESULT 0) -if (TEST_GREP_COMPARE) - # now grep the output with the reference - file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) - list(LENGTH TEST_STREAM test_len) - if (test_len GREATER 0) - # TEST_REFERENCE should always be matched - string (REGEX MATCH "${TEST_REFERENCE}" TEST_MATCH ${TEST_STREAM}) - string (COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_GREP_RESULT) - if (NOT TEST_GREP_RESULT) - message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}") - endif () - - string (REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM}) - if (TEST_EXPECT) - # TEST_EXPECT (1) interprets TEST_FILTER as; NOT to match - string (LENGTH "${TEST_MATCH}" TEST_GREP_RESULT) - if (TEST_GREP_RESULT) - message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_FILTER}") - endif () - endif () - endif () -endif () - -# dump the output unless nodisplay option is set -if (TEST_SKIP_COMPARE AND NOT TEST_NO_DISPLAY) - file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) - execute_process ( - COMMAND ${CMAKE_COMMAND} -E echo ${TEST_STREAM} - RESULT_VARIABLE TEST_RESULT - ) -endif () - -# everything went fine... -message (STATUS "${TEST_PROGRAM} program used vol ${TEST_VOL} Passed") - diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index eb83c3a..d80b0f8 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -64,28 +64,29 @@ Languages: Features: --------- - Parallel HDF5: @HDF5_ENABLE_PARALLEL@ -Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ - Large Parallel I/O: @LARGE_PARALLEL_IO@ - High-level library: @HDF5_BUILD_HL_LIB@ - Build HDF5 Tests: @BUILD_TESTING@ - Build HDF5 Tools: @HDF5_BUILD_TOOLS@ - Build High-level HDF5 Tools: @HDF5_BUILD_HL_TOOLS@ - Threadsafety: @HDF5_ENABLE_THREADSAFE@ - Default API mapping: @DEFAULT_API_VERSION@ - With deprecated public symbols: @HDF5_ENABLE_DEPRECATED_SYMBOLS@ - I/O filters (external): @EXTERNAL_FILTERS@ - MPE: @H5_HAVE_LIBLMPE@ - Direct VFD: @H5_HAVE_DIRECT@ - Mirror VFD: @H5_HAVE_MIRROR_VFD@ - (Read-Only) S3 VFD: @H5_HAVE_ROS3_VFD@ - (Read-Only) HDFS VFD: @H5_HAVE_LIBHDFS@ - dmalloc: @H5_HAVE_LIBDMALLOC@ - Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@ - API Tracing: @HDF5_ENABLE_TRACE@ - Using memory checker: @HDF5_ENABLE_USING_MEMCHECKER@ - Memory allocation sanity checks: @HDF5_MEMORY_ALLOC_SANITY_CHECK@ - Function Stack Tracing: @HDF5_ENABLE_CODESTACK@ - Use file locking: @HDF5_FILE_LOCKING_SETTING@ - Strict File Format Checks: @HDF5_STRICT_FORMAT_CHECKS@ - Optimization Instrumentation: @HDF5_Enable_Instrument@ + Parallel HDF5: @HDF5_ENABLE_PARALLEL@ + Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ + Large Parallel I/O: @LARGE_PARALLEL_IO@ + High-level library: @HDF5_BUILD_HL_LIB@ +Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@ + Build HDF5 Tests: @BUILD_TESTING@ + Build HDF5 Tools: @HDF5_BUILD_TOOLS@ + Build High-level HDF5 Tools: @HDF5_BUILD_HL_TOOLS@ + Threadsafety: @HDF5_ENABLE_THREADSAFE@ + Default API mapping: @DEFAULT_API_VERSION@ + With deprecated public symbols: @HDF5_ENABLE_DEPRECATED_SYMBOLS@ + I/O filters (external): @EXTERNAL_FILTERS@ + MPE: @H5_HAVE_LIBLMPE@ + Direct VFD: @H5_HAVE_DIRECT@ + Mirror VFD: @H5_HAVE_MIRROR_VFD@ + (Read-Only) S3 VFD: @H5_HAVE_ROS3_VFD@ + (Read-Only) HDFS VFD: @H5_HAVE_LIBHDFS@ + dmalloc: @H5_HAVE_LIBDMALLOC@ + Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@ + API Tracing: @HDF5_ENABLE_TRACE@ + Using memory checker: @HDF5_ENABLE_USING_MEMCHECKER@ + Memory allocation sanity checks: @HDF5_MEMORY_ALLOC_SANITY_CHECK@ + Function Stack Tracing: @HDF5_ENABLE_CODESTACK@ + Use file locking: @HDF5_FILE_LOCKING_SETTING@ + Strict File Format Checks: @HDF5_STRICT_FORMAT_CHECKS@ + Optimization Instrumentation: @HDF5_Enable_Instrument@ diff --git a/config/gnu-cxxflags b/config/gnu-cxxflags index 280679d..56e89bc 100644 --- a/config/gnu-cxxflags +++ b/config/gnu-cxxflags @@ -221,8 +221,8 @@ if test "X-g++" = "X-$cxx_vendor"; then if test $cxx_vers_major -ge 5 -o $cxx_vers_major -eq 4 -a $cxx_vers_minor -ge 8; then H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-4.8)" # Use the C warnings as CXX warnings are the same - DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments developer-4.8)" - NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-developer-4.8)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments cxx-developer-4.8)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gnu_arguments no-cxx-developer-4.8)" fi # gcc >= 4.9 diff --git a/config/gnu-fflags b/config/gnu-fflags index ce12561..1333ce5 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -161,10 +161,10 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # gfortran 4.9 (nothing new) - # gfortran >= 5 (do not include -Wuse-without-only) - #if test $f9x_vers_major -ge 5; then - # H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-5)" - #fi + # gfortran >= 5 + if test $f9x_vers_major -ge 5; then + DEVELOPER_WARNING_FCFLAGS="$DEVELOPER_WARNING_FCFLAGS $(load_gnu_arguments developer-gfort-5)" + fi # gfortran >= 6 if test $f9x_vers_major -ge 6; then diff --git a/config/gnu-warnings/cxx-developer-4.8 b/config/gnu-warnings/cxx-developer-4.8 new file mode 100644 index 0000000..e0d975f --- /dev/null +++ b/config/gnu-warnings/cxx-developer-4.8 @@ -0,0 +1,16 @@ +# developer warning flags added for GCC >= 4.5 +# +# developer warning flag added for GCC >= 4.6 +-Wsuggest-attribute=const + +# developer warning flags added for GCC >= 4.7 +-Wsuggest-attribute=noreturn +-Wsuggest-attribute=pure +# +# It's not clear that -Wvector-operation-performance warnings are +# actionable, so they are demoted to "developer" warnings. +# +-Wvector-operation-performance + +# developer warning flag added for GCC >= 4.8 +-Wsuggest-attribute=format diff --git a/config/gnu-warnings/developer-gfort-5 b/config/gnu-warnings/developer-gfort-5 new file mode 100644 index 0000000..c5d3850 --- /dev/null +++ b/config/gnu-warnings/developer-gfort-5 @@ -0,0 +1 @@ +-Wuse-without-only diff --git a/config/gnu-warnings/error-5 b/config/gnu-warnings/error-5 index f7e1138..282ee3f 100644 --- a/config/gnu-warnings/error-5 +++ b/config/gnu-warnings/error-5 @@ -1,4 +1,5 @@ -Werror=incompatible-pointer-types +-Werror=int-conversion # # In GCC 4.4.7, the compiler gripes about shadowed global # declarations when a local variable uses the name of a diff --git a/config/gnu-warnings/error-8 b/config/gnu-warnings/error-8 index 2f54a4d..cbb25f6 100644 --- a/config/gnu-warnings/error-8 +++ b/config/gnu-warnings/error-8 @@ -1,7 +1,4 @@ -# NOTE: src/ files are not compatible with these warnings as errors -# src/H5Dchunk.c -# -Werror=cast-function-type --Wcast-function-type +-Werror=cast-function-type # # For GCC 8, promote maybe-initialized warnings to an error. GCC 8 # reports 0 maybe-uninitialized warnings where earlier versions diff --git a/config/gnu-warnings/error-general b/config/gnu-warnings/error-general index 8405c40..a66d284 100644 --- a/config/gnu-warnings/error-general +++ b/config/gnu-warnings/error-general @@ -11,6 +11,7 @@ -Werror=packed -Werror=pointer-sign -Werror=pointer-to-int-cast +-Werror=int-to-pointer-cast -Werror=redundant-decls -Werror=strict-prototypes -Werror=switch diff --git a/config/gnu-warnings/gfort-5 b/config/gnu-warnings/gfort-5 deleted file mode 100644 index c5d3850..0000000 --- a/config/gnu-warnings/gfort-5 +++ /dev/null @@ -1 +0,0 @@ --Wuse-without-only diff --git a/config/gnu-warnings/no-cxx-developer-4.8 b/config/gnu-warnings/no-cxx-developer-4.8 new file mode 100644 index 0000000..3c3de93 --- /dev/null +++ b/config/gnu-warnings/no-cxx-developer-4.8 @@ -0,0 +1,9 @@ +# no-developer warning flag added for GCC >= 4.6 +-Wno-suggest-attribute=const + +# no-developer warning flags added for GCC >= 4.7 +-Wno-suggest-attribute=noreturn +-Wno-suggest-attribute=pure + +# no-developer warning flag added for GCC >= 4.8 +-Wno-suggest-attribute=format diff --git a/configure.ac b/configure.ac index 7281af4..4882e58 100644 --- a/configure.ac +++ b/configure.ac @@ -876,6 +876,38 @@ fi ## ---------------------------------------------------------------------- +## Enable new references for dimension scales +## +AC_SUBST([DIMENSION_SCALES_WITH_NEW_REF]) +AC_MSG_CHECKING([whether to use new references with dimension scales]); +AC_ARG_ENABLE([dimension-scales-with-new-ref], + [AS_HELP_STRING([--enable-dimension-scales-with-new-ref], + [Use new references when creating dimension scales. + [default=no] + ])], + [DIMENSION_SCALES_WITH_NEW_REF=$enableval]) + +## Set the default value to use old references. +if test "X-$DIMENSION_SCALES_WITH_NEW_REF" = X- ; then + DIMENSION_SCALES_WITH_NEW_REF=no +fi + +case "X-$DIMENSION_SCALES_WITH_NEW_REF" in + X-yes) + AC_MSG_RESULT([yes]) + AC_DEFINE([DIMENSION_SCALES_WITH_NEW_REF], [1], + [Define if new references for dimension scales were requested]) + + ;; + X-no) + AC_MSG_RESULT([no]) + ;; + *) + AC_MSG_ERROR([Unrecognized value: $DIMENSION_SCALES_WITH_NEW_REF]) + ;; +esac + +## ---------------------------------------------------------------------- ## Check which archiving tool to use. This needs to be done before ## the AM_PROG_LIBTOOL macro. ## @@ -2364,6 +2396,7 @@ fi case "X-$DEV_WARNINGS" in X-yes) H5_CFLAGS="$H5_CFLAGS $DEVELOPER_WARNING_CFLAGS" + H5_FCFLAGS="$H5_FCFLAGS $DEVELOPER_WARNING_FCFLAGS" AC_MSG_RESULT([yes]) ;; X-no) @@ -4091,6 +4124,7 @@ AC_CONFIG_FILES([src/libhdf5.settings testpar/testpflush.sh utils/Makefile utils/mirror_vfd/Makefile + utils/test/Makefile tools/Makefile tools/lib/Makefile tools/libtest/Makefile diff --git a/doc/library-init-shutdown.md b/doc/library-init-shutdown.md new file mode 100644 index 0000000..917d213 --- /dev/null +++ b/doc/library-init-shutdown.md @@ -0,0 +1,56 @@ +# HDF5 Library initialization and shutdown + +## Application perspective + +### Implicit initialization and shutdown + +When a developer exports a new symbol as part of the HDF5 library, +they should make sure that an application cannot enter the library in an +uninitialized state through a new API function, or read an uninitialized +value from a non-function HDF5 symbol. + +The HDF5 library initializes itself when an application either enters +the library through an API function call such as `H5Fopen`, or when +an application evaluates an HDF5 symbol that represents either a +property-list identifier such as `H5F_ACC_RDONLY` or `H5F_ACC_RDWR`, +a property-list class identifier such as `H5P_FILE_ACCESS`, a VFD +identifier such as `H5FD_FAMILY` or `H5FD_SEC2`, or a type identifier +such as `H5T_NATIVE_INT64`. + +The library sets a flag when initialization occurs and as long as the +flag is set, skips initialization. + +The library provides a couple of macros that initialize the library +as necessary. The library is initialized as a side-effect of the +`FUNC_ENTER_API*` macros used at the top of most API functions. HDF5 +library symbols other than functions are provided through `#define`s +that use `H5OPEN` to introduce a library-initialization call (`H5open`) +at each site where a non-function symbol is used. + +Ordinarily the library registers an `atexit(3)` handler to shut itself +down when the application exits. + +### Explicit initialization and shutdown + +An application may use an API call, `H5open`, to explicitly initialize +the library. `H5close` explicitly shuts down the library. + +## Library internals perspective + +No matter how library initializion begins, eventually the internal +function `H5_init_library` will be called. `H5_init_library` is +responsible for calling the initializers for every internal HDF5 +library module (aka "package") in the correct order so that no module is +initialized before its prerequisite modules. A table in `H5_init_library` +establishes the order of initialization. If a developer adds a +module to the library that it is appropriate to initialize with the rest +of the library, then they should insert its initializer into the right +place in the table. + +`H5_term_library` drives library shutdown. Library shutdown is +table-driven, too. If a developer adds a module that needs to release +resources during library shutdown, then they should add a call at the +right place to the shutdown table. Note that some entries in the shutdown +table are marked as "barriers," and if a new module should only be +shutdown *strictly after* the preceding modules, then it should be marked +as a barrier. See the comments in `H5_term_library` for more information. diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index d245cae..0277e5c 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -118,24 +118,20 @@ h5init_types_c(hid_t_f *types, hid_t_f *floatingtypes, hid_t_f *integertypes) if ((types[6] = (hid_t_f)H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) return ret_value; } /* end if */ -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (sizeof(real_f) == sizeof(long double)) { if ((types[6] = (hid_t_f)H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) return ret_value; } /* end else */ -#endif /* Find appropriate size to store Fortran DOUBLE */ if (sizeof(double_f) == sizeof(double)) { if ((types[7] = (hid_t_f)H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) return ret_value; } /*end if */ -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (sizeof(double_f) == sizeof(long double)) { if ((types[7] = (hid_t_f)H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) return ret_value; } /*end else */ -#endif #ifdef H5_HAVE_FLOAT128 else if (sizeof(double_f) == sizeof(__float128)) { if ((types[7] = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) @@ -169,12 +165,10 @@ h5init_types_c(hid_t_f *types, hid_t_f *floatingtypes, hid_t_f *integertypes) if ((types[11] = (hid_t_f)H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) return ret_value; } /*end if */ -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (sizeof(real_C_FLOAT_f) == sizeof(long double)) { if ((types[11] = (hid_t_f)H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) return ret_value; } /*end else */ -#endif /* * FIND H5T_NATIVE_REAL_C_DOUBLE */ @@ -186,12 +180,10 @@ h5init_types_c(hid_t_f *types, hid_t_f *floatingtypes, hid_t_f *integertypes) if ((types[12] = (hid_t_f)H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) return ret_value; } /*end if */ -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (sizeof(real_C_DOUBLE_f) == sizeof(long double)) { if ((types[12] = (hid_t_f)H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) return ret_value; } /*end else */ -#endif /* * FIND H5T_NATIVE_REAL_C_LONG_DOUBLE */ diff --git a/fortran/test/tH5A.F90 b/fortran/test/tH5A.F90 index 4d56bed..d5ce9a2 100644 --- a/fortran/test/tH5A.F90 +++ b/fortran/test/tH5A.F90 @@ -408,13 +408,13 @@ CONTAINS !open the INTEGER attrbute by name ! CALL h5aopen_name_f(dset_id, aname5, attr5_id, error) - CALL check("h5aopen_idx_f",error,total_error) + CALL check("h5aopen_name_f",error,total_error) ! !open the NULL attrbute by name ! CALL h5aopen_name_f(dset_id, aname6, attr6_id, error) - CALL check("h5aopen_idx_f",error,total_error) + CALL check("h5aopen_name_f",error,total_error) ! !get the attrbute name diff --git a/hl/CMakeLists.txt b/hl/CMakeLists.txt index 5061c6c..9391231 100644 --- a/hl/CMakeLists.txt +++ b/hl/CMakeLists.txt @@ -2,6 +2,14 @@ cmake_minimum_required (VERSION 3.12) project (HDF5_HL C) #----------------------------------------------------------------------------- +# Option to use new-style references with dimension scale APIs +#----------------------------------------------------------------------------- +option (HDF5_DIMENSION_SCALES_NEW_REF "Use new-style references with dimension scale APIs" OFF) +if (HDF5_DIMENSION_SCALES_NEW_REF) + set (H5_DIMENSION_SCALES_WITH_NEW_REF 1) +endif () + +#----------------------------------------------------------------------------- # List Source files #----------------------------------------------------------------------------- diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c index e87a9d3..4cb9265 100644 --- a/hl/fortran/src/H5LTfc.c +++ b/hl/fortran/src/H5LTfc.c @@ -319,11 +319,9 @@ h5ltset_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f else if ((size_t)*sizeof_val == sizeof(double)) ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_DOUBLE, (const double *)buf); -#if H5_SIZEOF_LONG_DOUBLE != 0 else if ((size_t)*sizeof_val == sizeof(long double)) ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_LDOUBLE, (const long double *)buf); -#endif else goto done; } @@ -413,10 +411,8 @@ h5ltget_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_FLOAT, buf); else if ((size_t)*sizeof_val == sizeof(double)) ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_DOUBLE, buf); -#if H5_SIZEOF_LONG_DOUBLE != 0 else if ((size_t)*sizeof_val == sizeof(long double)) ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_LDOUBLE, buf); -#endif else goto done; } diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 2bd4046..c947d16 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -18,7 +18,40 @@ /* Local routines */ static herr_t H5DS_is_reserved(hid_t did); -static hid_t H5DS_get_REFLIST_type(void); + +/*------------------------------------------------------------------------- + * Function: H5DSwith_new_ref + * + * Purpose: Determines if new references are used with dimension scales. + * The function H5DSwith_new_ref takes any object identifier and checks + * if new references are used for dimension scales. Currently, + * new references are used when non-native VOL connector is used or when + * H5_DIMENSION_SCALES_WITH_NEW_REF is set up via configure option. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5DSwith_new_ref(hid_t obj_id, hbool_t *with_new_ref) +{ + hbool_t config_flag = FALSE; + hbool_t native = FALSE; + + if (!with_new_ref) + return FAIL; + + if (H5VLobject_is_native(obj_id, &native) < 0) + return FAIL; + +#ifdef H5_DIMENSION_SCALES_WITH_NEW_REF + config_flag = TRUE; +#endif + + *with_new_ref = (config_flag || !native); + + return SUCCEED; +} /*------------------------------------------------------------------------- * Function: H5DSset_scale @@ -106,22 +139,34 @@ H5DSset_scale(hid_t dsid, const char *dimname) herr_t H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) { - int has_dimlist; - int has_reflist; - int is_ds; - hssize_t nelmts; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ - ds_list_t dsl; /* attribute data in the DS pointing to the dataset */ - ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hobj_ref_t ref_to_ds; /* reference to the DS */ - hobj_ref_t ref_j; /* iterator reference */ - hvl_t * buf = NULL; /* VL buffer to store in the attribute */ - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + int has_dimlist; + int has_reflist; + int is_ds; + hssize_t nelmts; + hid_t sid, sid_w; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t ntid = H5I_INVALID_HID; /* attribute native type ID */ + hid_t aid = H5I_INVALID_HID; /* attribute ID */ + int rank; /* rank of dataset */ + hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ + + ds_list_t dsl; /* attribute data in the DS pointing to the dataset */ + ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + ds_list_t *dsbuf_w = + NULL; /* array of "REFERENCE_LIST" attribute data to write when adding new reference to a dataset */ + hobj_ref_t ref_to_ds; /* reference to the DS */ + hobj_ref_t ref_j; /* iterator reference */ + + /* Variables to be used when new references are used */ + nds_list_t ndsl; + nds_list_t *ndsbuf = NULL; + nds_list_t *ndsbuf_w = NULL; + H5R_ref_t nref_to_ds; + H5R_ref_t nref_j; + hbool_t is_new_ref; + + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ H5O_info2_t oi1, oi2; H5I_type_t it1, it2; int i; @@ -159,6 +204,14 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) return FAIL; } /* end if */ + /*------------------------------------------------------------------------- + * determine if old or new references should be used + *------------------------------------------------------------------------- + */ + + if (H5DSwith_new_ref(did, &is_new_ref) < 0) + return FAIL; + /* get ID type */ if ((it1 = H5Iget_type(did)) < 0) return FAIL; @@ -209,14 +262,23 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) * and one to the dataset, saved in "REFERENCE_LIST" *------------------------------------------------------------------------- */ - /* create a reference for the >>DS<< dataset */ - if (H5Rcreate(&ref_to_ds, dsid, ".", H5R_OBJECT, (hid_t)-1) < 0) - return FAIL; - - /* create a reference for the >>data<< dataset */ - if (H5Rcreate(&dsl.ref, did, ".", H5R_OBJECT, (hid_t)-1) < 0) - return FAIL; + if (is_new_ref) { + /* create a reference for the >>DS<< dataset */ + if (H5Rcreate_object(dsid, ".", H5P_DEFAULT, &nref_to_ds) < 0) + return FAIL; + /* create a reference for the >>data<< dataset */ + if (H5Rcreate_object(did, ".", H5P_DEFAULT, &ndsl.ref) < 0) + return FAIL; + } + else { + /* create a reference for the >>DS<< dataset */ + if (H5Rcreate(&ref_to_ds, dsid, ".", H5R_OBJECT, (hid_t)-1) < 0) + return FAIL; + /* create a reference for the >>data<< dataset */ + if (H5Rcreate(&dsl.ref, did, ".", H5R_OBJECT, (hid_t)-1) < 0) + 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; @@ -234,9 +296,14 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) return FAIL; /* create the type for the attribute "DIMENSION_LIST" */ - if ((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0) - goto out; - + if (is_new_ref) { + if ((tid = H5Tvlen_create(H5T_STD_REF)) < 0) + goto out; + } + else { + if ((tid = H5Tvlen_create(H5T_STD_REF_OBJ)) < 0) + goto out; + } /* create the attribute */ if ((aid = H5Acreate2(did, DIMENSION_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; @@ -252,24 +319,32 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) } /* store the REF information in the index of the dataset that has the DS */ - buf[idx].len = 1; - buf[idx].p = HDmalloc(1 * sizeof(hobj_ref_t)); - ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; - + buf[idx].len = 1; + if (is_new_ref) { + buf[idx].p = HDmalloc(1 * sizeof(H5R_ref_t)); + ((H5R_ref_t *)buf[idx].p)[0] = nref_to_ds; + } + else { + buf[idx].p = HDmalloc(1 * sizeof(hobj_ref_t)); + ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; + } /* write the attribute with the reference */ if (H5Awrite(aid, tid, buf) < 0) goto out; /* close */ - if (H5Treclaim(tid, sid, H5P_DEFAULT, buf) < 0) - goto out; + if (is_new_ref) { + if (H5Rdestroy(&nref_to_ds) < 0) + goto out; + } if (H5Sclose(sid) < 0) goto out; if (H5Tclose(tid) < 0) goto out; if (H5Aclose(aid) < 0) goto out; - + HDfree(buf[idx].p); + buf[idx].p = NULL; HDfree(buf); buf = NULL; } @@ -302,12 +377,20 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) /* iterate all the REFs in this dimension IDX */ for (i = 0; i < (int)buf[idx].len; i++) { /* get the reference */ - ref_j = ((hobj_ref_t *)buf[idx].p)[i]; + if (is_new_ref) { + nref_j = ((H5R_ref_t *)buf[idx].p)[i]; - /* get the scale id for this REF */ - if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0) - goto out; + /* get the scale id for this REF */ + if ((dsid_j = H5Ropen_object(&nref_j, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + } + else { + ref_j = ((hobj_ref_t *)buf[idx].p)[i]; + /* get the scale id for this REF */ + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref_j)) < 0) + goto out; + } /* get info for DS in the parameter list */ if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0) goto out; @@ -335,17 +418,33 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) /* we are adding one more DS to this dimension */ if (buf[idx].len > 0) { buf[idx].len++; - len = buf[idx].len; - buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t)); - ((hobj_ref_t *)buf[idx].p)[len - 1] = ref_to_ds; + len = buf[idx].len; + if (is_new_ref) { + buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(H5R_ref_t)); + ((H5R_ref_t *)buf[idx].p)[len - 1] = nref_to_ds; + } + else { + buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t)); + ((hobj_ref_t *)buf[idx].p)[len - 1] = ref_to_ds; + } } /* end if */ else { /* store the REF information in the index of the dataset that has the DS */ - buf[idx].len = 1; - buf[idx].p = HDmalloc(sizeof(hobj_ref_t)); - ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; + buf[idx].len = 1; + if (is_new_ref) { + buf[idx].p = HDmalloc(sizeof(H5R_ref_t)); + ((H5R_ref_t *)buf[idx].p)[0] = nref_to_ds; + } + else { + buf[idx].p = HDmalloc(sizeof(hobj_ref_t)); + ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; + } } /* end else */ } /* end if */ + else { + if (is_new_ref && H5Rdestroy(&nref_to_ds) < 0) + goto out; + } /* write the attribute with the new references */ if (H5Awrite(aid, tid, buf) < 0) @@ -385,29 +484,40 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) goto out; /* create the compound datatype for the attribute "REFERENCE_LIST" */ - if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) - goto out; - - /* insert reference field */ - if (H5Tinsert(tid, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0) - goto out; - - /* insert dimension idx of the dataset field */ - if (H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) - goto out; + if (is_new_ref) { + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(nds_list_t))) < 0) + goto out; + if (H5Tinsert(tid, "dataset", HOFFSET(nds_list_t, ref), H5T_STD_REF) < 0) + goto out; + if (H5Tinsert(tid, "dimension", HOFFSET(nds_list_t, dim_idx), H5T_NATIVE_UINT) < 0) + goto out; + } + else { + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) + goto out; + if (H5Tinsert(tid, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0) + goto out; + if (H5Tinsert(tid, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_UINT) < 0) + goto out; + } /* create the attribute */ if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* store the IDX information */ - dsl.dim_idx = idx; - - /* write the attribute with the reference */ - if (H5Awrite(aid, tid, &dsl) < 0) - goto out; - - /* close */ + if (is_new_ref) { + ndsl.dim_idx = idx; + if (H5Awrite(aid, tid, &ndsl) < 0) + goto out; + if (H5Rdestroy(&ndsl.ref) < 0) + goto out; + } + else { + dsl.dim_idx = idx; + if (H5Awrite(aid, tid, &dsl) < 0) + goto out; + } if (H5Sclose(sid) < 0) goto out; if (H5Tclose(tid) < 0) @@ -421,6 +531,9 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) *------------------------------------------------------------------------- */ else if (has_reflist == 1) { + hid_t tmp_id; /* Temporary DS dataset ID to recreate reference */ + int j; + if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0) goto out; @@ -428,7 +541,7 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) goto out; /* get native type to read attribute REFERENCE_LIST */ - if ((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5Tget_native_type(tid, H5T_DIR_ASCEND)) < 0) goto out; /* get and save the old reference(s) */ @@ -439,17 +552,22 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) goto out; nelmts++; - - dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); - if (dsbuf == NULL) - goto out; - - if (H5Aread(aid, ntid, dsbuf) < 0) - goto out; + if (is_new_ref) { + ndsbuf = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t)); + if (ndsbuf == NULL) + goto out; + if (H5Aread(aid, ntid, ndsbuf) < 0) + goto out; + } + else { + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf == NULL) + goto out; + if (H5Aread(aid, ntid, dsbuf) < 0) + goto out; + } /* close */ - if (H5Sclose(sid) < 0) - goto out; if (H5Aclose(aid) < 0) goto out; @@ -458,40 +576,93 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx) *------------------------------------------------------------------------- */ + /* Allocate new buffer to copy old references and add new one */ + + if (is_new_ref) { + ndsbuf_w = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t)); + if (ndsbuf_w == NULL) + goto out; + } + else { + dsbuf_w = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf_w == NULL) + goto out; + } + /* Recreate the references we read from the existing "REFERENCE_LIST" attribute */ + for (j = 0; j < nelmts - 1; j++) { + if (is_new_ref) { + ndsbuf_w[j].dim_idx = ndsbuf[j].dim_idx; + tmp_id = H5Ropen_object(&ndsbuf[j].ref, H5P_DEFAULT, H5P_DEFAULT); + if (tmp_id < 0) + goto out; + if (H5Rcreate_object(tmp_id, ".", H5P_DEFAULT, &ndsbuf_w[j].ref) < 0) { + H5Dclose(tmp_id); + goto out; + } + } + else { + dsbuf_w[j] = dsbuf[j]; + } + } + /* store the IDX information (index of the dataset that has the DS) */ + if (is_new_ref) { + ndsl.dim_idx = idx; + ndsbuf_w[nelmts - 1] = ndsl; + } + else { + dsl.dim_idx = idx; + dsbuf_w[nelmts - 1] = dsl; + } + /* the attribute must be deleted, in order to the new one can reflect the changes*/ if (H5Adelete(dsid, REFERENCE_LIST) < 0) goto out; - /* store the IDX information (index of the dataset that has the DS) */ - dsl.dim_idx = idx; - dsbuf[nelmts - 1] = dsl; - /* create a new data space for the new references array */ dims[0] = (hsize_t)nelmts; - if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid_w = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* create the attribute again with the changes of space */ - if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid_w, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* write the attribute with the new references */ - if (H5Awrite(aid, ntid, dsbuf) < 0) - goto out; - - /* close */ + if (is_new_ref) { + if (H5Awrite(aid, ntid, ndsbuf_w) < 0) + goto out; + if (H5Treclaim(tid, sid, H5P_DEFAULT, ndsbuf_w) < 0) + goto out; + } + else { + if (H5Awrite(aid, ntid, dsbuf_w) < 0) + goto out; + if (H5Treclaim(tid, sid, H5P_DEFAULT, dsbuf_w) < 0) + goto out; + } if (H5Sclose(sid) < 0) goto out; + if (H5Sclose(sid_w) < 0) + goto out; if (H5Tclose(tid) < 0) goto out; if (H5Aclose(aid) < 0) goto out; if (H5Tclose(ntid) < 0) goto out; - - HDfree(dsbuf); - dsbuf = NULL; + if (is_new_ref) { + HDfree(ndsbuf); + dsbuf = NULL; + HDfree(ndsbuf_w); + dsbuf = NULL; + } + else { + HDfree(dsbuf); + dsbuf = NULL; + HDfree(dsbuf_w); + dsbuf = NULL; + } } /* has_reflist */ /*------------------------------------------------------------------------- @@ -515,6 +686,8 @@ out: HDfree(buf); if (dsbuf) HDfree(dsbuf); + if (dsbuf_w) + HDfree(dsbuf_w); H5E_BEGIN_TRY { @@ -554,27 +727,35 @@ out: herr_t H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) { - int has_dimlist; - int has_reflist; - hssize_t nelmts; - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ - hid_t did_i; /* dataset ID in REFERENCE_LIST */ - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ - hobj_ref_t ref; /* reference to the DS */ - hvl_t * buf = NULL; /* VL buffer to store in the attribute */ - int i; - size_t j; - hssize_t ii; - H5O_info2_t did_oi, dsid_oi, tmp_oi; - int found_dset = 0, found_ds = 0; - int have_ds = 0; - htri_t is_scale; + int has_dimlist; + int has_reflist; + hssize_t nelmts; + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + hid_t did_i; /* dataset ID in REFERENCE_LIST */ + hid_t sid = H5I_INVALID_HID; /* space ID */ + hid_t sid_w = H5I_INVALID_HID; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t ntid = H5I_INVALID_HID; /* attribute native type ID */ + hid_t aid = H5I_INVALID_HID; /* attribute ID */ + int rank; /* rank of dataset */ + nds_list_t * ndsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + nds_list_t * ndsbuf_w = NULL; /* array of attribute data in the DS pointing to the dataset to write*/ + ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + ds_list_t * dsbuf_w = NULL; /* array of attribute data in the DS pointing to the dataset to write*/ + hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ + H5R_ref_t nref; + hobj_ref_t ref; /* reference to the DS */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + int i; + size_t j; + hssize_t ii; + H5O_info2_t did_oi, dsid_oi, tmp_oi; + int found_dset = 0, found_ds = 0; + int have_ds = 0; + htri_t is_scale; + hbool_t is_new_ref; + unsigned int tmp_idx; + hid_t tmp_id; /*------------------------------------------------------------------------- * parameter checking @@ -612,9 +793,17 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) } /* end if */ /*------------------------------------------------------------------------- - * Find "DIMENSION_LIST" + * determine if old or new references should be used + *------------------------------------------------------------------------- + */ + if (H5DSwith_new_ref(did, &is_new_ref) < 0) + return FAIL; + + /*------------------------------------------------------------------------- + * find "DIMENSION_LIST" *------------------------------------------------------------------------- */ + /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) return FAIL; @@ -676,13 +865,22 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) /* reset */ if (buf[idx].len > 0) { for (j = 0; j < buf[idx].len; j++) { - /* get the reference */ - ref = ((hobj_ref_t *)buf[idx].p)[j]; + if (is_new_ref) { + /* get the reference */ + nref = ((H5R_ref_t *)buf[idx].p)[j]; - /* get the DS id */ - if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) - goto out; + /* get the scale id for this REF */ + if ((dsid_j = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + } + else { + /* get the reference */ + ref = ((hobj_ref_t *)buf[idx].p)[j]; + /* get the DS id */ + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) + goto out; + } /* get info for this DS */ if (H5Oget_info3(dsid_j, &tmp_oi, H5O_INFO_BASIC) < 0) goto out; @@ -708,8 +906,14 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) size_t len = buf[idx].len; - if (j < len - 1) - ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len - 1]; + if (j < len - 1) { + if (is_new_ref) { + ((H5R_ref_t *)buf[idx].p)[j] = ((H5R_ref_t *)buf[idx].p)[len - 1]; + } + else { + ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len - 1]; + } + } len = --buf[idx].len; if (len == 0) { HDfree(buf[idx].p); @@ -770,7 +974,7 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) goto out; /* get native type to read attribute REFERENCE_LIST */ - if ((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5Tget_native_type(tid, H5T_DIR_ASCEND)) < 0) goto out; /* get and save the old reference(s) */ @@ -780,22 +984,65 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); - if (dsbuf == NULL) - goto out; - - if (H5Aread(aid, ntid, dsbuf) < 0) - goto out; - + if (is_new_ref) { + ndsbuf = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t)); + if (ndsbuf == NULL) + goto out; + if (H5Aread(aid, ntid, ndsbuf) < 0) + goto out; + ndsbuf_w = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t)); + if (ndsbuf_w == NULL) + goto out; + } + else { + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf == NULL) + goto out; + if (H5Aread(aid, ntid, dsbuf) < 0) + goto out; + dsbuf_w = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf_w == NULL) + goto out; + } + /* Recreate the references we read from the existing "REFERENCE_LIST" attribute */ + for (i = 0; i < nelmts; i++) { + if (is_new_ref) { + ndsbuf_w[i].dim_idx = ndsbuf[i].dim_idx; + tmp_id = H5Ropen_object(&ndsbuf[i].ref, H5P_DEFAULT, H5P_DEFAULT); + if (tmp_id < 0) + goto out; + if (H5Rcreate_object(tmp_id, ".", H5P_DEFAULT, &ndsbuf_w[i].ref) < 0) { + H5Dclose(tmp_id); + goto out; + } + H5Dclose(tmp_id); + } + else { + dsbuf_w[i] = dsbuf[i]; + } + } for (ii = 0; ii < nelmts; ii++) { /* First check if we have the same dimension index */ - if (idx == dsbuf[ii].dim_idx) { + if (is_new_ref) { + tmp_idx = ndsbuf_w[ii].dim_idx; + } + else { + tmp_idx = dsbuf_w[ii].dim_idx; + } + if (idx == tmp_idx) { /* get the reference to the dataset */ - ref = dsbuf[ii].ref; - - /* get the dataset id */ - if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) - goto out; + if (is_new_ref) { + /* get the dataset id */ + nref = ndsbuf_w[ii].ref; + if ((did_i = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + } + else { + /* get the dataset id */ + ref = dsbuf_w[ii].ref; + if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) + goto out; + } /* get info for this dataset */ if (H5Oget_info3(did_i, &tmp_oi, H5O_INFO_BASIC) < 0) @@ -813,7 +1060,12 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) goto out; if (!token_cmp) { /* copy the last one to replace the one which is found */ - dsbuf[ii] = dsbuf[nelmts - 1]; + if (is_new_ref) { + ndsbuf_w[ii] = ndsbuf_w[nelmts - 1]; + } + else { + dsbuf_w[ii] = dsbuf_w[nelmts - 1]; + } nelmts--; found_dset = 1; break; @@ -822,9 +1074,7 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) } /* if we have the same dimension index */ } /* ii */ - /* close space and attribute */ - if (H5Sclose(sid) < 0) - goto out; + /* close attribute */ if (H5Aclose(aid) < 0) goto out; @@ -851,32 +1101,69 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) /* create a new data space for the new references array */ dims[0] = (hsize_t)nelmts; - if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid_w = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* create the attribute again with the changes of space */ - if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(dsid, REFERENCE_LIST, tid, sid_w, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* write the new attribute with the new references */ - if (H5Awrite(aid, ntid, dsbuf) < 0) - goto out; + if (is_new_ref) { + if (H5Awrite(aid, ntid, ndsbuf_w) < 0) + goto out; + } + else { + if (H5Awrite(aid, ntid, dsbuf_w) < 0) + goto out; + } - /* close space and attribute */ - if (H5Sclose(sid) < 0) - goto out; if (H5Aclose(aid) < 0) goto out; } /* nelmts */ + /* Free refrences */ + if (is_new_ref) { + if (H5Treclaim(tid, sid, H5P_DEFAULT, ndsbuf) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + if (sid_w > 0) { + if (H5Treclaim(tid, sid_w, H5P_DEFAULT, ndsbuf_w) < 0) + goto out; + if (H5Sclose(sid_w) < 0) + goto out; + } + } + else { + if (H5Treclaim(tid, sid, H5P_DEFAULT, dsbuf) < 0) + goto out; + if (H5Sclose(sid) < 0) + goto out; + if (sid_w > 0) { + if (H5Treclaim(tid, sid_w, H5P_DEFAULT, dsbuf_w) < 0) + goto out; + if (H5Sclose(sid_w) < 0) + goto out; + } + } /* close type */ if (H5Tclose(tid) < 0) goto out; if (H5Tclose(ntid) < 0) goto out; - - HDfree(dsbuf); - dsbuf = NULL; + if (is_new_ref) { + HDfree(ndsbuf); + HDfree(ndsbuf_w); + ndsbuf = NULL; + ndsbuf_w = NULL; + } + else { + HDfree(dsbuf); + HDfree(dsbuf_w); + dsbuf = NULL; + dsbuf_w = NULL; + } return SUCCEED; @@ -889,6 +1176,14 @@ out: H5Tclose(ntid); H5Tclose(tid); + if (ndsbuf) { + HDfree(ndsbuf); + ndsbuf = NULL; + } + if (ndsbuf_w) { + HDfree(ndsbuf_w); + ndsbuf_w = NULL; + } if (dsbuf) { HDfree(dsbuf); dsbuf = NULL; @@ -936,21 +1231,24 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) int has_dimlist; int has_reflist; hssize_t nelmts; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t ntid = -1; /* attribute native type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - hobj_ref_t ref; /* reference to the DS */ - hvl_t * buf = NULL; /* VL buffer to store in the attribute */ - hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ - hid_t did_i; /* dataset ID in REFERENCE_LIST */ + hid_t sid; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t ntid = H5I_INVALID_HID; /* attribute native type ID */ + hid_t aid = H5I_INVALID_HID; /* attribute ID */ + int rank; /* rank of dataset */ + nds_list_t *ndsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + ds_list_t * dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ + H5R_ref_t nref; /* reference to the DS */ + hobj_ref_t ref; /* reference to the DS */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */ + hid_t did_i; /* dataset ID in REFERENCE_LIST */ H5O_info2_t oi1, oi2, oi3, oi4; H5I_type_t it1, it2; int i; int found_dset = 0, found_ds = 0; htri_t is_scale; + hbool_t is_new_ref; /*------------------------------------------------------------------------- * parameter checking @@ -982,6 +1280,14 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) return FAIL; } /* end if */ + /*------------------------------------------------------------------------- + * determine if old or new references should be used + *------------------------------------------------------------------------- + */ + + if (H5DSwith_new_ref(did, &is_new_ref) < 0) + return FAIL; + /* get ID type */ if ((it1 = H5Iget_type(did)) < 0) return FAIL; @@ -1042,12 +1348,22 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) /* iterate all the REFs in this dimension IDX */ for (i = 0; i < (int)buf[idx].len; i++) { - /* get the reference */ - ref = ((hobj_ref_t *)buf[idx].p)[i]; + if (is_new_ref) { + /* get the reference */ + nref = ((H5R_ref_t *)buf[idx].p)[i]; - /* get the scale id for this REF */ - if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) - goto out; + /* get the scale id for this REF */ + if ((dsid_j = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + } + else { + /* get the reference */ + ref = ((hobj_ref_t *)buf[idx].p)[i]; + + /* get the scale id for this REF */ + if ((dsid_j = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) + goto out; + } /* get info for DS in the parameter list */ if (H5Oget_info3(dsid, &oi1, H5O_INFO_BASIC) < 0) @@ -1107,7 +1423,7 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) goto out; /* get native type to read REFERENCE_LIST attribute */ - if ((ntid = H5DS_get_REFLIST_type()) < 0) + if ((ntid = H5Tget_native_type(tid, H5T_DIR_ASCEND)) < 0) goto out; /* get and save the old reference(s) */ @@ -1117,13 +1433,20 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); - - if (dsbuf == NULL) - goto out; - - if (H5Aread(aid, ntid, dsbuf) < 0) - goto out; + if (is_new_ref) { + ndsbuf = (nds_list_t *)HDmalloc((size_t)nelmts * sizeof(nds_list_t)); + if (ndsbuf == NULL) + goto out; + if (H5Aread(aid, ntid, ndsbuf) < 0) + goto out; + } + else { + dsbuf = (ds_list_t *)HDmalloc((size_t)nelmts * sizeof(ds_list_t)); + if (dsbuf == NULL) + goto out; + if (H5Aread(aid, ntid, dsbuf) < 0) + goto out; + } /*------------------------------------------------------------------------- * iterate @@ -1131,40 +1454,58 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) */ for (i = 0; i < nelmts; i++) { - /* get the reference */ - ref = dsbuf[i].ref; - /* the reference was not deleted */ - if (ref) { + if (is_new_ref) { + nref = ndsbuf[i].ref; + /* get the dataset id */ + if ((did_i = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + } + else { + ref = dsbuf[i].ref; /* get the dataset id */ if ((did_i = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) goto out; + } - /* get info for dataset in the parameter list */ - if (H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0) - goto out; + /* get info for dataset in the parameter list */ + if (H5Oget_info3(did, &oi3, H5O_INFO_BASIC) < 0) + goto out; - /* get info for this dataset */ - if (H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0) - goto out; + /* get info for this dataset */ + if (H5Oget_info3(did_i, &oi4, H5O_INFO_BASIC) < 0) + goto out; - /* same object */ - if (oi3.fileno == oi4.fileno) { - int token_cmp; + /* same object */ + if (oi3.fileno == oi4.fileno) { + int token_cmp; - if (H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0) - goto out; + if (H5Otoken_cmp(did, &oi3.token, &oi4.token, &token_cmp) < 0) + goto out; + if (is_new_ref) { + if (!token_cmp && (idx == ndsbuf[i].dim_idx)) + found_dset = 1; + } + else { if (!token_cmp && (idx == dsbuf[i].dim_idx)) found_dset = 1; - } /* end if */ + } + } /* end if */ - /* close the dereferenced dataset */ - if (H5Dclose(did_i) < 0) - goto out; - } /* if */ - } /* i */ + /* close the dereferenced dataset */ + if (H5Dclose(did_i) < 0) + goto out; + } /* for */ /* close */ + if (is_new_ref) { + if (H5Treclaim(ntid, sid, H5P_DEFAULT, ndsbuf) < 0) + goto out; + } + else { + if (H5Treclaim(ntid, sid, H5P_DEFAULT, dsbuf) < 0) + goto out; + } if (H5Sclose(sid) < 0) goto out; if (H5Tclose(ntid) < 0) @@ -1174,8 +1515,14 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx) if (H5Aclose(aid) < 0) goto out; - HDfree(dsbuf); - dsbuf = NULL; + if (ndsbuf) { + HDfree(ndsbuf); + ndsbuf = NULL; + } + if (dsbuf) { + HDfree(dsbuf); + dsbuf = NULL; + } } /* has_reflist */ if (found_ds && found_dset) @@ -1198,6 +1545,10 @@ out: HDfree(buf); buf = NULL; } + if (ndsbuf) { + HDfree(ndsbuf); + ndsbuf = NULL; + } if (dsbuf) { HDfree(dsbuf); dsbuf = NULL; @@ -1249,17 +1600,19 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi { hid_t scale_id; int rank; - hobj_ref_t ref; /* reference to the DS */ - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - hvl_t * buf = NULL; /* VL buffer to store in the attribute */ - H5I_type_t it; /* ID type */ + H5R_ref_t nref; /* reference to the DS */ + hobj_ref_t ref; /* reference to the DS */ + hid_t sid; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t aid = H5I_INVALID_HID; /* attribute ID */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + H5I_type_t it; /* ID type */ herr_t ret_value = 0; int j_idx; int nscales; int has_dimlist; int i; + hbool_t is_new_ref; /*------------------------------------------------------------------------- * parameter checking @@ -1272,6 +1625,14 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi if (H5I_DATASET != it) return FAIL; + /*------------------------------------------------------------------------- + * determine if old or new references should be used + *------------------------------------------------------------------------- + */ + + if (H5DSwith_new_ref(did, &is_new_ref) < 0) + return FAIL; + /* get the number of scales assotiated with this DIM */ if ((nscales = H5DSget_num_scales(did, dim)) < 0) return FAIL; @@ -1330,17 +1691,32 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi /* iterate */ for (i = j_idx; i < nscales; i++) { - /* get the reference */ - ref = ((hobj_ref_t *)buf[dim].p)[i]; - - /* disable error reporting, the ID might refer to a deleted dataset */ - H5E_BEGIN_TRY - { - /* get the DS id */ - if ((scale_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) - goto out; + if (is_new_ref) { + /* get the reference */ + nref = ((H5R_ref_t *)buf[dim].p)[i]; + + /* disable error reporting, the ID might refer to a deleted dataset */ + H5E_BEGIN_TRY + { + /* get the DS id */ + if ((scale_id = H5Ropen_object(&nref, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto out; + } + H5E_END_TRY; + } + else { + /* get the reference */ + ref = ((hobj_ref_t *)buf[dim].p)[i]; + + /* disable error reporting, the ID might refer to a deleted dataset */ + H5E_BEGIN_TRY + { + /* get the DS id */ + if ((scale_id = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &ref)) < 0) + goto out; + } + H5E_END_TRY; } - H5E_END_TRY; /* set the return IDX OUT value at current scale index */ if (ds_idx != NULL) { @@ -1413,12 +1789,12 @@ 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 */ - H5I_type_t it; /* ID type */ + hid_t sid = H5I_INVALID_HID; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t aid = H5I_INVALID_HID; /* attribute ID */ + int rank; /* rank of dataset */ + hsize_t dims[1]; /* dimensions of dataset */ + H5I_type_t it; /* ID type */ unsigned int i; union { /* union is needed to eliminate compiler warnings about */ char ** buf; /* discarding the 'const' qualifier in the free */ @@ -1616,12 +1992,12 @@ 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 */ + hid_t sid = H5I_INVALID_HID; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t aid = H5I_INVALID_HID; /* 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 = 0; size_t copy_len; int i; @@ -1764,10 +2140,10 @@ out: ssize_t H5DSget_scale_name(hid_t did, char *name, size_t size) { - hid_t aid; /* attribute ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t sid; /* space ID */ - H5I_type_t it; /* ID type */ + hid_t aid = H5I_INVALID_HID; /* attribute ID */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t sid = H5I_INVALID_HID; /* space ID */ + H5I_type_t it; /* ID type */ size_t nbytes; size_t copy_len; int has_name; @@ -1881,13 +2257,13 @@ out: htri_t H5DSis_scale(hid_t did) { - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - herr_t attr_class; /* has the "CLASS" attribute */ - htri_t is_ds = -1; /* set to "not a dimension scale" */ - H5I_type_t it; /* type of identifier */ - char * buf = NULL; /* buffer to read name of attribute */ - size_t string_size; /* size of storage for the attribute */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t aid = H5I_INVALID_HID; /* attribute ID */ + herr_t attr_class; /* has the "CLASS" attribute */ + htri_t is_ds = -1; /* set to "not a dimension scale" */ + H5I_type_t it; /* type of identifier */ + char * buf = NULL; /* buffer to read name of attribute */ + size_t string_size; /* size of storage for the attribute */ H5T_class_t type_class; H5T_str_t strpad; @@ -1995,12 +2371,12 @@ int H5DSget_num_scales(hid_t did, unsigned int idx) { int has_dimlist; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - hvl_t * buf = NULL; /* VL buffer to store in the attribute */ - H5I_type_t it; /* ID type */ + hid_t sid; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* attribute type ID */ + hid_t aid = H5I_INVALID_HID; /* attribute ID */ + int rank; /* rank of dataset */ + hvl_t * buf = NULL; /* VL buffer to store in the attribute */ + H5I_type_t it; /* ID type */ int nscales; /*------------------------------------------------------------------------- @@ -2112,12 +2488,12 @@ out: static herr_t H5DS_is_reserved(hid_t did) { - int has_class; - hid_t tid = -1; - hid_t aid = -1; - char * buf; /* Name of attribute */ - hsize_t storage_size; /* Size of storage for attribute */ - herr_t ret; + int has_class; + hid_t tid = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + char * buf = NULL; /* Name of attribute */ + size_t string_size; /* Size of storage for attribute */ + herr_t ret; /* try to find the attribute "CLASS" on the dataset */ if ((has_class = H5LT_find_attribute(did, "CLASS")) < 0) @@ -2142,10 +2518,10 @@ H5DS_is_reserved(hid_t did) goto out; /* allocate buffer large enough to hold string */ - if ((storage_size = H5Aget_storage_size(aid)) == 0) + if ((string_size = H5Tget_size(tid)) == 0) goto out; - buf = (char *)HDmalloc((size_t)storage_size * sizeof(char) + 1); + buf = (char *)HDmalloc((size_t)string_size * sizeof(char)); if (buf == NULL) goto out; @@ -2174,51 +2550,11 @@ H5DS_is_reserved(hid_t did) out: H5E_BEGIN_TRY { + if (buf) + HDfree(buf); H5Tclose(tid); H5Aclose(aid); } H5E_END_TRY; return FAIL; } - -/*------------------------------------------------------------------------- - * Function: H5DS_get_REFLIST_type - * - * Purpose: This is a helper function to return a native type for - * the REFERENCE_LIST attribute. - * - * Return: Type identifier on success and negative on failure - * - * Programmer: Elena Pourmal - * - * Date: May 22, 2010 - * - *------------------------------------------------------------------------- - */ -static hid_t -H5DS_get_REFLIST_type(void) -{ - hid_t ntid_t = -1; - - /* Build native type that corresponds to compound datatype - used to store ds_list_t structure in the REFERENCE_LIST - attribute */ - - if ((ntid_t = H5Tcreate(H5T_COMPOUND, sizeof(ds_list_t))) < 0) - goto out; - - if (H5Tinsert(ntid_t, "dataset", HOFFSET(ds_list_t, ref), H5T_STD_REF_OBJ) < 0) - goto out; - - if (H5Tinsert(ntid_t, "dimension", HOFFSET(ds_list_t, dim_idx), H5T_NATIVE_INT) < 0) - goto out; - - return ntid_t; -out: - H5E_BEGIN_TRY - { - H5Tclose(ntid_t); - } - H5E_END_TRY; - return FAIL; -} diff --git a/hl/src/H5DSprivate.h b/hl/src/H5DSprivate.h index 0403a4c..ede0209 100644 --- a/hl/src/H5DSprivate.h +++ b/hl/src/H5DSprivate.h @@ -20,12 +20,18 @@ /* public LT prototypes */ #include "H5DSpublic.h" -/* attribute type of a DS dataset */ +/* attribute type of a DS dataset when old references are used*/ typedef struct ds_list_t { hobj_ref_t ref; /* object reference */ unsigned int dim_idx; /* dimension index of the dataset */ } ds_list_t; +/* attribute type of a DS dataset when new references are used*/ +typedef struct nds_list_t { + H5R_ref_t ref; + unsigned int dim_idx; /* dimension index of the dataset */ +} nds_list_t; + /*------------------------------------------------------------------------- * private functions *------------------------------------------------------------------------- diff --git a/hl/src/H5DSpublic.h b/hl/src/H5DSpublic.h index 7306cbc..979a173 100644 --- a/hl/src/H5DSpublic.h +++ b/hl/src/H5DSpublic.h @@ -25,6 +25,8 @@ typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *vi extern "C" { #endif +H5_HLDLL herr_t H5DSwith_new_ref(hid_t obj_id, hbool_t *with_new_ref); + H5_HLDLL herr_t H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx); H5_HLDLL herr_t H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx); diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 8f2b33f..238bbf2 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1856,46 +1856,6 @@ H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_na } /*------------------------------------------------------------------------- - * Function: find_attr - * - * Purpose: operator function used by H5LT_find_attribute - * - * Programmer: Pedro Vicente - * - * Date: June 21, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -find_attr(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5A_info_t *ainfo, - void *op_data) -{ - int ret = H5_ITER_CONT; - - /* check the arguments */ - if (name == NULL) - return H5_ITER_CONT; - - /* Shut compiler up */ - (void)loc_id; - (void)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 - */ - - if (HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data), HDstrlen(name))) == 0) - ret = H5_ITER_STOP; - - return ret; -} - -/*------------------------------------------------------------------------- * Function: H5LTfind_attribute * * Purpose: Inquires if an attribute named attr_name exists attached to @@ -1926,32 +1886,22 @@ H5LTfind_attribute(hid_t loc_id, const char *attr_name) * * 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. + * Success: Positive if the attribute exists attached to the + * object loc_id. Zero if the attribute does not + * exist attached to the object loc_id. * * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. + * library. * *------------------------------------------------------------------------- */ -/* H5Aiterate wants a non-const pointer but we have a const pointer in the API - * call. It's safe to ignore this because we control the callback, don't - * modify the op_data buffer (i.e.: attr_name) during the traversal, and the - * library never modifies that buffer. - */ -H5_GCC_CLANG_DIAG_OFF("cast-qual") herr_t H5LT_find_attribute(hid_t loc_id, const char *attr_name) { - return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name); + htri_t attr_exists = H5Aexists(loc_id, attr_name); + return (attr_exists < 0) ? (herr_t)-1 : (attr_exists) ? (herr_t)1 : (herr_t)0; } -H5_GCC_CLANG_DIAG_ON("cast-qual") /*------------------------------------------------------------------------- * Function: H5LTget_attribute_ndims @@ -2579,11 +2529,9 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb } else if (H5Tequal(dtype, H5T_NATIVE_DOUBLE)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_DOUBLE"); -#if H5_SIZEOF_LONG_DOUBLE != 0 } else if (H5Tequal(dtype, H5T_NATIVE_LDOUBLE)) { HDsnprintf(dt_str, *slen, "H5T_NATIVE_LDOUBLE"); -#endif } else { HDsnprintf(dt_str, *slen, "undefined float"); diff --git a/hl/test/CMakeTests.cmake b/hl/test/CMakeTests.cmake index 44208e3..e532253 100644 --- a/hl/test/CMakeTests.cmake +++ b/hl/test/CMakeTests.cmake @@ -31,7 +31,9 @@ set (HL_REFERENCE_TEST_FILES dslat.txt dslon.txt test_ds_be.h5 + test_ds_be_new_ref.h5 test_ds_le.h5 + test_ds_le_new_ref.h5 test_ld.h5 ) diff --git a/hl/test/gen_test_ds.c b/hl/test/gen_test_ds.c index a56e6cf..d7a9f44 100644 --- a/hl/test/gen_test_ds.c +++ b/hl/test/gen_test_ds.c @@ -63,7 +63,11 @@ static int test_foreign_scaleattached(const char *filename); #define SCALE_4_NAME "scalename_4_" #define FILENAME "test_ds_" -#define FILEEXT ".h5" +#ifdef H5_DIMENSION_SCALES_WITH_NEW_REF +#define FILEEXT "_new_ref.h5" +#else +#define FILEEXT ".h5" +#endif /*------------------------------------------------------------------------- * the main program diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 964e13f..c66ef49 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -137,10 +137,15 @@ static int test_attach_detach(void); #define DIM0_LABEL "Latitude" #define DIM1_LABEL "Longitude" +#ifdef H5_DIMENSION_SCALES_WITH_NEW_REF +#define FOREIGN_FILE1 "test_ds_le_new_ref.h5" +#define FOREIGN_FILE2 "test_ds_be_new_ref.h5" +#else #define FOREIGN_FILE1 "test_ds_le.h5" #define FOREIGN_FILE2 "test_ds_be.h5" -#define FILENAME "test_ds" -#define FILEEXT ".h5" +#endif +#define FILENAME "test_ds" +#define FILEEXT ".h5" #define FILE1 "test_ds3.h5" #define FILE2 "test_ds4.h5" @@ -161,10 +166,15 @@ static int test_attach_detach(void); int main(void) { - int nerrors = 0; + hid_t file_id = H5I_INVALID_HID; + int nerrors = 0; /* create file to be used in following tests */ - if (create_test_file("1") < 0) { + if ((file_id = create_test_file("1")) < 0) { + nerrors = 1; + goto error; + } + if (H5Fclose(file_id) < 0) { nerrors = 1; goto error; } @@ -179,7 +189,11 @@ main(void) nerrors += test_long_scalenames("1") < 0 ? 1 : 0; nerrors += test_float_scalenames("1") < 0 ? 1 : 0; nerrors += test_numberofscales("1") < 0 ? 1 : 0; - if (create_test_file("2") < 0) { + if ((file_id = create_test_file("2")) < 0) { + nerrors = 1; + goto error; + } + if (H5Fclose(file_id) < 0) { nerrors = 1; goto error; } @@ -254,10 +268,9 @@ open_test_file(const char *fileext) herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims) { - int rank = 3; - int rankds = 1; - hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE}; - char buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE]; + int rank = 3; + int rankds = 1; + hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE}; hsize_t s1_dim[1] = {DIM1_SIZE}; hsize_t s2_dim[1] = {DIM2_SIZE}; hsize_t s3_dim[1] = {DIM3_SIZE}; @@ -275,7 +288,7 @@ create_char_dataset(hid_t fid, const char *dsidx, int fulldims) HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx); /* make a dataset */ - if (H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) { + if (H5LTmake_dataset_char(fid, name, rank, dims, NULL) >= 0) { if (fulldims == 0) { /* make a DS dataset for the first dimension */ if (create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) @@ -309,10 +322,9 @@ create_char_dataset(hid_t fid, const char *dsidx, int fulldims) herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims) { - int rank = 3; - int rankds = 1; - hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE}; - short buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE]; + int rank = 3; + int rankds = 1; + hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE}; hsize_t s1_dim[1] = {DIM1_SIZE}; hsize_t s2_dim[1] = {DIM2_SIZE}; hsize_t s3_dim[1] = {DIM3_SIZE}; @@ -330,7 +342,7 @@ create_short_dataset(hid_t fid, const char *dsidx, int fulldims) HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx); /* make a dataset */ - if (H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) { + if (H5LTmake_dataset_short(fid, name, rank, dims, NULL) >= 0) { if (fulldims == 0) { /* make a DS dataset for the first dimension */ if (create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) @@ -364,10 +376,9 @@ create_short_dataset(hid_t fid, const char *dsidx, int fulldims) herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims) { - int rank = RANK; - int rankds = 1; - hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; - int buf[DIM1_SIZE * DIM2_SIZE]; + int rank = RANK; + int rankds = 1; + hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; hsize_t s1_dim[1] = {DIM1_SIZE}; hsize_t s2_dim[1] = {DIM2_SIZE}; int s1_wbuf[DIM1_SIZE] = {10, 20, 30}; @@ -380,7 +391,7 @@ create_int_dataset(hid_t fid, const char *dsidx, int fulldims) HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx); /* make a dataset */ - if (H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) { + if (H5LTmake_dataset_int(fid, name, rank, dims, NULL) >= 0) { if (fulldims == 0) { /* make a DS dataset for the first dimension */ if (create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) @@ -409,7 +420,6 @@ create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldi int rank = 4; int rankds = 1; hsize_t dims[4] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE, DIM4_SIZE}; - long * buf = NULL; hsize_t s1_dim[1] = {DIM1_SIZE}; hsize_t s2_dim[1] = {DIM2_SIZE}; hsize_t s3_dim[1] = {DIM3_SIZE}; @@ -429,12 +439,8 @@ create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldi long s43_wbuf[DIM4_SIZE] = {180, 180}; long s44_wbuf[DIM4_SIZE] = {280, 280}; - /* Allocate buffer */ - if (NULL == (buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE))) - goto error; - /* make a dataset */ - if (H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) { + if (H5LTmake_dataset_long(fid, dsname, rank, dims, NULL) >= 0) { if (fulldims == 0) { /* make a DS dataset for the first dimension */ if (create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) @@ -471,23 +477,18 @@ create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldi else goto error; - HDfree(buf); - return SUCCEED; error: - HDfree(buf); - return FAIL; } herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims) { - int rank = RANK; - int rankds = 1; - hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; - float buf[DIM1_SIZE * DIM2_SIZE]; + int rank = RANK; + int rankds = 1; + hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; hsize_t s1_dim[1] = {DIM1_SIZE}; hsize_t s2_dim[1] = {DIM2_SIZE}; float s1_wbuf[DIM1_SIZE] = {10, 20, 30}; @@ -500,7 +501,7 @@ create_float_dataset(hid_t fid, const char *dsidx, int fulldims) HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx); /* make a dataset */ - if (H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) { + if (H5LTmake_dataset_float(fid, name, rank, dims, NULL) >= 0) { if (fulldims == 0) { /* make a DS dataset for the first dimension */ if (create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0) diff --git a/hl/test/test_ds_be_new_ref-32bit.h5 b/hl/test/test_ds_be_new_ref-32bit.h5 new file mode 100644 index 0000000..ee327e9 Binary files /dev/null and b/hl/test/test_ds_be_new_ref-32bit.h5 differ diff --git a/hl/test/test_ds_be_new_ref.h5 b/hl/test/test_ds_be_new_ref.h5 new file mode 100644 index 0000000..eddfa02 Binary files /dev/null and b/hl/test/test_ds_be_new_ref.h5 differ diff --git a/hl/test/test_ds_le_new_ref.h5 b/hl/test/test_ds_le_new_ref.h5 new file mode 100644 index 0000000..8625d77 Binary files /dev/null and b/hl/test/test_ds_le_new_ref.h5 differ diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c index c668a07..6d6bf34 100644 --- a/hl/test/test_packet_vlen.c +++ b/hl/test/test_packet_vlen.c @@ -539,8 +539,8 @@ test_VLof_VLtype(void) HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; } - t1->len = vv * 1; - for (ww = 0; ww < (vv * 1); ww++) + t1->len = vv + 1; + for (ww = 0; ww < (vv + 1); ww++) ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww; } /* end for */ } /* end for */ diff --git a/hl/tools/h5watch/CMakeLists.txt b/hl/tools/h5watch/CMakeLists.txt index be983ba..1ab473d 100644 --- a/hl/tools/h5watch/CMakeLists.txt +++ b/hl/tools/h5watch/CMakeLists.txt @@ -40,29 +40,6 @@ if (HDF5_ENABLE_FORMATTERS) endif () if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL) - #-- Add swmr_check_compat_vfd program - set (hl_swmr_check_compat_vfd_SOURCES - ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/swmr_check_compat_vfd.c - ) - add_executable (hl_swmr_check_compat_vfd ${hl_swmr_check_compat_vfd_SOURCES}) - target_compile_options(hl_swmr_check_compat_vfd PRIVATE "${HDF5_CMAKE_C_FLAGS}") - target_include_directories (hl_swmr_check_compat_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") - if (NOT ONLY_SHARED_LIBS) - TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd STATIC) - target_link_libraries (hl_swmr_check_compat_vfd PRIVATE ${HDF5_LIB_TARGET}) - else () - TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd SHARED) - target_link_libraries (hl_swmr_check_compat_vfd PRIVATE ${HDF5_LIBSH_TARGET}) - endif () - set_target_properties (hl_swmr_check_compat_vfd PROPERTIES FOLDER tools/hl) - - #----------------------------------------------------------------------------- - # Add Target to clang-format - #----------------------------------------------------------------------------- - if (HDF5_ENABLE_FORMATTERS) - clang_format (HDF5_HL_TOOLS_H5WATCH_hl_swmr_check_compat_vfd_FORMAT hl_swmr_check_compat_vfd) - endif () - #-- Add extend_dset program set (extend_dset_SOURCES ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/extend_dset.c diff --git a/hl/tools/h5watch/CMakeTests.cmake b/hl/tools/h5watch/CMakeTests.cmake index 60c099b..b2f689b 100644 --- a/hl/tools/h5watch/CMakeTests.cmake +++ b/hl/tools/h5watch/CMakeTests.cmake @@ -149,18 +149,22 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes # Check to see if the VFD specified by the HDF5_DRIVER environment variable # supports SWMR. -set (SWMR_INCOMPAT ${hl_swmr_check_compat_vfd}) +add_test ( + NAME H5WATCH-SWMR_INCOMPAT + COMMAND swmr_check_compat_vfd +) +set_tests_properties (H5WATCH-SWMR_INCOMPAT PROPERTIES FIXTURES_SETUP swmr_vfd_check_compat) -if (NOT SWMR_INCOMPAT) # Remove any output file left over from previous test run - add_test ( - NAME H5WATCH-clearall-objects - COMMAND ${CMAKE_COMMAND} -E remove WATCH.h5 - ) - if (last_test) - set_tests_properties (H5WATCH-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5WATCH-clearall-objects") +add_test ( + NAME H5WATCH-clearall-objects + COMMAND ${CMAKE_COMMAND} -E remove WATCH.h5 +) +set_tests_properties (H5WATCH-clearall-objects PROPERTIES FIXTURES_REQUIRED swmr_vfd_check_compat) +if (last_test) + set_tests_properties (H5WATCH-clearall-objects PROPERTIES DEPENDS ${last_test}) +endif () +set (last_test "H5WATCH-clearall-objects") ################################################################################################# # # @@ -182,32 +186,32 @@ if (NOT SWMR_INCOMPAT) # # ################################################################################################# # create the output files to be used. - add_test (NAME H5WATCH-h5watchgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - set_tests_properties (H5WATCH-h5watchgentest PROPERTIES - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" - DEPENDS "H5WATCH-clearall-objects" - ) - set_tests_properties (H5WATCH-h5watchgentest PROPERTIES FIXTURES_SETUP gen_test_watch) - set (last_test "H5WATCH-h5watchgentest") +add_test (NAME H5WATCH-h5watchgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) +set_tests_properties (H5WATCH-h5watchgentest PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS "H5WATCH-clearall-objects" +) +set_tests_properties (H5WATCH-h5watchgentest PROPERTIES FIXTURES_SETUP gen_test_watch) +set_tests_properties (H5WATCH-h5watchgentest PROPERTIES FIXTURES_REQUIRED swmr_vfd_check_compat) +set (last_test "H5WATCH-h5watchgentest") # Test on --help options - ADD_H5_TEST (w-help1 0 --help) +ADD_H5_TEST (w-help1 0 --help) # # Tests on expected failures - ADD_H5_ERR_TEST (w-err-dset1 1 WATCH.h5) - ADD_H5_ERR_TEST (w-err-dset2 1 WATCH.h5/group/DSET_CMPD) - ADD_H5_ERR_TEST (w-err-dset-none 1 WATCH.h5/DSET_NONE) - ADD_H5_ERR_TEST (w-err-dset-nomax 1 WATCH.h5/DSET_NOMAX) - ADD_H5_ERR_TEST (w-err-file 1 ../WATCH.h5/DSET_CMPD) - ADD_H5_TEST (w-err-width 1 --width=-8 WATCH.h5/DSET_ONE) - ADD_H5_TEST (w-err-poll 1 --polling=-8 WATCH.h5/DSET_ONE) - ADD_H5_TEST (w-err-poll0 1 --polling=0 WATCH.h5/DSET_ONE) +ADD_H5_ERR_TEST (w-err-dset1 1 WATCH.h5) +ADD_H5_ERR_TEST (w-err-dset2 1 WATCH.h5/group/DSET_CMPD) +ADD_H5_ERR_TEST (w-err-dset-none 1 WATCH.h5/DSET_NONE) +ADD_H5_ERR_TEST (w-err-dset-nomax 1 WATCH.h5/DSET_NOMAX) +ADD_H5_ERR_TEST (w-err-file 1 ../WATCH.h5/DSET_CMPD) +ADD_H5_TEST (w-err-width 1 --width=-8 WATCH.h5/DSET_ONE) +ADD_H5_TEST (w-err-poll 1 --polling=-8 WATCH.h5/DSET_ONE) +ADD_H5_TEST (w-err-poll0 1 --polling=0 WATCH.h5/DSET_ONE) # # Tests on invalid field names via --fields option for a compound typed dataset: DSET_CMPD - ADD_H5_ERR_TEST (w-err-cmpd1 1 --fields=fieldx WATCH.h5/DSET_CMPD) - ADD_H5_ERR_TEST (w-err-cmpd2 1 --fields=field1,field2. WATCH.h5/DSET_CMPD) - ADD_H5_ERR_TEST (w-err-cmpd3 1 --fields=field1,field2, WATCH.h5/DSET_CMPD) - ADD_H5_ERR_TEST (w-err-cmpd4 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD) - ADD_H5_ERR_TEST (w-err-cmpd5 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD) +ADD_H5_ERR_TEST (w-err-cmpd1 1 --fields=fieldx WATCH.h5/DSET_CMPD) +ADD_H5_ERR_TEST (w-err-cmpd2 1 --fields=field1,field2. WATCH.h5/DSET_CMPD) +ADD_H5_ERR_TEST (w-err-cmpd3 1 --fields=field1,field2, WATCH.h5/DSET_CMPD) +ADD_H5_ERR_TEST (w-err-cmpd4 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD) +ADD_H5_ERR_TEST (w-err-cmpd5 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD) # -endif () diff --git a/hl/tools/h5watch/Makefile.am b/hl/tools/h5watch/Makefile.am index 5112965..13bd820 100644 --- a/hl/tools/h5watch/Makefile.am +++ b/hl/tools/h5watch/Makefile.am @@ -24,7 +24,6 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib -I$(top_srcdir)/hl/sr # These are our main targets, the tools bin_PROGRAMS=h5watch -noinst_PROGRAMS=swmr_check_compat_vfd # Add h5watch specific linker flags here h5watch_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) @@ -38,7 +37,7 @@ if BUILD_TESTS_CONDITIONAL TEST_SCRIPT=testh5watch.sh check_SCRIPTS=$(TEST_SCRIPT) SCRIPT_DEPEND=swmr_check_compat_vfd$(EXEEXT) extend_dset$(EXEEXT) h5watch$(EXEEXT) - noinst_PROGRAMS+=h5watchgentest extend_dset + noinst_PROGRAMS=h5watchgentest extend_dset # Add extend_dset specific preprocessor flags here # (add the main test subdirectory to the include file path) extend_dset_CPPFLAGS=$(AM_CPPFLAGS) -I$(top_srcdir)/test diff --git a/hl/tools/h5watch/swmr_check_compat_vfd.c b/hl/tools/h5watch/swmr_check_compat_vfd.c deleted file mode 100644 index b4021e4..0000000 --- a/hl/tools/h5watch/swmr_check_compat_vfd.c +++ /dev/null @@ -1,55 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* Purpose: This is a small program that checks if the HDF5_DRIVER - * environment variable is set to a value that supports SWMR. - * - * It is intended for use in shell scripts. - */ - -#include - -#include "H5private.h" - -/* This file needs to access the file driver testing code */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ -#define H5FD_TESTING -#include "H5FDpkg.h" /* File drivers */ - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: Inspects the HDF5_DRIVER environment variable, which - * determines the VFD that the test harness will use with - * the majority of the tests. - * - * Return: VFD supports SWMR: EXIT_SUCCESS - * - * VFD does not support SWMR - * or failure: EXIT_FAILURE - * - *------------------------------------------------------------------------- - */ -int -main(void) -{ - char *driver = NULL; - - driver = HDgetenv(HDF5_DRIVER); - - if (H5FD__supports_swmr_test(driver)) - return EXIT_SUCCESS; - else - return EXIT_FAILURE; - -} /* end main() */ diff --git a/hl/tools/h5watch/testh5watch.sh.in b/hl/tools/h5watch/testh5watch.sh.in index 67ffcc3..04b6ef8 100644 --- a/hl/tools/h5watch/testh5watch.sh.in +++ b/hl/tools/h5watch/testh5watch.sh.in @@ -13,10 +13,16 @@ # # Tests for the h5watch tool # +bindir=@bindir@ + +# If the bindir directory is not set just use current (.). +if test -z "$bindir"; then + bindir=. +fi # Check to see if the VFD specified by the HDF5_DRIVER environment variable # supports SWMR. -./swmr_check_compat_vfd +$bindir/swmr_check_compat_vfd rc=$? if [ $rc != 0 ] ; then echo diff --git a/java/src/hdf/hdf5lib/CMakeLists.txt b/java/src/hdf/hdf5lib/CMakeLists.txt index 5651031..a26e117 100644 --- a/java/src/hdf/hdf5lib/CMakeLists.txt +++ b/java/src/hdf/hdf5lib/CMakeLists.txt @@ -40,6 +40,11 @@ set (HDF5_JAVA_HDF_HDF5_CALLBACKS_SOURCES callbacks/Callbacks.java ) +set (HDF5_JAVADOC_HDF_HDF5_CALLBACKS_SOURCES + ${HDF5_JAVA_HDF_HDF5_CALLBACKS_SOURCES} + callbacks/package-info.java +) + set (HDF5_JAVA_HDF_HDF5_EXCEPTIONS_SOURCES exceptions/HDF5Exception.java exceptions/HDF5IdException.java @@ -67,6 +72,11 @@ set (HDF5_JAVA_HDF_HDF5_EXCEPTIONS_SOURCES exceptions/HDF5SymbolTableException.java ) +set (HDF5_JAVADOC_HDF_HDF5_EXCEPTIONS_SOURCES + ${HDF5_JAVA_HDF_HDF5_EXCEPTIONS_SOURCES} + exceptions/package-info.java +) + set (HDF5_JAVA_HDF_HDF5_STRUCTS_SOURCES structs/H5_ih_info_t.java structs/H5A_info_t.java @@ -83,6 +93,11 @@ set (HDF5_JAVA_HDF_HDF5_STRUCTS_SOURCES structs/H5O_token_t.java ) +set (HDF5_JAVADOC_HDF_HDF5_STRUCTS_SOURCES + ${HDF5_JAVA_HDF_HDF5_STRUCTS_SOURCES} + structs/package-info.java +) + set (HDF5_JAVA_HDF_HDF5_SOURCES HDFArray.java HDF5Constants.java @@ -91,6 +106,11 @@ set (HDF5_JAVA_HDF_HDF5_SOURCES H5.java ) +set (HDF5_JAVADOC_HDF_HDF5_SOURCES + ${HDF5_JAVA_HDF_HDF5_SOURCES} + package-info.java +) + set (CMAKE_JNI_TARGET TRUE) file (WRITE ${PROJECT_BINARY_DIR}/Manifest.txt @@ -114,7 +134,7 @@ add_dependencies (${HDF5_JAVA_HDF5_LIB_TARGET} ${HDF5_JAVA_JNI_LIB_TARGET}) set_target_properties (${HDF5_JAVA_HDF5_LIB_TARGET} PROPERTIES FOLDER libraries/java) create_javadoc(hdf5_java_doc - FILES ${HDF5_JAVA_HDF_HDF5_CALLBACKS_SOURCES} ${HDF5_JAVA_HDF_HDF5_EXCEPTIONS_SOURCES} ${HDF5_JAVA_HDF_HDF5_STRUCTS_SOURCES} ${HDF5_JAVA_HDF_HDF5_SOURCES} + FILES ${HDF5_JAVADOC_HDF_HDF5_CALLBACKS_SOURCES} ${HDF5_JAVADOC_HDF_HDF5_EXCEPTIONS_SOURCES} ${HDF5_JAVADOC_HDF_HDF5_STRUCTS_SOURCES} ${HDF5_JAVADOC_HDF_HDF5_SOURCES} OVERVIEW ${HDF5_JAVA_HDF5_SRC_DIR}/overview.html CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} WINDOWTITLE "HDF5 Java" diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 63547df..3a485da 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -64,8 +64,8 @@ import hdf.hdf5lib.structs.H5O_token_t; * This code is the called by Java programs to access the entry points of the HDF5 library. Each routine wraps a single * HDF5 entry point, generally with the arguments and return codes analogous to the C interface. *

- * For details of the HDF5 library, see the HDF5 Documentation at: http://hdfgroup.org/HDF5/ + * For details of the HDF5 library, see the HDF5 Documentation at: + * http://hdfgroup.org/HDF5/ *


*

* Mapping of arguments for Java @@ -162,8 +162,8 @@ import hdf.hdf5lib.structs.H5O_token_t; *

* For Java, this ``ANY'' is a problem, as the type of data must always be declared. Furthermore, multidimensional * arrays are definitely not layed out contiguously in memory. It would be infeasible to declare a separate - * routine for every combination of number type and dimensionality. For that reason, the HDFArray class is used to discover the type, shape, and size of the + * routine for every combination of number type and dimensionality. For that reason, the + * HDFArray class is used to discover the type, shape, and size of the * data array at run time, and to convert to and from a contiguous array of bytes in synchronized static native C order. *

* The upshot is that any Java array of numbers (either primitive or sub-classes of type Number) can be passed as @@ -187,8 +187,8 @@ import hdf.hdf5lib.structs.H5O_token_t; * H5F_ACC_RDWR and H5P_DEFAULT. *

* The HDF-5 API defines a set of values that describe number types and sizes, such as "H5T_NATIVE_INT" and "hsize_t". - * These values are determined at run time by the HDF-5 C library. To support these parameters, the Java class HDF5CDataTypes looks up the values when initiated. The values + * These values are determined at run time by the HDF-5 C library. To support these parameters, the Java class + * HDF5CDataTypes looks up the values when initiated. The values * can be accessed as public variables of the Java class, such as: * *

@@ -204,8 +204,8 @@ import hdf.hdf5lib.structs.H5O_token_t;
  * JHI5. Errors are converted into Java exceptions. This is totally different from the C interface, but is very natural
  * for Java programming.
  * 

- * The exceptions of the JHI5 are organized as sub-classes of the class HDF5Exception. There are two subclasses of + * The exceptions of the JHI5 are organized as sub-classes of the class + * HDF5Exception. There are two subclasses of * HDF5Exception, HDF5LibraryException * and HDF5JavaException. The sub-classes of the * former represent errors from the HDF-5 C library, while sub-classes of the latter represent errors in the JHI5 @@ -12776,8 +12776,11 @@ public class H5 implements java.io.Serializable { * IN: Field name of the field index to retrieve. * * @return if field is defined, the index; else negative. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. **/ - public synchronized static native int H5Tget_member_index(long type_id, String field_name); + public synchronized static native int H5Tget_member_index(long type_id, String field_name) throws HDF5LibraryException; /** * H5Tget_member_name retrieves the name of a field of a compound datatype or an element of an enumeration datatype. @@ -12788,8 +12791,11 @@ public class H5 implements java.io.Serializable { * IN: Field index (0-based) of the field name to retrieve. * * @return a valid pointer to the name if successful; otherwise null. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. **/ - public synchronized static native String H5Tget_member_name(long type_id, int field_idx); + public synchronized static native String H5Tget_member_name(long type_id, int field_idx) throws HDF5LibraryException; /** * H5Tget_member_offset returns the byte offset of the specified member of the compound datatype. This is the byte @@ -12801,11 +12807,8 @@ public class H5 implements java.io.Serializable { * IN: Field index (0-based) of the field type to retrieve. * * @return the offset of the member. - * - * @exception HDF5LibraryException - * - Error from the HDF-5 Library. **/ - public synchronized static native long H5Tget_member_offset(long type_id, int membno) throws HDF5LibraryException; + public synchronized static native long H5Tget_member_offset(long type_id, int membno); /** * H5Tget_member_type returns the datatype of the specified member. @@ -13460,7 +13463,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native long H5VLregister_connector_by_name(String connector_name, long vipl_id); + public synchronized static native long H5VLregister_connector_by_name(String connector_name, long vipl_id) throws HDF5LibraryException; /** * H5VLregister_connector_by_value registers a new VOL connector as a member of the virtual object layer class. * @@ -13475,7 +13478,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native long H5VLregister_connector_by_value(int connector_value, long vipl_id); + public synchronized static native long H5VLregister_connector_by_value(int connector_value, long vipl_id) throws HDF5LibraryException; /** * H5VLis_connector_registered_by_name tests whether a VOL class has been registered. * @@ -13487,7 +13490,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native boolean H5VLis_connector_registered_by_name(String name); + public synchronized static native boolean H5VLis_connector_registered_by_name(String name) throws HDF5LibraryException; /** * H5VLis_connector_registered_by_value tests whether a VOL class has been registered. * @@ -13499,7 +13502,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native boolean H5VLis_connector_registered_by_value(int connector_value); + public synchronized static native boolean H5VLis_connector_registered_by_value(int connector_value) throws HDF5LibraryException; /** * H5VLget_connector_id retrieves the ID for a registered VOL connector for a given object. * @@ -13511,7 +13514,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native long H5VLget_connector_id(long object_id); + public synchronized static native long H5VLget_connector_id(long object_id) throws HDF5LibraryException; /** * H5VLget_connector_id_by_name retrieves the ID for a registered VOL connector. * @@ -13523,7 +13526,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native long H5VLget_connector_id_by_name(String name); + public synchronized static native long H5VLget_connector_id_by_name(String name) throws HDF5LibraryException; /** * H5VLget_connector_id_by_value retrieves the ID for a registered VOL connector. * @@ -13535,7 +13538,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native long H5VLget_connector_id_by_value(int connector_value); + public synchronized static native long H5VLget_connector_id_by_value(int connector_value) throws HDF5LibraryException; /** * H5VLget_connector_name returns the connector name for the VOL associated with the * object or file ID. @@ -13548,7 +13551,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native String H5VLget_connector_name(long object_id); + public synchronized static native String H5VLget_connector_name(long object_id) throws HDF5LibraryException; /** * H5VLclose closes a VOL connector ID. * @@ -13558,7 +13561,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native void H5VLclose(long connector_id); + public synchronized static native void H5VLclose(long connector_id) throws HDF5LibraryException; /** * H5VLunregister_connector removes a VOL connector ID from the library. * @@ -13568,7 +13571,7 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public synchronized static native void H5VLunregister_connector(long connector_id); + public synchronized static native void H5VLunregister_connector(long connector_id) throws HDF5LibraryException; // /////// unimplemented //////// // hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); diff --git a/java/src/hdf/hdf5lib/callbacks/package-info.java b/java/src/hdf/hdf5lib/callbacks/package-info.java new file mode 100644 index 0000000..0833162 --- /dev/null +++ b/java/src/hdf/hdf5lib/callbacks/package-info.java @@ -0,0 +1,27 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** All callback definitions must derive from the Callbacks interface. Any + * derived interfaces must define a single public method named "callback". + * You are responsible for deregistering your callback (if necessary) + * in its {@link Object#finalize} method. If native code attempts to call + * a callback which has been GC'd, you will likely crash the VM. If + * there is no method to deregister the callback (e.g. atexit + * in the C library), you must ensure that you always keep a live reference + * to the callback object.

+ * A callback should generally never throw an exception, since it doesn't + * necessarily have an encompassing Java environment to catch it. Any + * exceptions thrown will be passed to the default callback exception + * handler. + */ +package hdf.hdf5lib.callbacks; diff --git a/java/src/hdf/hdf5lib/exceptions/package-info.java b/java/src/hdf/hdf5lib/exceptions/package-info.java new file mode 100644 index 0000000..8640ccb --- /dev/null +++ b/java/src/hdf/hdf5lib/exceptions/package-info.java @@ -0,0 +1,31 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** + *

+ * The package exceptions contains error classes for the Java HDF5 Interface. + *

+ * There are two sub-classes of exceptions defined: + *

    + *
  1. + * HDF5LibraryException -- errors raised the HDF5 library code + *
  2. + * HDF5JavaException -- errors raised the HDF5 Java wrapper code + *
+ *

+ * The HDF5LibraryException is the base class for the classes that represent specific error conditions. + * In particular, HDF5LibraryException has a sub-class for each major + * error code returned by the HDF5 library. + * + */ +package hdf.hdf5lib.exceptions; \ No newline at end of file diff --git a/java/src/hdf/hdf5lib/package-info.java b/java/src/hdf/hdf5lib/package-info.java new file mode 100644 index 0000000..838a266 --- /dev/null +++ b/java/src/hdf/hdf5lib/package-info.java @@ -0,0 +1,174 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + +/** + * This package is the Java interface for the HDF5 library. + *

+ * This code is the called by Java programs to access the entry points of the HDF5 library. Each routine wraps a single + * HDF5 entry point, generally with the arguments and return codes analogous to the C interface. + *

+ * For details of the HDF5 library, see the HDF5 Documentation at: + * http://hdfgroup.org/HDF5/ + *


+ *

+ * Mapping of arguments for Java + * + *

+ * In general, arguments to the HDF Java API are straightforward translations from the 'C' API described in the HDF + * Reference Manual. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
HDF-5 C types to Java types
HDF-5Java
H5T_NATIVE_INTint, Integer
H5T_NATIVE_SHORTshort, Short
H5T_NATIVE_FLOATfloat, Float
H5T_NATIVE_DOUBLEdouble, Double
H5T_NATIVE_CHARbyte, Byte
H5T_C_S1java.lang.String
void *
+ * (i.e., pointer to `Any')
Special -- see HDFArray
+ * General Rules for Passing Arguments and Results + *

+ * In general, arguments passed IN to Java are the analogous basic types, as above. The exception is for arrays, + * which are discussed below. + *

+ * The return value of Java methods is also the analogous type, as above. A major exception to that rule is that + * all HDF functions that return SUCCEED/FAIL are declared boolean in the Java version, rather than int as + * in the C. Functions that return a value or else FAIL are declared the equivalent to the C function. However, in most + * cases the Java method will raise an exception instead of returning an error code. + * See Errors and Exceptions below. + *

+ * Java does not support pass by reference of arguments, so arguments that are returned through OUT parameters + * must be wrapped in an object or array. The Java API for HDF consistently wraps arguments in arrays. + *

+ * For instance, a function that returns two integers is declared: + * + *

+ *       h_err_t HDF5dummy( int *a1, int *a2)
+ * 
+ * + * For the Java interface, this would be declared: + * + *
+ * public synchronized static native void HDF5dummy(int args[]);
+ * 
+ * + * where a1 is args[0] and a2 is args[1], and would be invoked: + * + *
+ * H5.HDF5dummy(a);
+ * 
+ * + *

+ * All the routines where this convention is used will have specific documentation of the details, given below. + *

+ * Arrays + *

+ * HDF5 needs to read and write multi-dimensional arrays of any number type (and records). The HDF5 API describes the + * layout of the source and destination, and the data for the array passed as a block of bytes, for instance, + * + *

+ *      herr_t H5Dread(long fid, long filetype, long memtype, long memspace, void *data);
+ * 
+ * + *

+ * where ``void *'' means that the data may be any valid numeric type, and is a contiguous block of bytes that is the + * data for a multi-dimensional array. The other parameters describe the dimensions, rank, and datatype of the array on + * disk (source) and in memory (destination). + *

+ * For Java, this ``ANY'' is a problem, as the type of data must always be declared. Furthermore, multidimensional + * arrays are definitely not layed out contiguously in memory. It would be infeasible to declare a separate + * routine for every combination of number type and dimensionality. For that reason, the + * HDFArray class is used to discover the type, shape, and size of the + * data array at run time, and to convert to and from a contiguous array of bytes in synchronized static native C order. + *

+ * The upshot is that any Java array of numbers (either primitive or sub-classes of type Number) can be passed as + * an ``Object'', and the Java API will translate to and from the appropriate packed array of bytes needed by the C + * library. So the function above would be declared: + * + *

+ * public synchronized static native int H5Dread(long fid, long filetype, long memtype, long memspace, Object data);
+ * 
+ * OPEN_IDS.addElement(id); + + * and the parameter data can be any multi-dimensional array of numbers, such as float[][], or int[][][], or + * Double[][]. + *

+ * HDF-5 Constants + *

+ * The HDF-5 API defines a set of constants and enumerated values. Most of these values are available to Java programs + * via the class HDF5Constants. For example, the parameters for + * the h5open() call include two numeric values, HDFConstants.H5F_ACC_RDWR and + * HDF5Constants.H5P_DEFAULT. As would be expected, these numbers correspond to the C constants + * H5F_ACC_RDWR and H5P_DEFAULT. + *

+ * The HDF-5 API defines a set of values that describe number types and sizes, such as "H5T_NATIVE_INT" and "hsize_t". + * These values are determined at run time by the HDF-5 C library. To support these parameters, the Java class + * HDF5CDataTypes looks up the values when initiated. The values + * can be accessed as public variables of the Java class, such as: + * + *

+ * long data_type = HDF5CDataTypes.JH5T_NATIVE_INT;
+ * 
+ * + * The Java application uses both types of constants the same way, the only difference is that the + * HDF5CDataTypes may have different values on different platforms. + *

+ * Error handling and Exceptions + *

+ * The HDF5 error API (H5E) manages the behavior of the error stack in the HDF-5 library. This API is available from the + * JHI5. Errors are converted into Java exceptions. This is totally different from the C interface, but is very natural + * for Java programming. + *

+ * The exceptions of the JHI5 are organized as sub-classes of the class + * HDF5Exception. There are two subclasses of + * HDF5Exception, HDF5LibraryException + * and HDF5JavaException. The sub-classes of the + * former represent errors from the HDF-5 C library, while sub-classes of the latter represent errors in the JHI5 + * wrapper and support code. + *

+ * The super-class HDF5LibraryException implements the method 'printStackTrace()', which + * prints out the HDF-5 error stack, as described in the HDF-5 C API H5Eprint(). This may be used by Java + * exception handlers to print out the HDF-5 error stack. + *


+ * + * See also: http://hdfgroup.org/HDF5" + **/ +package hdf.hdf5lib; \ No newline at end of file diff --git a/java/src/hdf/hdf5lib/structs/package-info.java b/java/src/hdf/hdf5lib/structs/package-info.java new file mode 100644 index 0000000..8a9d97d --- /dev/null +++ b/java/src/hdf/hdf5lib/structs/package-info.java @@ -0,0 +1,17 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** All structure definitions define java equivalents of the C structures needed + * by the C API calls. See the C API for information about the structures. + */ +package hdf.hdf5lib.structs; diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 2550ad9..7313c28 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -237,7 +237,7 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_ HDmemcpy(cptr, &tmp_double, sizeof(double)); break; } -#if H5_SIZEOF_LONG_DOUBLE != 0 && H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE case sizeof(long double): { long double tmp_ldouble = 0.0; @@ -816,7 +816,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i break; } -#if H5_SIZEOF_LONG_DOUBLE != 0 && H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE case sizeof(long double): { long double tmp_ldouble = 0.0; diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index ffaf5f5..c6cf607 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -113,14 +113,14 @@ endif () get_property (target_name TARGET ${HDF5_JAVA_JNI_LIB_TARGET} PROPERTY OUTPUT_NAME) set (CMD_ARGS "-Dhdf.hdf5lib.H5.loadLibraryName=${target_name}$<$:${CMAKE_DEBUG_POSTFIX}>;") +set (CMAKE_JAVA_CLASSPATH ".") +foreach (CMAKE_INCLUDE_PATH ${CMAKE_JAVA_INCLUDE_PATH}) + set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${CMAKE_INCLUDE_PATH}") +endforeach () if (HDF5_TEST_JAVA AND HDF5_TEST_SERIAL) foreach (test_file ${HDF5_JAVA_TEST_SOURCES}) - set (CMAKE_JAVA_CLASSPATH ".") - foreach (CMAKE_INCLUDE_PATH ${CMAKE_JAVA_INCLUDE_PATH}) - set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${CMAKE_INCLUDE_PATH}") - endforeach () - set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${HDF5_JAVA_TEST_LIB_TARGET}_${test_file}_JAR_FILE}") + set (TEST_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${HDF5_JAVA_TEST_LIB_TARGET}_${test_file}_JAR_FILE}") add_test ( NAME JUnit-${test_file}-clearall-objects @@ -132,7 +132,7 @@ if (HDF5_TEST_JAVA AND HDF5_TEST_SERIAL) NAME JUnit-${test_file} COMMAND "${CMAKE_COMMAND}" -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" - -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}" + -D "TEST_CLASSPATH:STRING=${TEST_JAVA_CLASSPATH}" -D "TEST_ARGS:STRING=${CMD_ARGS}-ea;org.junit.runner.JUnitCore" -D "TEST_PROGRAM=test.${test_file}" -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" @@ -184,7 +184,7 @@ if (HDF5_TEST_JAVA AND HDF5_TEST_SERIAL) -D "TEST_MASK_ERROR=TRUE" # -D "TEST_FILTER:STRING=${testfilter}" -D "TEST_REFERENCE=JUnit-${volname}-${voltest}.txt" - -P "${HDF_RESOURCES_DIR}/jvolTest.cmake" + -P "${HDF_RESOURCES_DIR}/jrunTest.cmake" ) set_tests_properties (JUnit-VOL-${volname}-${voltest} PROPERTIES ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir2" @@ -228,12 +228,8 @@ if (HDF5_TEST_JAVA AND HDF5_TEST_SERIAL) foreach (volinfo IN LISTS ${voltest}) foreach (h5_file ${HDF5_JAVA_TEST_SOURCES}) - set (CMAKE_JAVA_CLASSPATH ".") - foreach (CMAKE_INCLUDE_PATH ${CMAKE_JAVA_INCLUDE_PATH}) - set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${CMAKE_INCLUDE_PATH}") - endforeach () - set (CMAKE_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${HDF5_JAVA_TEST_LIB_TARGET}_${h5_file}_JAR_FILE}") - DO_VOL_TEST (${h5_file} ${voltest} "${volinfo}" ${CMAKE_JAVA_CLASSPATH}) + set (VOL_JAVA_CLASSPATH "${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${HDF5_JAVA_TEST_LIB_TARGET}_${h5_file}_JAR_FILE}") + DO_VOL_TEST (${h5_file} ${voltest} "${volinfo}" "${VOL_JAVA_CLASSPATH}") endforeach () endforeach () endforeach () diff --git a/m4/aclocal_fc.f90 b/m4/aclocal_fc.f90 index e9a11c0..240a768 100644 --- a/m4/aclocal_fc.f90 +++ b/m4/aclocal_fc.f90 @@ -82,6 +82,7 @@ END PROGRAM PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE !---- START ----- Determine the available KINDs for REALs and INTEGERs PROGRAM FC_AVAIL_KINDS + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : stderr=>ERROR_UNIT IMPLICIT NONE INTEGER :: ik, jk, k, kk, max_decimal_prec INTEGER :: prev_rkind, num_rkinds = 1, num_ikinds = 1 @@ -89,8 +90,6 @@ PROGRAM FC_AVAIL_KINDS INTEGER, DIMENSION(1:10) :: list_rkinds = -1 LOGICAL :: new_kind - OPEN(8, FILE='pac_fconftest.out', FORM='formatted') - ! Find integer KINDs list_ikinds(num_ikinds)=SELECTED_INT_KIND(1) DO ik = 2, 36 @@ -103,11 +102,11 @@ PROGRAM FC_AVAIL_KINDS ENDDO DO k = 1, num_ikinds - WRITE(8,'(I0)', ADVANCE='NO') list_ikinds(k) + WRITE(stderr,'(I0)', ADVANCE='NO') list_ikinds(k) IF(k.NE.num_ikinds)THEN - WRITE(8,'(A)',ADVANCE='NO') ',' + WRITE(stderr,'(A)',ADVANCE='NO') ',' ELSE - WRITE(8,'()') + WRITE(stderr,'()') ENDIF ENDDO @@ -140,17 +139,17 @@ PROGRAM FC_AVAIL_KINDS ENDDO prec DO k = 1, num_rkinds - WRITE(8,'(I0)', ADVANCE='NO') list_rkinds(k) + WRITE(stderr,'(I0)', ADVANCE='NO') list_rkinds(k) IF(k.NE.num_rkinds)THEN - WRITE(8,'(A)',ADVANCE='NO') ',' + WRITE(stderr,'(A)',ADVANCE='NO') ',' ELSE - WRITE(8,'()') + WRITE(stderr,'()') ENDIF ENDDO - WRITE(8,'(I0)') max_decimal_prec - WRITE(8,'(I0)') num_ikinds - WRITE(8,'(I0)') num_rkinds + WRITE(stderr,'(I0)') max_decimal_prec + WRITE(stderr,'(I0)') num_ikinds + WRITE(stderr,'(I0)') num_rkinds END PROGRAM FC_AVAIL_KINDS !---- END ----- Determine the available KINDs for REALs and INTEGERs diff --git a/m4/aclocal_fc.m4 b/m4/aclocal_fc.m4 index e5d664d..49ff485 100644 --- a/m4/aclocal_fc.m4 +++ b/m4/aclocal_fc.m4 @@ -68,7 +68,7 @@ AC_DEFUN([PAC_PROG_FC_ISO_FORTRAN_ENV],[ AC_MSG_CHECKING([if Fortran compiler supports intrinsic module ISO_FORTRAN_ENV]) TEST_SRC="`sed -n '/PROGRAM PROG_FC_ISO_FORTRAN_ENV/,/END PROGRAM PROG_FC_ISO_FORTRAN_ENV/p' $srcdir/m4/aclocal_fc.f90`" AC_LINK_IFELSE([$TEST_SRC],[AC_MSG_RESULT([yes]) - HAVE_ISO_FORTRAN_ENV="yes"], + HAVE_ISO_FORTRAN_ENV="yes"], [AC_MSG_RESULT([no])]) ]) @@ -79,7 +79,7 @@ AC_DEFUN([PAC_PROG_FC_SIZEOF],[ AC_MSG_CHECKING([if Fortran compiler supports intrinsic SIZEOF]) TEST_SRC="`sed -n '/PROGRAM PROG_FC_SIZEOF/,/END PROGRAM PROG_FC_SIZEOF/p' $srcdir/m4/aclocal_fc.f90`" AC_LINK_IFELSE([$TEST_SRC],[AC_MSG_RESULT([yes]) - HAVE_SIZEOF_FORTRAN="yes"], + HAVE_SIZEOF_FORTRAN="yes"], [AC_MSG_RESULT([no])]) ]) @@ -90,7 +90,7 @@ AC_DEFUN([PAC_PROG_FC_C_SIZEOF],[ AC_MSG_CHECKING([if Fortran compiler supports intrinsic C_SIZEOF]) TEST_SRC="`sed -n '/PROGRAM PROG_FC_C_SIZEOF/,/END PROGRAM PROG_FC_C_SIZEOF/p' $srcdir/m4/aclocal_fc.f90`" AC_LINK_IFELSE([$TEST_SRC], [AC_MSG_RESULT([yes]) - HAVE_C_SIZEOF_FORTRAN="yes"], + HAVE_C_SIZEOF_FORTRAN="yes"], [AC_MSG_RESULT([no])]) ]) @@ -101,7 +101,7 @@ AC_DEFUN([PAC_PROG_FC_STORAGE_SIZE],[ AC_MSG_CHECKING([if Fortran compiler supports intrinsic STORAGE_SIZE]) TEST_SRC="`sed -ne '/PROGRAM PROG_FC_STORAGE_SIZE/,/END PROGRAM PROG_FC_STORAGE_SIZE/p' $srcdir/m4/aclocal_fc.f90`" AC_LINK_IFELSE([$TEST_SRC], [AC_MSG_RESULT([yes]) - HAVE_STORAGE_SIZE_FORTRAN="yes"], + HAVE_STORAGE_SIZE_FORTRAN="yes"], [AC_MSG_RESULT([no])]) ]) @@ -114,7 +114,7 @@ AC_DEFUN([PAC_PROG_FC_HAVE_C_LONG_DOUBLE],[ TEST_SRC="" TEST_SRC="`sed -n '/PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE/,/END PROGRAM PROG_FC_HAVE_C_LONG_DOUBLE/p' $srcdir/m4/aclocal_fc.f90`" AC_LINK_IFELSE([$TEST_SRC], [AC_MSG_RESULT([yes]) - HAVE_C_LONG_DOUBLE_FORTRAN="yes"], + HAVE_C_LONG_DOUBLE_FORTRAN="yes"], [AC_MSG_RESULT([no])]) ]) @@ -146,8 +146,8 @@ AC_DEFUN([PAC_PROG_FC_HAVE_F2003_REQUIREMENTS],[ dnl ------------------------------------------------------------------------- dnl AC_F9X_MODS() dnl -dnl Check how F9X handles modules. This macro also checks which -dnl command-line option to use to include the module once it's built. +dnl Check how F9X handles modules. This macro also checks which +dnl command-line option to use to include the module once it's built. dnl AC_DEFUN([AC_F9X_MODS], [AC_MSG_CHECKING(what $FC does with modules) @@ -223,7 +223,6 @@ else fi AC_SUBST(F9XMODFLAG) AC_SUBST(F9XMODEXT) -rm -rf conftest* AC_LANG_POP(Fortran) ]) @@ -241,9 +240,9 @@ dnl Change to the Fortran 90 language dnl Try link a simple MPI program. AC_MSG_CHECKING([whether a simple MPI-IO Fortran program can be linked]) AC_LINK_IFELSE([$TEST_SRC], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AC_MSG_ERROR([unable to link a simple MPI-IO Fortran program])]) + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([unable to link a simple MPI-IO Fortran program])]) dnl Change to the C language AC_LANG_POP(Fortran) @@ -257,51 +256,43 @@ dnl This is a runtime test. dnl AC_DEFUN([PAC_FC_AVAIL_KINDS],[ AC_LANG_PUSH([Fortran]) -rm -f pac_fconftest.out TEST_SRC="`sed -n '/PROGRAM FC_AVAIL_KINDS/,/END PROGRAM FC_AVAIL_KINDS/p' $srcdir/m4/aclocal_fc.f90`" AC_RUN_IFELSE([$TEST_SRC], [ - if test -s pac_fconftest.out ; then - - dnl The output from the above program will be: - dnl -- LINE 1 -- valid integer kinds (comma seperated list) - dnl -- LINE 2 -- valid real kinds (comma seperated list) - dnl -- LINE 3 -- max decimal precision for reals - dnl -- LINE 4 -- number of valid integer kinds - dnl -- LINE 5 -- number of valid real kinds - - pac_validIntKinds="`sed -n '1p' pac_fconftest.out`" - pac_validRealKinds="`sed -n '2p' pac_fconftest.out`" - PAC_FC_MAX_REAL_PRECISION="`sed -n '3p' pac_fconftest.out`" + dnl The output from the above program will be: + dnl -- LINE 1 -- valid integer kinds (comma seperated list) + dnl -- LINE 2 -- valid real kinds (comma seperated list) + dnl -- LINE 3 -- max decimal precision for reals + dnl -- LINE 4 -- number of valid integer kinds + dnl -- LINE 5 -- number of valid real kinds + + pac_validIntKinds=$(./conftest$EXEEXT 2>&1 | sed -n '1p') + pac_validRealKinds=$(./conftest$EXEEXT 2>&1 | sed -n '2p') + PAC_FC_MAX_REAL_PRECISION=$(./conftest$EXEEXT 2>&1 | sed -n '3p') AC_DEFINE_UNQUOTED([PAC_FC_MAX_REAL_PRECISION], $PAC_FC_MAX_REAL_PRECISION, [Define Fortran Maximum Real Decimal Precision]) PAC_FC_ALL_INTEGER_KINDS="{`echo $pac_validIntKinds`}" PAC_FC_ALL_REAL_KINDS="{`echo $pac_validRealKinds`}" - PAC_FORTRAN_NUM_INTEGER_KINDS="`sed -n '4p' pac_fconftest.out`" - H5CONFIG_F_NUM_IKIND="INTEGER, PARAMETER :: num_ikinds = `echo $PAC_FORTRAN_NUM_INTEGER_KINDS`" - H5CONFIG_F_IKIND="INTEGER, DIMENSION(1:num_ikinds) :: ikind = (/`echo $pac_validIntKinds`/)" - H5CONFIG_F_NUM_RKIND="INTEGER, PARAMETER :: num_rkinds = `sed -n '5p' pac_fconftest.out`" - H5CONFIG_F_RKIND="INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/`echo $pac_validRealKinds`/)" + PAC_FORTRAN_NUM_INTEGER_KINDS=$(./conftest$EXEEXT 2>&1 | sed -n '4p') + H5CONFIG_F_NUM_IKIND="INTEGER, PARAMETER :: num_ikinds = `echo $PAC_FORTRAN_NUM_INTEGER_KINDS`" + H5CONFIG_F_IKIND="INTEGER, DIMENSION(1:num_ikinds) :: ikind = (/`echo $pac_validIntKinds`/)" + H5CONFIG_F_NUM_RKIND="INTEGER, PARAMETER :: num_rkinds = $(./conftest$EXEEXT 2>&1 | sed -n '5p')" + H5CONFIG_F_RKIND="INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/`echo $pac_validRealKinds`/)" - AC_DEFINE_UNQUOTED([H5CONFIG_F_NUM_RKIND], $H5CONFIG_F_NUM_RKIND, [Define number of valid Fortran REAL KINDs]) - AC_DEFINE_UNQUOTED([H5CONFIG_F_NUM_IKIND], $H5CONFIG_F_NUM_IKIND, [Define number of valid Fortran INTEGER KINDs]) - AC_DEFINE_UNQUOTED([H5CONFIG_F_RKIND], $H5CONFIG_F_RKIND, [Define valid Fortran REAL KINDs]) - AC_DEFINE_UNQUOTED([H5CONFIG_F_IKIND], $H5CONFIG_F_IKIND, [Define valid Fortran INTEGER KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_NUM_RKIND], $H5CONFIG_F_NUM_RKIND, [Define number of valid Fortran REAL KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_NUM_IKIND], $H5CONFIG_F_NUM_IKIND, [Define number of valid Fortran INTEGER KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_RKIND], $H5CONFIG_F_RKIND, [Define valid Fortran REAL KINDs]) + AC_DEFINE_UNQUOTED([H5CONFIG_F_IKIND], $H5CONFIG_F_IKIND, [Define valid Fortran INTEGER KINDs]) AC_MSG_CHECKING([for Number of Fortran INTEGER KINDs]) AC_MSG_RESULT([$PAC_FORTRAN_NUM_INTEGER_KINDS]) AC_MSG_CHECKING([for Fortran INTEGER KINDs]) AC_MSG_RESULT([$PAC_FC_ALL_INTEGER_KINDS]) - AC_MSG_CHECKING([for Fortran REAL KINDs]) - AC_MSG_RESULT([$PAC_FC_ALL_REAL_KINDS]) - AC_MSG_CHECKING([for Fortran REALs maximum decimal precision]) - AC_MSG_RESULT([$PAC_FC_MAX_REAL_PRECISION]) - else - AC_MSG_RESULT([Error]) - AC_MSG_ERROR([No output from Fortran test program!]) - fi - rm -f pac_fconftest.out + AC_MSG_CHECKING([for Fortran REAL KINDs]) + AC_MSG_RESULT([$PAC_FC_ALL_REAL_KINDS]) + AC_MSG_CHECKING([for Fortran REALs maximum decimal precision]) + AC_MSG_RESULT([$PAC_FC_MAX_REAL_PRECISION]) ],[ AC_MSG_RESULT([Error]) AC_MSG_ERROR([Failed to run Fortran program to determine available KINDs]) @@ -314,29 +305,22 @@ AC_REQUIRE([PAC_FC_AVAIL_KINDS]) AC_MSG_CHECKING([sizeof of available INTEGER KINDs]) AC_LANG_PUSH([Fortran]) pack_int_sizeof="" -rm -f pac_fconftest.out for kind in `echo $pac_validIntKinds | sed -e 's/,/ /g'`; do AC_LANG_CONFTEST([ AC_LANG_SOURCE([ PROGRAM main USE ISO_C_BINDING + USE ISO_FORTRAN_ENV, ONLY : stderr=>ERROR_UNIT IMPLICIT NONE INTEGER (KIND=$kind) a - OPEN(8, FILE='pac_fconftest.out', FORM='formatted') - WRITE(8,'(I0)') $FC_SIZEOF_A - CLOSE(8) + WRITE(stderr,'(I0)') $FC_SIZEOF_A END ]) ]) AC_RUN_IFELSE([],[ - if test -s pac_fconftest.out ; then - sizes="`cat pac_fconftest.out`" - pack_int_sizeof="$pack_int_sizeof $sizes," - else - AC_MSG_ERROR([No output from Fortran test program!]) - fi - rm -f pac_fconftest.out + sizes=$(./conftest$EXEEXT 2>&1) + pack_int_sizeof="$pack_int_sizeof $sizes," ],[ AC_MSG_ERROR([Fortran program fails to build or run!]) ],[ @@ -359,22 +343,16 @@ for kind in `echo $pac_validRealKinds | sed -e 's/,/ /g'`; do AC_LANG_SOURCE([ PROGRAM main USE ISO_C_BINDING + USE ISO_FORTRAN_ENV, ONLY : stderr=>ERROR_UNIT IMPLICIT NONE REAL (KIND=$kind) :: a - OPEN(8, FILE='pac_fconftest.out', FORM='formatted') - WRITE(8,'(I0)') $FC_SIZEOF_A - CLOSE(8) + WRITE(stderr,'(I0)') $FC_SIZEOF_A END ]) ]) AC_RUN_IFELSE([],[ - if test -s pac_fconftest.out ; then - sizes="`cat pac_fconftest.out`" - pack_real_sizeof="$pack_real_sizeof $sizes," - else - AC_MSG_ERROR([No output from Fortran test program!]) - fi - rm -f pac_fconftest.out + sizes=$(./conftest$EXEEXT 2>&1) + pack_real_sizeof="$pack_real_sizeof $sizes," ],[ AC_MSG_ERROR([Fortran program fails to build or run!]) ],[ @@ -396,33 +374,27 @@ rm -f pac_fconftest.out AC_LANG_SOURCE([ PROGRAM main USE ISO_C_BINDING + USE ISO_FORTRAN_ENV, ONLY : stderr=>ERROR_UNIT IMPLICIT NONE INTEGER a REAL b DOUBLE PRECISION c - OPEN(8, FILE='pac_fconftest.out', FORM='formatted') - WRITE(8,*) $FC_SIZEOF_A - WRITE(8,*) KIND(a) - WRITE(8,*) $FC_SIZEOF_B - WRITE(8,*) KIND(b) - WRITE(8,*) $FC_SIZEOF_C - WRITE(8,*) KIND(c) - CLOSE(8) + WRITE(stderr,*) $FC_SIZEOF_A + WRITE(stderr,*) KIND(a) + WRITE(stderr,*) $FC_SIZEOF_B + WRITE(stderr,*) KIND(b) + WRITE(stderr,*) $FC_SIZEOF_C + WRITE(stderr,*) KIND(c) END ]) ]) AC_RUN_IFELSE([],[ - if test -s pac_fconftest.out ; then - PAC_FORTRAN_NATIVE_INTEGER_SIZEOF="`sed -n '1p' pac_fconftest.out`" - PAC_FORTRAN_NATIVE_INTEGER_KIND="`sed -n '2p' pac_fconftest.out`" - PAC_FORTRAN_NATIVE_REAL_SIZEOF="`sed -n '3p' pac_fconftest.out`" - PAC_FORTRAN_NATIVE_REAL_KIND="`sed -n '4p' pac_fconftest.out`" - PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF="`sed -n '5p' pac_fconftest.out`" - PAC_FORTRAN_NATIVE_DOUBLE_KIND="`sed -n '6p' pac_fconftest.out`" - else - AC_MSG_ERROR([No output from Fortran test program!]) - fi - rm -f pac_fconftest.out + PAC_FORTRAN_NATIVE_INTEGER_SIZEOF=$(./conftest$EXEEXT 2>&1 | sed -n '1p') + PAC_FORTRAN_NATIVE_INTEGER_KIND=$(./conftest$EXEEXT 2>&1 | sed -n '2p') + PAC_FORTRAN_NATIVE_REAL_SIZEOF=$(./conftest$EXEEXT 2>&1 | sed -n '3p') + PAC_FORTRAN_NATIVE_REAL_KIND=$(./conftest$EXEEXT 2>&1 | sed -n '4p') + PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF=$(./conftest$EXEEXT 2>&1 | sed -n '5p') + PAC_FORTRAN_NATIVE_DOUBLE_KIND=$(./conftest$EXEEXT 2>&1 | sed -n '6p') ],[ AC_MSG_ERROR([Fortran program fails to build or run!]) ],[ @@ -434,7 +406,6 @@ AC_LANG_POP([Fortran]) AC_DEFUN([PAC_FC_LDBL_DIG],[ AC_MSG_CHECKING([maximum decimal precision for C]) -rm -f pac_Cconftest.out AC_LANG_CONFTEST([ AC_LANG_PROGRAM([ #include @@ -458,19 +429,12 @@ rm -f pac_Cconftest.out #define C_LDBL_DIG LDBL_DIG #endif ],[[ - FILE * pFile; - pFile = fopen("pac_Cconftest.out","w"); - fprintf(pFile, "%d\n%d\n", C_LDBL_DIG, C_FLT128_DIG); + fprintf(stderr, "%d\n%d\n", C_LDBL_DIG, C_FLT128_DIG); ]]) ]) AC_RUN_IFELSE([],[ - if test -s pac_Cconftest.out ; then - LDBL_DIG="`sed -n '1p' pac_Cconftest.out`" - FLT128_DIG="`sed -n '2p' pac_Cconftest.out`" - else - AC_MSG_ERROR([No output from C decimal precision program!]) - fi - rm -f pac_Cconftest.out + LDBL_DIG=$(./conftest$EXEEXT 2>&1 | sed -n '1p') + FLT128_DIG=$(./conftest$EXEEXT 2>&1 | sed -n '2p') ],[ AC_MSG_ERROR([C program fails to build or run!]) ],[]) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 8a2c496..fbdbf3f 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -47,10 +47,28 @@ New Features Configuration: ------------- + - Added new configure options to enable dimension scales APIs (H5DS*) to + use new object references with the native VOL connector (aka native HDF5 + library). New references are always used for non-native terminal VOL + connectors (e.g., DAOS). + + Autotools --enable-dimension-scales-with-new-ref + CMake HDF5_DIMENSION_SCALES_NEW_REF=ON + + (EIP - 2021/10/25, HDFFV-11180) + + - Refactored the utils folder. + + Added subfolder test and moved the 'swmr_check_compat_vfd.c file' + from test into utils/test. Deleted the duplicate swmr_check_compat_vfd.c + file in hl/tools/h5watch folder. Also fixed vfd check options. + + (ADB - 2021/10/18) + - Changed autotools and CMake configurations to derive both compilation warnings-as-errors and warnings-only-warn configurations - from the same files, `config/*/*error*`. Removed redundant files - `config/*/*noerror*`. + from the same files, 'config/*/*error*'. Removed redundant files + 'config/*/*noerror*'. (DCY - 2021/09/29) @@ -58,7 +76,13 @@ New Features that default ON/enabled. Add configure options (autotools - CMake): - enable-hltools HDF5_BUILD_HL_TOOLS + --enable-hltools HDF5_BUILD_HL_TOOLS + + Disabling this option prevents building the gif tool which + contains the following CVEs: + HDFFV-10592 CVE-2018-17433 + HDFFV-10593 CVE-2018-17436 + HDFFV-11048 CVE-2020-10809 (ADB - 2021/09/16, HDFFV-11266) @@ -1015,6 +1039,13 @@ Bug Fixes since HDF5-1.12.0 release =================================== Library ------- + - Fixed an issue with collective metadata reads being permanently disabled + after a dataset chunk lookup operation. This would usually cause a + mismatched MPI_Bcast and MPI_ERR_TRUNCATE issue in the library for + simple cases of H5Dcreate() -> H5Dwrite() -> H5Dcreate(). + + (JTH - 2021/11/08, HDFFV-11090) + - Fixed cross platform incompatibility of references within variable length types @@ -1092,6 +1123,14 @@ Bug Fixes since HDF5-1.12.0 release (ADB - 2021/03/03, #361) + - Fixed a segmentation fault + + A segmentation fault occurred with a Mathworks corrupted file. + + A detection of accessing a null pointer was added to prevent the problem. + + (BMR - 2021/02/19, HDFFV-11150) + - Fixed issue with MPI communicator and info object not being copied into new FAPL retrieved from H5F_get_access_plist @@ -1110,6 +1149,17 @@ Bug Fixes since HDF5-1.12.0 release (NAF - 2021/01/22) + - Fixed CVE-2018-17432 + + The tool h5repack produced a segfault on a corrupted file which had + invalid rank for scalar or NULL datatype. + + The problem was fixed by modifying the dataspace encode and decode + functions to detect and report invalid rank. h5repack now fails + with an error message for the corrupted file. + + (BMR - 2020/10/26, HDFFV-10590) + - Creation of dataset with optional filter When the combination of type, space, etc doesn't work for filter @@ -1439,7 +1489,11 @@ Bug Fixes since HDF5-1.12.0 release High-Level Library ------------------ - - + - Fixed HL_test_packet, test for packet table vlen of vlen. + + Incorrect length assignment. + + (ADB - 2021/10/14) Fortran High-Level APIs @@ -1645,3 +1699,11 @@ The share folder will have the most differences because CMake builds include a number of CMake specific files for support of CMake's find_package and support for the HDF5 Examples CMake project. +The issues with the gif tool are: + HDFFV-10592 CVE-2018-17433 + HDFFV-10593 CVE-2018-17436 + HDFFV-11048 CVE-2020-10809 +These CVE issues have not yet been addressed and can be avoided by not building +the gif tool. Disable building the High-Level tools with these options: + autotools: --disable-hltools + cmake: HDF5_BUILD_HL_TOOLS=OFF diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b18aed7..1974cbc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -273,6 +273,7 @@ set (H5FD_SOURCES ${HDF5_SRC_DIR}/H5FDmpi.c ${HDF5_SRC_DIR}/H5FDmpio.c ${HDF5_SRC_DIR}/H5FDmulti.c + ${HDF5_SRC_DIR}/H5FDperform.c ${HDF5_SRC_DIR}/H5FDros3.c ${HDF5_SRC_DIR}/H5FDs3comms.c ${HDF5_SRC_DIR}/H5FDsec2.c diff --git a/src/H5.c b/src/H5.c index af090fd..d0fb0f7 100644 --- a/src/H5.c +++ b/src/H5.c @@ -32,6 +32,8 @@ #include "H5SLprivate.h" /* Skip lists */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5FDsec2.h" /* for H5FD_sec2_init() */ + /****************/ /* Local Macros */ /****************/ @@ -63,9 +65,6 @@ static int H5__mpi_delete_cb(MPI_Comm comm, int keyval, void *attr_val, int *fla /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -103,32 +102,30 @@ static H5_atclose_node_t *H5_atclose_head = NULL; /* Declare a free list to manage the H5_atclose_node_t struct */ H5FL_DEFINE_STATIC(H5_atclose_node_t); -/*-------------------------------------------------------------------------- -NAME - H5__init_package -- Initialize interface-specific information -USAGE - herr_t H5__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------*/ -herr_t -H5__init_package(void) +/*------------------------------------------------------------------------- + * Function: H5_default_vfd_init + * + * Purpose: Initialize the default VFD. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ +static herr_t +H5_default_vfd_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Run the library initialization routine, if it hasn't already ran */ - if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { - if (H5_init_library() < 0) - HGOTO_ERROR(H5E_LIB, H5E_CANTINIT, FAIL, "unable to initialize library") - } /* end if */ + herr_t ret_value = SUCCEED; + FUNC_ENTER_NOAPI(FAIL) + /* Load the hid_t for the default VFD for the side effect + * it has of initializing the default VFD. + */ + if (H5FD_sec2_init() == H5I_INVALID_HID) { + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to load default VFD ID") + } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5__init_package() */ +} /*-------------------------------------------------------------------------- * NAME @@ -147,9 +144,14 @@ done: herr_t H5_init_library(void) { + size_t i; char * env_use_select_io = NULL; herr_t ret_value = SUCCEED; + /* Run the library initialization routine, if it hasn't already run */ + if (H5_INIT_GLOBAL || H5_TERM_GLOBAL) + HGOTO_DONE(SUCCEED) + /* Set the 'library initialized' flag as early as possible, to avoid * possible re-entrancy. */ @@ -260,26 +262,32 @@ H5_init_library(void) * The dataspace interface needs to be initialized so that future IDs for * dataspaces work. */ - if (H5E_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface") - if (H5VL_init_phase1() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") - if (H5P_init_phase1() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") - if (H5AC_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface") - if (H5L_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize link interface") - if (H5FS_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize FS interface") - if (H5S_init() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataspace interface") - + /* clang-format off */ + struct { + herr_t (*func)(void); + const char *descr; + } initializer[] = { + {H5E_init, "error"} + , {H5VL_init_phase1, "VOL"} + , {H5SL_init, "skip lists"} + , {H5FD_init, "VFD"} + , {H5_default_vfd_init, "default VFD"} + , {H5P_init_phase1, "property list"} + , {H5AC_init, "metadata caching"} + , {H5L_init, "link"} + , {H5S_init, "dataspace"} /* Finish initializing interfaces that depend on the interfaces above */ - if (H5P_init_phase2() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") - if (H5VL_init_phase2() < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") + , {H5P_init_phase2, "property list"} + , {H5VL_init_phase2, "VOL"} + }; + + for (i = 0; i < NELMTS(initializer); i++) { + if (initializer[i].func() < 0) { + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, + "unable to initialize %s interface", initializer[i].descr) + } + } + /* clang-format on */ /* Check for HDF5_USE_SELECTION_IO env variable */ env_use_select_io = HDgetenv("HDF5_USE_SELECTION_IO"); @@ -311,9 +319,11 @@ done: void H5_term_library(void) { - int pending, ntries = 0, n; - size_t at = 0; - char loop[1024]; + int pending, ntries = 0; + char loop[1024], *next = loop; + size_t i; + size_t nleft = sizeof(loop); + int nprinted; H5E_auto2_t func; #ifdef H5_HAVE_THREADSAFE @@ -357,108 +367,137 @@ H5_term_library(void) H5_atclose_head = NULL; } /* end if */ + /* clang-format off */ + /* * Terminate each interface. The termination functions return a positive * value if they do something that might affect some other interface in a * way that would necessitate some cleanup work in the other interface. */ -#define DOWN(F) \ - (((n = H5##F##_term_package()) && (at + 8) < sizeof loop) \ - ? (HDsprintf(loop + at, "%s%s", (at ? "," : ""), #F), at += HDstrlen(loop + at), n) \ - : ((n > 0 && (at + 5) < sizeof loop) ? (HDsprintf(loop + at, "..."), at += HDstrlen(loop + at), n) \ - : n)) - do { - pending = 0; - - /* Try to organize these so the "higher" level components get shut - * down before "lower" level components that they might rely on. -QAK - */ +#define TERMINATOR(module, wait) { \ + .func = H5##module##_term_package \ + , .name = #module \ + , .completed = false \ + , .await_prior = wait \ + } + /* + * Termination is ordered by the `terminator` table so the "higher" level + * packages are shut down before "lower" level packages that they + * rely on: + */ + struct { + int (*func)(void); /* function to terminate the module; returns 0 + * on success, >0 if termination was not + * completed and we should try to terminate + * some dependent modules, first. + */ + const char *name; /* name of the module */ + hbool_t completed; /* true iff this terminator was already + * completed + */ + const hbool_t await_prior; /* true iff all prior terminators in the + * list must complete before this + * terminator is attempted + */ + } terminator[] = { /* Close the event sets first, so that all asynchronous operations - * complete before anything else attempts to shut down. + * complete before anything else attempts to shut down. */ - pending += DOWN(ES); - - /* Close down the user-facing interfaces, after the event sets */ - if (pending == 0) { - /* Close the interfaces dependent on others */ - pending += DOWN(L); - - /* Close the "top" of various interfaces (IDs, etc) but don't shut - * down the whole interface yet, so that the object header messages - * get serialized correctly for entries in the metadata cache and the - * symbol table entry in the superblock gets serialized correctly, etc. - * all of which is performed in the 'F' shutdown. - */ - pending += DOWN(A_top); - pending += DOWN(D_top); - pending += DOWN(G_top); - pending += DOWN(M_top); - pending += DOWN(R_top); - pending += DOWN(S_top); - pending += DOWN(T_top); - } /* end if */ - + TERMINATOR(ES, false) + /* Do not attempt to close down package L until after event sets + * have finished closing down. + */ + , TERMINATOR(L, true) + /* Close the "top" of various interfaces (IDs, etc) but don't shut + * down the whole interface yet, so that the object header messages + * get serialized correctly for entries in the metadata cache and the + * symbol table entry in the superblock gets serialized correctly, etc. + * all of which is performed in the 'F' shutdown. + * + * The tops of packages A, D, G, M, S, T do not need to wait for L + * or previous packages to finish closing down. + */ + , TERMINATOR(A_top, false) + , TERMINATOR(D_top, false) + , TERMINATOR(G_top, false) + , TERMINATOR(M_top, false) + , TERMINATOR(S_top, false) + , TERMINATOR(T_top, false) /* Don't shut down the file code until objects in files are shut down */ - if (pending == 0) - pending += DOWN(F); - + , TERMINATOR(F, true) /* Don't shut down the property list code until all objects that might - * use property lists are shut down */ - if (pending == 0) - pending += DOWN(P); - + * use property lists are shut down + */ + , TERMINATOR(P, true) /* Wait to shut down the "bottom" of various interfaces until the - * files are closed, so pieces of the file can be serialized - * correctly. + * files are closed, so pieces of the file can be serialized + * correctly. + * + * Shut down the "bottom" of the attribute, dataset, group, + * reference, dataspace, and datatype interfaces, fully closing + * out the interfaces now. */ - if (pending == 0) { - /* Shut down the "bottom" of the attribute, dataset, group, - * reference, dataspace, and datatype interfaces, fully closing - * out the interfaces now. - */ - pending += DOWN(A); - pending += DOWN(D); - pending += DOWN(G); - pending += DOWN(M); - pending += DOWN(R); - pending += DOWN(S); - pending += DOWN(T); - } /* end if */ - - /* Don't shut down "low-level" components until "high-level" components - * have successfully shut down. This prevents property lists and IDs - * from being closed "out from underneath" of the high-level objects - * that depend on them. -QAK + , TERMINATOR(A, true) + , TERMINATOR(D, false) + , TERMINATOR(G, false) + , TERMINATOR(M, false) + , TERMINATOR(S, false) + , TERMINATOR(T, false) + /* Wait to shut down low-level packages like AC until after + * the preceding high-level packages have shut down. This prevents + * low-level objects from closing "out from underneath" their + * reliant high-level objects. */ - if (pending == 0) { - pending += DOWN(AC); - /* Shut down the "pluggable" interfaces, before the plugin framework */ - pending += DOWN(Z); - pending += DOWN(FD); - pending += DOWN(VL); - /* Don't shut down the plugin code until all "pluggable" interfaces (Z, FD, PL) are shut down */ - if (pending == 0) - pending += DOWN(PL); - /* Don't shut down the error code until other APIs which use it are shut down */ - if (pending == 0) - pending += DOWN(E); - /* Don't shut down the ID code until other APIs which use them are shut down */ - if (pending == 0) - pending += DOWN(I); - /* Don't shut down the skip list code until everything that uses it is down */ - if (pending == 0) - pending += DOWN(SL); - /* Don't shut down the free list code until everything that uses it is down */ - if (pending == 0) - pending += DOWN(FL); - /* Don't shut down the API context code until _everything_ else is down */ - if (pending == 0) - pending += DOWN(CX); - } /* end if */ + , TERMINATOR(AC, true) + /* Shut down the "pluggable" interfaces, before the plugin framework */ + , TERMINATOR(Z, false) + , TERMINATOR(FD, false) + , TERMINATOR(VL, false) + /* Don't shut down the plugin code until all "pluggable" interfaces + * (Z, FD, PL) are shut down + */ + , TERMINATOR(PL, true) + /* Shut down the following packages in strictly the order given + * by the table. + */ + , TERMINATOR(E, true) + , TERMINATOR(I, true) + , TERMINATOR(SL, true) + , TERMINATOR(FL, true) + , TERMINATOR(CX, true) + }; + + do { + pending = 0; + for (i = 0; i < NELMTS(terminator); i++) { + if (terminator[i].completed) + continue; + if (pending != 0 && terminator[i].await_prior) + break; + if (terminator[i].func() == 0) { + terminator[i].completed = true; + continue; + } + + /* log a package when its terminator needs to be retried */ + pending++; + nprinted = HDsnprintf(next, nleft, "%s%s", + (next != loop) ? "," : "", terminator[i].name); + if (nprinted < 0) + continue; + if ((size_t)nprinted >= nleft) + nprinted = HDsnprintf(next, nleft, "..."); + if (nprinted < 0 || (size_t)nprinted >= nleft) + continue; + nleft -= (size_t)nprinted; + next += nprinted; + } } while (pending && ntries++ < 100); + /* clang-format on */ + if (pending) { /* Only display the error message if the user is interested in them. */ if (func) { diff --git a/src/H5AC.c b/src/H5AC.c index 1c75aff..e727a9e 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -70,9 +70,6 @@ static herr_t H5AC__verify_tag(const H5AC_class_t *type); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -143,29 +140,7 @@ H5AC_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5AC_init() */ - -/*------------------------------------------------------------------------- - * Function: H5AC__init_package - * - * Purpose: Initialize interface-specific information - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, July 18, 2002 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__init_package(void) -{ - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_NOAPI_NOERR #ifdef H5_HAVE_PARALLEL /* check whether to enable strict collective function calling @@ -182,8 +157,8 @@ H5AC__init_package(void) } #endif /* H5_HAVE_PARALLEL */ - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5AC__init_package() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5AC_init() */ /*------------------------------------------------------------------------- * Function: H5AC_term_package @@ -204,10 +179,6 @@ H5AC_term_package(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) - /* Reset interface initialization flag */ - H5_PKG_INIT_VAR = FALSE; - FUNC_LEAVE_NOAPI(0) } /* end H5AC_term_package() */ diff --git a/src/H5ACproxy_entry.c b/src/H5ACproxy_entry.c index b3d31b2..31d3224 100644 --- a/src/H5ACproxy_entry.c +++ b/src/H5ACproxy_entry.c @@ -421,7 +421,7 @@ H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(pentry); @@ -433,7 +433,6 @@ H5AC_proxy_entry_dest(H5AC_proxy_entry_t *pentry) /* Free the proxy entry object */ pentry = H5FL_FREE(H5AC_proxy_entry_t, pentry); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5AC_proxy_entry_dest() */ diff --git a/src/H5Aint.c b/src/H5Aint.c index 300d686..b0b91d0 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -99,9 +99,6 @@ static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_ord /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Format version bounds for attribute */ const unsigned H5O_attr_ver_bounds[] = { H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */ @@ -139,9 +136,6 @@ static const H5I_class_t H5I_ATTR_CLS[1] = {{ (H5I_free_t)H5A__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5A_top_package_initialize_s = FALSE; - /*------------------------------------------------------------------------- * Function: H5A_init * @@ -158,30 +152,6 @@ H5A_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5A_init() */ - -/*-------------------------------------------------------------------------- -NAME - H5A__init_package -- Initialize interface-specific information -USAGE - herr_t H5A__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ -herr_t -H5A__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* * Create attribute ID type. @@ -189,12 +159,9 @@ H5A__init_package(void) if (H5I_register_type(H5I_ATTR_CLS) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize interface") - /* Mark "top" of interface as initialized, too */ - H5A_top_package_initialize_s = TRUE; - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5A__init_package() */ +} /* end H5A_init() */ /*-------------------------------------------------------------------------- NAME @@ -220,16 +187,10 @@ H5A_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5A_top_package_initialize_s) { - if (H5I_nmembers(H5I_ATTR) > 0) { - (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if (0 == n) - H5A_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_ATTR) > 0) { + (void)H5I_clear_type(H5I_ATTR, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* H5A_top_term_package() */ @@ -260,18 +221,11 @@ H5A_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_ATTR)); - HDassert(FALSE == H5A_top_package_initialize_s); - - /* Destroy the attribute object id group */ - n += (H5I_dec_type_ref(H5I_ATTR) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_ATTR)); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the attribute object id group */ + n += (H5I_dec_type_ref(H5I_ATTR) > 0); FUNC_LEAVE_NOAPI(n) } /* H5A_term_package() */ @@ -1148,7 +1102,7 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(attr); @@ -1166,7 +1120,6 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) ainfo->corder = attr->shared->crt_idx; } /* end else */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_info() */ @@ -1383,14 +1336,13 @@ H5A_oloc(H5A_t *attr) { H5O_loc_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(attr); /* Set return value */ ret_value = &(attr->oloc); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_oloc() */ @@ -1414,14 +1366,13 @@ H5A_nameof(H5A_t *attr) { H5G_name_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(attr); /* Set return value */ ret_value = &(attr->path); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_nameof() */ @@ -1443,14 +1394,13 @@ H5A_type(const H5A_t *attr) { H5T_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(attr); /* Set return value */ ret_value = attr->shared->dt; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_type() */ diff --git a/src/H5B.c b/src/H5B.c index fa6284c..a9aa312 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -157,9 +157,6 @@ static H5B_t *H5B__copy(const H5B_t *old_bt); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the haddr_t sequence information */ H5FL_SEQ_DEFINE(haddr_t); diff --git a/src/H5B2.c b/src/H5B2.c index cc6a664..b64f253 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -61,9 +61,6 @@ /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* v2 B-tree client ID to class mapping */ /* Remember to add client ID to H5B2_subid_t in H5B2private.h when adding a new diff --git a/src/H5B2int.c b/src/H5B2int.c index 610da6c..ab43a5a 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -52,9 +52,9 @@ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, - const H5B2_node_ptr_t *node_ptrs, unsigned start_idx, - unsigned end_idx, void *old_parent, void *new_parent); +static herr_t H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *node_ptrs, + unsigned start_idx, unsigned end_idx, void *old_parent, + void *new_parent); /*********************/ /* Package Variables */ @@ -1617,7 +1617,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, +H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, H5B2_operator_t op, void *op_data) { const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */ @@ -1642,8 +1642,7 @@ H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_ /* Lock the current B-tree node */ if (NULL == - (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, - H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ + (internal = H5B2__protect_internal(hdr, parent, curr_node, depth, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set up information about current node */ @@ -1739,8 +1738,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, - H5B2_remove_t op, void *op_data) +H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, H5B2_remove_t op, + void *op_data) { const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */ void * node = NULL; /* Pointers to current node */ @@ -1759,8 +1758,7 @@ H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_n /* Lock the current B-tree node */ if (NULL == - (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, - H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + (internal = H5B2__protect_internal(hdr, parent, curr_node, depth, FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Set up information about current node */ @@ -1824,7 +1822,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, +H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, hsize_t *btree_size) { H5B2_internal_t *internal = NULL; /* Pointer to internal node */ @@ -1839,8 +1837,8 @@ H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_nod HDassert(depth > 0); /* Lock the current B-tree node */ - if (NULL == (internal = H5B2__protect_internal(hdr, parent, (H5B2_node_ptr_t *)curr_node, depth, FALSE, - H5AC__READ_ONLY_FLAG))) /* Casting away const OK -QAK */ + if (NULL == + (internal = H5B2__protect_internal(hdr, parent, curr_node, depth, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") /* Recursively descend into child nodes, if we are above the "twig" level in the B-tree */ @@ -1910,7 +1908,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptr, void *old_parent, +H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *node_ptr, void *old_parent, void *new_parent) { const H5AC_class_t *child_class; /* Pointer to child node's class info */ @@ -1941,9 +1939,8 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t H5B2_internal_t *child_int; /* Protect child */ - if (NULL == (child_int = H5B2__protect_internal( - hdr, new_parent, (H5B2_node_ptr_t *)node_ptr, (uint16_t)(depth - 1), FALSE, - H5AC__NO_FLAGS_SET))) /* Casting away const OK -QAK */ + if (NULL == (child_int = H5B2__protect_internal(hdr, new_parent, node_ptr, (uint16_t)(depth - 1), + FALSE, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") child_class = H5AC_BT2_INT; child = child_int; @@ -2010,7 +2007,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptrs, +H5B2__update_child_flush_depends(H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *node_ptrs, unsigned start_idx, unsigned end_idx, void *old_parent, void *new_parent) { unsigned u; /* Local index variable */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 8d620cc..66d04fa 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -321,7 +321,7 @@ extern const H5B2_class_t *const H5B2_client_class_g[H5B2_NUM_BTREE_ID]; /* Generic routines */ H5_DLL herr_t H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); -H5_DLL herr_t H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *node_ptr, +H5_DLL herr_t H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, H5B2_node_ptr_t *node_ptr, void *old_parent, void *new_parent); H5_DLL herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); @@ -390,9 +390,9 @@ H5_DLL herr_t H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *op_data); /* Routines for iterating over nodes/records */ -H5_DLL herr_t H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, - void *parent, H5B2_operator_t op, void *op_data); -H5_DLL herr_t H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, void *parent, +H5_DLL herr_t H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, + H5B2_operator_t op, void *op_data); +H5_DLL herr_t H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, hsize_t *op_data); /* Routines for locating records */ @@ -423,8 +423,8 @@ H5_DLL herr_t H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_no void *op_data); /* Routines for deleting nodes */ -H5_DLL herr_t H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_node, - void *parent, H5B2_remove_t op, void *op_data); +H5_DLL herr_t H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, void *parent, + H5B2_remove_t op, void *op_data); /* Debugging routines for dumping file structures */ H5_DLL herr_t H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, diff --git a/src/H5C.c b/src/H5C.c index 7853933..275afea 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -157,9 +157,6 @@ static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the tag info struct */ H5FL_DEFINE(H5C_tag_info_t); diff --git a/src/H5CX.c b/src/H5CX.c index 01bf435..1329b9d 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -428,9 +428,6 @@ static H5CX_node_t *H5CX__pop_common(hbool_t update_dxpl_props); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*******************/ /* Local Variables */ /*******************/ @@ -463,18 +460,17 @@ H5FL_DEFINE_STATIC(H5CX_node_t); /* Declare a static free list to manage H5CX_state_t structs */ H5FL_DEFINE_STATIC(H5CX_state_t); -/*-------------------------------------------------------------------------- -NAME - H5CX__init_package -- Initialize interface-specific information -USAGE - herr_t H5CX__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5CX_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ herr_t -H5CX__init_package(void) +H5CX_init(void) { H5P_genplist_t *dx_plist; /* Data transfer property list */ H5P_genplist_t *lc_plist; /* Link creation property list */ @@ -484,7 +480,7 @@ H5CX__init_package(void) H5P_genplist_t *fa_plist; /* File access property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_NOAPI(FAIL) /* Reset the "default DXPL cache" information */ HDmemset(&H5CX_def_dxpl_cache, 0, sizeof(H5CX_dxpl_cache_t)); @@ -649,10 +645,9 @@ H5CX__init_package(void) if (H5P_get(fa_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &H5CX_def_fapl_cache.high_bound) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5CX_term_package @@ -673,24 +668,20 @@ H5CX_term_package(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - H5CX_node_t *cnode; /* Context node */ + H5CX_node_t *cnode; /* Context node */ - /* Pop the top context node from the stack */ - /* (Can't check for errors, as rest of library is shut down) */ - cnode = H5CX__pop_common(FALSE); + /* Pop the top context node from the stack */ + /* (Can't check for errors, as rest of library is shut down) */ + cnode = H5CX__pop_common(FALSE); - /* Free the context node */ - /* (Allocated with HDmalloc() in H5CX_push_special() ) */ - HDfree(cnode); + /* Free the context node */ + /* (Allocated with HDmalloc() in H5CX_push_special() ) */ + HDfree(cnode); #ifndef H5_HAVE_THREADSAFE - H5CX_head_g = NULL; + H5CX_head_g = NULL; #endif /* H5_HAVE_THREADSAFE */ - H5_PKG_INIT_VAR = FALSE; - } /* end if */ - FUNC_LEAVE_NOAPI(0) } /* end H5CX_term_package() */ @@ -1227,7 +1218,7 @@ H5CX_set_libver_bounds(H5F_t *f) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -1241,7 +1232,6 @@ H5CX_set_libver_bounds(H5F_t *f) (*head)->ctx.low_bound_valid = TRUE; (*head)->ctx.high_bound_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_libver_bounds() */ @@ -1509,7 +1499,7 @@ H5CX_set_vol_wrap_ctx(void *vol_wrap_ctx) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -1521,7 +1511,6 @@ H5CX_set_vol_wrap_ctx(void *vol_wrap_ctx) /* Mark the value as valid */ (*head)->ctx.vol_wrap_ctx_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vol_wrap_ctx() */ @@ -1543,7 +1532,7 @@ H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -1555,7 +1544,6 @@ H5CX_set_vol_connector_prop(const H5VL_connector_prop_t *vol_connector_prop) /* Mark the value as valid */ (*head)->ctx.vol_connector_prop_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vol_connector_prop() */ @@ -1637,7 +1625,7 @@ H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(vol_wrap_ctx); @@ -1651,7 +1639,6 @@ H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) else *vol_wrap_ctx = NULL; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vol_wrap_ctx() */ @@ -1673,7 +1660,7 @@ H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(vol_connector_prop); @@ -1687,7 +1674,6 @@ H5CX_get_vol_connector_prop(H5VL_connector_prop_t *vol_connector_prop) else HDmemset(vol_connector_prop, 0, sizeof(H5VL_connector_prop_t)); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vol_connector_prop() */ @@ -3135,7 +3121,7 @@ H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -3150,7 +3136,6 @@ H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free /* Mark the value as valid */ (*head)->ctx.vl_alloc_info_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_vlen_alloc_info() */ @@ -3172,7 +3157,7 @@ H5CX_set_nlinks(size_t nlinks) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ @@ -3184,7 +3169,6 @@ H5CX_set_nlinks(size_t nlinks) /* Mark the value as valid */ (*head)->ctx.nlinks_valid = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_nlinks() */ diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index c500356..8ec1c59 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -160,6 +160,8 @@ H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_i /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); +H5_DLL herr_t H5CX_init(void); + /* "Setter" routines for cached DXPL properties that must be returned to application */ #ifdef H5_HAVE_PARALLEL H5_DLL void H5CX_set_mpio_actual_chunk_opt(H5D_mpio_actual_chunk_opt_mode_t chunk_opt); diff --git a/src/H5D.c b/src/H5D.c index 7153c7d..cfa8692 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -62,9 +62,6 @@ static herr_t H5D__set_extent_api_common(hid_t dset_id, const hsize_t size[], vo /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 0cc1681..b0b54dd 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -264,9 +264,9 @@ static herr_t H5D__chunk_io_init(H5D_io_info_t *io_info, const H5D_type_info_t * static herr_t H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); static herr_t H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); static herr_t H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); static herr_t H5D__chunk_flush(H5D_t *dset); static herr_t H5D__chunk_io_term(const H5D_chunk_map_t *fm); static herr_t H5D__chunk_dest(H5D_t *dset); @@ -331,13 +331,24 @@ static int H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_uda /*********************/ /* Chunked storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = { - {H5D__chunk_construct, H5D__chunk_init, H5D__chunk_is_space_alloc, H5D__chunk_is_data_cached, - H5D__chunk_io_init, H5D__chunk_read, H5D__chunk_write, +const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {{ + H5D__chunk_construct, /* construct */ + H5D__chunk_init, /* init */ + H5D__chunk_is_space_alloc, /* is_space_alloc */ + H5D__chunk_is_data_cached, /* is_data_cached */ + H5D__chunk_io_init, /* io_init */ + H5D__chunk_read, /* ser_read */ + H5D__chunk_write, /* ser_write */ #ifdef H5_HAVE_PARALLEL - H5D__chunk_collective_read, H5D__chunk_collective_write, -#endif /* H5_HAVE_PARALLEL */ - NULL, NULL, H5D__chunk_flush, H5D__chunk_io_term, H5D__chunk_dest}}; + H5D__chunk_collective_read, /* par_read */ + H5D__chunk_collective_write, /* par_write */ +#endif + NULL, /* readvv */ + NULL, /* writevv */ + H5D__chunk_flush, /* flush */ + H5D__chunk_io_term, /* io_term */ + H5D__chunk_dest /* dest */ +}}; /*******************/ /* Local Variables */ @@ -1091,7 +1102,7 @@ H5D__chunk_io_init(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsi * speed up hyperslab calculations by removing the extra checks and/or * additions involving the offset and the hyperslab selection -QAK) */ - if ((file_space_normalized = H5S_hyper_normalize_offset((H5S_t *)file_space, old_offset)) < 0) + if ((file_space_normalized = H5S_hyper_normalize_offset(file_space, old_offset)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to normalize selection") /* Decide the number of chunks in each dimension */ @@ -1409,6 +1420,19 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline) } /* H5D__chunk_mem_xfree() */ /*------------------------------------------------------------------------- + * Function: H5D__chunk_mem_free + * + * Purpose: Wrapper with H5MM_free_t-compatible signature that just + * calls H5D__chunk_mem_xfree and discards the return value. + *------------------------------------------------------------------------- + */ +static void +H5D__chunk_mem_free(void *chk, const void *_pline) +{ + (void)H5D__chunk_mem_xfree(chk, _pline); +} + +/*------------------------------------------------------------------------- * Function: H5D__chunk_mem_realloc * * Purpose: Reallocate space for a chunk in memory. This routine allocates @@ -2529,8 +2553,7 @@ done: */ static herr_t H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t H5_ATTR_UNUSED nelmts, - const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t *fm) + H5S_t H5_ATTR_UNUSED *file_space, H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t *fm) { H5SL_node_t * chunk_node; /* Current node in chunk skip list */ H5D_io_info_t nonexistent_io_info; /* "nonexistent" I/O info object */ @@ -2801,8 +2824,7 @@ done: */ static herr_t H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t H5_ATTR_UNUSED nelmts, - const H5S_t H5_ATTR_UNUSED *file_space, const H5S_t H5_ATTR_UNUSED *mem_space, - H5D_chunk_map_t *fm) + H5S_t H5_ATTR_UNUSED *file_space, H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t *fm) { H5SL_node_t * chunk_node; /* Current node in chunk skip list */ H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ @@ -3538,11 +3560,14 @@ H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled) herr_t H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udata) { - H5D_rdcc_ent_t * ent = NULL; /* Cache entry */ - H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - unsigned idx = 0; /* Index of chunk in cache, if present */ - hbool_t found = FALSE; /* In cache? */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_rdcc_ent_t * ent = NULL; /* Cache entry */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + unsigned idx = 0; /* Index of chunk in cache, if present */ + hbool_t found = FALSE; /* In cache? */ +#ifdef H5_HAVE_PARALLEL + hbool_t reenable_coll_md_reads = FALSE; +#endif + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3613,8 +3638,13 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udat * highly unlikely that users would read the same chunks from all * processes. */ - if (H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) - H5CX_set_coll_metadata_read(FALSE); + if (H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) { + hbool_t do_coll_md_reads = H5CX_get_coll_metadata_read(); + if (do_coll_md_reads) { + H5CX_set_coll_metadata_read(FALSE); + reenable_coll_md_reads = TRUE; + } + } #endif /* H5_HAVE_PARALLEL */ /* Go get the chunk information */ @@ -3657,6 +3687,12 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udat } /* end else */ done: +#ifdef H5_HAVE_PARALLEL + /* Re-enable collective metadata reads if we disabled them */ + if (reenable_coll_md_reads) + H5CX_set_coll_metadata_read(TRUE); +#endif /* H5_HAVE_PARALLEL */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_lookup() */ @@ -4772,7 +4808,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const /* (delay allocating fill buffer for VL datatypes until refilling) */ /* (casting away const OK - QAK) */ if (H5D__fill_init(&fb_info, NULL, (H5MM_allocate_t)H5D__chunk_mem_alloc, (void *)pline, - (H5MM_free_t)H5D__chunk_mem_xfree, (void *)pline, &dset->shared->dcpl_cache.fill, + (H5MM_free_t)H5D__chunk_mem_free, (void *)pline, &dset->shared->dcpl_cache.fill, dset->shared->type, dset->shared->type_id, (size_t)0, orig_chunk_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index c79bae0..dfd1847 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -80,13 +80,24 @@ static herr_t H5D__compact_dest(H5D_t *dset); /*********************/ /* Compact storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = { - {H5D__compact_construct, NULL, H5D__compact_is_space_alloc, NULL, H5D__compact_io_init, H5D__contig_read, - H5D__contig_write, +const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{ + H5D__compact_construct, /* construct */ + NULL, /* init */ + H5D__compact_is_space_alloc, /* is_space_alloc */ + NULL, /* is_data_cached */ + H5D__compact_io_init, /* io_init */ + H5D__contig_read, /* ser_read */ + H5D__contig_write, /* ser_write */ #ifdef H5_HAVE_PARALLEL - NULL, NULL, -#endif /* H5_HAVE_PARALLEL */ - H5D__compact_readvv, H5D__compact_writevv, H5D__compact_flush, NULL, H5D__compact_dest}}; + NULL, /* par_read */ + NULL, /* par_write */ +#endif + H5D__compact_readvv, /* readvv */ + H5D__compact_writevv, /* writevv */ + H5D__compact_flush, /* flush */ + NULL, /* io_term */ + H5D__compact_dest /* dest */ +}}; /*******************/ /* Local Variables */ diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index d7ebbee..5eaa37f 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -110,13 +110,24 @@ static htri_t H5D__contig_may_use_select_io(const H5D_io_info_t *io_info, H5D_io /*********************/ /* Contiguous storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = { - {H5D__contig_construct, H5D__contig_init, H5D__contig_is_space_alloc, H5D__contig_is_data_cached, - H5D__contig_io_init, H5D__contig_read, H5D__contig_write, +const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {{ + H5D__contig_construct, /* construct */ + H5D__contig_init, /* init */ + H5D__contig_is_space_alloc, /* is_space_alloc */ + H5D__contig_is_data_cached, /* is_data_cached */ + H5D__contig_io_init, /* io_init */ + H5D__contig_read, /* ser_read */ + H5D__contig_write, /* ser_write */ #ifdef H5_HAVE_PARALLEL - H5D__contig_collective_read, H5D__contig_collective_write, -#endif /* H5_HAVE_PARALLEL */ - H5D__contig_readvv, H5D__contig_writevv, H5D__contig_flush, NULL, NULL}}; + H5D__contig_collective_read, /* par_read */ + H5D__contig_collective_write, /* par_write */ +#endif + H5D__contig_readvv, /* readvv */ + H5D__contig_writevv, /* writevv */ + H5D__contig_flush, /* flush */ + NULL, /* io_term */ + NULL /* dest */ +}}; /*******************/ /* Local Variables */ @@ -637,8 +648,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) +H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, H5S_t *file_space, + H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { herr_t ret_value = SUCCEED; /* Return value */ @@ -684,8 +695,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) +H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, H5S_t *file_space, + H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Defl.c b/src/H5Defl.c index ce6d481..18721d9 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -80,12 +80,24 @@ static herr_t H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t ad /*********************/ /* External File List (EFL) storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{H5D__efl_construct, NULL, H5D__efl_is_space_alloc, NULL, - H5D__efl_io_init, H5D__contig_read, H5D__contig_write, +const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ + H5D__efl_construct, /* construct */ + NULL, /* init */ + H5D__efl_is_space_alloc, /* is_space_alloc */ + NULL, /* is_data_cached */ + H5D__efl_io_init, /* io_init */ + H5D__contig_read, /* ser_read */ + H5D__contig_write, /* ser_write */ #ifdef H5_HAVE_PARALLEL - NULL, NULL, -#endif /* H5_HAVE_PARALLEL */ - H5D__efl_readvv, H5D__efl_writevv, NULL, NULL, NULL}}; + NULL, /* par_read */ + NULL, /* par_write */ +#endif + H5D__efl_readvv, /* readvv */ + H5D__efl_writevv, /* writevv */ + NULL, /* flush */ + NULL, /* io_term */ + NULL /* dest */ +}}; /*******************/ /* Local Variables */ diff --git a/src/H5Dfill.c b/src/H5Dfill.c index fe98487..cec7e8b 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -112,7 +112,7 @@ H5FL_EXTERN(H5S_sel_iter_t); on each element so that each of them has a copy of the VL data. --------------------------------------------------------------------------*/ herr_t -H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_type, const H5S_t *space) +H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_type, H5S_t *space) { H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info */ hbool_t mem_iter_init = FALSE; /* Whether the memory selection iterator has been initialized */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 6d3f4a3..8a09364 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -139,9 +139,6 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{ (H5I_free_t)H5D__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5D_top_package_initialize_s = FALSE; - /* Prefixes of VDS and external file from the environment variables * HDF5_EXTFILE_PREFIX and HDF5_VDS_PREFIX */ static const char *H5D_prefix_ext_env = NULL; @@ -160,37 +157,10 @@ static const char *H5D_prefix_vds_env = NULL; herr_t H5D_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D_init() */ - -/*-------------------------------------------------------------------------- -NAME - H5D__init_package -- Initialize interface-specific information -USAGE - herr_t H5D__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. -NOTES - Care must be taken when using the H5P functions, since they can cause - a deadlock in the library when the library is attempting to terminate -QAK - ---------------------------------------------------------------------------*/ -herr_t -H5D__init_package(void) -{ H5P_genplist_t *def_dcpl; /* Default Dataset Creation Property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Initialize the ID group for the dataset IDs */ if (H5I_register_type(H5I_DATASET_CLS) < 0) @@ -220,16 +190,13 @@ H5D__init_package(void) if (H5P_get(def_dcpl, H5O_CRT_PIPELINE_NAME, &H5D_def_dset.dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter") - /* Mark "top" of interface as initialized, too */ - H5D_top_package_initialize_s = TRUE; - /* Retrieve the prefixes of VDS and external file from the environment variable */ H5D_prefix_vds_env = HDgetenv("HDF5_VDS_PREFIX"); H5D_prefix_ext_env = HDgetenv("HDF5_EXTFILE_PREFIX"); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__init_package() */ +} /* end H5D_init() */ /*------------------------------------------------------------------------- * Function: H5D_top_term_package @@ -248,38 +215,32 @@ H5D_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5D_top_package_initialize_s) { - if (H5I_nmembers(H5I_DATASET) > 0) { - /* The dataset API uses the "force" flag set to true because it - * is using the "file objects" (H5FO) API functions to track open - * objects in the file. Using the H5FO code means that dataset - * IDs can have reference counts >1, when an existing dataset is - * opened more than once. However, the H5I code does not attempt - * to close objects with reference counts>1 unless the "force" flag - * is set to true. - * - * At some point (probably after the group and datatypes use the - * the H5FO code), the H5FO code might need to be switched around - * to storing pointers to the objects being tracked (H5D_t, H5G_t, - * etc) and reference count those itself instead of relying on the - * reference counting in the H5I layer. Then, the "force" flag can - * be put back to false. - * - * Setting the "force" flag to true for all the interfaces won't - * work because the "file driver" (H5FD) APIs use the H5I reference - * counting to avoid closing a file driver out from underneath an - * open file... - * - * QAK - 5/13/03 - */ - (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if (0 == n) - H5D_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_DATASET) > 0) { + /* The dataset API uses the "force" flag set to true because it + * is using the "file objects" (H5FO) API functions to track open + * objects in the file. Using the H5FO code means that dataset + * IDs can have reference counts >1, when an existing dataset is + * opened more than once. However, the H5I code does not attempt + * to close objects with reference counts>1 unless the "force" flag + * is set to true. + * + * At some point (probably after the group and datatypes use the + * the H5FO code), the H5FO code might need to be switched around + * to storing pointers to the objects being tracked (H5D_t, H5G_t, + * etc) and reference count those itself instead of relying on the + * reference counting in the H5I layer. Then, the "force" flag can + * be put back to false. + * + * Setting the "force" flag to true for all the interfaces won't + * work because the "file driver" (H5FD) APIs use the H5I reference + * counting to avoid closing a file driver out from underneath an + * open file... + * + * QAK - 5/13/03 + */ + (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); + n++; /*H5I*/ + } FUNC_LEAVE_NOAPI(n) } /* end H5D_top_term_package() */ @@ -304,18 +265,11 @@ H5D_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_DATASET)); - HDassert(FALSE == H5D_top_package_initialize_s); - - /* Destroy the dataset object id group */ - n += (H5I_dec_type_ref(H5I_DATASET) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_DATASET)); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the dataset object id group */ + n += (H5I_dec_type_ref(H5I_DATASET) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5D_term_package() */ diff --git a/src/H5Dio.c b/src/H5Dio.c index c245a5c..f852175 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -82,8 +82,7 @@ H5FL_DEFINE(H5D_chunk_map_t); *------------------------------------------------------------------------- */ herr_t -H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, - void *buf /*out*/) +H5D__read(H5D_t *dataset, hid_t mem_type_id, H5S_t *mem_space, H5S_t *file_space, void *buf /*out*/) { H5D_chunk_map_t *fm = NULL; /* Chunk file<->memory mapping */ H5D_io_info_t io_info; /* Dataset I/O info */ @@ -295,8 +294,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, - const void *buf) +H5D__write(H5D_t *dataset, hid_t mem_type_id, H5S_t *mem_space, H5S_t *file_space, const void *buf) { H5D_chunk_map_t *fm = NULL; /* Chunk file<->memory mapping */ H5D_io_info_t io_info; /* Dataset I/O info */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index e6b6143..0b25f9d 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -125,10 +125,10 @@ typedef herr_t (*H5D_layout_io_init_func_t)(struct H5D_io_info_t *io_info, const hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, struct H5D_chunk_map_t *cm); typedef herr_t (*H5D_layout_read_func_t)(struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, struct H5D_chunk_map_t *fm); typedef herr_t (*H5D_layout_write_func_t)(struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, struct H5D_chunk_map_t *fm); typedef ssize_t (*H5D_layout_readvv_func_t)(const struct H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], @@ -169,10 +169,10 @@ typedef struct H5D_layout_ops_t { /* Function pointers for either multiple or single block I/O access */ typedef herr_t (*H5D_io_single_read_func_t)(const struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space); + H5S_t *file_space, H5S_t *mem_space); typedef herr_t (*H5D_io_single_write_func_t)(const struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space); + H5S_t *file_space, H5S_t *mem_space); /* Typedef for raw data I/O framework info */ typedef struct H5D_io_ops_t { @@ -346,10 +346,10 @@ typedef struct H5D_chunk_map_t { H5O_layout_t *layout; /* Dataset layout information*/ hsize_t nelmts; /* Number of elements selected in file & memory dataspaces */ - const H5S_t *file_space; /* Pointer to the file dataspace */ - unsigned f_ndims; /* Number of dimensions for file dataspace */ + H5S_t * file_space; /* Pointer to the file dataspace */ + unsigned f_ndims; /* Number of dimensions for file dataspace */ - const H5S_t * mem_space; /* Pointer to the memory dataspace */ + H5S_t * mem_space; /* Pointer to the memory dataspace */ H5S_t * mchunk_tmpl; /* Dataspace template for new memory chunks */ H5S_sel_iter_t mem_iter; /* Iterator for elements in memory selection */ unsigned m_ndims; /* Number of dimensions for memory dataspace */ @@ -581,25 +581,25 @@ H5_DLL herr_t H5D__refresh(H5D_t *dataset, hid_t dset_id); H5_DLL herr_t H5D__format_convert(H5D_t *dataset); /* Internal I/O routines */ -H5_DLL herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, +H5_DLL herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, H5S_t *mem_space, H5S_t *file_space, void *buf /*out*/); -H5_DLL herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, +H5_DLL herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, H5S_t *mem_space, H5S_t *file_space, const void *buf); /* Functions that perform direct serial I/O operations */ H5_DLL herr_t H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space); + H5S_t *file_space, H5S_t *mem_space); H5_DLL herr_t H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space); /* Functions that perform scatter-gather serial I/O operations */ H5_DLL herr_t H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_buf); H5_DLL size_t H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf /*out*/); H5_DLL herr_t H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space); H5_DLL herr_t H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space); + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space); /* Functions that operate on dataset's layout information */ H5_DLL herr_t H5D__layout_set_io_ops(const H5D_t *dataset); @@ -617,9 +617,9 @@ H5_DLL hbool_t H5D__contig_is_space_alloc(const H5O_storage_t *storage); H5_DLL hbool_t H5D__contig_is_data_cached(const H5D_shared_t *shared_dset); H5_DLL herr_t H5D__contig_fill(const H5D_io_info_t *io_info); H5_DLL herr_t H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); H5_DLL herr_t H5D__contig_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); H5_DLL herr_t H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f_dst, H5O_storage_contig_t *storage_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info); H5_DLL herr_t H5D__contig_delete(H5F_t *f, const H5O_storage_t *store); @@ -686,7 +686,7 @@ H5_DLL herr_t H5D__efl_bh_info(H5F_t *f, H5O_efl_t *efl, hsize_t *heap_size); /* Functions that perform fill value operations on datasets */ H5_DLL herr_t H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_type, - const H5S_t *space); + H5S_t *space); H5_DLL herr_t H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info, const H5O_fill_t *fill, const H5T_t *dset_type, hid_t dset_type_id, size_t nelmts, size_t min_buf_size); diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index 971ddfb..500ea9e 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -437,7 +437,7 @@ done: */ herr_t H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space) + H5S_t *file_space, H5S_t *mem_space) { void * buf = io_info->u.rbuf; /* Local pointer to application buffer */ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/ @@ -577,7 +577,7 @@ done: */ herr_t H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space) + H5S_t *file_space, H5S_t *mem_space) { const void * buf = io_info->u.wbuf; /* Local pointer to application buffer */ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/ diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 7d2ead1..e64d657 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -44,8 +44,8 @@ /* Local Prototypes */ /********************/ -static herr_t H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space); +static herr_t H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, H5S_t *file_space, + H5S_t *mem_space); /*********************/ /* Package Variables */ @@ -77,8 +77,8 @@ H5FL_EXTERN(H5S_sel_iter_t); *------------------------------------------------------------------------- */ static herr_t -H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, const H5S_t *file_space, - const H5S_t *mem_space) +H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, H5S_t *file_space, + H5S_t *mem_space) { H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info */ hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ @@ -270,7 +270,7 @@ done: */ herr_t H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space) + H5S_t *file_space, H5S_t *mem_space) { herr_t ret_value = SUCCEED; /* Return value */ @@ -299,7 +299,7 @@ done: */ herr_t H5D__select_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space) + H5S_t *file_space, H5S_t *mem_space) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 4012188..49d1c04 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -84,9 +84,9 @@ /* Layout operation callbacks */ static hbool_t H5D__virtual_is_data_cached(const H5D_shared_t *shared_dset); static herr_t H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); static herr_t H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm); + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); static herr_t H5D__virtual_flush(H5D_t *dset); /* Other functions */ @@ -103,26 +103,37 @@ static herr_t H5D__virtual_build_source_name(char * size_t static_strlen, size_t nsubs, hsize_t blockno, char **built_name); static herr_t H5D__virtual_init_all(const H5D_t *dset); -static herr_t H5D__virtual_pre_io(H5D_io_info_t *io_info, H5O_storage_virtual_t *storage, - const H5S_t *file_space, const H5S_t *mem_space, hsize_t *tot_nelmts); +static herr_t H5D__virtual_pre_io(H5D_io_info_t *io_info, H5O_storage_virtual_t *storage, H5S_t *file_space, + H5S_t *mem_space, hsize_t *tot_nelmts); static herr_t H5D__virtual_post_io(H5O_storage_virtual_t *storage); static herr_t H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset); + H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset); static herr_t H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset); + H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset); /*********************/ /* Package Variables */ /*********************/ /* Contiguous storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{NULL, H5D__virtual_init, H5D__virtual_is_space_alloc, - H5D__virtual_is_data_cached, NULL, H5D__virtual_read, - H5D__virtual_write, +const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{ + NULL, /* construct */ + H5D__virtual_init, /* init */ + H5D__virtual_is_space_alloc, /* is_space_alloc */ + H5D__virtual_is_data_cached, /* is_data_cached */ + NULL, /* io_init */ + H5D__virtual_read, /* ser_read */ + H5D__virtual_write, /* ser_write */ #ifdef H5_HAVE_PARALLEL - NULL, NULL, -#endif /* H5_HAVE_PARALLEL */ - NULL, NULL, H5D__virtual_flush, NULL, NULL}}; + NULL, /* par_read */ + NULL, /* par_write */ +#endif + NULL, /* readvv */ + NULL, /* writevv */ + H5D__virtual_flush, /* flush */ + NULL, /* io_term */ + NULL /* dest */ +}}; /*******************/ /* Local Variables */ @@ -1304,7 +1315,7 @@ H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg) H5O_storage_virtual_name_seg_t *next_seg; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Walk name segments, freeing them */ while (name_seg) { @@ -1314,7 +1325,6 @@ H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg) name_seg = next_seg; } /* end while */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_free_parsed_name() */ @@ -2377,8 +2387,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_pre_io(H5D_io_info_t *io_info, H5O_storage_virtual_t *storage, const H5S_t *file_space, - const H5S_t *mem_space, hsize_t *tot_nelmts) +H5D__virtual_pre_io(H5D_io_info_t *io_info, H5O_storage_virtual_t *storage, H5S_t *file_space, + H5S_t *mem_space, hsize_t *tot_nelmts) { hssize_t select_nelmts; /* Number of elements in selection */ hsize_t bounds_start[H5S_MAX_RANK]; /* Selection bounds start */ @@ -2688,7 +2698,7 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space, +H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset) { H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ @@ -2748,8 +2758,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) +H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, H5S_t *file_space, + H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ @@ -2878,7 +2888,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space, +H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5S_t *file_space, H5O_storage_virtual_srcdset_t *source_dset) { H5S_t *projected_src_space = NULL; /* File space for selection in a single source dataset */ @@ -2941,7 +2951,7 @@ done: */ static herr_t H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ hsize_t tot_nelmts; /* Total number of elements mapped to mem_space */ diff --git a/src/H5E.c b/src/H5E.c index a5a9a2e..7f657fd 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -92,9 +92,6 @@ static herr_t H5E__append_stack(H5E_t *dst_estack, const H5E_t *src_stack); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -141,46 +138,19 @@ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ * * Purpose: Initialize the interface from some other layer. * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * Tuesday, June 29, 2004 - * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t H5E_init(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E_init() */ - -/*-------------------------------------------------------------------------- - * Function: H5E__init_package - * - * Purpose: Initialize interface-specific information - * - * Return: SUCCEED/FAIL - * - * Programmer: Raymond Lu - * Friday, July 11, 2003 - * - *-------------------------------------------------------------------------- - */ -herr_t -H5E__init_package(void) -{ H5E_cls_t *cls; /* Pointer to error class */ H5E_msg_t *msg; /* Pointer to new error message */ char lib_vers[128]; /* Buffer to constructu library version within */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Initialize the ID group for the error class IDs */ if (H5I_register_type(H5I_ERRCLS_CLS) < 0) @@ -213,7 +183,7 @@ H5E__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5E__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5E_term_package @@ -237,66 +207,61 @@ H5E_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - int64_t ncls, nmsg, nstk; - - /* Check if there are any open error stacks, classes or messages */ - ncls = H5I_nmembers(H5I_ERROR_CLASS); - nmsg = H5I_nmembers(H5I_ERROR_MSG); - nstk = H5I_nmembers(H5I_ERROR_STACK); - - if ((ncls + nmsg + nstk) > 0) { - /* Clear the default error stack. Note that - * the following H5I_clear_type calls do not - * force the clears and will not be able to - * clear any error message IDs that are still - * in use by the default error stack unless we - * clear that stack manually. - * - * Error message IDs will typically still be - * in use by the default error stack when the - * application does H5E_BEGIN/END_TRY cleanup - * at the very end. - */ - H5E_clear_stack(NULL); - - /* Clear any outstanding error stacks */ - if (nstk > 0) - (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); - - /* Clear all the error classes */ - if (ncls > 0) { - (void)H5I_clear_type(H5I_ERROR_CLASS, FALSE, FALSE); - - /* Reset the HDF5 error class, if its been closed */ - if (H5I_nmembers(H5I_ERROR_CLASS) == 0) - H5E_ERR_CLS_g = -1; - } /* end if */ + int64_t ncls, nmsg, nstk; + + /* Check if there are any open error stacks, classes or messages */ + ncls = H5I_nmembers(H5I_ERROR_CLASS); + nmsg = H5I_nmembers(H5I_ERROR_MSG); + nstk = H5I_nmembers(H5I_ERROR_STACK); + + if ((ncls + nmsg + nstk) > 0) { + /* Clear the default error stack. Note that + * the following H5I_clear_type calls do not + * force the clears and will not be able to + * clear any error message IDs that are still + * in use by the default error stack unless we + * clear that stack manually. + * + * Error message IDs will typically still be + * in use by the default error stack when the + * application does H5E_BEGIN/END_TRY cleanup + * at the very end. + */ + H5E_clear_stack(NULL); + + /* Clear any outstanding error stacks */ + if (nstk > 0) + (void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE); + + /* Clear all the error classes */ + if (ncls > 0) { + (void)H5I_clear_type(H5I_ERROR_CLASS, FALSE, FALSE); - /* Clear all the error messages */ - if (nmsg > 0) { - (void)H5I_clear_type(H5I_ERROR_MSG, FALSE, FALSE); + /* Reset the HDF5 error class, if its been closed */ + if (H5I_nmembers(H5I_ERROR_CLASS) == 0) + H5E_ERR_CLS_g = -1; + } /* end if */ - /* Reset the HDF5 error messages, if they've been closed */ - if (H5I_nmembers(H5I_ERROR_MSG) == 0) { + /* Clear all the error messages */ + if (nmsg > 0) { + (void)H5I_clear_type(H5I_ERROR_MSG, FALSE, FALSE); + + /* Reset the HDF5 error messages, if they've been closed */ + if (H5I_nmembers(H5I_ERROR_MSG) == 0) { /* Include the automatically generated error code termination */ #include "H5Eterm.h" - } /* end if */ - } /* end if */ - - n++; /*H5I*/ - } /* end if */ - else { - /* Destroy the error class, message, and stack id groups */ - n += (H5I_dec_type_ref(H5I_ERROR_STACK) > 0); - n += (H5I_dec_type_ref(H5I_ERROR_CLASS) > 0); - n += (H5I_dec_type_ref(H5I_ERROR_MSG) > 0); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end if */ + } /* end if */ + } /* end if */ + + n++; /*H5I*/ + } /* end if */ + else { + /* Destroy the error class, message, and stack id groups */ + n += (H5I_dec_type_ref(H5I_ERROR_STACK) > 0); + n += (H5I_dec_type_ref(H5I_ERROR_CLASS) > 0); + n += (H5I_dec_type_ref(H5I_ERROR_MSG) > 0); + + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5E_term_package() */ diff --git a/src/H5EA.c b/src/H5EA.c index 8f9a4b6..66eb8cc 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -75,9 +75,6 @@ static H5EA_t *H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Extensible array client ID to class mapping */ /* Remember to add client ID to H5EA_cls_id_t in H5EAprivate.h when adding a new diff --git a/src/H5ESint.c b/src/H5ESint.c index 6f9efe9..c66be16 100644 --- a/src/H5ESint.c +++ b/src/H5ESint.c @@ -95,9 +95,6 @@ static int H5ES__close_failed_cb(H5ES_event_t *ev, void *_ctx); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -118,23 +115,20 @@ static const H5I_class_t H5I_EVENTSET_CLS[1] = {{ H5FL_DEFINE_STATIC(H5ES_t); /*------------------------------------------------------------------------- - * Function: H5ES__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success / Negative on failure + * Function: H5ES_init * - * Programmer: Quincey Koziol - * Monday, April 6, 2020 + * Purpose: Initialize the interface from some other layer. * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5ES__init_package(void) +H5ES_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Initialize the ID group for the event set IDs */ if (H5I_register_type(H5I_EVENTSET_CLS) < 0) @@ -142,7 +136,7 @@ H5ES__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ES__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5ES_term_package @@ -165,14 +159,8 @@ H5ES_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Destroy the event set ID group */ - n += (H5I_dec_type_ref(H5I_EVENTSET) > 0); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the event set ID group */ + n += (H5I_dec_type_ref(H5I_EVENTSET) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5ES_term_package() */ diff --git a/src/H5ESprivate.h b/src/H5ESprivate.h index 3d9ce9f..153e3e3 100644 --- a/src/H5ESprivate.h +++ b/src/H5ESprivate.h @@ -51,5 +51,6 @@ typedef struct H5ES_t H5ES_t; /***************************************/ herr_t H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, const char *caller_args, ...); +H5_DLL herr_t H5ES_init(void); #endif /* H5ESprivate_H */ diff --git a/src/H5ESpublic.h b/src/H5ESpublic.h index 4cf71c5..c8696b3 100644 --- a/src/H5ESpublic.h +++ b/src/H5ESpublic.h @@ -51,13 +51,13 @@ typedef enum H5ES_status_t { /* Information about operations in an event set */ typedef struct H5ES_op_info_t { /* API call info */ - char *api_name; /* Name of HDF5 API routine called */ - char *api_args; /* "Argument string" for arguments to HDF5 API routine called */ + const char *api_name; /* Name of HDF5 API routine called */ + char * api_args; /* "Argument string" for arguments to HDF5 API routine called */ /* Application info */ - char * app_file_name; /* Name of source file where the HDF5 API routine was called */ - char * app_func_name; /* Name of function where the HDF5 API routine was called */ - unsigned app_line_num; /* Line # of source file where the HDF5 API routine was called */ + const char *app_file_name; /* Name of source file where the HDF5 API routine was called */ + const char *app_func_name; /* Name of function where the HDF5 API routine was called */ + unsigned app_line_num; /* Line # of source file where the HDF5 API routine was called */ /* Operation info */ uint64_t op_ins_count; /* Counter of operation's insertion into event set */ diff --git a/src/H5Eint.c b/src/H5Eint.c index 6438cd9..d744db3 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -930,7 +930,7 @@ H5E_dump_api_stack(hbool_t is_api) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Only dump the error stack during an API call */ if (is_api) { @@ -953,6 +953,5 @@ H5E_dump_api_stack(hbool_t is_api) #endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* end if */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_dump_api_stack() */ diff --git a/src/H5FA.c b/src/H5FA.c index ad69ee2..23c9fe4 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -64,9 +64,6 @@ static H5FA_t *H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Fixed array client ID to class mapping */ /* Remember to add client ID to H5FA_cls_id_t in H5FAprivate.h when adding a new diff --git a/src/H5FD.c b/src/H5FD.c index fad212e..233addc 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -61,9 +61,6 @@ static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags /*out*/); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -95,20 +92,20 @@ static const H5I_class_t H5I_VFL_CLS[1] = {{ }}; /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initialize the virtual file layer. + * Function: H5FD_init * - * Return: SUCCEED/FAIL + * Purpose: Initialize the interface from some other layer. * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5FD__init_package(void) +H5FD_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) if (H5I_register_type(H5I_VFL_CLS) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface") @@ -118,7 +115,7 @@ H5FD__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5FD_term_package @@ -142,20 +139,14 @@ H5FD_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - if (H5I_nmembers(H5I_VFL) > 0) { - (void)H5I_clear_type(H5I_VFL, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - else { - /* Destroy the VFL driver ID group */ - n += (H5I_dec_type_ref(H5I_VFL) > 0); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end if */ + if (H5I_nmembers(H5I_VFL) > 0) { + (void)H5I_clear_type(H5I_VFL, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ + else { + /* Destroy the VFL driver ID group */ + n += (H5I_dec_type_ref(H5I_VFL) > 0); + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5FD_term_package() */ @@ -165,7 +156,7 @@ H5FD_term_package(void) * * Purpose: Frees a file driver class struct and returns an indication of * success. This function is used as the free callback for the - * virtual file layer object identifiers (cf H5FD__init_package). + * virtual file layer object identifiers (cf H5FD_init). * * Return: SUCCEED/FAIL * @@ -454,7 +445,7 @@ H5FD_sb_size(H5FD_t *file) { hsize_t ret_value = 0; - FUNC_ENTER_NOAPI(0) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(file); @@ -464,7 +455,6 @@ H5FD_sb_size(H5FD_t *file) if (file->cls->sb_size) ret_value = (file->cls->sb_size)(file); -done: FUNC_LEAVE_NOAPI(ret_value) } @@ -592,7 +582,7 @@ H5FD_fapl_get(H5FD_t *file) { void *ret_value = NULL; - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(file); @@ -602,7 +592,6 @@ H5FD_fapl_get(H5FD_t *file) if (file->cls->fapl_get) ret_value = (file->cls->fapl_get)(file); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_fapl_get() */ @@ -939,10 +928,9 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) { int ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI(-1) /* return value is arbitrary */ + FUNC_ENTER_NOAPI_NOERR /* return value is arbitrary */ - if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) - HGOTO_DONE(0) + if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) HGOTO_DONE(0) if (!f1 || !f1->cls) HGOTO_DONE(-1) if (!f2 || !f2->cls) @@ -1300,7 +1288,7 @@ H5FD_get_maxaddr(const H5FD_t *file) { haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_NOAPI(HADDR_UNDEF) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(file); @@ -1308,7 +1296,6 @@ H5FD_get_maxaddr(const H5FD_t *file) /* Set return value */ ret_value = file->maxaddr; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_maxaddr() */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 7ae89c6..e8788c0 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -194,9 +194,9 @@ static const H5FD_class_t H5FD_core_g = { }; /* Default configurations, if none provided */ -static const H5FD_core_fapl_t H5FD_core_default_config_g = {H5_MB, TRUE, H5FD_CORE_WRITE_TRACKING_FLAG, - H5FD_CORE_WRITE_TRACKING_PAGE_SIZE}; -static const H5FD_core_fapl_t H5FD_core_default_paged_config_g = {H5_MB, TRUE, TRUE, (size_t)4096}; +static const H5FD_core_fapl_t H5FD_core_default_config_g = { + (size_t)H5_MB, TRUE, H5FD_CORE_WRITE_TRACKING_FLAG, H5FD_CORE_WRITE_TRACKING_PAGE_SIZE}; +static const H5FD_core_fapl_t H5FD_core_default_paged_config_g = {(size_t)H5_MB, TRUE, TRUE, (size_t)4096}; /* Define a free list to manage the region type */ H5FL_DEFINE(H5FD_core_region_t); @@ -402,7 +402,7 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, " "errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this " "sub-write = %llu, bytes actually written = %llu, offset = %llu", - HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, + HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), (void *)ptr, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ @@ -446,39 +446,6 @@ H5FD__core_get_default_config(void) } /* end H5FD__core_get_default_config() */ /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - char * lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); - if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ - else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - - if (H5FD_core_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize core VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_core_init * * Purpose: Initialize this driver by registering the driver with the @@ -495,9 +462,19 @@ done: hid_t H5FD_core_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + char *lock_env_var = NULL; /* Environment variable pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI_NOERR + + /* Check the use disabled file locks environment variable */ + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + else + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ if (H5I_VFL != H5I_get_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g, sizeof(H5FD_class_t), FALSE); @@ -505,7 +482,6 @@ H5FD_core_init(void) /* Set return value */ ret_value = H5FD_CORE_g; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_core_init() */ @@ -956,8 +932,8 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, " "error message = '%s', file->mem = %p, total read size = %llu, bytes this " "sub-read = %llu, bytes actually read = %llu, offset = %llu", - HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), file->mem, - (unsigned long long)size, (unsigned long long)bytes_in, + HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), + (void *)file->mem, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); } /* end if */ diff --git a/src/H5FDcore.h b/src/H5FDcore.h index 590478e..4067980 100644 --- a/src/H5FDcore.h +++ b/src/H5FDcore.h @@ -20,7 +20,7 @@ #ifndef H5FDcore_H #define H5FDcore_H -#define H5FD_CORE (H5FD_core_init()) +#define H5FD_CORE (H5FDperform_init(H5FD_core_init)) #define H5FD_CORE_VALUE H5_VFD_CORE #ifdef __cplusplus diff --git a/src/H5FDdevelop.h b/src/H5FDdevelop.h index 9b31fae..f9843c9 100644 --- a/src/H5FDdevelop.h +++ b/src/H5FDdevelop.h @@ -245,6 +245,7 @@ struct H5FD_t { extern "C" { #endif +H5_DLL hid_t H5FDperform_init(hid_t (*)(void)); H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); H5_DLL htri_t H5FDis_driver_registered_by_name(const char *driver_name); H5_DLL htri_t H5FDis_driver_registered_by_value(H5FD_class_value_t driver_value); diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 81d311f..f6b4ebd 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -186,42 +186,6 @@ static const H5FD_class_t H5FD_direct_g = { /* Declare a free list to manage the H5FD_direct_t struct */ H5FL_DEFINE_STATIC(H5FD_direct_t); -/*-------------------------------------------------------------------------- -NAME - H5FD__init_package -- Initialize interface-specific information -USAGE - herr_t H5FD__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_direct_init currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD__init_package(void) -{ - char * lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); - if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ - else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - - if (H5FD_direct_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize direct VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_direct_init * @@ -239,10 +203,20 @@ done: hid_t H5FD_direct_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + char *lock_env_var = NULL; /* Environment variable pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) + /* Check the use disabled file locks environment variable */ + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + else + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ + if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g)) H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDdirect.h b/src/H5FDdirect.h index a439e55..bfad16a 100644 --- a/src/H5FDdirect.h +++ b/src/H5FDdirect.h @@ -21,7 +21,7 @@ #define H5FDdirect_H #ifdef H5_HAVE_DIRECT -#define H5FD_DIRECT (H5FD_direct_init()) +#define H5FD_DIRECT (H5FDperform_init(H5FD_direct_init)) #define H5FD_DIRECT_VALUE H5_VFD_DIRECT #else #define H5FD_DIRECT (H5I_INVALID_HID) diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index a1a90d8..9e362e5 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -269,32 +269,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_get_default_printf_filename() */ -/*-------------------------------------------------------------------------- -NAME - H5FD__init_package -- Initialize interface-specific information -USAGE - herr_t H5FD__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_family_init currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - if (H5FD_family_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize family VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - /*------------------------------------------------------------------------- * Function: H5FD_family_init * @@ -312,9 +286,9 @@ done: hid_t H5FD_family_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI_NOERR if (H5I_VFL != H5I_get_type(H5FD_FAMILY_g)) H5FD_FAMILY_g = H5FD_register(&H5FD_family_g, sizeof(H5FD_class_t), FALSE); @@ -322,7 +296,6 @@ H5FD_family_init(void) /* Set return value */ ret_value = H5FD_FAMILY_g; -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_family_init() */ diff --git a/src/H5FDfamily.h b/src/H5FDfamily.h index 7b76a16..bd51f36 100644 --- a/src/H5FDfamily.h +++ b/src/H5FDfamily.h @@ -20,7 +20,7 @@ #ifndef H5FDfamily_H #define H5FDfamily_H -#define H5FD_FAMILY (H5FD_family_init()) +#define H5FD_FAMILY (H5FDperform_init(H5FD_family_init)) #define H5FD_FAMILY_VALUE H5_VFD_FAMILY #ifdef __cplusplus diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index 82985cc..cd1cedf 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -323,29 +323,6 @@ static const H5FD_class_t H5FD_hdfs_g = { H5FL_DEFINE_STATIC(H5FD_hdfs_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - if (H5FD_hdfs_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize hdfs VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_hdfs_init * * Purpose: Initialize this driver by registering the driver with the diff --git a/src/H5FDhdfs.h b/src/H5FDhdfs.h index a9f34a0..e401e81 100644 --- a/src/H5FDhdfs.h +++ b/src/H5FDhdfs.h @@ -22,7 +22,7 @@ #define H5FDhdfs_H #ifdef H5_HAVE_LIBHDFS -#define H5FD_HDFS (H5FD_hdfs_init()) +#define H5FD_HDFS (H5FDperform_init(H5FD_hdfs_init)) #define H5FD_HDFS_VALUE H5_VFD_HDFS #else /* H5_HAVE_LIBHDFS */ #define H5FD_HDFS (H5I_INVALID_HID) diff --git a/src/H5FDint.c b/src/H5FDint.c index af3562b..641f847 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -2392,7 +2392,7 @@ H5FD_check_plugin_load(const H5FD_class_t *cls, const H5PL_key_t *key, hbool_t * { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(cls); @@ -2404,7 +2404,7 @@ H5FD_check_plugin_load(const H5FD_class_t *cls, const H5PL_key_t *key, hbool_t * /* Check if plugin name matches VFD class name */ if (cls->name && !HDstrcmp(cls->name, key->vfd.u.name)) *success = TRUE; - } /* end if */ + } else { /* Sanity check */ HDassert(key->vfd.kind == H5FD_GET_DRIVER_BY_VALUE); @@ -2412,9 +2412,8 @@ H5FD_check_plugin_load(const H5FD_class_t *cls, const H5PL_key_t *key, hbool_t * /* Check if plugin value matches VFD class value */ if (cls->value == key->vfd.u.value) *success = TRUE; - } /* end else */ + } -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_check_plugin_load() */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 253c35b..9ea4582 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -228,39 +228,6 @@ static const H5FD_log_fapl_t H5FD_log_default_config_g = {NULL, H5FD_LOG_LOC_IO H5FL_DEFINE_STATIC(H5FD_log_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - char * lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); - if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ - else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - - if (H5FD_log_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize log VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_log_init * * Purpose: Initialize this driver by registering the driver with the @@ -277,9 +244,19 @@ done: hid_t H5FD_log_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + char *lock_env_var = NULL; /* Environment variable pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI_NOERR + + /* Check the use disabled file locks environment variable */ + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + else + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ if (H5I_VFL != H5I_get_type(H5FD_LOG_g)) H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE); @@ -287,7 +264,6 @@ H5FD_log_init(void) /* Set return value */ ret_value = H5FD_LOG_g; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_init() */ diff --git a/src/H5FDlog.h b/src/H5FDlog.h index bc96c52..a916fec 100644 --- a/src/H5FDlog.h +++ b/src/H5FDlog.h @@ -20,7 +20,7 @@ #ifndef H5FDlog_H #define H5FDlog_H -#define H5FD_LOG (H5FD_log_init()) +#define H5FD_LOG (H5FDperform_init(H5FD_log_init)) #define H5FD_LOG_VALUE H5_VFD_LOG /* Flags for H5Pset_fapl_log() */ diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index f1fbc46..9fd0f7b 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -210,30 +210,6 @@ H5FL_DEFINE_STATIC(H5FD_mirror_t); /* Declare a free list to manage the H5FD_mirror_xmit_open_t struct */ H5FL_DEFINE_STATIC(H5FD_mirror_xmit_open_t); -/*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - LOG_OP_CALL(__func__); - - if (H5FD_mirror_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mirror VFD"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - /* ------------------------------------------------------------------------- * Function: H5FD_mirror_init * diff --git a/src/H5FDmirror.h b/src/H5FDmirror.h index 66954b1..2fdf6c4 100644 --- a/src/H5FDmirror.h +++ b/src/H5FDmirror.h @@ -19,7 +19,7 @@ #ifdef H5_HAVE_MIRROR_VFD -#define H5FD_MIRROR (H5FD_mirror_init()) +#define H5FD_MIRROR (H5FDperform_init(H5FD_mirror_init)) #define H5FD_MIRROR_VALUE H5_VFD_MIRROR #ifdef __cplusplus diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index ad0812d..145f2be 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -164,35 +164,6 @@ static int H5FD_mpio_debug_rank_s = -1; (H5FD_mpio_debug_rank_s < 0 || H5FD_mpio_debug_rank_s == (file)->mpi_rank) #endif -/*-------------------------------------------------------------------------- -NAME - H5FD__init_package -- Initialize interface-specific information - -USAGE - herr_t H5FD__init_package() - -RETURNS - SUCCEED/FAIL - -DESCRIPTION - Initializes any interface-specific data or routines. (Just calls - H5FD_mpio_init currently). - ---------------------------------------------------------------------------*/ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - if (H5FD_mpio_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize mpio VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - #ifdef H5FDmpio_DEBUG /*--------------------------------------------------------------------------- @@ -2826,6 +2797,12 @@ H5FD__mpio_delete(const char *filename, hid_t fapl_id) HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) done: + /* Free duplicated MPI Communicator and Info objects */ + if (H5_mpi_comm_free(&comm) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free MPI communicator") + if (H5_mpi_info_free(&info) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free MPI info object") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_delete() */ diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index 8caf11c..00dea1b 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -23,7 +23,7 @@ /* Macros */ #ifdef H5_HAVE_PARALLEL -#define H5FD_MPIO (H5FD_mpio_init()) +#define H5FD_MPIO (H5FDperform_init(H5FD_mpio_init)) #else #define H5FD_MPIO (H5I_INVALID_HID) #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5FDmulti.h b/src/H5FDmulti.h index 62cc9c8..7a01f4c 100644 --- a/src/H5FDmulti.h +++ b/src/H5FDmulti.h @@ -20,7 +20,7 @@ #ifndef H5FDmulti_H #define H5FDmulti_H -#define H5FD_MULTI (H5FD_multi_init()) +#define H5FD_MULTI (H5FDperform_init(H5FD_multi_init)) #ifdef __cplusplus extern "C" { diff --git a/src/H5FDperform.c b/src/H5FDperform.c new file mode 100644 index 0000000..096fdd6 --- /dev/null +++ b/src/H5FDperform.c @@ -0,0 +1,58 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5Iprivate.h" /* IDs */ + +/*------------------------------------------------------------------------- + * Function: H5FDperform_init + * + * Purpose: Ensure that the library is initialized and then call + * the provided VFD initializer. + * + * Return: Success: identifier for the VFD just initialized + * Failure: H5I_INVALID_HID + *------------------------------------------------------------------------- + */ +hid_t H5FDperform_init(hid_t (*init)(void)) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API_NOINIT + /*NO TRACE*/ + + /* It is possible that an application will evaluate an + * `H5FD_*` symbol (`H5FD_FAMILY`, `H5FD_MULTI`, `H5FD_SEC2`, et + * cetera) before the library has had an opportunity to initialize. + * Call H5_init_library() to make sure that the library has been + * initialized before `init` is run. + */ + if (H5_init_library() < 0) { + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, H5I_INVALID_HID, "library initialization failed") + } + + ret_value = init(); +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index c48d0fc..96d79bd 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -178,6 +178,7 @@ H5_DLL herr_t H5FD_sort_vector_io_req(hbool_t *vector_was_sorted, uint32_t count haddr_t addrs[], size_t sizes[], const void *bufs[], H5FD_mem_t **s_types_ptr, haddr_t **s_addrs_ptr, size_t **s_sizes_ptr, void ***s_bufs_ptr); +H5_DLL herr_t H5FD_init(void); /* Function prototypes for MPI based VFDs*/ #ifdef H5_HAVE_PARALLEL diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 6c855a1..4a101f5 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -282,31 +282,6 @@ static const H5FD_class_t H5FD_ros3_g = { H5FL_DEFINE_STATIC(H5FD_ros3_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Jacob Smith 2017 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - if (H5FD_ros3_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize ros3 VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_ros3_init * * Purpose: Initialize this driver by registering the driver with the diff --git a/src/H5FDros3.h b/src/H5FDros3.h index d69ebe4..4a623c4 100644 --- a/src/H5FDros3.h +++ b/src/H5FDros3.h @@ -22,7 +22,7 @@ #define H5FDros3_H #ifdef H5_HAVE_ROS3_VFD -#define H5FD_ROS3 (H5FD_ros3_init()) +#define H5FD_ROS3 (H5FDperform_init(H5FD_ros3_init)) #define H5FD_ROS3_VALUE H5_VFD_ROS3 #else #define H5FD_ROS3 (H5I_INVALID_HID) diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 90844c1..4f0e40a 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -188,39 +188,6 @@ static const H5FD_class_t H5FD_sec2_g = { H5FL_DEFINE_STATIC(H5FD_sec2_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - char * lock_env_var = NULL; /* Environment variable pointer */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); - if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) - ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ - else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) - ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ - else - ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ - - if (H5FD_sec2_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize sec2 VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_sec2_init * * Purpose: Initialize this driver by registering the driver with the @@ -237,9 +204,19 @@ done: hid_t H5FD_sec2_init(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + char *lock_env_var = NULL; /* Environment variable pointer */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI_NOERR + + /* Check the use disabled file locks environment variable */ + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) + ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ + else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) + ignore_disabled_file_locks_s = FALSE; /* Override: Don't ignore disabled locks */ + else + ignore_disabled_file_locks_s = FAIL; /* Environment variable not set, or not set correctly */ if (H5I_VFL != H5I_get_type(H5FD_SEC2_g)) H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g, sizeof(H5FD_class_t), FALSE); @@ -247,7 +224,6 @@ H5FD_sec2_init(void) /* Set return value */ ret_value = H5FD_SEC2_g; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_sec2_init() */ diff --git a/src/H5FDsec2.h b/src/H5FDsec2.h index 5c35677..df4d4d4 100644 --- a/src/H5FDsec2.h +++ b/src/H5FDsec2.h @@ -20,7 +20,7 @@ #ifndef H5FDsec2_H #define H5FDsec2_H -#define H5FD_SEC2 (H5FD_sec2_init()) +#define H5FD_SEC2 (H5FDperform_init(H5FD_sec2_init)) #define H5FD_SEC2_VALUE H5_VFD_SEC2 #ifdef __cplusplus diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index 3e03c9f..8cb5509 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -186,30 +186,6 @@ H5FL_DEFINE_STATIC(H5FD_splitter_t); H5FL_DEFINE_STATIC(H5FD_splitter_fapl_t); /*------------------------------------------------------------------------- - * Function: H5FD__init_package - * - * Purpose: Initializes any interface-specific data or routines. - * - * Return: SUCCEED/FAIL - *------------------------------------------------------------------------- - */ -static herr_t -H5FD__init_package(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - H5FD_SPLITTER_LOG_CALL(__func__); - - if (H5FD_splitter_init() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize splitter VFD") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5FD_splitter_init * * Purpose: Initialize the splitter driver by registering it with the @@ -224,7 +200,7 @@ H5FD_splitter_init(void) { hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI_NOERR H5FD_SPLITTER_LOG_CALL(__func__); @@ -233,7 +209,6 @@ H5FD_splitter_init(void) ret_value = H5FD_SPLITTER_g; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_splitter_init() */ diff --git a/src/H5FDsplitter.h b/src/H5FDsplitter.h index 3a743e4..6463158 100644 --- a/src/H5FDsplitter.h +++ b/src/H5FDsplitter.h @@ -17,7 +17,7 @@ #ifndef H5FDsplitter_H #define H5FDsplitter_H -#define H5FD_SPLITTER (H5FD_splitter_init()) +#define H5FD_SPLITTER (H5FDperform_init(H5FD_splitter_init)) #define H5FD_SPLITTER_VALUE H5_VFD_SPLITTER /* The version of the H5FD_splitter_vfd_config_t structure used */ diff --git a/src/H5FDstdio.h b/src/H5FDstdio.h index 9db92ed..484c6ea 100644 --- a/src/H5FDstdio.h +++ b/src/H5FDstdio.h @@ -22,7 +22,7 @@ #include "H5Ipublic.h" -#define H5FD_STDIO (H5FD_stdio_init()) +#define H5FD_STDIO (H5FDperform_init(H5FD_stdio_init)) #ifdef __cplusplus extern "C" { diff --git a/src/H5FL.c b/src/H5FL.c index cb58868..8316fa6 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -114,9 +114,6 @@ struct H5FL_fac_node_t { struct H5FL_fac_node_t *next; /* Pointer to next block in free list */ }; -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* The head of the list of factory things to garbage collect */ static H5FL_fac_gc_list_t H5FL_fac_gc_head = {0, NULL}; @@ -184,20 +181,15 @@ H5FL_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { /* Garbage collect any nodes on the free lists */ - (void)H5FL_garbage_coll(); - - /* Shut down the various kinds of free lists */ - n += H5FL__reg_term(); - n += H5FL__fac_term_all(); - n += H5FL__arr_term(); - n += H5FL__blk_term(); - - /* Mark interface closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + (void) + H5FL_garbage_coll(); + + /* Shut down the various kinds of free lists */ + n += H5FL__reg_term(); + n += H5FL__fac_term_all(); + n += H5FL__arr_term(); + n += H5FL__blk_term(); #ifdef H5FL_TRACK /* If we haven't freed all the allocated memory, dump out the list now */ diff --git a/src/H5FS.c b/src/H5FS.c index cb18ab3..a50a0e2 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -61,9 +61,6 @@ static herr_t H5FS__sinfo_free_node_cb(void *item, void *key, void *op_data); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5FS_section_class_t sequence information */ H5FL_SEQ_DEFINE(H5FS_section_class_t); diff --git a/src/H5FSint.c b/src/H5FSint.c index 0ab975b..d7950ab 100644 --- a/src/H5FSint.c +++ b/src/H5FSint.c @@ -68,31 +68,6 @@ /*******************/ /*------------------------------------------------------------------------- - * Function: H5FS_init - * - * Purpose: Initialize the interface in case it is unable to initialize - * itself soon enough. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Saturday, March 4, 2000 - * - *------------------------------------------------------------------------- - */ -herr_t -H5FS_init(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOERR - /* FUNC_ENTER() does all the work */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS_init() */ - -/*------------------------------------------------------------------------- * Function: H5FS__create_flush_depend * * Purpose: Create a flush dependency between two data structure components diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index fdc5c91..718c4a7 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -186,9 +186,6 @@ H5FL_SEQ_EXTERN(H5FS_section_class_t); /* Library-private Function Prototypes */ /***************************************/ -/* Package initialization routine */ -H5_DLL herr_t H5FS_init(void); - /* Free space manager routines */ H5_DLL H5FS_t *H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, diff --git a/src/H5Fcwfs.c b/src/H5Fcwfs.c index d689737..43c8cf7 100644 --- a/src/H5Fcwfs.c +++ b/src/H5Fcwfs.c @@ -252,7 +252,7 @@ H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(f); @@ -272,7 +272,6 @@ H5F_cwfs_advance_heap(H5F_t *f, H5HG_heap_t *heap, hbool_t add_heap) f->shared->cwfs[f->shared->ncwfs - 1] = heap; } /* end if */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_advance_heap() */ @@ -295,7 +294,7 @@ H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(shared); @@ -310,6 +309,5 @@ H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) } /* end if */ } /* end for */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_remove_heap() */ diff --git a/src/H5Fint.c b/src/H5Fint.c index d772088..b9be873 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -91,9 +91,6 @@ static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Based on the value of the HDF5_USE_FILE_LOCKING environment variable. * TRUE/FALSE have obvious meanings. FAIL means the environment variable was * not set, so the code should ignore it and use the fapl value instead. @@ -138,29 +135,6 @@ H5F_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_init() */ - -/*-------------------------------------------------------------------------- -NAME - H5F__init_package -- Initialize interface-specific information -USAGE - herr_t H5F__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ -herr_t -H5F__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* Initialize the ID group for the file IDs */ if (H5I_register_type(H5I_FILE_CLS) < 0) @@ -172,7 +146,7 @@ H5F__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__init_package() */ +} /* end H5F_init() */ /*------------------------------------------------------------------------- * Function: H5F_term_package @@ -196,23 +170,17 @@ H5F_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - if (H5I_nmembers(H5I_FILE) > 0) { - (void)H5I_clear_type(H5I_FILE, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - else { - /* Make certain we've cleaned up all the shared file objects */ - H5F_sfile_assert_num(0); - - /* Destroy the file object id group */ - n += (H5I_dec_type_ref(H5I_FILE) > 0); + if (H5I_nmembers(H5I_FILE) > 0) { + (void)H5I_clear_type(H5I_FILE, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ + else { + /* Make certain we've cleaned up all the shared file objects */ + H5F_sfile_assert_num(0); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end if */ + /* Destroy the file object id group */ + n += (H5I_dec_type_ref(H5I_FILE) > 0); + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5F_term_package() */ diff --git a/src/H5Gint.c b/src/H5Gint.c index 90a2c6b..ba0cb6d 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -91,9 +91,6 @@ static herr_t H5G__close_cb(H5VL_object_t *grp_vol_obj, void **request); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5G_t struct */ H5FL_DEFINE(H5G_t); H5FL_DEFINE(H5G_shared_t); @@ -117,9 +114,6 @@ static const H5I_class_t H5I_GROUP_CLS[1] = {{ (H5I_free_t)H5G__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5G_top_package_initialize_s = FALSE; - /*------------------------------------------------------------------------- * Function: H5G_init * @@ -136,48 +130,13 @@ H5G_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_init() */ - -/*------------------------------------------------------------------------- - * Function: H5G__init_package - * - * Purpose: Initializes the H5G interface. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, January 5, 1998 - * - * Notes: The group creation properties are registered in the property - * list interface initialization routine (H5P_init_package) - * so that the file creation property class can inherit from it - * correctly. (Which allows the file creation property list to - * control the group creation properties of the root group of - * a file) QAK - 24/10/2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - /* Initialize the ID group for the group IDs */ if (H5I_register_type(H5I_GROUP_CLS) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface") - /* Mark "top" of interface as initialized, too */ - H5G_top_package_initialize_s = TRUE; - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__init_package() */ +} /* end H5G_init() */ /*------------------------------------------------------------------------- * Function: H5G_top_term_package @@ -200,16 +159,10 @@ H5G_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5G_top_package_initialize_s) { - if (H5I_nmembers(H5I_GROUP) > 0) { - (void)H5I_clear_type(H5I_GROUP, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if (0 == n) - H5G_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_GROUP) > 0) { + (void)H5I_clear_type(H5I_GROUP, FALSE, FALSE); + n++; + } FUNC_LEAVE_NOAPI(n) } /* end H5G_top_term_package() */ @@ -238,18 +191,11 @@ H5G_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_GROUP)); - HDassert(FALSE == H5G_top_package_initialize_s); - - /* Destroy the group object id group */ - n += (H5I_dec_type_ref(H5I_GROUP) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_GROUP)); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the group object id group */ + n += (H5I_dec_type_ref(H5I_GROUP) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5G_term_package() */ diff --git a/src/H5HF.c b/src/H5HF.c index 1f4cc26..8e69032 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -63,9 +63,6 @@ /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -117,8 +114,14 @@ H5HF__op_write(const void *obj, size_t obj_len, void *op_data) { FUNC_ENTER_PACKAGE_NOERR - /* Perform "write", using memcpy() */ - H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */ + /* Perform "write", using memcpy() + * + * We cast away const here because no obj pointer that was originally + * const should ever arrive here. + */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") + H5MM_memcpy((void *)obj, op_data, obj_len); + H5_GCC_CLANG_DIAG_ON("cast-qual") FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__op_write() */ @@ -350,10 +353,15 @@ H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id /*out*/) /* Check for 'huge' object */ if (size > hdr->max_man_size) { - /* Store 'huge' object in heap */ - /* (Casting away const OK - QAK) */ + /* Store 'huge' object in heap + * + * Although not ideal, we can quiet the const warning here becuase no + * obj pointer that was originally const should ever arrive here. + */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") if (H5HF__huge_insert(hdr, size, (void *)obj, id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'huge' object in fractal heap") + H5_GCC_CLANG_DIAG_ON("cast-qual") } /* end if */ /* Check for 'tiny' object */ else if (size <= hdr->tiny_max_len) { diff --git a/src/H5HFcache.c b/src/H5HFcache.c index fde5a4f..5b50725 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -1655,9 +1655,15 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) /* Update info about direct block */ udata->decompressed = TRUE; len = nbytes; - } /* end if */ - else - read_buf = (void *)image; /* Casting away const OK - QAK */ + } + else { + /* If the data are unfiltered, we just point to the image, which we + * never modify. Casting away const is okay here. + */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") + read_buf = (void *)image; + H5_GCC_CLANG_DIAG_OFF("cast-qual") + } /* Decode checksum */ chk_size = (size_t)(H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) - H5HF_SIZEOF_CHKSUM); diff --git a/src/H5HFman.c b/src/H5HFman.c index 427be00..a362d99 100644 --- a/src/H5HFman.c +++ b/src/H5HFman.c @@ -487,10 +487,16 @@ H5HF__man_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) HDassert(id); HDassert(obj); - /* Call the internal 'op' routine routine */ - /* (Casting away const OK - QAK) */ + /* Call the internal 'op' routine routine + * + * In this case, the callback operation needs to modify the obj buffer that + * was passed in as const. We quiet the warning here because an obj pointer + * that was originally const should *never* arrive here. + */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") if (H5HF__man_op_real(hdr, id, H5HF__op_write, (void *)obj, H5HF_OP_MODIFY) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object") + H5_GCC_CLANG_DIAG_ON("cast-qual") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HG.c b/src/H5HG.c index cae23a7..031bc32 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -84,9 +84,6 @@ static size_t H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *h /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5HG_heap_t struct */ H5FL_DEFINE(H5HG_heap_t); diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h index d8e6b46..5deae88 100644 --- a/src/H5HGprivate.h +++ b/src/H5HGprivate.h @@ -50,7 +50,7 @@ typedef struct H5HG_heap_t H5HG_heap_t; /* Size of encoded global heap ID */ /* (size of file address + 32-bit integer) */ -#define H5HG_HEAP_ID_SIZE(F) ((size_t)H5F_SIZEOF_ADDR(F) + H5_SIZEOF_UINT32_T) +#define H5HG_HEAP_ID_SIZE(F) ((size_t)H5F_SIZEOF_ADDR(F) + sizeof(uint32_t)) /* Main global heap routines */ H5_DLL herr_t H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj /*out*/); diff --git a/src/H5HL.c b/src/H5HL.c index 1f2369a..eb25875 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -64,9 +64,6 @@ static herr_t H5HL__dirty(H5HL_t *heap); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5HL_free_t struct */ H5FL_DEFINE(H5HL_free_t); diff --git a/src/H5Iint.c b/src/H5Iint.c index 86a2810..1ea2ad7 100644 --- a/src/H5Iint.c +++ b/src/H5Iint.c @@ -85,9 +85,6 @@ static int H5I__find_id_cb(void *_item, void *_key, void *_udata); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declared extern in H5Ipkg.h and documented there */ H5I_type_info_t *H5I_type_info_array_g[H5I_MAX_NUM_TYPES]; int H5I_next_type_g = (int)H5I_NTYPES; @@ -127,30 +124,24 @@ H5I_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - H5I_type_info_t *type_info = NULL; /* Pointer to ID type */ - int i; - - /* Count the number of types still in use */ - for (i = 0; i < H5I_next_type_g; i++) - if ((type_info = H5I_type_info_array_g[i]) && type_info->hash_table) + H5I_type_info_t *type_info = NULL; /* Pointer to ID type */ + int i; + + /* Count the number of types still in use */ + for (i = 0; i < H5I_next_type_g; i++) + if ((type_info = H5I_type_info_array_g[i]) && type_info->hash_table) + in_use++; + + /* If no types are still being used then clean up */ + if (0 == in_use) { + for (i = 0; i < H5I_next_type_g; i++) { + type_info = H5I_type_info_array_g[i]; + if (type_info) { + HDassert(NULL == type_info->hash_table); + type_info = H5MM_xfree(type_info); + H5I_type_info_array_g[i] = NULL; in_use++; - - /* If no types are still being used then clean up */ - if (0 == in_use) { - for (i = 0; i < H5I_next_type_g; i++) { - type_info = H5I_type_info_array_g[i]; - if (type_info) { - HDassert(NULL == type_info->hash_table); - type_info = H5MM_xfree(type_info); - H5I_type_info_array_g[i] = NULL; - in_use++; - } } - - /* Mark interface closed */ - if (0 == in_use) - H5_PKG_INIT_VAR = FALSE; } } diff --git a/src/H5Lint.c b/src/H5Lint.c index 346c37d..9e45124 100644 --- a/src/H5Lint.c +++ b/src/H5Lint.c @@ -175,9 +175,6 @@ static herr_t H5L__get_name_by_idx_cb(H5G_loc_t *grp_loc /*in*/, const char *nam /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -211,30 +208,6 @@ H5L_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_init() */ - -/*------------------------------------------------------------------------- - * Function: H5L__init_package - * - * Purpose: Initialize information specific to H5L interface. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Tuesday, January 24, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5L__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* Initialize user-defined link classes */ if (H5L_register_external() < 0) @@ -242,12 +215,12 @@ H5L__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5L_init_package() */ +} /* end H5L_init() */ /*------------------------------------------------------------------------- * Function: H5L_term_package * - * Purpose: Terminate any resources allocated in H5L__init_package. + * Purpose: Terminate any resources allocated in H5L_init. * * Return: Non-negative on success/Negative on failure * @@ -263,17 +236,11 @@ H5L_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Free the table of link types */ - if (H5L_table_g) { - H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); - H5L_table_used_g = H5L_table_alloc_g = 0; - n++; - } /* end if */ - - /* Mark the interface as uninitialized */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; + /* Free the table of link types */ + if (H5L_table_g) { + H5L_table_g = (H5L_class_t *)H5MM_xfree(H5L_table_g); + H5L_table_used_g = H5L_table_alloc_g = 0; + n++; } /* end if */ FUNC_LEAVE_NOAPI(n) diff --git a/src/H5M.c b/src/H5M.c index b890a5c..59ce615 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -58,9 +58,6 @@ static herr_t H5M__get_api_common(hid_t map_id, hid_t key_mem_type_id, const voi /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -77,9 +74,6 @@ static const H5I_class_t H5I_MAP_CLS[1] = {{ (H5I_free_t)H5M__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5M_top_package_initialize_s = FALSE; - /*------------------------------------------------------------------------- * Function: H5M_init * @@ -96,41 +90,14 @@ H5M_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5M_init() */ - -/*------------------------------------------------------------------------- -NAME - H5M__init_package -- Initialize interface-specific information -USAGE - herr_t H5M__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------- -*/ -herr_t -H5M__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* Initialize the ID group for the map IDs */ if (H5I_register_type(H5I_MAP_CLS) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, FAIL, "unable to initialize interface") - /* Mark "top" of interface as initialized, too */ - H5M_top_package_initialize_s = TRUE; - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5M__init_package() */ +} /* end H5M_init() */ /*------------------------------------------------------------------------- * Function: H5M_top_term_package @@ -149,16 +116,10 @@ H5M_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5M_top_package_initialize_s) { - if (H5I_nmembers(H5I_MAP) > 0) { - (void)H5I_clear_type(H5I_MAP, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if (0 == n) - H5M_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_MAP) > 0) { + (void)H5I_clear_type(H5I_MAP, FALSE, FALSE); + n++; + } FUNC_LEAVE_NOAPI(n) } /* end H5M_top_term_package() */ @@ -183,18 +144,11 @@ H5M_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_MAP)); - HDassert(FALSE == H5M_top_package_initialize_s); - - /* Destroy the dataset object id group */ - n += (H5I_dec_type_ref(H5I_MAP) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_MAP)); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the dataset object id group */ + n += (H5I_dec_type_ref(H5I_MAP) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5M_term_package() */ @@ -533,7 +487,7 @@ H5M__open_api_common(hid_t loc_id, const char *name, hid_t mapl_id, void **token /* Open the map */ if (H5VL_optional(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open map") - map = map_args.create.map; + map = map_args.open.map; /* Register an ID for the map */ if ((ret_value = H5VL_register(H5I_MAP, map, (*vol_obj_ptr)->connector, TRUE)) < 0) @@ -1360,6 +1314,7 @@ H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, map_args.specific.args.iterate.loc_params.type = H5VL_OBJECT_BY_SELF; map_args.specific.args.iterate.loc_params.obj_type = H5I_get_type(map_id); map_args.specific.args.iterate.idx = (idx ? *idx : 0); + map_args.specific.args.iterate.key_mem_type_id = key_mem_type_id; map_args.specific.args.iterate.op = op; map_args.specific.args.iterate.op_data = op_data; vol_cb_args.op_type = H5VL_MAP_SPECIFIC; @@ -1450,6 +1405,7 @@ H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, hid_t key_m map_args.specific.args.iterate.loc_params.loc_data.loc_by_name.name = map_name; map_args.specific.args.iterate.loc_params.loc_data.loc_by_name.lapl_id = lapl_id; map_args.specific.args.iterate.idx = (idx ? *idx : 0); + map_args.specific.args.iterate.key_mem_type_id = key_mem_type_id; map_args.specific.args.iterate.op = op; map_args.specific.args.iterate.op_data = op_data; vol_cb_args.op_type = H5VL_MAP_SPECIFIC; diff --git a/src/H5MF.c b/src/H5MF.c index 66bf823..4bd32a8 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -115,9 +115,6 @@ static herr_t H5MF__sects_cb(H5FS_section_info_t *_sect, void *_udata); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ diff --git a/src/H5MP.c b/src/H5MP.c index 474a995..397d26b 100644 --- a/src/H5MP.c +++ b/src/H5MP.c @@ -58,9 +58,6 @@ /* Package Variable Definitions */ /********************************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /********************/ /* Static Variables */ /********************/ diff --git a/src/H5Oint.c b/src/H5Oint.c index f24d0bb..ee79b0c 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -82,9 +82,6 @@ static herr_t H5O__reset_info2(H5O_info2_t *oinfo); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Header message ID to class mapping * * Remember to increment H5O_MSG_TYPES in H5Opkg.h when adding a new @@ -178,21 +175,20 @@ static const H5O_obj_class_t *const H5O_obj_class_g[] = { }; /*------------------------------------------------------------------------- - * Function: H5O__init_package - * - * Purpose: Initialize information specific to H5O interface. - * - * Return: Non-negative on success/Negative on failure + * Function: H5O_init * - * Programmer: Quincey Koziol - * Thursday, January 18, 2007 + * Purpose: Initialize the interface from some other layer. * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5O__init_package(void) +H5O_init(void) { - FUNC_ENTER_PACKAGE_NOERR + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOERR /* H5O interface sanity checks */ HDcompile_assert(H5O_MSG_TYPES == NELMTS(H5O_msg_class_g)); @@ -200,8 +196,8 @@ H5O__init_package(void) HDcompile_assert(H5O_UNKNOWN_ID < H5O_MSG_TYPES); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O__init_package() */ + FUNC_LEAVE_NOAPI(ret_value) +} /*------------------------------------------------------------------------- * Function: H5O__set_version @@ -567,7 +563,7 @@ H5O_open(H5O_loc_t *loc) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(loc); @@ -584,7 +580,6 @@ H5O_open(H5O_loc_t *loc) else H5F_INCR_NOPEN_OBJS(loc->file); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open() */ diff --git a/src/H5P.c b/src/H5P.c index a2d9cfc..5717b8c 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -54,9 +54,6 @@ typedef struct { /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ diff --git a/src/H5PB.c b/src/H5PB.c index 4f65da3..4fc9a52 100644 --- a/src/H5PB.c +++ b/src/H5PB.c @@ -131,9 +131,6 @@ static herr_t H5PB__write_entry(H5F_shared_t *f_sh, H5PB_entry_t *page_entry); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ diff --git a/src/H5PLint.c b/src/H5PLint.c index 848bd1d..fe9d3c1 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -46,9 +46,6 @@ /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -123,22 +120,21 @@ H5PL__set_plugin_control_mask(unsigned int mask) } /* end H5PL__set_plugin_control_mask() */ /*------------------------------------------------------------------------- - * Function: H5PL__init_package - * - * Purpose: Initialize any package-specific data and call any init - * routines for the package. + * Function: H5PL_init * - * Return: SUCCEED/FAIL + * Purpose: Initialize the interface from some other layer. * + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5PL__init_package(void) +H5PL_init(void) { char * env_var = NULL; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Check the environment variable to determine if the user wants * to ignore plugins. The special symbol H5PL_NO_PLUGIN (defined in @@ -160,7 +156,7 @@ H5PL__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5PL__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5PL_term_package @@ -183,24 +179,17 @@ H5PL_term_package(void) FUNC_ENTER_NOAPI_NOINIT - if (H5_PKG_INIT_VAR) { - - /* Close the plugin cache. - * We need to bump the return value if we did any real work here. - */ - if (H5PL__close_plugin_cache(&already_closed) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTFREE, (-1), "problem closing plugin cache") - if (!already_closed) - ret_value++; - - /* Close the search path table and free the paths */ - if (H5PL__close_path_table() < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTFREE, (-1), "problem closing search path table") + /* Close the plugin cache. + * We need to bump the return value if we did any real work here. + */ + if (H5PL__close_plugin_cache(&already_closed) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTFREE, (-1), "problem closing plugin cache") + if (!already_closed) + ret_value++; - /* Mark the interface as uninitialized */ - if (0 == ret_value) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Close the search path table and free the paths */ + if (H5PL__close_path_table() < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTFREE, (-1), "problem closing search path table") done: FUNC_LEAVE_NOAPI(ret_value) @@ -510,10 +499,9 @@ H5PL_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, void *op_dat { herr_t ret_value = H5_ITER_CONT; - FUNC_ENTER_NOAPI(H5_ITER_ERROR) + FUNC_ENTER_NOAPI_NOERR ret_value = H5PL__path_table_iterate(iter_type, iter_op, op_data); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL_iterate() */ diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index 7ff5c1a..83cc8a5 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -82,5 +82,6 @@ typedef herr_t (*H5PL_iterate_t)(H5PL_type_t plugin_type, const void *plugin_inf /* Internal API routines */ H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, const H5PL_key_t *key); H5_DLL herr_t H5PL_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, void *op_data); +H5_DLL herr_t H5PL_init(void); #endif /* H5PLprivate_H */ diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index 46dc94c..42dd6e4 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -2213,10 +2213,18 @@ H5P__dxfr_dset_io_hyp_sel_cmp(const void *_space1, const void *_space2, size_t H if (TRUE != H5S_extent_equal(*space1, *space2)) HGOTO_DONE(-1); - /* Compare the selection "shape" of the dataspaces */ - /* (Error & not-equal count the same) */ - if (TRUE != H5S_select_shape_same(*space1, *space2)) + /* Compare the selection "shape" of the dataspaces + * (Error & not-equal count the same) + * + * Since H5S_select_shape_same() can result in the dataspaces being + * rebuilt, the parameters are not const which makes it impossible + * to match the cmp prototype. Since we need to compare them, + * we quiet the const warning. + */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") + if (TRUE != H5S_select_shape_same((H5S_t *)*space1, (H5S_t *)*space2)) HGOTO_DONE(-1); + H5_GCC_CLANG_DIAG_ON("cast-qual") } /* end if */ done: diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index f37cb74..98f9ed9 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -93,7 +93,7 @@ #define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_size_t /* Definition for preemption read chunks first */ #define H5F_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) -#define H5F_ACS_PREEMPT_READ_CHUNKS_DEF 0.75f +#define H5F_ACS_PREEMPT_READ_CHUNKS_DEF 0.75 #define H5F_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double #define H5F_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double /* Definition for threshold for alignment */ @@ -5315,8 +5315,7 @@ H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) /* (Dataset, group, attribute, and named datype access property lists * are sub-classes of link access property lists -QAK) */ - if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) + if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* set property to either TRUE if > 0, or FALSE otherwise */ @@ -5367,8 +5366,7 @@ H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective /*out*/) /* (Dataset, group, attribute, and named datype access property lists * are sub-classes of link access property lists -QAK) */ - if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && - TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) + if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist") /* Get value */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 9206d4c..614f4d3 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -123,76 +123,77 @@ static herr_t H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H /* * Predefined property list classes. These are initialized at runtime by - * H5P__init_package() in this source file. + * H5P_init() in this source file. */ -hid_t H5P_CLS_ROOT_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ROOT_g = NULL; -hid_t H5P_CLS_OBJECT_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g = NULL; -hid_t H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_FILE_CREATE_g = NULL; -hid_t H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_FILE_ACCESS_g = NULL; -hid_t H5P_CLS_DATASET_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATASET_CREATE_g = NULL; +hid_t H5P_CLS_ROOT_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ROOT_g = NULL; + +hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g = NULL; +hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; hid_t H5P_CLS_DATASET_ACCESS_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_DATASET_ACCESS_g = NULL; +hid_t H5P_CLS_DATASET_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATASET_CREATE_g = NULL; hid_t H5P_CLS_DATASET_XFER_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_DATASET_XFER_g = NULL; +hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; +hid_t H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL; +hid_t H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_FILE_ACCESS_g = NULL; +hid_t H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_FILE_CREATE_g = NULL; hid_t H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_FILE_MOUNT_g = NULL; -hid_t H5P_CLS_GROUP_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_GROUP_CREATE_g = NULL; hid_t H5P_CLS_GROUP_ACCESS_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g = NULL; -hid_t H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g = NULL; -hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; -hid_t H5P_CLS_MAP_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_MAP_CREATE_g = NULL; +hid_t H5P_CLS_GROUP_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_GROUP_CREATE_g = NULL; +hid_t H5P_CLS_LINK_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL; +hid_t H5P_CLS_LINK_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_LINK_CREATE_g = NULL; hid_t H5P_CLS_MAP_ACCESS_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_MAP_ACCESS_g = NULL; -hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; -hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g = NULL; +hid_t H5P_CLS_MAP_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_MAP_CREATE_g = NULL; hid_t H5P_CLS_OBJECT_COPY_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_OBJECT_COPY_g = NULL; -hid_t H5P_CLS_LINK_CREATE_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_LINK_CREATE_g = NULL; -hid_t H5P_CLS_LINK_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_LINK_ACCESS_g = NULL; +hid_t H5P_CLS_OBJECT_CREATE_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_OBJECT_CREATE_g = NULL; +hid_t H5P_CLS_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; +H5P_genclass_t *H5P_CLS_REFERENCE_ACCESS_g = NULL; hid_t H5P_CLS_STRING_CREATE_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_STRING_CREATE_g = NULL; hid_t H5P_CLS_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; H5P_genclass_t *H5P_CLS_VOL_INITIALIZE_g = NULL; -hid_t H5P_CLS_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; -H5P_genclass_t *H5P_CLS_REFERENCE_ACCESS_g = NULL; /* * Predefined property lists for each predefined class. These are initialized - * at runtime by H5P__init_package() in this source file. + * at runtime by H5P_init() in this source file. */ -hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_DATASET_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_GROUP_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_MAP_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_MAP_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_MAP_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; +hid_t H5P_LST_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; /* Root property list class library initialization object */ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ @@ -429,63 +430,12 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ herr_t H5P_init_phase1(void) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_init_phase1() */ - -/*------------------------------------------------------------------------- - * Function: H5P_init_phase2 - * - * Purpose: Finish initializing the interface from some other package. - * - * Note: This is broken out as a separate routine so that the - * library's default VFL driver can be chosen and initialized - * after the entire H5P interface has been initialized. - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5P_init_phase2(void) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Set up the default VFL driver */ - if (H5P__facc_set_def_driver() < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "unable to set default VFL driver") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_init_phase2() */ - -/*-------------------------------------------------------------------------- -NAME - H5P__init_package -- Initialize interface-specific information -USAGE - herr_t H5P__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------*/ -herr_t -H5P__init_package(void) -{ size_t tot_init = 0; /* Total # of classes initialized */ size_t pass_init; /* # of classes initialized in each pass */ size_t u; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDcompile_assert(H5P_TYPE_REFERENCE_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); @@ -576,7 +526,36 @@ done: } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__init_package() */ +} + +/*------------------------------------------------------------------------- + * Function: H5P_init_phase2 + * + * Purpose: Finish initializing the interface from some other package. + * + * Note: This is broken out as a separate routine so that the + * library's default VFL driver can be chosen and initialized + * after the entire H5P interface has been initialized. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_init_phase2(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Set up the default VFL driver */ + if (H5P__facc_set_def_driver() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "unable to set default VFL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_init_phase2() */ /*-------------------------------------------------------------------------- NAME @@ -602,77 +581,107 @@ H5P_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - int64_t nlist, nclass; - - /* Destroy HDF5 library property classes & lists */ - - /* Check if there are any open property list classes or lists */ - nclass = H5I_nmembers(H5I_GENPROP_CLS); - nlist = H5I_nmembers(H5I_GENPROP_LST); - - /* If there are any open classes or groups, attempt to get rid of them. */ - if ((nclass + nlist) > 0) { - /* Clear the lists */ - if (nlist > 0) { - (void)H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE); - - /* Reset the default property lists, if they've been closed */ - if (H5I_nmembers(H5I_GENPROP_LST) == 0) { - H5P_LST_FILE_CREATE_ID_g = H5P_LST_FILE_ACCESS_ID_g = H5P_LST_DATASET_CREATE_ID_g = - H5P_LST_DATASET_ACCESS_ID_g = H5P_LST_DATASET_XFER_ID_g = H5P_LST_GROUP_CREATE_ID_g = - H5P_LST_GROUP_ACCESS_ID_g = H5P_LST_DATATYPE_CREATE_ID_g = - H5P_LST_DATATYPE_ACCESS_ID_g = H5P_LST_MAP_CREATE_ID_g = - H5P_LST_MAP_ACCESS_ID_g = H5P_LST_ATTRIBUTE_CREATE_ID_g = - H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5P_LST_OBJECT_COPY_ID_g = - H5P_LST_LINK_CREATE_ID_g = H5P_LST_LINK_ACCESS_ID_g = - H5P_LST_VOL_INITIALIZE_ID_g = H5P_LST_REFERENCE_ACCESS_ID_g = - H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; - } /* end if */ - } /* end if */ - - /* Only attempt to close the classes after all the lists are closed */ - if (nlist == 0 && nclass > 0) { - (void)H5I_clear_type(H5I_GENPROP_CLS, FALSE, FALSE); - - /* Reset the default property classes, if they've been closed */ - if (H5I_nmembers(H5I_GENPROP_CLS) == 0) { - H5P_CLS_ROOT_g = H5P_CLS_OBJECT_CREATE_g = H5P_CLS_FILE_CREATE_g = H5P_CLS_FILE_ACCESS_g = - H5P_CLS_DATASET_CREATE_g = H5P_CLS_DATASET_ACCESS_g = H5P_CLS_DATASET_XFER_g = - H5P_CLS_GROUP_CREATE_g = H5P_CLS_GROUP_ACCESS_g = H5P_CLS_DATATYPE_CREATE_g = - H5P_CLS_DATATYPE_ACCESS_g = H5P_CLS_MAP_CREATE_g = H5P_CLS_MAP_ACCESS_g = - H5P_CLS_STRING_CREATE_g = H5P_CLS_ATTRIBUTE_CREATE_g = - H5P_CLS_ATTRIBUTE_ACCESS_g = H5P_CLS_OBJECT_COPY_g = - H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = - H5P_CLS_VOL_INITIALIZE_g = H5P_CLS_REFERENCE_ACCESS_g = - H5P_CLS_FILE_MOUNT_g = NULL; - - H5P_CLS_ROOT_ID_g = H5P_CLS_OBJECT_CREATE_ID_g = H5P_CLS_FILE_CREATE_ID_g = - H5P_CLS_FILE_ACCESS_ID_g = H5P_CLS_DATASET_CREATE_ID_g = H5P_CLS_DATASET_ACCESS_ID_g = - H5P_CLS_DATASET_XFER_ID_g = H5P_CLS_GROUP_CREATE_ID_g = - H5P_CLS_GROUP_ACCESS_ID_g = H5P_CLS_DATATYPE_CREATE_ID_g = - H5P_CLS_DATATYPE_ACCESS_ID_g = H5P_CLS_MAP_CREATE_ID_g = - H5P_CLS_MAP_ACCESS_ID_g = H5P_CLS_STRING_CREATE_ID_g = - H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5P_CLS_ATTRIBUTE_ACCESS_ID_g = - H5P_CLS_OBJECT_COPY_ID_g = H5P_CLS_LINK_CREATE_ID_g = - H5P_CLS_LINK_ACCESS_ID_g = H5P_CLS_VOL_INITIALIZE_ID_g = - H5P_CLS_REFERENCE_ACCESS_ID_g = - H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; - } /* end if */ - } /* end if */ + int64_t nlist, nclass; + + /* Destroy HDF5 library property classes & lists */ + + /* Check if there are any open property list classes or lists */ + nclass = H5I_nmembers(H5I_GENPROP_CLS); + nlist = H5I_nmembers(H5I_GENPROP_LST); + + /* If there are any open classes or groups, attempt to get rid of them. */ + if ((nclass + nlist) > 0) { + /* Clear the lists */ + if (nlist > 0) { + (void)H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE); + + /* Reset the default property lists, if they've been closed */ + if (H5I_nmembers(H5I_GENPROP_LST) == 0) { + H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; + H5P_LST_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; + H5P_LST_DATASET_ACCESS_ID_g = H5I_INVALID_HID; + H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID; + H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID; + H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; + H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; + H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; + H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; + H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; + H5P_LST_GROUP_ACCESS_ID_g = H5I_INVALID_HID; + H5P_LST_GROUP_CREATE_ID_g = H5I_INVALID_HID; + H5P_LST_LINK_ACCESS_ID_g = H5I_INVALID_HID; + H5P_LST_LINK_CREATE_ID_g = H5I_INVALID_HID; + H5P_LST_MAP_ACCESS_ID_g = H5I_INVALID_HID; + H5P_LST_MAP_CREATE_ID_g = H5I_INVALID_HID; + H5P_LST_OBJECT_COPY_ID_g = H5I_INVALID_HID; + H5P_LST_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; + H5P_LST_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; + } + } - n++; /*H5I*/ + /* Only attempt to close the classes after all the lists are closed */ + if (nlist == 0 && nclass > 0) { + (void)H5I_clear_type(H5I_GENPROP_CLS, FALSE, FALSE); + + /* Reset the default property classes and IDs if they've been closed */ + if (H5I_nmembers(H5I_GENPROP_CLS) == 0) { + H5P_CLS_ROOT_g = NULL; + + H5P_CLS_ATTRIBUTE_ACCESS_g = NULL; + H5P_CLS_ATTRIBUTE_CREATE_g = NULL; + H5P_CLS_DATASET_ACCESS_g = NULL; + H5P_CLS_DATASET_CREATE_g = NULL; + H5P_CLS_DATASET_XFER_g = NULL; + H5P_CLS_DATATYPE_ACCESS_g = NULL; + H5P_CLS_DATATYPE_CREATE_g = NULL; + H5P_CLS_FILE_ACCESS_g = NULL; + H5P_CLS_FILE_CREATE_g = NULL; + H5P_CLS_FILE_MOUNT_g = NULL; + H5P_CLS_GROUP_ACCESS_g = NULL; + H5P_CLS_GROUP_CREATE_g = NULL; + H5P_CLS_LINK_ACCESS_g = NULL; + H5P_CLS_LINK_CREATE_g = NULL; + H5P_CLS_MAP_ACCESS_g = NULL; + H5P_CLS_MAP_CREATE_g = NULL; + H5P_CLS_OBJECT_COPY_g = NULL; + H5P_CLS_OBJECT_CREATE_g = NULL; + H5P_CLS_REFERENCE_ACCESS_g = NULL; + H5P_CLS_STRING_CREATE_g = NULL; + H5P_CLS_VOL_INITIALIZE_g = NULL; + + H5P_CLS_ROOT_ID_g = H5I_INVALID_HID; + + H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5I_INVALID_HID; + H5P_CLS_ATTRIBUTE_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_DATASET_ACCESS_ID_g = H5I_INVALID_HID; + H5P_CLS_DATASET_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_DATASET_XFER_ID_g = H5I_INVALID_HID; + H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; + H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID; + H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; + H5P_CLS_GROUP_ACCESS_ID_g = H5I_INVALID_HID; + H5P_CLS_GROUP_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_LINK_ACCESS_ID_g = H5I_INVALID_HID; + H5P_CLS_LINK_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_MAP_ACCESS_ID_g = H5I_INVALID_HID; + H5P_CLS_MAP_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_OBJECT_COPY_ID_g = H5I_INVALID_HID; + H5P_CLS_OBJECT_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_REFERENCE_ACCESS_ID_g = H5I_INVALID_HID; + H5P_CLS_STRING_CREATE_ID_g = H5I_INVALID_HID; + H5P_CLS_VOL_INITIALIZE_ID_g = H5I_INVALID_HID; + } } - else { - /* Destroy the property list and class id groups */ - n += (H5I_dec_type_ref(H5I_GENPROP_LST) > 0); - n += (H5I_dec_type_ref(H5I_GENPROP_CLS) > 0); - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end if */ + n++; /*H5I*/ + } + else { + /* Destroy the property list and class id groups */ + n += (H5I_dec_type_ref(H5I_GENPROP_LST) > 0); + n += (H5I_dec_type_ref(H5I_GENPROP_CLS) > 0); + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5P_term_package() */ @@ -3553,7 +3562,7 @@ H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recu { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(pclass); HDassert(nprops); @@ -3568,7 +3577,6 @@ H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recu *nprops += pclass->nprops; } /* end while */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P_get_nprops_pclass() */ @@ -3999,7 +4007,7 @@ H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2) { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(pclass1); HDassert(pclass2); @@ -5301,14 +5309,13 @@ H5P_get_class_name(H5P_genclass_t *pclass) { char *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI_NOERR HDassert(pclass); /* Get class name */ ret_value = H5MM_xstrdup(pclass->name); -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P_get_class_name() */ diff --git a/src/H5RS.c b/src/H5RS.c index d9915f2..117c8ea 100644 --- a/src/H5RS.c +++ b/src/H5RS.c @@ -69,9 +69,6 @@ static herr_t H5RS__resize_for_append(H5RS_str_t *rs, size_t len); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -316,8 +313,16 @@ H5RS_wrap(const char *s) if (NULL == (ret_value = H5FL_MALLOC(H5RS_str_t))) HGOTO_ERROR(H5E_RS, H5E_CANTALLOC, NULL, "memory allocation failed") - /* Set the internal fields */ - ret_value->s = (char *)s; + /* Set the internal fields + * + * We ignore warnings about storing a const char pointer in the struct + * since we never modify or free the string when the wrapped struct + * field is set to TRUE. + */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") + ret_value->s = (char *)s; + H5_GCC_CLANG_DIAG_ON("cast-qual") + ret_value->len = HDstrlen(s); ret_value->end = ret_value->s + ret_value->len; diff --git a/src/H5Rint.c b/src/H5Rint.c index e1a5dcd..65bd485 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -141,9 +141,6 @@ static herr_t H5R__decode_string(const unsigned char *buf, size_t *nbytes, char /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -152,106 +149,27 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5R_top_package_initialize_s = FALSE; - -/*-------------------------------------------------------------------------- -NAME - H5R__init_package -- Initialize interface-specific information -USAGE - herr_t H5R__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5R_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ herr_t -H5R__init_package(void) +H5R_init(void) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + herr_t ret_value = SUCCEED; - /* Mark "top" of interface as initialized */ - H5R_top_package_initialize_s = TRUE; + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check, if assert fails, H5R_REF_BUF_SIZE must be increased */ HDcompile_assert(sizeof(H5R_ref_priv_t) <= H5R_REF_BUF_SIZE); - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5R__init_package() */ - -/*-------------------------------------------------------------------------- - NAME - H5R_top_term_package - PURPOSE - Terminate various H5R objects - USAGE - void H5R_top_term_package() - RETURNS - void - DESCRIPTION - Release IDs for the ID group, deferring full interface shutdown - until later (in H5R_term_package). - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -int -H5R_top_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Mark closed if initialized */ - if (H5R_top_package_initialize_s) - if (0 == n) - H5R_top_package_initialize_s = FALSE; - - FUNC_LEAVE_NOAPI(n) -} /* end H5R_top_term_package() */ - -/*-------------------------------------------------------------------------- - NAME - H5R_term_package - PURPOSE - Terminate various H5R objects - USAGE - void H5R_term_package() - RETURNS - void - DESCRIPTION - Release the ID group and any other resources allocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - - Finishes shutting down the interface, after H5R_top_term_package() - is called - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -int -H5R_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(FALSE == H5R_top_package_initialize_s); - - /* Mark closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } - - FUNC_LEAVE_NOAPI(n) -} /* end H5R_term_package() */ + FUNC_LEAVE_NOAPI(ret_value) +} /*------------------------------------------------------------------------- * Function: H5R__create_object @@ -1150,7 +1068,7 @@ H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned /* Encode token */ H5MM_memcpy(p, obj_token, token_size); } - *nalloc = token_size + H5_SIZEOF_UINT8_T; + *nalloc = token_size + sizeof(uint8_t); FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__encode_obj_token() */ @@ -1178,7 +1096,7 @@ H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj HDassert(token_size); /* Don't decode if buffer size isn't big enough */ - if (*nbytes < H5_SIZEOF_UINT8_T) + if (*nbytes < sizeof(uint8_t)) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Get token size */ @@ -1192,7 +1110,7 @@ H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj /* Decode token */ H5MM_memcpy(obj_token, p, *token_size); - *nbytes = (size_t)(*token_size + H5_SIZEOF_UINT8_T); + *nbytes = (size_t)(*token_size + sizeof(uint8_t)); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1225,7 +1143,7 @@ H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc) "Cannot determine amount of space needed for serializing selection") /* Don't encode if buffer size isn't big enough or buffer is empty */ - if (buf && *nalloc >= ((size_t)buf_size + 2 * H5_SIZEOF_UINT32_T)) { + if (buf && *nalloc >= ((size_t)buf_size + 2 * sizeof(uint32_t))) { int rank; p = (uint8_t *)buf; @@ -1241,7 +1159,7 @@ H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc) if (H5S_SELECT_SERIALIZE(space, (unsigned char **)&p) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "can't serialize selection") } /* end if */ - *nalloc = (size_t)buf_size + 2 * H5_SIZEOF_UINT32_T; + *nalloc = (size_t)buf_size + 2 * sizeof(uint32_t); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1272,16 +1190,16 @@ H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr) HDassert(space_ptr); /* Don't decode if buffer size isn't big enough */ - if (*nbytes < (2 * H5_SIZEOF_UINT32_T)) + if (*nbytes < (2 * sizeof(uint32_t))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Decode the selection size */ UINT32DECODE(p, buf_size); - buf_size += H5_SIZEOF_UINT32_T; + buf_size += sizeof(uint32_t); /* Decode the extent rank */ UINT32DECODE(p, rank); - buf_size += H5_SIZEOF_UINT32_T; + buf_size += sizeof(uint32_t); /* Don't decode if buffer size isn't big enough */ if (*nbytes < buf_size) diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index ee5fb71..09144f9 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -43,7 +43,7 @@ #define H5R_REF_ATTRNAME(x) ((x)->info.attr.name) /* Header size */ -#define H5R_ENCODE_HEADER_SIZE (2 * H5_SIZEOF_UINT8_T) +#define H5R_ENCODE_HEADER_SIZE (2 * sizeof(uint8_t)) /****************************/ /* Package Private Typedefs */ diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h index 6d6fcd5..59d2ed2 100644 --- a/src/H5Rprivate.h +++ b/src/H5Rprivate.h @@ -39,4 +39,6 @@ /* Library Private Prototypes */ /******************************/ +H5_DLL herr_t H5R_init(void); + #endif /* H5Rprivate_H */ diff --git a/src/H5S.c b/src/H5S.c index c0c940a..a89c9d8 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -55,9 +55,6 @@ static htri_t H5S__is_simple(const H5S_t *sdim); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Format version bounds for dataspace */ const unsigned H5O_sdspace_ver_bounds[] = { H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */ @@ -96,9 +93,6 @@ static const H5I_class_t H5I_SPACE_SEL_ITER_CLS[1] = {{ (H5I_free_t)H5S__sel_iter_close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5S_top_package_initialize_s = FALSE; - /*------------------------------------------------------------------------- * Function: H5S_init * @@ -114,28 +108,6 @@ H5S_init(void) herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_init() */ - -/*-------------------------------------------------------------------------- -NAME - H5S__init_package -- Initialize interface-specific information -USAGE - herr_t H5S__init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. ---------------------------------------------------------------------------*/ -herr_t -H5S__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE /* Initialize the ID group for the dataspace IDs */ if (H5I_register_type(H5I_DATASPACE_CLS) < 0) @@ -146,12 +118,9 @@ H5S__init_package(void) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace selection iterator ID class") - /* Mark "top" of interface as initialized, too */ - H5S_top_package_initialize_s = TRUE; - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S__init_package() */ +} /* end H5S_init() */ /*-------------------------------------------------------------------------- NAME @@ -178,21 +147,14 @@ H5S_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5S_top_package_initialize_s) { - if (H5I_nmembers(H5I_DATASPACE) > 0) { - (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - if (H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { - (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark "top" of interface as closed */ - if (0 == n) - H5S_top_package_initialize_s = FALSE; - } /* end if */ + if (H5I_nmembers(H5I_DATASPACE) > 0) { + (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); + n++; + } + if (H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { + (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE); + n++; + } FUNC_LEAVE_NOAPI(n) } /* end H5S_top_term_package() */ @@ -224,22 +186,15 @@ H5S_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_DATASPACE)); - HDassert(0 == H5I_nmembers(H5I_SPACE_SEL_ITER)); - HDassert(FALSE == H5S_top_package_initialize_s); - - /* Destroy the dataspace object id group */ - n += (H5I_dec_type_ref(H5I_DATASPACE) > 0); + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_DATASPACE)); + HDassert(0 == H5I_nmembers(H5I_SPACE_SEL_ITER)); - /* Destroy the dataspace selection iterator object id group */ - n += (H5I_dec_type_ref(H5I_SPACE_SEL_ITER) > 0); + /* Destroy the dataspace object id group */ + n += (H5I_dec_type_ref(H5I_DATASPACE) > 0); - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the dataspace selection iterator object id group */ + n += (H5I_dec_type_ref(H5I_SPACE_SEL_ITER) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5S_term_package() */ @@ -812,7 +767,7 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) { hssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI(-1) + FUNC_ENTER_NOAPI_NOERR /* check args */ HDassert(ds); @@ -820,7 +775,6 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) /* Get the number of elements in extent */ ret_value = (hssize_t)ds->extent.nelem; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_npoints() */ @@ -1793,13 +1747,12 @@ H5S_get_simple_extent_type(const H5S_t *space) { H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ - FUNC_ENTER_NOAPI(H5S_NO_CLASS) + FUNC_ENTER_NOAPI_NOERR HDassert(space); ret_value = H5S_GET_EXTENT_TYPE(space); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_type() */ diff --git a/src/H5SL.c b/src/H5SL.c index ba9721c..5752fdc 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -36,13 +36,6 @@ * 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 - * -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/ * search by position) in section 3.4 of "A Skip List Cookbook", @@ -71,25 +64,14 @@ /* Define the code template for searches for the "OP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_SEARCH_FOUND(SLIST, X, I) \ { \ - HDassert(!X->removed); \ - HGOTO_DONE(X->item); \ - } /* end block */ - -/* Define the code template for deferred removals for the "OP" in the - * H5SL_LOCATE macro */ -#define H5SL_LOCATE_SEARCH_DEFER_REMOVE_FOUND(SLIST, X, I) \ - { \ - HDassert(!X->removed); \ - X->removed = TRUE; \ HGOTO_DONE(X->item); \ - } /* end block */ + } /* Define the code template for finds for the "OP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_FIND_FOUND(SLIST, X, I) \ { \ - HDassert(!X->removed); \ HGOTO_DONE(X); \ - } /* end block */ + } /* Define a code template for comparing scalar keys for the "CMP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_SCALAR_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) (*(TYPE *)((PNODE)->key) < *(TYPE *)PKEY) @@ -155,51 +137,19 @@ H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, 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)(SLIST, TYPE, X, KEY, HASHVAL)) { \ /* What to do when a node is found */ \ H5_GLUE3(H5SL_LOCATE_, OP, _FOUND)(SLIST, X, _i) \ - } /* end if */ \ - } - -/* Macro used to find node for operation, if there may be "removed" nodes in the - * list (whose keys cannot be read) */ -#define H5SL_LOCATE_SAFE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - { \ - int _i; /* Local index variable */ \ - H5SL_node_t *_low = X; \ - H5SL_node_t *_high = NULL; \ - \ - H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ - (KEY, HASHVAL) for (_i = (int)SLIST->curr_level; _i >= 0; _i--) \ - { \ - X = _low->forward[_i]; \ - while (X != _high) { \ - if (!X->removed) { \ - if (H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X, KEY, HASHVAL)) \ - _low = X; \ - else \ - break; \ - } /* end if */ \ - X = X->forward[_i]; \ - } /* end while */ \ - _high = X; \ - if (X != NULL && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, X, KEY, HASHVAL)) { \ - /* What to do when a node is found */ \ - H5_GLUE3(H5SL_LOCATE_, OP, _FOUND)(SLIST, X, _i) break; \ - } /* end if */ \ - } /* end for */ \ + } \ } /* Macro used to find node for operation */ #define H5SL_LOCATE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ { \ - if ((SLIST)->safe_iterating) \ - H5SL_LOCATE_SAFE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - else \ - H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ } /* Macro used to grow a node by 1. Does not update pointers. LVL is the current @@ -225,13 +175,13 @@ if (NULL == (H5SL_fac_g = (H5FL_fac_head_t **)H5MM_realloc( \ (void *)H5SL_fac_g, H5SL_fac_nalloc_g * sizeof(H5FL_fac_head_t *)))) \ HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \ - } /* 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]))) \ @@ -239,7 +189,7 @@ H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL + 1) * sizeof(H5SL_node_t *)); \ X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc - 1], (void *)X->forward); \ X->forward = _tmp; \ - } /* end if */ \ + } \ \ X->level++; \ } @@ -260,7 +210,7 @@ H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL) * sizeof(H5SL_node_t *)); \ X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc + 1], (void *)X->forward); \ X->forward = _tmp; \ - } /* end if */ \ + } \ \ X->level--; \ } @@ -284,7 +234,7 @@ else { \ HDassert(_lvl < (size_t)SLIST->curr_level); \ X->forward[_lvl + 1] = PREV->forward[_lvl + 1]; \ - } /* end else */ \ + } \ PREV->forward[_lvl + 1] = X; \ } @@ -322,7 +272,7 @@ 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)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) \ @@ -337,7 +287,7 @@ break; \ } \ X = X->forward[_i]; \ - } /* end for */ \ + } \ HDassert(!_drop->forward[_i] || \ !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ \ @@ -350,7 +300,7 @@ /* Prepare to drop down */ \ X = _last = _drop; \ _next = _drop->forward[_i]; \ - } /* end for */ \ + } \ \ if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) \ HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, NULL, "can't insert duplicate key") \ @@ -359,172 +309,167 @@ /* Macro used to remove node */ #define H5SL_REMOVE(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ { \ - /* Check for deferred removal */ \ - if (SLIST->safe_iterating) \ - H5SL_LOCATE(SEARCH_DEFER_REMOVE, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - else { \ - 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; \ + 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); \ + if (_i < 0) \ + HGOTO_DONE(NULL); \ \ - H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ - (KEY, HASHVAL) \ + 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)(SLIST, TYPE, X, KEY, HASHVAL))) \ - { \ - _llast = _last; \ - _last = X; \ - X = X->forward[_i]; \ - } \ - _next = X; \ + /* Find the gap to drop in to at the highest level */ \ + while (X && (!X->key || H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, 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 */ \ + /* 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; \ + } \ \ - /* 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; \ + /* 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)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) { \ + _drop = X; \ + /* Again check if we can stop searching */ \ + if (_count) { \ + _count = 2; \ + break; \ + } \ } \ - else { /* !_drop */ \ - /* Check if this node is the start of the next gap */ \ - if (!H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, 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 */ \ + else \ + _ldrop = 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]; \ - break; \ - } /* end if */ \ - X = X->forward[_i]; \ - } /* end for */ \ - HDassert(_count >= 1 && _count <= 3); \ - HDassert(!_drop->forward[_i] || \ - !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ + /* 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; \ + } \ + X = X->forward[_i]; \ + } \ + HDassert(_count >= 1 && _count <= 3); \ + HDassert(!_drop->forward[_i] || \ + !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, 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 */ \ - /* onenode to see if we should promote the first node */ \ - /* in the next gap */ \ - _llast = _next->forward[_i + 1]; \ + /* 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 */ \ + /* onenode 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) \ + /* 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, NULL) \ - } \ - else if (!_head->forward[_i + 1]) { \ - /* shrink the header */ \ - HDassert(_i == SLIST->curr_level - 1); \ - HDassert((size_t)SLIST->curr_level == _head->level); \ + /* 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, NULL) \ + } \ + 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 */ \ + H5SL_SHRINK(_head, (size_t)(_i + 1)) \ + SLIST->curr_level--; \ } \ - 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); \ + } \ + 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) \ + /* 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, NULL) \ - else if (!_head->forward[_i + 1]) { \ - /* shrink the header */ \ - HDassert(_i == SLIST->curr_level - 1); \ - HDassert((size_t)SLIST->curr_level == _head->level); \ + /* If there are 2 or more nodes, promote the last */ \ + if (_count >= 2) \ + H5SL_PROMOTE(SLIST, X, _llast, NULL) \ + 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 */ \ + H5SL_SHRINK(_head, (size_t)(_i + 1)) \ + SLIST->curr_level--; \ + } \ + } \ + } \ \ - /* Prepare to drop down */ \ - _llast = _ldrop; \ - _last = _drop; \ - _next = _drop->forward[_i]; \ - } /* end for */ \ + /* Prepare to drop down */ \ + _llast = _ldrop; \ + _last = _drop; \ + _next = _drop->forward[_i]; \ + } \ \ - /* Check if we've found the node */ \ - if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) { \ - void *tmp = _next->item; \ - X = _next; \ + /* Check if we've found the node */ \ + if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, 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); \ + /* 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; \ + } \ + 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--; \ - X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[0], X->forward); \ - X = H5FL_FREE(H5SL_node_t, X); \ + /* 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--; \ + X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[0], X->forward); \ + X = H5FL_FREE(H5SL_node_t, X); \ \ - HGOTO_DONE(tmp); \ - } /* end if */ \ - } /* end else */ \ + HGOTO_DONE(tmp); \ + } \ } /* Macro used to search for node */ @@ -542,7 +487,6 @@ struct H5SL_node_t { 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) */ - hbool_t removed; /* Whether the node is "removed" (actual removal deferred) */ struct H5SL_node_t **forward; /* Array of forward pointers from this node */ struct H5SL_node_t * backward; /* Backward pointer from this node */ }; @@ -558,8 +502,6 @@ struct H5SL_t { size_t nobjs; /* Number of active objects in skip list */ H5SL_node_t *header; /* Header for nodes in skip list */ H5SL_node_t *last; /* Pointer to last node in skip list */ - hbool_t safe_iterating; /* Whether a routine is "safely" iterating over the list and removals should be - deferred */ }; /* Static functions */ @@ -568,9 +510,6 @@ static H5SL_node_t *H5SL__insert_common(H5SL_t *slist, void *item, const void *k 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); -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Declare a free list to manage the H5SL_t struct */ H5FL_DEFINE_STATIC(H5SL_t); @@ -582,26 +521,21 @@ static H5FL_fac_head_t **H5SL_fac_g; static size_t H5SL_fac_nused_g; static size_t H5SL_fac_nalloc_g; -/*-------------------------------------------------------------------------- - NAME - H5SL__init_package - PURPOSE - Initialize interface-specific information - USAGE - herr_t H5SL__init_package() - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Initializes any interface-specific data or routines. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5SL_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ herr_t -H5SL__init_package(void) +H5SL_init(void) { - FUNC_ENTER_PACKAGE_NOERR + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOERR /* Allocate space for array of factories */ H5SL_fac_g = (H5FL_fac_head_t **)H5MM_malloc(sizeof(H5FL_fac_head_t *)); @@ -613,8 +547,8 @@ H5SL__init_package(void) HDassert(H5SL_fac_g[0]); H5SL_fac_nused_g = 1; - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SL__init_package() */ + FUNC_LEAVE_NOAPI(ret_value) +} /*-------------------------------------------------------------------------- NAME @@ -642,33 +576,27 @@ H5SL_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Terminate all the factories */ - if (H5SL_fac_nused_g > 0) { - size_t i; - herr_t H5_ATTR_NDEBUG_UNUSED ret; + /* Terminate all the factories */ + if (H5SL_fac_nused_g > 0) { + size_t i; + herr_t H5_ATTR_NDEBUG_UNUSED ret; - for (i = 0; i < H5SL_fac_nused_g; i++) { - ret = H5FL_fac_term(H5SL_fac_g[i]); - HDassert(ret >= 0); - } /* end if */ - H5SL_fac_nused_g = 0; + for (i = 0; i < H5SL_fac_nused_g; i++) { + ret = H5FL_fac_term(H5SL_fac_g[i]); + HDassert(ret >= 0); + } + H5SL_fac_nused_g = 0; - n++; - } /* end if */ - - /* Free the list of factories */ - if (H5SL_fac_g) { - H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); - H5SL_fac_nalloc_g = 0; + n++; + } - n++; - } /* end if */ + /* Free the list of factories */ + if (H5SL_fac_g) { + H5SL_fac_g = (H5FL_fac_head_t **)H5MM_xfree((void *)H5SL_fac_g); + H5SL_fac_nalloc_g = 0; - /* Mark the interface as uninitialized */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + n++; + } FUNC_LEAVE_NOAPI(n) } /* H5SL_term_package() */ @@ -711,11 +639,10 @@ H5SL__new_node(void *item, const void *key, uint32_t hashval) ret_value->item = item; ret_value->level = 0; ret_value->hashval = hashval; - ret_value->removed = FALSE; if (NULL == (ret_value->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) { ret_value = H5FL_FREE(H5SL_node_t, ret_value); HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") - } /* end if */ + } ret_value->log_nalloc = 0; done: @@ -805,7 +732,7 @@ H5SL__insert_common(H5SL_t *slist, void *item, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* 'key' must not have been found in existing list, if we get here */ @@ -880,15 +807,22 @@ H5SL__release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) while (node) { next_node = node->forward[0]; - /* Call callback, if one is given */ + /* Call callback, if one is given. + * + * Ignoring const here is fine as we only need the value to be const + * with respect to the list code, which should never modify the + * elements. The library code that is making use of the skip list + * container can do what it likes with the elements. + */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") if (op) - /* Casting away const OK -QAK */ (void)(op)(node->item, (void *)node->key, op_data); + H5_GCC_CLANG_DIAG_ON("cast-qual") node->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], node->forward); node = H5FL_FREE(H5SL_node_t, node); node = next_node; - } /* end while */ + } /* Reset the header pointers */ slist->header->forward = @@ -1001,9 +935,8 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) new_slist->cmp = cmp; /* Set the dynamic internal fields */ - new_slist->curr_level = -1; - new_slist->nobjs = 0; - new_slist->safe_iterating = FALSE; + new_slist->curr_level = -1; + new_slist->nobjs = 0; /* Allocate the header node */ if (NULL == (header = H5SL__new_node(NULL, NULL, (uint32_t)ULONG_MAX))) @@ -1027,7 +960,7 @@ done: if (ret_value == NULL) { if (new_slist != NULL) new_slist = H5FL_FREE(H5SL_t, new_slist); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_create() */ @@ -1058,9 +991,6 @@ H5SL_count(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1099,9 +1029,6 @@ H5SL_insert(H5SL_t *slist, void *item, const void *key) HDassert(slist); HDassert(key); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1148,9 +1075,6 @@ H5SL_add(H5SL_t *slist, void *item, const void *key) HDassert(slist); HDassert(key); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1242,7 +1166,7 @@ H5SL_remove(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1281,9 +1205,6 @@ H5SL_remove_first(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Assign level */ H5_CHECK_OVERFLOW(slist->curr_level, int, size_t); level = (size_t)slist->curr_level; @@ -1345,12 +1266,12 @@ H5SL_remove_first(H5SL_t *slist) H5SL_SHRINK(head, level) slist->curr_level--; - } /* end else */ + } } else break; - } /* end for */ - } /* end if */ + } + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1436,7 +1357,7 @@ H5SL_search(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* 'key' must not have been found in list, if we get here */ ret_value = NULL; @@ -1480,9 +1401,6 @@ H5SL_less(H5SL_t *slist, const void *key) HDassert(slist); HDassert(key); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1531,7 +1449,7 @@ H5SL_less(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* An exact match for 'key' must not have been found in list, if we get here */ /* Check for a node with a key that is less than the given 'key' */ @@ -1541,13 +1459,13 @@ H5SL_less(H5SL_t *slist, const void *key) ret_value = slist->last->item; else ret_value = NULL; - } /* end if */ + } else { if (x->backward != slist->header) ret_value = x->backward->item; else ret_value = NULL; - } /* end else */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1588,9 +1506,6 @@ H5SL_greater(H5SL_t *slist, const void *key) HDassert(slist); HDassert(key); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1639,7 +1554,7 @@ H5SL_greater(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* An exact match for 'key' must not have been found in list, if we get here */ /* ('x' must be the next node with a key greater than the 'key', or NULL) */ @@ -1734,7 +1649,7 @@ H5SL_find(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* 'key' must not have been found in list, if we get here */ ret_value = NULL; @@ -1826,7 +1741,7 @@ H5SL_below(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* An exact match for 'key' must not have been found in list, if we get here */ /* Check for a node with a key that is less than the given 'key' */ @@ -1836,13 +1751,13 @@ H5SL_below(H5SL_t *slist, const void *key) ret_value = slist->last; else ret_value = NULL; - } /* end if */ + } else { if (x->backward != slist->header) ret_value = x->backward; else ret_value = NULL; - } /* end else */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1931,7 +1846,7 @@ H5SL_above(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* An exact match for 'key' must not have been found in list, if we get here */ /* ('x' must be the next node with a key greater than the 'key', or NULL) */ @@ -1971,9 +1886,6 @@ H5SL_first(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2007,9 +1919,6 @@ H5SL_next(H5SL_node_t *slist_node) /* Check args */ HDassert(slist_node); - /* Not currently supported */ - HDassert(!slist_node->removed); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2043,9 +1952,6 @@ H5SL_prev(H5SL_node_t *slist_node) /* Check args */ HDassert(slist_node); - /* Not currently supported */ - HDassert(!slist_node->removed); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2080,9 +1986,6 @@ H5SL_last(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2116,9 +2019,6 @@ H5SL_item(H5SL_node_t *slist_node) /* Check args */ HDassert(slist_node); - /* Not currently supported */ - HDassert(!slist_node->removed); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2179,15 +2079,21 @@ H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Protect against the node being deleted by the callback */ next = node->forward[0]; - /* Call the iterator callback */ - /* Casting away const OK -QAK */ - if (!node->removed) - if ((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) - break; + /* Call the iterator callback + * + * Ignoring const here is fine as we only need the value to be const + * with respect to the list code, which should never modify the + * elements. The library code that is making use of the skip list + * container can do what it likes with the elements. + */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") + if ((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) + break; + H5_GCC_CLANG_DIAG_ON("cast-qual") /* Advance to next node */ node = next; - } /* end while */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_iterate() */ @@ -2222,9 +2128,6 @@ H5SL_release(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2274,9 +2177,6 @@ H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2290,186 +2190,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5SL_try_free_safe - PURPOSE - Makes the supplied callback on all nodes in the skip list, freeing each - node that the callback returns TRUE for. - USAGE - herr_t PURPOSE(slist,op,opdata) - H5SL_t *slist; IN/OUT: Pointer to skip list to release nodes - H5SL_try_free_op_t op; IN: Callback function to try to free item & key - void *op_data; IN/OUT: Pointer to application data for callback - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Makes the supplied callback on all nodes in the skip list, freeing each - node that the callback returns TRUE for. The iteration is performed in - a safe manner, such that the callback can call H5SL_remove(), - H5SL_search(), H5SL_find(), and H5SL_iterate() on nodes in this - skiplist, except H5SL_remove() may not be call on *this* node. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This function is written to be most efficient when most nodes are - removed from the skiplist, as it rebuilds the nodes afterwards. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) -{ - H5SL_node_t *node, *next_node, *last_node; /* Pointers to skip list nodes */ - htri_t op_ret; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Check args */ - HDassert(slist); - HDassert(op); - - /* Not currently supported */ - HDassert(!slist->safe_iterating); - - /* Check internal consistency */ - /* (Pre-condition) */ - - /* Mark skip list as safe iterating, so nodes aren't freed out from under - * us */ - slist->safe_iterating = TRUE; - - /* Iterate over skip list nodes, making the callback for each and marking - * them as removed if requested by the callback */ - node = slist->header->forward[0]; - while (node) { - /* Check if the node was already removed */ - if (!node->removed) { - /* Call callback */ - /* Casting away const OK -NAF */ - if ((op_ret = (op)(node->item, (void *)node->key, op_data)) < 0) - HGOTO_ERROR(H5E_SLIST, H5E_CALLBACK, FAIL, "callback operation failed") - - /* Check if op indicated that the node should be removed */ - if (op_ret) - /* Mark the node as removed */ - node->removed = TRUE; - } /* end if */ - - /* Advance node */ - node = node->forward[0]; - } /* end while */ - - /* Reset safe_iterating */ - slist->safe_iterating = FALSE; - - /* Iterate over nodes, freeing ones marked as removed */ - node = slist->header->forward[0]; - last_node = slist->header; - while (node) { - /* Save next node */ - next_node = node->forward[0]; - - /* Check if the node was marked as removed */ - if (node->removed) { - /* Remove the node */ - node->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], node->forward); - node = H5FL_FREE(H5SL_node_t, node); - slist->nobjs--; - } /* end if */ - else { - /* Update backwards and forwards[0] pointers, and set the level to - * 0. Since the list is flattened we must rebuild the skiplist - * afterwards. */ - /* Set level to 0. Note there is no need to preserve - * node->forward[0] since it was cached above and will always be - * updated later. */ - if (node->level > 0) { - node->forward = - (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], (void *)node->forward); - if (NULL == (node->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) - HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - node->log_nalloc = 0; - node->level = 0; - } /* end if */ - - /* Update pointers */ - last_node->forward[0] = node; - node->backward = last_node; - last_node = node; - } /* end else */ - - /* Advance node */ - node = next_node; - } /* end while */ - - /* Final pointer update */ - last_node->forward[0] = NULL; - slist->last = last_node; - - /* Demote skip list to level 0 */ - if (slist->curr_level > 0) { - HDassert(slist->header->level == (size_t)slist->curr_level); - - node = slist->header->forward[0]; - slist->header->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], - (void *)slist->header->forward); - if (NULL == (slist->header->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) - HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - slist->header->forward[0] = node; - slist->header->log_nalloc = 0; - slist->header->level = 0; - } /* end if */ - - /* Check if there are any nodes left */ - if (slist->nobjs > 0) { - int i; - - HDassert(slist->header->forward[0]); - - /* Set skiplist level to 0 */ - slist->curr_level = 0; - - /* Rebuild the forward arrays */ - for (i = 0; slist->curr_level >= i; i++) { - HDassert(slist->curr_level == i); - - /* Promote every third node this level until we run out of nodes */ - node = last_node = slist->header; - while (1) { - /* Check second node in gap, if not present, no need to promote - * further this level. */ - HDassert(node->forward[i]); - node = node->forward[i]->forward[i]; - if (!node) - break; - - /* Check third and fourth node in gap, if either is not present, - * no need to promote further this level. */ - node = node->forward[i]; - if (!node || !node->forward[i]) - break; - - /* Promote the third node in the gap */ - H5SL_PROMOTE(slist, node, last_node, FAIL) - last_node = node; - } /* end while */ - } /* end for */ - } /* end if */ - else { - HDassert(!slist->header->forward[0]); - HDassert(slist->last == slist->header); - HDassert(slist->nobjs == 0); - - /* Reset the skiplist level */ - slist->curr_level = -1; - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SL_try_free_safe() */ - -/*-------------------------------------------------------------------------- - NAME H5SL_destroy PURPOSE Close a skip list, deallocating it and freeing all its nodes. diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index c9e1147..f4f7506 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -60,9 +60,6 @@ typedef int (*H5SL_cmp_t)(const void *key1, const void *key2); /* Typedef for iteration operations */ typedef herr_t (*H5SL_operator_t)(void *item, void *key, void *operator_data /*in,out*/); -/* Typedef for H5SL_try_free_safe operation callback */ -typedef htri_t (*H5SL_try_free_op_t)(void *item, void *key, void *operator_data /*in,out*/); - /********************/ /* Private routines */ /********************/ @@ -86,9 +83,9 @@ H5_DLL void * H5SL_item(H5SL_node_t *slist_node); H5_DLL herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data); 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_try_free_safe(H5SL_t *slist, H5SL_try_free_op_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 herr_t H5SL_init(void); H5_DLL int H5SL_term_interface(void); #endif /* H5SLprivate_H */ diff --git a/src/H5SM.c b/src/H5SM.c index b09cb45..45d72d4 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -76,9 +76,6 @@ static herr_t H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - H5FL_DEFINE(H5SM_master_table_t); H5FL_ARR_DEFINE(H5SM_index_header_t, H5O_SHMESG_MAX_NINDEXES); H5FL_DEFINE(H5SM_list_t); diff --git a/src/H5Sall.c b/src/H5Sall.c index 35ddf3d..4dcc83a 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -49,22 +49,22 @@ static herr_t H5S__all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S__all_release(H5S_t *space); static htri_t H5S__all_is_valid(const H5S_t *space); -static hssize_t H5S__all_serial_size(const H5S_t *space); -static herr_t H5S__all_serialize(const H5S_t *space, uint8_t **p); +static hssize_t H5S__all_serial_size(H5S_t *space); +static herr_t H5S__all_serialize(H5S_t *space, uint8_t **p); static herr_t H5S__all_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__all_offset(const H5S_t *space, hsize_t *off); static int H5S__all_unlim_dim(const H5S_t *space); static htri_t H5S__all_is_contiguous(const H5S_t *space); static htri_t H5S__all_is_single(const H5S_t *space); -static htri_t H5S__all_is_regular(const H5S_t *space); -static htri_t H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__all_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static htri_t H5S__all_is_regular(H5S_t *space); +static htri_t H5S__all_shape_same(H5S_t *space1, H5S_t *space2); +static htri_t H5S__all_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end); static herr_t H5S__all_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__all_adjust_s(H5S_t *space, const hssize_t *offset); static herr_t H5S__all_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__all_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__all_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__all_iter_init(H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ static herr_t H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); @@ -144,7 +144,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5S__all_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) +H5S__all_iter_init(H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) { FUNC_ENTER_STATIC_NOERR @@ -557,7 +557,7 @@ H5S__all_is_valid(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static hssize_t -H5S__all_serial_size(const H5S_t H5_ATTR_UNUSED *space) +H5S__all_serial_size(H5S_t H5_ATTR_UNUSED *space) { FUNC_ENTER_STATIC_NOERR @@ -577,7 +577,7 @@ H5S__all_serial_size(const H5S_t H5_ATTR_UNUSED *space) Serialize the current selection into a user-provided buffer. USAGE herr_t H5S__all_serialize(space, p) - const H5S_t *space; IN: Dataspace with selection to serialize + H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of serialized selection. @@ -592,7 +592,7 @@ H5S__all_serial_size(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__all_serialize(const H5S_t *space, uint8_t **p) +H5S__all_serialize(H5S_t *space, uint8_t **p) { uint8_t *pp = (*p); /* Local pointer for decoding */ @@ -864,7 +864,7 @@ H5S__all_is_single(const H5S_t H5_ATTR_UNUSED *space) Check if a "all" selection is "regular" USAGE htri_t H5S__all_is_regular(space) - const H5S_t *space; IN: Dataspace pointer to check + H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION @@ -877,7 +877,7 @@ H5S__all_is_single(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space) +H5S__all_is_regular(H5S_t H5_ATTR_UNUSED *space) { FUNC_ENTER_STATIC_NOERR @@ -894,8 +894,8 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space) Check if a two "all" selections are the same shape USAGE htri_t H5S__all_shape_same(space1, space2) - const H5S_t *space1; IN: First dataspace to check - const H5S_t *space2; IN: Second dataspace to check + H5S_t *space1; IN: First dataspace to check + H5S_t *space2; IN: Second dataspace to check RETURNS TRUE / FALSE / FAIL DESCRIPTION @@ -907,7 +907,7 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) +H5S__all_shape_same(H5S_t *space1, H5S_t *space2) { int space1_dim; /* Current dimension in first dataspace */ int space2_dim; /* Current dimension in second dataspace */ @@ -957,7 +957,7 @@ done: Detect intersections of selection with block USAGE htri_t H5S__all_intersect_block(space, start, end) - const H5S_t *space; IN: Dataspace with selection to use + H5S_t *space; IN: Dataspace with selection to use const hsize_t *start; IN: Starting coordinate for block const hsize_t *end; IN: Ending coordinate for block RETURNS @@ -970,7 +970,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S__all_intersect_block(const H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, +H5S__all_intersect_block(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, const hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Shyper.c b/src/H5Shyper.c index a5b9b6c..af2794a 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -173,8 +173,8 @@ static herr_t H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_sele static herr_t H5S__hyper_release(H5S_t *space); static htri_t H5S__hyper_is_valid(const H5S_t *space); static hsize_t H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans); -static hssize_t H5S__hyper_serial_size(const H5S_t *space); -static herr_t H5S__hyper_serialize(const H5S_t *space, uint8_t **p); +static hssize_t H5S__hyper_serial_size(H5S_t *space); +static herr_t H5S__hyper_serialize(H5S_t *space, uint8_t **p); static herr_t H5S__hyper_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__hyper_offset(const H5S_t *space, hsize_t *offset); @@ -182,14 +182,14 @@ static int H5S__hyper_unlim_dim(const H5S_t *space); static herr_t H5S__hyper_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim); static htri_t H5S__hyper_is_contiguous(const H5S_t *space); static htri_t H5S__hyper_is_single(const H5S_t *space); -static htri_t H5S__hyper_is_regular(const H5S_t *space); -static htri_t H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static htri_t H5S__hyper_is_regular(H5S_t *space); +static htri_t H5S__hyper_shape_same(H5S_t *space1, H5S_t *space2); +static htri_t H5S__hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end); static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset); static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__hyper_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__hyper_iter_init(H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ static herr_t H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); @@ -559,7 +559,7 @@ H5S__hyper_get_op_gen(void) *------------------------------------------------------------------------- */ static herr_t -H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) +H5S__hyper_iter_init(H5S_t *space, H5S_sel_iter_t *iter) { hsize_t *slab_size; /* Pointer to the dataspace dimensions to use for calc. slab */ hsize_t acc; /* Accumulator for computing cumulative sizes */ @@ -586,7 +586,7 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) * to be impossible. */ if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */ + H5S__hyper_rebuild(space); /* Check for the special case of just one H5Sselect_hyperslab call made */ if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { @@ -3575,7 +3575,7 @@ H5S__hyper_get_enc_size_real(hsize_t max_size) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_t *version, uint8_t *enc_size) +H5S__hyper_get_version_enc_size(H5S_t *space, hsize_t block_count, uint32_t *version, uint8_t *enc_size) { hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ @@ -3728,7 +3728,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static hssize_t -H5S__hyper_serial_size(const H5S_t *space) +H5S__hyper_serial_size(H5S_t *space) { hsize_t block_count = 0; /* block counter for regular hyperslabs */ uint32_t version; /* Version number */ @@ -3928,7 +3928,7 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, hsize_t *start, Serialize the current selection into a user-provided buffer. USAGE herr_t H5S__hyper_serialize(space, p) - const H5S_t *space; IN: Dataspace with selection to serialize + H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of serialized selection. @@ -3943,7 +3943,7 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, hsize_t *start, REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_serialize(const H5S_t *space, uint8_t **p) +H5S__hyper_serialize(H5S_t *space, uint8_t **p) { const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ @@ -5326,7 +5326,7 @@ done: Check if a hyperslab selection is "regular" USAGE htri_t H5S__hyper_is_regular(space) - const H5S_t *space; IN: Dataspace pointer to check + H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION @@ -5339,7 +5339,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__hyper_is_regular(const H5S_t *space) +H5S__hyper_is_regular(H5S_t *space) { htri_t ret_value = FAIL; /* return value */ @@ -5352,7 +5352,7 @@ H5S__hyper_is_regular(const H5S_t *space) * to be impossible. */ if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -NAF */ + H5S__hyper_rebuild(space); /* Only simple check for regular hyperslabs for now... */ if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) @@ -5576,8 +5576,8 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, const H5S_h Check if a two hyperslab selections are the same shape USAGE htri_t H5S__hyper_shape_same(space1, space2) - const H5S_t *space1; IN: First dataspace to check - const H5S_t *space2; IN: Second dataspace to check + H5S_t *space1; IN: First dataspace to check + H5S_t *space2; IN: Second dataspace to check RETURNS TRUE / FALSE / FAIL DESCRIPTION @@ -5594,7 +5594,7 @@ H5S__hyper_spans_shape_same(const H5S_hyper_span_info_t *span_info1, const H5S_h REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) +H5S__hyper_shape_same(H5S_t *space1, H5S_t *space2) { unsigned space1_rank; /* Number of dimensions of first dataspace */ unsigned space2_rank; /* Number of dimensions of second dataspace */ @@ -5617,9 +5617,9 @@ H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) /* Rebuild diminfo if it is invalid and has not been confirmed to be * impossible */ if (space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space1); /* Casting away const OK -QAK */ + H5S__hyper_rebuild(space1); if (space2->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space2); /* Casting away const OK -QAK */ + H5S__hyper_rebuild(space2); /* If both are regular hyperslabs, compare their diminfo values */ if (space1->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES && @@ -5664,11 +5664,11 @@ H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2) /* Make certain that both selections have span trees */ if (NULL == space1->select.sel_info.hslab->span_lst) - if (H5S__hyper_generate_spans((H5S_t *)space1) < 0) /* Casting away const OK -QAK */ + if (H5S__hyper_generate_spans(space1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for hyperslab selection") if (NULL == space2->select.sel_info.hslab->span_lst) - if (H5S__hyper_generate_spans((H5S_t *)space2) < 0) /* Casting away const OK -QAK */ + if (H5S__hyper_generate_spans(space2) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for hyperslab selection") @@ -6255,7 +6255,7 @@ done: Detect intersections of selection with block USAGE htri_t H5S__hyper_intersect_block(space, start, end) - const H5S_t *space; IN: Dataspace with selection to use + H5S_t *space; IN: Dataspace with selection to use const hsize_t *start; IN: Starting coordinate for block const hsize_t *end; IN: Ending coordinate for block RETURNS @@ -6270,7 +6270,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end) +H5S__hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end) { htri_t ret_value = FAIL; /* Return value */ @@ -6286,7 +6286,7 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize * to be impossible. */ if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO) - H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -QAK */ + H5S__hyper_rebuild(space); /* Check for regular hyperslab intersection */ if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { @@ -11592,8 +11592,8 @@ also that proj_space can share some span trees with dst_space, so proj_space mus if dst_space must be preserved. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, - const H5S_t *src_intersect_space, H5S_t *proj_space, hbool_t share_selection) +H5S__hyper_project_intersection(H5S_t *src_space, H5S_t *dst_space, H5S_t *src_intersect_space, + H5S_t *proj_space, hbool_t share_selection) { H5S_hyper_project_intersect_ud_t udata; /* User data for subroutines */ const H5S_hyper_span_info_t * ss_span_info; @@ -11622,7 +11622,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, if (H5S_GET_SELECT_TYPE(src_space) == H5S_SEL_HYPERSLABS) { /* Make certain the selection has a span tree */ if (NULL == src_space->select.sel_info.hslab->span_lst) - if (H5S__hyper_generate_spans((H5S_t *)src_space) < 0) /* Casting away const OK -NAF */ + if (H5S__hyper_generate_spans(src_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for source hyperslab selection") @@ -11644,7 +11644,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, if (H5S_GET_SELECT_TYPE(dst_space) == H5S_SEL_HYPERSLABS) { /* Make certain the selection has a span tree */ if (NULL == dst_space->select.sel_info.hslab->span_lst) - if (H5S__hyper_generate_spans((H5S_t *)dst_space) < 0) /* Casting away const OK -NAF */ + if (H5S__hyper_generate_spans(dst_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for dsetination hyperslab selection") @@ -11664,7 +11664,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Make certain the source intersect selection has a span tree */ if (NULL == src_intersect_space->select.sel_info.hslab->span_lst) - if (H5S__hyper_generate_spans((H5S_t *)src_intersect_space) < 0) /* Casting away const OK -NAF */ + if (H5S__hyper_generate_spans(src_intersect_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "can't construct span tree for source intersect hyperslab selection") @@ -12036,7 +12036,7 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, hbo hsize_t num_slices; /* Number of slices in unlimited dimension */ hsize_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(0) + FUNC_ENTER_NOAPI_NOERR /* Check parameters */ HDassert(clip_space); @@ -12058,7 +12058,6 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, hbo /* Call "real" get_clip_extent function */ ret_value = H5S__hyper_get_clip_extent_real(clip_space, num_slices, incl_trail); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent() */ @@ -12094,7 +12093,7 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, const H5S_t *match_spac hsize_t num_slices; /* Number of slices in unlimited dimension */ hsize_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(0) + FUNC_ENTER_NOAPI_NOERR /* Check parameters */ HDassert(clip_space); @@ -12140,7 +12139,6 @@ H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, const H5S_t *match_spac /* Call "real" get_clip_extent function */ ret_value = H5S__hyper_get_clip_extent_real(clip_space, num_slices, incl_trail); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent_match() */ @@ -12256,7 +12254,7 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *pa H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo in unlimited dimension */ hsize_t ret_value = 0; - FUNC_ENTER_NOAPI(0) + FUNC_ENTER_NOAPI_NOERR /* Check parameters */ HDassert(space); @@ -12286,7 +12284,6 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *pa } /* end if */ } /* end else */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_first_inc_block */ diff --git a/src/H5Snone.c b/src/H5Snone.c index 82e513e..9292cd4 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -49,22 +49,22 @@ static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S__none_release(H5S_t *space); static htri_t H5S__none_is_valid(const H5S_t *space); -static hssize_t H5S__none_serial_size(const H5S_t *space); -static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p); +static hssize_t H5S__none_serial_size(H5S_t *space); +static herr_t H5S__none_serialize(H5S_t *space, uint8_t **p); static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off); static int H5S__none_unlim_dim(const H5S_t *space); static htri_t H5S__none_is_contiguous(const H5S_t *space); static htri_t H5S__none_is_single(const H5S_t *space); -static htri_t H5S__none_is_regular(const H5S_t *space); -static htri_t H5S__none_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__none_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static htri_t H5S__none_is_regular(H5S_t *space); +static htri_t H5S__none_shape_same(H5S_t *space1, H5S_t *space2); +static htri_t H5S__none_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end); static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__none_adjust_s(H5S_t *space, const hssize_t *offset); static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__none_iter_init(H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ static herr_t H5S__none_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); @@ -144,7 +144,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5S__none_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) +H5S__none_iter_init(H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) { FUNC_ENTER_STATIC_NOERR @@ -513,7 +513,7 @@ H5S__none_is_valid(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static hssize_t -H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) +H5S__none_serial_size(H5S_t H5_ATTR_UNUSED *space) { FUNC_ENTER_STATIC_NOERR @@ -533,7 +533,7 @@ H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) Serialize the current selection into a user-provided buffer. USAGE herr_t H5S__none_serialize(space, p) - const H5S_t *space; IN: Dataspace with selection to serialize + H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of serialized selection. @@ -548,7 +548,7 @@ H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_serialize(const H5S_t *space, uint8_t **p) +H5S__none_serialize(H5S_t *space, uint8_t **p) { uint8_t *pp = (*p); /* Local pointer for decoding */ @@ -803,7 +803,7 @@ H5S__none_is_single(const H5S_t H5_ATTR_UNUSED *space) Check if a "none" selection is "regular" USAGE htri_t H5S__none_is_regular(space) - const H5S_t *space; IN: Dataspace pointer to check + H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION @@ -816,7 +816,7 @@ H5S__none_is_single(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) +H5S__none_is_regular(H5S_t H5_ATTR_UNUSED *space) { FUNC_ENTER_STATIC_NOERR @@ -833,8 +833,8 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) Check if a two "none" selections are the same shape USAGE htri_t H5S__none_shape_same(space1, space2) - const H5S_t *space1; IN: First dataspace to check - const H5S_t *space2; IN: Second dataspace to check + H5S_t *space1; IN: First dataspace to check + H5S_t *space2; IN: Second dataspace to check RETURNS TRUE / FALSE / FAIL DESCRIPTION @@ -846,7 +846,7 @@ H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, const H5S_t H5_ATTR_UNUSED *space2) +H5S__none_shape_same(H5S_t H5_ATTR_UNUSED *space1, H5S_t H5_ATTR_UNUSED *space2) { FUNC_ENTER_STATIC_NOERR @@ -864,7 +864,7 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, const H5S_t H5_ATTR_UNU Detect intersections of selection with block USAGE htri_t H5S__none_intersect_block(space, start, end) - const H5S_t *space; IN: Dataspace with selection to use + H5S_t *space; IN: Dataspace with selection to use const hsize_t *start; IN: Starting coordinate for block const hsize_t *end; IN: Ending coordinate for block RETURNS @@ -877,7 +877,7 @@ H5S__none_shape_same(const H5S_t H5_ATTR_UNUSED *space1, const H5S_t H5_ATTR_UNU REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S__none_intersect_block(const H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, +H5S__none_intersect_block(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *start, const hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Spkg.h b/src/H5Spkg.h index c89b616..74013bc 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -242,9 +242,9 @@ typedef herr_t (*H5S_sel_release_func_t)(H5S_t *space); /* Method to determine if current selection is valid for dataspace */ typedef htri_t (*H5S_sel_is_valid_func_t)(const H5S_t *space); /* Method to determine number of bytes required to store current selection */ -typedef hssize_t (*H5S_sel_serial_size_func_t)(const H5S_t *space); +typedef hssize_t (*H5S_sel_serial_size_func_t)(H5S_t *space); /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ -typedef herr_t (*H5S_sel_serialize_func_t)(const H5S_t *space, uint8_t **p); +typedef herr_t (*H5S_sel_serialize_func_t)(H5S_t *space, uint8_t **p); /* Method to create selection from "serialized" form (a byte sequence suitable for storing on disk) */ typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t **space, const uint8_t **p); /* Method to determine smallest n-D bounding box containing the current selection */ @@ -260,12 +260,11 @@ typedef htri_t (*H5S_sel_is_contiguous_func_t)(const H5S_t *space); /* Method to determine if current selection is a single block */ typedef htri_t (*H5S_sel_is_single_func_t)(const H5S_t *space); /* Method to determine if current selection is "regular" */ -typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space); +typedef htri_t (*H5S_sel_is_regular_func_t)(H5S_t *space); /* Method to determine if two dataspaces' selections are the same shape */ -typedef htri_t (*H5S_sel_shape_same_func_t)(const H5S_t *space1, const H5S_t *space2); +typedef htri_t (*H5S_sel_shape_same_func_t)(H5S_t *space1, H5S_t *space2); /* Method to determine if selection intersects a block */ -typedef htri_t (*H5S_sel_intersect_block_func_t)(const H5S_t *space, const hsize_t *start, - const hsize_t *end); +typedef htri_t (*H5S_sel_intersect_block_func_t)(H5S_t *space, const hsize_t *start, const hsize_t *end); /* Method to adjust a selection by an offset */ typedef herr_t (*H5S_sel_adjust_u_func_t)(H5S_t *space, const hsize_t *offset); /* Method to adjust a selection by an offset (signed) */ @@ -275,7 +274,7 @@ typedef herr_t (*H5S_sel_project_scalar)(const H5S_t *space, hsize_t *offset); /* Method to construct selection projection onto/into simple dataspace */ typedef herr_t (*H5S_sel_project_simple)(const H5S_t *space, H5S_t *new_space, hsize_t *offset); /* Method to initialize iterator for current selection */ -typedef herr_t (*H5S_sel_iter_init_func_t)(const H5S_t *space, H5S_sel_iter_t *sel_iter); +typedef herr_t (*H5S_sel_iter_init_func_t)(H5S_t *space, H5S_sel_iter_t *sel_iter); /* Selection class information */ typedef struct { @@ -405,9 +404,8 @@ H5_DLL herr_t H5S__extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, H5_DLL uint64_t H5S__hyper_get_op_gen(void); H5_DLL void H5S__hyper_rebuild(H5S_t *space); H5_DLL herr_t H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2); -H5_DLL herr_t H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, - const H5S_t *src_intersect_space, H5S_t *proj_space, - hbool_t share_space); +H5_DLL herr_t H5S__hyper_project_intersection(H5S_t *src_space, H5S_t *dst_space, H5S_t *src_intersect_space, + H5S_t *proj_space, hbool_t share_space); /* Operations on selection iterators */ H5_DLL herr_t H5S__sel_iter_close_cb(H5S_sel_iter_t *_sel_iter, void **request); diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 5991116..72f64fe 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -59,22 +59,22 @@ static void H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst); static herr_t H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); static herr_t H5S__point_release(H5S_t *space); static htri_t H5S__point_is_valid(const H5S_t *space); -static hssize_t H5S__point_serial_size(const H5S_t *space); -static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p); +static hssize_t H5S__point_serial_size(H5S_t *space); +static herr_t H5S__point_serialize(H5S_t *space, uint8_t **p); static herr_t H5S__point_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__point_offset(const H5S_t *space, hsize_t *off); static int H5S__point_unlim_dim(const H5S_t *space); static htri_t H5S__point_is_contiguous(const H5S_t *space); static htri_t H5S__point_is_single(const H5S_t *space); -static htri_t H5S__point_is_regular(const H5S_t *space); -static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); +static htri_t H5S__point_is_regular(H5S_t *space); +static htri_t H5S__point_shape_same(H5S_t *space1, H5S_t *space2); +static htri_t H5S__point_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end); static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__point_adjust_s(H5S_t *space, const hssize_t *offset); static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset); static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); +static herr_t H5S__point_iter_init(H5S_t *space, H5S_sel_iter_t *iter); static herr_t H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size); /* Selection iteration callbacks */ @@ -170,7 +170,7 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t); *------------------------------------------------------------------------- */ static herr_t -H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter) +H5S__point_iter_init(H5S_t *space, H5S_sel_iter_t *iter) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1159,7 +1159,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static hssize_t -H5S__point_serial_size(const H5S_t *space) +H5S__point_serial_size(H5S_t *space) { uint32_t version; /* Version number */ uint8_t enc_size; /* Encoded size of point selection info */ @@ -1204,7 +1204,7 @@ done: Serialize the current selection into a user-provided buffer. USAGE herr_t H5S__point_serialize(space, p) - const H5S_t *space; IN: Dataspace with selection to serialize + H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of serialized selection. @@ -1219,7 +1219,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__point_serialize(const H5S_t *space, uint8_t **p) +H5S__point_serialize(H5S_t *space, uint8_t **p) { H5S_pnt_node_t *curr; /* Point information nodes */ uint8_t * pp; /* Local pointer for encoding */ @@ -1844,7 +1844,7 @@ H5S__point_is_single(const H5S_t *space) Check if a point selection is "regular" USAGE htri_t H5S__point_is_regular(space) - const H5S_t *space; IN: Dataspace pointer to check + H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL DESCRIPTION @@ -1859,7 +1859,7 @@ H5S__point_is_single(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__point_is_regular(const H5S_t *space) +H5S__point_is_regular(H5S_t *space) { htri_t ret_value = FAIL; /* Return value */ @@ -1884,8 +1884,8 @@ H5S__point_is_regular(const H5S_t *space) Check if a two "point" selections are the same shape USAGE htri_t H5S__point_shape_same(space1, space2) - const H5S_t *space1; IN: First dataspace to check - const H5S_t *space2; IN: Second dataspace to check + H5S_t *space1; IN: First dataspace to check + H5S_t *space2; IN: Second dataspace to check RETURNS TRUE / FALSE / FAIL DESCRIPTION @@ -1897,7 +1897,7 @@ H5S__point_is_regular(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) +H5S__point_shape_same(H5S_t *space1, H5S_t *space2) { H5S_pnt_node_t *pnt1, *pnt2; /* Point information nodes */ hssize_t offset[H5S_MAX_RANK]; /* Offset between the selections */ @@ -1990,7 +1990,7 @@ done: Detect intersections of selection with block USAGE htri_t H5S__point_intersect_block(space, start, end) - const H5S_t *space; IN: Dataspace with selection to use + H5S_t *space; IN: Dataspace with selection to use const hsize_t *start; IN: Starting coordinate for block const hsize_t *end; IN: Ending coordinate for block RETURNS @@ -2003,7 +2003,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end) +H5S__point_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end) { H5S_pnt_node_t *pnt; /* Point information node */ htri_t ret_value = FALSE; /* Return value */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index e1a6409..e3c7119 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -235,36 +235,35 @@ H5_DLL herr_t H5S_extent_copy(H5S_t *dst, const H5S_t *src); /* Operations on selections */ H5_DLL herr_t H5S_select_deserialize(H5S_t **space, const uint8_t **p); H5_DLL H5S_sel_type H5S_get_select_type(const H5S_t *space); -H5_DLL herr_t H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, - const H5S_sel_iter_op_t *op, void *op_data); -H5_DLL herr_t H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *buf); -H5_DLL htri_t H5S_select_valid(const H5S_t *space); -H5_DLL hsize_t H5S_get_select_npoints(const H5S_t *space); -H5_DLL herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); -H5_DLL herr_t H5S_get_select_offset(const H5S_t *space, hsize_t *offset); -H5_DLL int H5S_get_select_unlim_dim(const H5S_t *space); -H5_DLL herr_t H5S_get_select_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim); -H5_DLL herr_t H5S_select_offset(H5S_t *space, const hssize_t *offset); -H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -H5_DLL htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2); -H5_DLL htri_t H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); -H5_DLL herr_t H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, - unsigned new_space_rank, const void *buf, - void const **adj_buf_ptr, hsize_t element_size); -H5_DLL herr_t H5S_select_release(H5S_t *ds); -H5_DLL hssize_t H5S_select_serial_size(const H5S_t *space); -H5_DLL herr_t H5S_select_serialize(const H5S_t *space, uint8_t **p); -H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space); -H5_DLL htri_t H5S_select_is_single(const H5S_t *space); -H5_DLL htri_t H5S_select_is_regular(const H5S_t *space); -H5_DLL herr_t H5S_select_adjust_u(H5S_t *space, const hsize_t *offset); -H5_DLL herr_t H5S_select_adjust_s(H5S_t *space, const hssize_t *offset); -H5_DLL herr_t H5S_select_project_scalar(const H5S_t *space, hsize_t *offset); -H5_DLL herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); -H5_DLL herr_t H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, - const H5S_t *src_intersect_space, H5S_t **new_space_ptr, - hbool_t share_space); -H5_DLL herr_t H5S_select_subtract(H5S_t *space, H5S_t *subtract_space); +H5_DLL herr_t H5S_select_iterate(void *buf, const H5T_t *type, H5S_t *space, const H5S_sel_iter_op_t *op, + void *op_data); +H5_DLL herr_t H5S_select_fill(const void *fill, size_t fill_size, H5S_t *space, void *buf); +H5_DLL htri_t H5S_select_valid(const H5S_t *space); +H5_DLL hsize_t H5S_get_select_npoints(const H5S_t *space); +H5_DLL herr_t H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); +H5_DLL herr_t H5S_get_select_offset(const H5S_t *space, hsize_t *offset); +H5_DLL int H5S_get_select_unlim_dim(const H5S_t *space); +H5_DLL herr_t H5S_get_select_num_elem_non_unlim(const H5S_t *space, hsize_t *num_elem_non_unlim); +H5_DLL herr_t H5S_select_offset(H5S_t *space, const hssize_t *offset); +H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +H5_DLL htri_t H5S_select_shape_same(H5S_t *space1, H5S_t *space2); +H5_DLL htri_t H5S_select_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end); +H5_DLL herr_t H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, + unsigned new_space_rank, const void *buf, + void const **adj_buf_ptr, hsize_t element_size); +H5_DLL herr_t H5S_select_release(H5S_t *ds); +H5_DLL hssize_t H5S_select_serial_size(H5S_t *space); +H5_DLL herr_t H5S_select_serialize(H5S_t *space, uint8_t **p); +H5_DLL htri_t H5S_select_is_contiguous(const H5S_t *space); +H5_DLL htri_t H5S_select_is_single(const H5S_t *space); +H5_DLL htri_t H5S_select_is_regular(H5S_t *space); +H5_DLL herr_t H5S_select_adjust_u(H5S_t *space, const hsize_t *offset); +H5_DLL herr_t H5S_select_adjust_s(H5S_t *space, const hssize_t *offset); +H5_DLL herr_t H5S_select_project_scalar(const H5S_t *space, hsize_t *offset); +H5_DLL herr_t H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); +H5_DLL herr_t H5S_select_project_intersection(H5S_t *src_space, H5S_t *dst_space, H5S_t *src_intersect_space, + H5S_t **new_space_ptr, hbool_t share_space); +H5_DLL herr_t H5S_select_subtract(H5S_t *space, H5S_t *subtract_space); /* Operations on all selections */ H5_DLL herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev); @@ -293,8 +292,7 @@ H5_DLL H5S_t * H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index H5_DLL hsize_t H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *partial); /* Operations on selection iterators */ -H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, const H5S_t *space, size_t elmt_size, - unsigned flags); +H5_DLL herr_t H5S_select_iter_init(H5S_sel_iter_t *iter, H5S_t *space, size_t elmt_size, unsigned flags); H5_DLL herr_t H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords); H5_DLL hsize_t H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter); H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 7a0ea3c..9b35cd3 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -304,7 +304,7 @@ done: *------------------------------------------------------------------------- */ hssize_t -H5S_select_serial_size(const H5S_t *space) +H5S_select_serial_size(H5S_t *space) { hssize_t ret_value = -1; /* Return value */ @@ -343,7 +343,7 @@ H5S_select_serial_size(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_serialize(const H5S_t *space, uint8_t **p) +H5S_select_serialize(H5S_t *space, uint8_t **p) { herr_t ret_value = SUCCEED; /* Return value */ @@ -880,7 +880,7 @@ H5S_select_is_single(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S_select_is_regular(const H5S_t *space) +H5S_select_is_regular(H5S_t *space) { herr_t ret_value = FAIL; /* Return value */ @@ -1116,7 +1116,7 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) in the dataspace's selection. --------------------------------------------------------------------------*/ herr_t -H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_size, unsigned flags) +H5S_select_iter_init(H5S_sel_iter_t *sel_iter, H5S_t *space, size_t elmt_size, unsigned flags) { herr_t ret_value = FAIL; /* Return value */ @@ -1497,8 +1497,7 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter) the selection is not modified. --------------------------------------------------------------------------*/ herr_t -H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, const H5S_sel_iter_op_t *op, - void *op_data) +H5S_select_iterate(void *buf, const H5T_t *type, H5S_t *space, const H5S_sel_iter_op_t *op, void *op_data) { H5S_sel_iter_t *iter = NULL; /* Selection iteration info */ hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ @@ -1739,7 +1738,7 @@ H5S_get_select_type(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) +H5S_select_shape_same(H5S_t *space1, H5S_t *space2) { H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */ H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */ @@ -1760,8 +1759,8 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) /* Check special cases if both dataspaces aren't scalar */ /* (If only one is, the number of selected points check is sufficient) */ if (space1->extent.rank > 0 && space2->extent.rank > 0) { - const H5S_t *space_a; /* Dataspace with larger rank */ - const H5S_t *space_b; /* Dataspace with smaller rank */ + H5S_t * space_a; /* Dataspace with larger rank */ + H5S_t * space_b; /* Dataspace with smaller rank */ unsigned space_a_rank; /* Number of dimensions of dataspace A */ unsigned space_b_rank; /* Number of dimensions of dataspace B */ int space_a_dim; /* Current dimension in dataspace A */ @@ -2063,7 +2062,7 @@ done: don't call it directly, use the appropriate macro defined in H5Sprivate.h. --------------------------------------------------------------------------*/ htri_t -H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end) +H5S_select_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end) { htri_t ret_value = TRUE; /* Return value */ @@ -2214,7 +2213,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, unsigned new_space_rank, +H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, unsigned new_space_rank, const void *buf, void const **adj_buf_ptr, hsize_t element_size) { H5S_t * new_space = NULL; /* New dataspace constructed */ @@ -2452,7 +2451,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_buf) +H5S_select_fill(const void *fill, size_t fill_size, H5S_t *space, void *_buf) { H5S_sel_iter_t *iter = NULL; /* Selection iteration info */ hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ @@ -2568,9 +2567,8 @@ to share structures inside dst_space with proj_space REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, - const H5S_t *src_intersect_space, H5S_t **new_space_ptr, - hbool_t share_selection) +H5S_select_project_intersection(H5S_t *src_space, H5S_t *dst_space, H5S_t *src_intersect_space, + H5S_t **new_space_ptr, hbool_t share_selection) { H5S_t * new_space = NULL; /* New dataspace constructed */ H5S_t * tmp_src_intersect_space = NULL; /* Temporary SIS converted from points->hyperslabs */ diff --git a/src/H5T.c b/src/H5T.c index 19a3d39..c23f85d 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -368,12 +368,9 @@ H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR; /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* * Predefined data types. These are initialized at runtime in H5Tinit.c and - * by H5T__init_package() in this source file. + * by H5T_init() in this source file. * * If more of these are added, the new ones must be added to the list of * types to reset in H5T_term_package(). @@ -423,31 +420,29 @@ hid_t H5T_C_S1_g = FAIL; hid_t H5T_FORTRAN_S1_g = FAIL; -hid_t H5T_NATIVE_SCHAR_g = FAIL; -hid_t H5T_NATIVE_UCHAR_g = FAIL; -hid_t H5T_NATIVE_SHORT_g = FAIL; -hid_t H5T_NATIVE_USHORT_g = FAIL; -hid_t H5T_NATIVE_INT_g = FAIL; -hid_t H5T_NATIVE_UINT_g = FAIL; -hid_t H5T_NATIVE_LONG_g = FAIL; -hid_t H5T_NATIVE_ULONG_g = FAIL; -hid_t H5T_NATIVE_LLONG_g = FAIL; -hid_t H5T_NATIVE_ULLONG_g = FAIL; -hid_t H5T_NATIVE_FLOAT_g = FAIL; -hid_t H5T_NATIVE_DOUBLE_g = FAIL; -#if H5_SIZEOF_LONG_DOUBLE != 0 +hid_t H5T_NATIVE_SCHAR_g = FAIL; +hid_t H5T_NATIVE_UCHAR_g = FAIL; +hid_t H5T_NATIVE_SHORT_g = FAIL; +hid_t H5T_NATIVE_USHORT_g = FAIL; +hid_t H5T_NATIVE_INT_g = FAIL; +hid_t H5T_NATIVE_UINT_g = FAIL; +hid_t H5T_NATIVE_LONG_g = FAIL; +hid_t H5T_NATIVE_ULONG_g = FAIL; +hid_t H5T_NATIVE_LLONG_g = FAIL; +hid_t H5T_NATIVE_ULLONG_g = FAIL; +hid_t H5T_NATIVE_FLOAT_g = FAIL; +hid_t H5T_NATIVE_DOUBLE_g = FAIL; hid_t H5T_NATIVE_LDOUBLE_g = FAIL; -#endif -hid_t H5T_NATIVE_B8_g = FAIL; -hid_t H5T_NATIVE_B16_g = FAIL; -hid_t H5T_NATIVE_B32_g = FAIL; -hid_t H5T_NATIVE_B64_g = FAIL; -hid_t H5T_NATIVE_OPAQUE_g = FAIL; -hid_t H5T_NATIVE_HADDR_g = FAIL; -hid_t H5T_NATIVE_HSIZE_g = FAIL; -hid_t H5T_NATIVE_HSSIZE_g = FAIL; -hid_t H5T_NATIVE_HERR_g = FAIL; -hid_t H5T_NATIVE_HBOOL_g = FAIL; +hid_t H5T_NATIVE_B8_g = FAIL; +hid_t H5T_NATIVE_B16_g = FAIL; +hid_t H5T_NATIVE_B32_g = FAIL; +hid_t H5T_NATIVE_B64_g = FAIL; +hid_t H5T_NATIVE_OPAQUE_g = FAIL; +hid_t H5T_NATIVE_HADDR_g = FAIL; +hid_t H5T_NATIVE_HSIZE_g = FAIL; +hid_t H5T_NATIVE_HSSIZE_g = FAIL; +hid_t H5T_NATIVE_HERR_g = FAIL; +hid_t H5T_NATIVE_HBOOL_g = FAIL; hid_t H5T_NATIVE_INT8_g = FAIL; hid_t H5T_NATIVE_UINT8_g = FAIL; @@ -483,21 +478,19 @@ hid_t H5T_NATIVE_UINT_FAST64_g = FAIL; * datatype or C structures, which are different from the alignments for memory * address below this group of variables. */ -size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_UCHAR_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_SHORT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_USHORT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_INT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_LONG_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_ULONG_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_LLONG_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_ULLONG_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g = 0; -size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g = 0; -#if H5_SIZEOF_LONG_DOUBLE != 0 +size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_UCHAR_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_SHORT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_USHORT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_INT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_LONG_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_ULONG_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_LLONG_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_ULLONG_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g = 0; +size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g = 0; size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g = 0; -#endif size_t H5T_POINTER_COMP_ALIGN_g = 0; size_t H5T_HVL_COMP_ALIGN_g = 0; @@ -509,21 +502,19 @@ size_t H5T_REF_COMP_ALIGN_g = 0; * Alignment constraints for native types. These are initialized at run time * in H5Tinit.c */ -size_t H5T_NATIVE_SCHAR_ALIGN_g = 0; -size_t H5T_NATIVE_UCHAR_ALIGN_g = 0; -size_t H5T_NATIVE_SHORT_ALIGN_g = 0; -size_t H5T_NATIVE_USHORT_ALIGN_g = 0; -size_t H5T_NATIVE_INT_ALIGN_g = 0; -size_t H5T_NATIVE_UINT_ALIGN_g = 0; -size_t H5T_NATIVE_LONG_ALIGN_g = 0; -size_t H5T_NATIVE_ULONG_ALIGN_g = 0; -size_t H5T_NATIVE_LLONG_ALIGN_g = 0; -size_t H5T_NATIVE_ULLONG_ALIGN_g = 0; -size_t H5T_NATIVE_FLOAT_ALIGN_g = 0; -size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0; -#if H5_SIZEOF_LONG_DOUBLE != 0 +size_t H5T_NATIVE_SCHAR_ALIGN_g = 0; +size_t H5T_NATIVE_UCHAR_ALIGN_g = 0; +size_t H5T_NATIVE_SHORT_ALIGN_g = 0; +size_t H5T_NATIVE_USHORT_ALIGN_g = 0; +size_t H5T_NATIVE_INT_ALIGN_g = 0; +size_t H5T_NATIVE_UINT_ALIGN_g = 0; +size_t H5T_NATIVE_LONG_ALIGN_g = 0; +size_t H5T_NATIVE_ULONG_ALIGN_g = 0; +size_t H5T_NATIVE_LLONG_ALIGN_g = 0; +size_t H5T_NATIVE_ULLONG_ALIGN_g = 0; +size_t H5T_NATIVE_FLOAT_ALIGN_g = 0; +size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0; size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; -#endif /* * Alignment constraints for C9x types. These are initialized at run time in @@ -606,34 +597,6 @@ static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ (H5I_free_t)H5T__close_cb /* Callback routine for closing objects of this class */ }}; -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5T_top_package_initialize_s = FALSE; - -/*------------------------------------------------------------------------- - * Function: H5T_init - * - * Purpose: Initialize the interface from some other package. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Robb Matzke - * Wednesday, December 16, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5T_init(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_init() */ - /*------------------------------------------------------------------------- * Function: H5T__init_inf * @@ -746,62 +709,58 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__init_inf() */ -/*-------------------------------------------------------------------------- -NAME - H5T__init_package -- Initialize interface-specific information -USAGE - herr__t H5T_init_package() -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5T_init + * + * Purpose: Initialize the interface from some other layer. + * + * Return: Success: non-negative + * Failure: negative + *------------------------------------------------------------------------- + */ herr_t -H5T__init_package(void) +H5T_init(void) { - H5T_t *native_schar = NULL; /* Datatype structure for native signed char */ - H5T_t *native_uchar = NULL; /* Datatype structure for native unsigned char */ - H5T_t *native_short = NULL; /* Datatype structure for native short */ - H5T_t *native_ushort = NULL; /* Datatype structure for native unsigned short */ - H5T_t *native_int = NULL; /* Datatype structure for native int */ - H5T_t *native_uint = NULL; /* Datatype structure for native unsigned int */ - H5T_t *native_long = NULL; /* Datatype structure for native long */ - H5T_t *native_ulong = NULL; /* Datatype structure for native unsigned long */ - H5T_t *native_llong = NULL; /* Datatype structure for native long long */ - H5T_t *native_ullong = NULL; /* Datatype structure for native unsigned long long */ - H5T_t *native_float = NULL; /* Datatype structure for native float */ - H5T_t *native_double = NULL; /* Datatype structure for native double */ -#if H5_SIZEOF_LONG_DOUBLE != 0 - H5T_t *native_ldouble = NULL; /* Datatype structure for native long double */ -#endif - H5T_t * std_u8le = NULL; /* Datatype structure for unsigned 8-bit little-endian integer */ - H5T_t * std_u8be = NULL; /* Datatype structure for unsigned 8-bit big-endian integer */ - H5T_t * std_u16le = NULL; /* Datatype structure for unsigned 16-bit little-endian integer */ - H5T_t * std_u16be = NULL; /* Datatype structure for unsigned 16-bit big-endian integer */ - H5T_t * std_u32le = NULL; /* Datatype structure for unsigned 32-bit little-endian integer */ - H5T_t * std_u32be = NULL; /* Datatype structure for unsigned 32-bit big-endian integer */ - H5T_t * std_u64le = NULL; /* Datatype structure for unsigned 64-bit little-endian integer */ - H5T_t * std_u64be = NULL; /* Datatype structure for unsigned 64-bit big-endian integer */ - H5T_t * dt = NULL; - H5T_t * fixedpt = NULL; /* Datatype structure for native int */ - H5T_t * floatpt = NULL; /* Datatype structure for native float */ - H5T_t * string = NULL; /* Datatype structure for C string */ - H5T_t * bitfield = NULL; /* Datatype structure for bitfield */ - H5T_t * compound = NULL; /* Datatype structure for compound objects */ - H5T_t * enum_type = NULL; /* Datatype structure for enum objects */ - H5T_t * vlen = NULL; /* Datatype structure for vlen objects */ - H5T_t * array = NULL; /* Datatype structure for array objects */ - H5T_t * objref = NULL; /* Datatype structure for deprecated reference objects */ - H5T_t * regref = NULL; /* Datatype structure for deprecated region references */ - H5T_t * ref = NULL; /* Datatype structure for opaque references */ - hsize_t dim[1] = {1}; /* Dimension info for array datatype */ + H5T_t * native_schar = NULL; /* Datatype structure for native signed char */ + H5T_t * native_uchar = NULL; /* Datatype structure for native unsigned char */ + H5T_t * native_short = NULL; /* Datatype structure for native short */ + H5T_t * native_ushort = NULL; /* Datatype structure for native unsigned short */ + H5T_t * native_int = NULL; /* Datatype structure for native int */ + H5T_t * native_uint = NULL; /* Datatype structure for native unsigned int */ + H5T_t * native_long = NULL; /* Datatype structure for native long */ + H5T_t * native_ulong = NULL; /* Datatype structure for native unsigned long */ + H5T_t * native_llong = NULL; /* Datatype structure for native long long */ + H5T_t * native_ullong = NULL; /* Datatype structure for native unsigned long long */ + H5T_t * native_float = NULL; /* Datatype structure for native float */ + H5T_t * native_double = NULL; /* Datatype structure for native double */ + H5T_t * native_ldouble = NULL; /* Datatype structure for native long double */ + H5T_t * std_u8le = NULL; /* Datatype structure for unsigned 8-bit little-endian integer */ + H5T_t * std_u8be = NULL; /* Datatype structure for unsigned 8-bit big-endian integer */ + H5T_t * std_u16le = NULL; /* Datatype structure for unsigned 16-bit little-endian integer */ + H5T_t * std_u16be = NULL; /* Datatype structure for unsigned 16-bit big-endian integer */ + H5T_t * std_u32le = NULL; /* Datatype structure for unsigned 32-bit little-endian integer */ + H5T_t * std_u32be = NULL; /* Datatype structure for unsigned 32-bit big-endian integer */ + H5T_t * std_u64le = NULL; /* Datatype structure for unsigned 64-bit little-endian integer */ + H5T_t * std_u64be = NULL; /* Datatype structure for unsigned 64-bit big-endian integer */ + H5T_t * dt = NULL; + H5T_t * fixedpt = NULL; /* Datatype structure for native int */ + H5T_t * floatpt = NULL; /* Datatype structure for native float */ + H5T_t * string = NULL; /* Datatype structure for C string */ + H5T_t * bitfield = NULL; /* Datatype structure for bitfield */ + H5T_t * compound = NULL; /* Datatype structure for compound objects */ + H5T_t * enum_type = NULL; /* Datatype structure for enum objects */ + H5T_t * vlen = NULL; /* Datatype structure for vlen objects */ + H5T_t * array = NULL; /* Datatype structure for array objects */ + H5T_t * objref = NULL; /* Datatype structure for deprecated reference objects */ + H5T_t * regref = NULL; /* Datatype structure for deprecated region references */ + H5T_t * ref = NULL; /* Datatype structure for opaque references */ + hsize_t dim[1] = {1}; /* Dimension info for array datatype */ herr_t status; hbool_t copied_dtype = TRUE; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(FAIL) /* Initialize the ID group for the file IDs */ if (H5I_register_type(H5I_DATATYPE_CLS) < 0) @@ -843,10 +802,8 @@ H5T__init_package(void) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") if (NULL == (native_double = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") -#if H5_SIZEOF_LONG_DOUBLE != 0 if (NULL == (native_ldouble = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object") -#endif /*------------------------------------------------------------ * Derived native types @@ -1116,7 +1073,6 @@ H5T__init_package(void) H5T__register_int(H5T_PERS_HARD, "flt_dbl", native_float, native_double, H5T__conv_float_double); status |= H5T__register_int(H5T_PERS_HARD, "dbl_flt", native_double, native_float, H5T__conv_double_float); -#if H5_SIZEOF_LONG_DOUBLE != 0 status |= H5T__register_int(H5T_PERS_HARD, "flt_ldbl", native_float, native_ldouble, H5T__conv_float_ldouble); status |= @@ -1125,7 +1081,6 @@ H5T__init_package(void) H5T__register_int(H5T_PERS_HARD, "ldbl_flt", native_ldouble, native_float, H5T__conv_ldouble_float); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_dbl", native_ldouble, native_double, H5T__conv_ldouble_double); -#endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ /* from long long */ status |= @@ -1445,7 +1400,7 @@ H5T__init_package(void) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function(s)") /* Register datatype creation property class properties here. See similar - * code in H5D__init_package(), etc. for example. + * code in H5D_init(), etc. for example. */ /* Only register the default property list if it hasn't been created yet */ @@ -1458,9 +1413,6 @@ H5T__init_package(void) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ - /* Mark "top" of interface as initialized, too */ - H5T_top_package_initialize_s = TRUE; - done: /* General cleanup */ if (compound != NULL) @@ -1488,7 +1440,7 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__init_package() */ +} /* end H5T_init() */ /*------------------------------------------------------------------------- * Function: H5T__unlock_cb @@ -1544,185 +1496,177 @@ H5T_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5T_top_package_initialize_s) { - /* Unregister all conversion functions */ - if (H5T_g.path) { - int i, nprint = 0; - - for (i = 0; i < H5T_g.npaths; i++) { - H5T_path_t *path; - - path = H5T_g.path[i]; - HDassert(path); - if (path->conv.u.app_func) { - H5T__print_stats(path, &nprint /*in,out*/); - path->cdata.command = H5T_CONV_FREE; - if (path->conv.is_app) { - if ((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, - (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { + /* Unregister all conversion functions */ + if (H5T_g.path) { + int i, nprint = 0; + + for (i = 0; i < H5T_g.npaths; i++) { + H5T_path_t *path; + + path = H5T_g.path[i]; + HDassert(path); + if (path->conv.u.app_func) { + H5T__print_stats(path, &nprint /*in,out*/); + path->cdata.command = H5T_CONV_FREE; + if (path->conv.is_app) { + if ((path->conv.u.app_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL, H5CX_get_dxpl()) < 0) { #ifdef H5T_DEBUG - if (H5DEBUG(T)) { - HDfprintf(H5DEBUG(T), - "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->conv.u.app_func), path->name); - } /* end if */ + if (H5DEBUG(T)) { + HDfprintf(H5DEBUG(T), + "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->conv.u.app_func), path->name); + } /* end if */ #endif - H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end if */ - else { - if ((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, - (size_t)0, (size_t)0, NULL, NULL) < 0) { + H5E_clear_stack(NULL); /*ignore the error*/ + } /* end if */ + } /* end if */ + else { + if ((path->conv.u.lib_func)((hid_t)FAIL, (hid_t)FAIL, &(path->cdata), (size_t)0, + (size_t)0, (size_t)0, NULL, NULL) < 0) { #ifdef H5T_DEBUG - if (H5DEBUG(T)) { - HDfprintf(H5DEBUG(T), - "H5T: conversion function " - "0x%08lx failed to free private data for " - "%s (ignored)\n", - (unsigned long)(path->conv.u.lib_func), path->name); - } /* end if */ + if (H5DEBUG(T)) { + HDfprintf(H5DEBUG(T), + "H5T: conversion function " + "0x%08lx failed to free private data for " + "%s (ignored)\n", + (unsigned long)(path->conv.u.lib_func), path->name); + } /* end if */ #endif - H5E_clear_stack(NULL); /*ignore the error*/ - } /* end if */ - } /* end else */ - } /* end if */ - - if (path->src) - (void)H5T_close_real(path->src); - if (path->dst) - (void)H5T_close_real(path->dst); - path = H5FL_FREE(H5T_path_t, path); - H5T_g.path[i] = NULL; - } /* end for */ + H5E_clear_stack(NULL); /*ignore the error*/ + } /* end if */ + } /* end else */ + } /* end if */ + + if (path->src) + (void)H5T_close_real(path->src); + if (path->dst) + (void)H5T_close_real(path->dst); + path = H5FL_FREE(H5T_path_t, path); + H5T_g.path[i] = NULL; + } /* end for */ - /* Clear conversion tables */ - H5T_g.path = (H5T_path_t **)H5MM_xfree(H5T_g.path); - H5T_g.npaths = 0; - H5T_g.apaths = 0; - H5T_g.soft = (H5T_soft_t *)H5MM_xfree(H5T_g.soft); - H5T_g.nsoft = 0; - H5T_g.asoft = 0; + /* Clear conversion tables */ + H5T_g.path = (H5T_path_t **)H5MM_xfree(H5T_g.path); + H5T_g.npaths = 0; + H5T_g.apaths = 0; + H5T_g.soft = (H5T_soft_t *)H5MM_xfree(H5T_g.soft); + H5T_g.nsoft = 0; + H5T_g.asoft = 0; - n++; - } /* end if */ - - /* Unlock all datatypes, then free them */ - /* note that we are ignoring the return value from H5I_iterate() */ - /* Also note that we are incrementing 'n' in the callback */ - H5I_iterate(H5I_DATATYPE, H5T__unlock_cb, &n, FALSE); - - /* Release all datatype IDs */ - if (H5I_nmembers(H5I_DATATYPE) > 0) { - (void)H5I_clear_type(H5I_DATATYPE, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Reset all the datatype IDs */ - if (H5T_IEEE_F32BE_g > 0) { - H5T_IEEE_F32BE_g = FAIL; - H5T_IEEE_F32LE_g = FAIL; - H5T_IEEE_F64BE_g = FAIL; - H5T_IEEE_F64LE_g = FAIL; - - H5T_STD_I8BE_g = FAIL; - H5T_STD_I8LE_g = FAIL; - H5T_STD_I16BE_g = FAIL; - H5T_STD_I16LE_g = FAIL; - H5T_STD_I32BE_g = FAIL; - H5T_STD_I32LE_g = FAIL; - H5T_STD_I64BE_g = FAIL; - H5T_STD_I64LE_g = FAIL; - H5T_STD_U8BE_g = FAIL; - H5T_STD_U8LE_g = FAIL; - H5T_STD_U16BE_g = FAIL; - H5T_STD_U16LE_g = FAIL; - H5T_STD_U32BE_g = FAIL; - H5T_STD_U32LE_g = FAIL; - H5T_STD_U64BE_g = FAIL; - H5T_STD_U64LE_g = FAIL; - H5T_STD_B8BE_g = FAIL; - H5T_STD_B8LE_g = FAIL; - H5T_STD_B16BE_g = FAIL; - H5T_STD_B16LE_g = FAIL; - H5T_STD_B32BE_g = FAIL; - H5T_STD_B32LE_g = FAIL; - H5T_STD_B64BE_g = FAIL; - H5T_STD_B64LE_g = FAIL; - H5T_STD_REF_OBJ_g = FAIL; - H5T_STD_REF_DSETREG_g = FAIL; - H5T_STD_REF_g = FAIL; - - H5T_UNIX_D32BE_g = FAIL; - H5T_UNIX_D32LE_g = FAIL; - H5T_UNIX_D64BE_g = FAIL; - H5T_UNIX_D64LE_g = FAIL; - - H5T_C_S1_g = FAIL; - - H5T_FORTRAN_S1_g = FAIL; - - H5T_NATIVE_SCHAR_g = FAIL; - H5T_NATIVE_UCHAR_g = FAIL; - H5T_NATIVE_SHORT_g = FAIL; - H5T_NATIVE_USHORT_g = FAIL; - H5T_NATIVE_INT_g = FAIL; - H5T_NATIVE_UINT_g = FAIL; - H5T_NATIVE_LONG_g = FAIL; - H5T_NATIVE_ULONG_g = FAIL; - H5T_NATIVE_LLONG_g = FAIL; - H5T_NATIVE_ULLONG_g = FAIL; - H5T_NATIVE_FLOAT_g = FAIL; - H5T_NATIVE_DOUBLE_g = FAIL; -#if H5_SIZEOF_LONG_DOUBLE != 0 - H5T_NATIVE_LDOUBLE_g = FAIL; -#endif - H5T_NATIVE_B8_g = FAIL; - H5T_NATIVE_B16_g = FAIL; - H5T_NATIVE_B32_g = FAIL; - H5T_NATIVE_B64_g = FAIL; - H5T_NATIVE_OPAQUE_g = FAIL; - H5T_NATIVE_HADDR_g = FAIL; - H5T_NATIVE_HSIZE_g = FAIL; - H5T_NATIVE_HSSIZE_g = FAIL; - H5T_NATIVE_HERR_g = FAIL; - H5T_NATIVE_HBOOL_g = FAIL; - - H5T_NATIVE_INT8_g = FAIL; - H5T_NATIVE_UINT8_g = FAIL; - H5T_NATIVE_INT_LEAST8_g = FAIL; - H5T_NATIVE_UINT_LEAST8_g = FAIL; - H5T_NATIVE_INT_FAST8_g = FAIL; - H5T_NATIVE_UINT_FAST8_g = FAIL; - - H5T_NATIVE_INT16_g = FAIL; - H5T_NATIVE_UINT16_g = FAIL; - H5T_NATIVE_INT_LEAST16_g = FAIL; - H5T_NATIVE_UINT_LEAST16_g = FAIL; - H5T_NATIVE_INT_FAST16_g = FAIL; - H5T_NATIVE_UINT_FAST16_g = FAIL; - - H5T_NATIVE_INT32_g = FAIL; - H5T_NATIVE_UINT32_g = FAIL; - H5T_NATIVE_INT_LEAST32_g = FAIL; - H5T_NATIVE_UINT_LEAST32_g = FAIL; - H5T_NATIVE_INT_FAST32_g = FAIL; - H5T_NATIVE_UINT_FAST32_g = FAIL; - - H5T_NATIVE_INT64_g = FAIL; - H5T_NATIVE_UINT64_g = FAIL; - H5T_NATIVE_INT_LEAST64_g = FAIL; - H5T_NATIVE_UINT_LEAST64_g = FAIL; - H5T_NATIVE_INT_FAST64_g = FAIL; - H5T_NATIVE_UINT_FAST64_g = FAIL; - - n++; - } /* end if */ + n++; + } /* end if */ - /* Mark "top" of interface as closed */ - if (0 == n) - H5T_top_package_initialize_s = FALSE; + /* Unlock all datatypes, then free them */ + /* note that we are ignoring the return value from H5I_iterate() */ + /* Also note that we are incrementing 'n' in the callback */ + H5I_iterate(H5I_DATATYPE, H5T__unlock_cb, &n, FALSE); + + /* Release all datatype IDs */ + if (H5I_nmembers(H5I_DATATYPE) > 0) { + (void)H5I_clear_type(H5I_DATATYPE, FALSE, FALSE); + n++; /*H5I*/ + } /* end if */ + + /* Reset all the datatype IDs */ + if (H5T_IEEE_F32BE_g > 0) { + H5T_IEEE_F32BE_g = FAIL; + H5T_IEEE_F32LE_g = FAIL; + H5T_IEEE_F64BE_g = FAIL; + H5T_IEEE_F64LE_g = FAIL; + + H5T_STD_I8BE_g = FAIL; + H5T_STD_I8LE_g = FAIL; + H5T_STD_I16BE_g = FAIL; + H5T_STD_I16LE_g = FAIL; + H5T_STD_I32BE_g = FAIL; + H5T_STD_I32LE_g = FAIL; + H5T_STD_I64BE_g = FAIL; + H5T_STD_I64LE_g = FAIL; + H5T_STD_U8BE_g = FAIL; + H5T_STD_U8LE_g = FAIL; + H5T_STD_U16BE_g = FAIL; + H5T_STD_U16LE_g = FAIL; + H5T_STD_U32BE_g = FAIL; + H5T_STD_U32LE_g = FAIL; + H5T_STD_U64BE_g = FAIL; + H5T_STD_U64LE_g = FAIL; + H5T_STD_B8BE_g = FAIL; + H5T_STD_B8LE_g = FAIL; + H5T_STD_B16BE_g = FAIL; + H5T_STD_B16LE_g = FAIL; + H5T_STD_B32BE_g = FAIL; + H5T_STD_B32LE_g = FAIL; + H5T_STD_B64BE_g = FAIL; + H5T_STD_B64LE_g = FAIL; + H5T_STD_REF_OBJ_g = FAIL; + H5T_STD_REF_DSETREG_g = FAIL; + H5T_STD_REF_g = FAIL; + + H5T_UNIX_D32BE_g = FAIL; + H5T_UNIX_D32LE_g = FAIL; + H5T_UNIX_D64BE_g = FAIL; + H5T_UNIX_D64LE_g = FAIL; + + H5T_C_S1_g = FAIL; + + H5T_FORTRAN_S1_g = FAIL; + + H5T_NATIVE_SCHAR_g = FAIL; + H5T_NATIVE_UCHAR_g = FAIL; + H5T_NATIVE_SHORT_g = FAIL; + H5T_NATIVE_USHORT_g = FAIL; + H5T_NATIVE_INT_g = FAIL; + H5T_NATIVE_UINT_g = FAIL; + H5T_NATIVE_LONG_g = FAIL; + H5T_NATIVE_ULONG_g = FAIL; + H5T_NATIVE_LLONG_g = FAIL; + H5T_NATIVE_ULLONG_g = FAIL; + H5T_NATIVE_FLOAT_g = FAIL; + H5T_NATIVE_DOUBLE_g = FAIL; + H5T_NATIVE_LDOUBLE_g = FAIL; + H5T_NATIVE_B8_g = FAIL; + H5T_NATIVE_B16_g = FAIL; + H5T_NATIVE_B32_g = FAIL; + H5T_NATIVE_B64_g = FAIL; + H5T_NATIVE_OPAQUE_g = FAIL; + H5T_NATIVE_HADDR_g = FAIL; + H5T_NATIVE_HSIZE_g = FAIL; + H5T_NATIVE_HSSIZE_g = FAIL; + H5T_NATIVE_HERR_g = FAIL; + H5T_NATIVE_HBOOL_g = FAIL; + + H5T_NATIVE_INT8_g = FAIL; + H5T_NATIVE_UINT8_g = FAIL; + H5T_NATIVE_INT_LEAST8_g = FAIL; + H5T_NATIVE_UINT_LEAST8_g = FAIL; + H5T_NATIVE_INT_FAST8_g = FAIL; + H5T_NATIVE_UINT_FAST8_g = FAIL; + + H5T_NATIVE_INT16_g = FAIL; + H5T_NATIVE_UINT16_g = FAIL; + H5T_NATIVE_INT_LEAST16_g = FAIL; + H5T_NATIVE_UINT_LEAST16_g = FAIL; + H5T_NATIVE_INT_FAST16_g = FAIL; + H5T_NATIVE_UINT_FAST16_g = FAIL; + + H5T_NATIVE_INT32_g = FAIL; + H5T_NATIVE_UINT32_g = FAIL; + H5T_NATIVE_INT_LEAST32_g = FAIL; + H5T_NATIVE_UINT_LEAST32_g = FAIL; + H5T_NATIVE_INT_FAST32_g = FAIL; + H5T_NATIVE_UINT_FAST32_g = FAIL; + + H5T_NATIVE_INT64_g = FAIL; + H5T_NATIVE_UINT64_g = FAIL; + H5T_NATIVE_INT_LEAST64_g = FAIL; + H5T_NATIVE_UINT_LEAST64_g = FAIL; + H5T_NATIVE_INT_FAST64_g = FAIL; + H5T_NATIVE_UINT_FAST64_g = FAIL; + + n++; } /* end if */ FUNC_LEAVE_NOAPI(n) @@ -1753,18 +1697,11 @@ H5T_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - /* Sanity check */ - HDassert(0 == H5I_nmembers(H5I_DATATYPE)); - HDassert(FALSE == H5T_top_package_initialize_s); - - /* Destroy the datatype object id group */ - n += (H5I_dec_type_ref(H5I_DATATYPE) > 0); + /* Sanity check */ + HDassert(0 == H5I_nmembers(H5I_DATATYPE)); - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ + /* Destroy the datatype object id group */ + n += (H5I_dec_type_ref(H5I_DATATYPE) > 0); FUNC_LEAVE_NOAPI(n) } /* end H5T_term_package() */ @@ -2184,7 +2121,7 @@ H5T_get_class(const H5T_t *dt, htri_t internal) { H5T_class_t ret_value = H5T_NO_CLASS; /* Return value */ - FUNC_ENTER_NOAPI(H5T_NO_CLASS) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); @@ -2199,7 +2136,6 @@ H5T_get_class(const H5T_t *dt, htri_t internal) ret_value = dt->shared->type; } -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_class() */ @@ -2257,7 +2193,7 @@ H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api) unsigned i; htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); HDassert(cls > H5T_NO_CLASS && cls < H5T_NCLASSES); @@ -5640,14 +5576,13 @@ H5T_is_immutable(const H5T_t *dt) { htri_t ret_value = FALSE; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); if (dt->shared->state == H5T_STATE_IMMUTABLE) ret_value = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } @@ -5665,7 +5600,7 @@ H5T_is_named(const H5T_t *dt) { htri_t ret_value = FALSE; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); @@ -5674,7 +5609,6 @@ H5T_is_named(const H5T_t *dt) else ret_value = (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state); -done: FUNC_LEAVE_NOAPI(ret_value) } @@ -5752,14 +5686,13 @@ H5T_get_ref_type(const H5T_t *dt) { H5R_type_t ret_value = H5R_BADTYPE; - FUNC_ENTER_NOAPI(H5R_BADTYPE) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); if (dt->shared->type == H5T_REFERENCE) ret_value = dt->shared->u.atomic.u.r.rtype; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_ref_type() */ @@ -5782,7 +5715,7 @@ H5T_is_sensible(const H5T_t *dt) { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(dt); @@ -5820,7 +5753,6 @@ H5T_is_sensible(const H5T_t *dt) break; } /* end switch */ -done: FUNC_LEAVE_NOAPI(ret_value) } @@ -6013,7 +5945,7 @@ H5T_is_relocatable(const H5T_t *dt) { htri_t ret_value = FALSE; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(dt); @@ -6022,7 +5954,6 @@ H5T_is_relocatable(const H5T_t *dt) if (H5T_detect_class(dt, H5T_VLEN, FALSE) || H5T_detect_class(dt, H5T_REFERENCE, FALSE)) ret_value = TRUE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_relocatable() */ @@ -6113,7 +6044,7 @@ H5T_is_vl_storage(const H5T_t *dt) { htri_t ret_value = FALSE; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(dt); @@ -6126,7 +6057,6 @@ H5T_is_vl_storage(const H5T_t *dt) else ret_value = FALSE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_is_vl_storage() */ @@ -6280,7 +6210,7 @@ H5T_patch_file(H5T_t *dt, H5F_t *f) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(dt); @@ -6291,7 +6221,6 @@ H5T_patch_file(H5T_t *dt, H5F_t *f) dt->sh_loc.file = f; } /* end if */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_patch_file() */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 273bb23..c796c00 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -7009,14 +7009,12 @@ H5T__conv_float_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE != 0 herr_t H5T__conv_float_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_fF(FLOAT, LDOUBLE, float, long double, -, -); } -#endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ /*------------------------------------------------------------------------- * Function: H5T__conv_double_float @@ -7051,14 +7049,12 @@ H5T__conv_double_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE != 0 herr_t H5T__conv_double_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_fF(DOUBLE, LDOUBLE, double, long double, -, -); } -#endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_float @@ -7073,14 +7069,12 @@ H5T__conv_double_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t * *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE != 0 herr_t H5T__conv_ldouble_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ff(LDOUBLE, FLOAT, long double, float, -FLT_MAX, FLT_MAX); } -#endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ /*------------------------------------------------------------------------- * Function: H5T__conv_ldouble_double @@ -7095,14 +7089,12 @@ H5T__conv_ldouble_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t n * *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE != 0 herr_t H5T__conv_ldouble_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { H5T_CONV_Ff(LDOUBLE, DOUBLE, long double, double, -DBL_MAX, DBL_MAX); } -#endif /* H5_SIZEOF_LONG_DOUBLE != 0 */ /*------------------------------------------------------------------------- * Function: H5T__conv_schar_float diff --git a/src/H5Tnative.c b/src/H5Tnative.c index 2688b23..c9a2907 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -718,9 +718,7 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali enum match_type { /* The different kinds of floating point types we can match */ H5T_NATIVE_FLOAT_MATCH_FLOAT, H5T_NATIVE_FLOAT_MATCH_DOUBLE, -#if H5_SIZEOF_LONG_DOUBLE != 0 H5T_NATIVE_FLOAT_MATCH_LDOUBLE, -#endif H5T_NATIVE_FLOAT_MATCH_UNKNOWN } match = H5T_NATIVE_FLOAT_MATCH_UNKNOWN; H5T_t *ret_value = NULL; /* Return value */ @@ -738,24 +736,16 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; native_size = sizeof(double); } -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (size <= sizeof(long double)) { match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; native_size = sizeof(long double); } -#endif else { /* If not match, return the biggest datatype */ -#if H5_SIZEOF_LONG_DOUBLE != 0 match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; native_size = sizeof(long double); -#else - match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; - native_size = sizeof(double); -#endif } } else { -#if H5_SIZEOF_LONG_DOUBLE != 0 if (size > sizeof(double)) { match = H5T_NATIVE_FLOAT_MATCH_LDOUBLE; native_size = sizeof(long double); @@ -768,16 +758,6 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali match = H5T_NATIVE_FLOAT_MATCH_FLOAT; native_size = sizeof(float); } -#else - if (size > sizeof(float)) { - match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; - native_size = sizeof(double); - } - else { - match = H5T_NATIVE_FLOAT_MATCH_FLOAT; - native_size = sizeof(float); - } -#endif } /* Set the appropriate native floating point information */ @@ -792,12 +772,11 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali align = H5T_NATIVE_DOUBLE_COMP_ALIGN_g; break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case H5T_NATIVE_FLOAT_MATCH_LDOUBLE: tid = H5T_NATIVE_LDOUBLE; align = H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; break; -#endif + case H5T_NATIVE_FLOAT_MATCH_UNKNOWN: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "Unknown native floating-point match") diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 51ecaca..19593dd 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -401,9 +401,7 @@ H5_DLLVAR size_t H5T_NATIVE_LONG_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LLONG_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g; -#if H5_SIZEOF_LONG_DOUBLE != 0 H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g; -#endif H5_DLLVAR size_t H5T_POINTER_COMP_ALIGN_g; H5_DLLVAR size_t H5T_HVL_COMP_ALIGN_g; @@ -429,9 +427,7 @@ H5_DLLVAR size_t H5T_NATIVE_LLONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_ULLONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_FLOAT_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_DOUBLE_ALIGN_g; -#if H5_SIZEOF_LONG_DOUBLE != 0 H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_ALIGN_g; -#endif /* C9x alignment constraints */ H5_DLLVAR size_t H5T_NATIVE_INT8_ALIGN_g; @@ -468,10 +464,8 @@ H5_DLLVAR float H5T_NATIVE_FLOAT_POS_INF_g; H5_DLLVAR float H5T_NATIVE_FLOAT_NEG_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_POS_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_NEG_INF_g; -#if H5_SIZEOF_LONG_DOUBLE != 0 H5_DLLVAR double H5T_NATIVE_LDOUBLE_POS_INF_g; H5_DLLVAR double H5T_NATIVE_LDOUBLE_NEG_INF_g; -#endif /* Declare extern the free lists for H5T_t's and H5T_shared_t's */ H5FL_EXTERN(H5T_t); diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index bb5b0ef..911efdf 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -803,13 +803,11 @@ H5_DLLVAR hid_t H5T_VAX_F64_g; * C-style \Code{double} */ #define H5T_NATIVE_DOUBLE (H5OPEN H5T_NATIVE_DOUBLE_g) -#if H5_SIZEOF_LONG_DOUBLE != 0 /** * \ingroup PDTNAT * C-style \Code{long double} */ #define H5T_NATIVE_LDOUBLE (H5OPEN H5T_NATIVE_LDOUBLE_g) -#endif /** * \ingroup PDTNAT * HDF5 8-bit bitfield based on native types @@ -872,9 +870,7 @@ H5_DLLVAR hid_t H5T_NATIVE_LLONG_g; H5_DLLVAR hid_t H5T_NATIVE_ULLONG_g; H5_DLLVAR hid_t H5T_NATIVE_FLOAT_g; H5_DLLVAR hid_t H5T_NATIVE_DOUBLE_g; -#if H5_SIZEOF_LONG_DOUBLE != 0 H5_DLLVAR hid_t H5T_NATIVE_LDOUBLE_g; -#endif H5_DLLVAR hid_t H5T_NATIVE_B8_g; H5_DLLVAR hid_t H5T_NATIVE_B16_g; H5_DLLVAR hid_t H5T_NATIVE_B32_g; diff --git a/src/H5Tref.c b/src/H5Tref.c index cac8cf6..511c531 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -309,8 +309,8 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't get encode size") /* Size on disk, memory size is different */ - dt->shared->size = MAX(H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE + cont_info.blob_id_size, - ref_encode_size); + dt->shared->size = + MAX(sizeof(uint32_t) + H5R_ENCODE_HEADER_SIZE + cont_info.blob_id_size, ref_encode_size); dt->shared->u.atomic.prec = 8 * dt->shared->size; /* Set up the function pointers to access the information on @@ -778,7 +778,7 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ /* Skip the size / header */ - p = (const uint8_t *)src_buf + H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T; + p = (const uint8_t *)src_buf + H5R_ENCODE_HEADER_SIZE + sizeof(uint32_t); /* Set up VOL callback arguments */ vol_cb_args.op_type = H5VL_BLOB_ISNULL; @@ -819,7 +819,7 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) /* TODO Should get rid of bg stuff */ if (p_bg) { /* Skip the size / header */ - p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); + p_bg += (sizeof(uint32_t) + H5R_ENCODE_HEADER_SIZE); /* Set up VOL callback arguments */ vol_cb_args.op_type = H5VL_BLOB_DELETE; @@ -929,8 +929,8 @@ H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_ blob_size -= H5R_ENCODE_HEADER_SIZE; /* Skip the size */ - p += H5_SIZEOF_UINT32_T; - HDassert(src_size > (H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T)); + p += sizeof(uint32_t); + HDassert(src_size > (H5R_ENCODE_HEADER_SIZE + sizeof(uint32_t))); /* Retrieve blob */ if (H5VL_blob_get(src_file, p, q, blob_size, NULL) < 0) @@ -974,9 +974,9 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t p_buf_size_left = dst_size; /* Skip the size / header */ - p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); - HDassert(p_buf_size_left > (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE)); - p_buf_size_left -= (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE); + p_bg += (sizeof(uint32_t) + H5R_ENCODE_HEADER_SIZE); + HDassert(p_buf_size_left > (sizeof(uint32_t) + H5R_ENCODE_HEADER_SIZE)); + p_buf_size_left -= (sizeof(uint32_t) + H5R_ENCODE_HEADER_SIZE); /* Set up VOL callback arguments */ vol_cb_args.op_type = H5VL_BLOB_DELETE; @@ -991,12 +991,12 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, p += H5R_ENCODE_HEADER_SIZE; q += H5R_ENCODE_HEADER_SIZE; src_size -= H5R_ENCODE_HEADER_SIZE; - buf_size_left -= H5_SIZEOF_UINT32_T; + buf_size_left -= sizeof(uint32_t); /* Set the size */ UINT32ENCODE(q, src_size); - HDassert(buf_size_left > H5_SIZEOF_UINT32_T); - buf_size_left -= H5_SIZEOF_UINT32_T; + HDassert(buf_size_left > sizeof(uint32_t)); + buf_size_left -= sizeof(uint32_t); /* Store blob */ if (H5VL_blob_put(dst_file, p, src_size, q, NULL) < 0) diff --git a/src/H5VL.c b/src/H5VL.c index 2cece6d..8c3277c 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -655,6 +655,39 @@ done: FUNC_LEAVE_API(ret_value) } /* H5VLobject() */ +/*--------------------------------------------------------------------------- + * Function: H5VLobject_is_native + * + * Purpose: Determines whether an object ID represents a native VOL + * connector object. + * + * Return: Non-negative on success/Negative on failure + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLobject_is_native(hid_t obj_id, hbool_t *is_native) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*b", obj_id, is_native); + + if (!is_native) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "`is_native` argument is NULL") + + /* Get the location object for the ID */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + if (H5VL_object_is_native(vol_obj, is_native) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine if object is a native connector object") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLobject_is_native() */ + /*------------------------------------------------------------------------- * Function: H5VLget_file_type * diff --git a/src/H5VLint.c b/src/H5VLint.c index 936614f..b602ac0 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -32,6 +32,7 @@ #include "H5CXprivate.h" /* API Contexts */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ +#include "H5ESprivate.h" /* Event sets */ #include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free lists */ #include "H5Gprivate.h" /* Groups */ @@ -94,9 +95,6 @@ static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -149,7 +147,9 @@ H5VL_init_phase1(void) FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ + /* Initialize the ID group for the VL IDs */ + if (H5I_register_type(H5I_VOL_CLS) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface") done: FUNC_LEAVE_NOAPI(ret_value) @@ -171,23 +171,39 @@ done: herr_t H5VL_init_phase2(void) { + size_t i; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* clang-format off */ + struct { + herr_t (*func)(void); + const char *descr; + } initializer[] = { + {H5T_init, "datatype"} + , {H5O_init, "object header"} + , {H5D_init, "dataset"} + , {H5F_init, "file"} + , {H5G_init, "group"} + , {H5A_init, "attribute"} + , {H5M_init, "map"} + , {H5CX_init, "context"} + , {H5ES_init, "event set"} + , {H5Z_init, "transform"} + , {H5PL_init, "plugin"} + , {H5R_init, "reference"} + }; + /* Initialize all packages for VOL-managed objects */ - if (H5T_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize datatype interface") - if (H5D_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize dataset interface") - if (H5F_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize file interface") - if (H5G_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize group interface") - if (H5A_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize attribute interface") - if (H5M_init() < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize map interface") + for (i = 0; i < NELMTS(initializer); i++) { + if (initializer[i].func() < 0) { + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, + "unable to initialize %s interface", initializer[i].descr) + } + } + + /* clang-format on */ /* Sanity check default VOL connector */ HDassert(H5VL_def_conn_s.connector_id == (-1)); @@ -202,32 +218,6 @@ done: } /* end H5VL_init_phase2() */ /*------------------------------------------------------------------------- - * Function: H5VL__init_package - * - * Purpose: Initialize interface-specific information - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Initialize the ID group for the VL IDs */ - if (H5I_register_type(H5I_VOL_CLS) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__init_package() */ - -/*------------------------------------------------------------------------- * Function: H5VL_term_package * * Purpose: Terminate various H5VL objects @@ -245,37 +235,31 @@ H5VL_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { - if (H5VL_def_conn_s.connector_id > 0) { - /* Release the default VOL connector */ - (void)H5VL_conn_free(&H5VL_def_conn_s); - H5VL_def_conn_s.connector_id = -1; - H5VL_def_conn_s.connector_info = NULL; + if (H5VL_def_conn_s.connector_id > 0) { + /* Release the default VOL connector */ + (void)H5VL_conn_free(&H5VL_def_conn_s); + H5VL_def_conn_s.connector_id = -1; + H5VL_def_conn_s.connector_info = NULL; + n++; + } /* end if */ + else { + if (H5I_nmembers(H5I_VOL) > 0) { + /* Unregister all VOL connectors */ + (void)H5I_clear_type(H5I_VOL, TRUE, FALSE); n++; } /* end if */ else { - if (H5I_nmembers(H5I_VOL) > 0) { - /* Unregister all VOL connectors */ - (void)H5I_clear_type(H5I_VOL, TRUE, FALSE); + if (H5VL__num_opt_operation() > 0) { + /* Unregister all dynamically registered optional operations */ + (void)H5VL__term_opt_operation(); n++; } /* end if */ else { - if (H5VL__num_opt_operation() > 0) { - /* Unregister all dynamically registered optional operations */ - (void)H5VL__term_opt_operation(); - n++; - } /* end if */ - else { - /* Destroy the VOL connector ID group */ - n += (H5I_dec_type_ref(H5I_VOL) > 0); - - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end else */ - } /* end else */ - } /* end else */ - } /* end if */ + /* Destroy the VOL connector ID group */ + n += (H5I_dec_type_ref(H5I_VOL) > 0); + } /* end else */ + } /* end else */ + } /* end else */ FUNC_LEAVE_NOAPI(n) } /* end H5VL_term_package() */ @@ -972,7 +956,7 @@ H5VL_conn_inc_rc(H5VL_t *connector) { int64_t ret_value = -1; - FUNC_ENTER_NOAPI(-1) + FUNC_ENTER_NOAPI_NOERR /* Check arguments */ HDassert(connector); @@ -982,7 +966,6 @@ H5VL_conn_inc_rc(H5VL_t *connector) ret_value = connector->nrefs; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_conn_inc_rc() */ @@ -2004,7 +1987,7 @@ H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_clas { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(cls1); @@ -2532,7 +2515,7 @@ H5VL_check_plugin_load(const H5VL_class_t *cls, const H5PL_key_t *key, hbool_t * { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ HDassert(cls); @@ -2558,7 +2541,6 @@ H5VL_check_plugin_load(const H5VL_class_t *cls, const H5PL_key_t *key, hbool_t * if (*success && cls->version != H5VL_VERSION) *success = FALSE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_check_plugin_load() */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 78e39e3..543c3c8 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -356,6 +356,19 @@ H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); * \since 1.12.0 */ H5_DLL herr_t H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, uint64_t *flags); +/** + * \ingroup H5VL + * \brief Determines whether an object ID represents a native + * VOL connector object. + * + * \param[in] obj_id Object identifier + * \param[in] is_native Boolean determining whether object is a native + * VOL connector object + * \return \herr_t + * + * \since 1.13.0 + */ +H5_DLL herr_t H5VLobject_is_native(hid_t obj_id, hbool_t *is_native); #ifdef __cplusplus } diff --git a/src/H5Z.c b/src/H5Z.c index ea92a01..34af8eb 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -56,9 +56,6 @@ typedef enum { H5Z_PRELUDE_SET_LOCAL /* Call "set local" callback */ } H5Z_prelude_type_t; -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /* Local variables */ static size_t H5Z_table_alloc_g = 0; static size_t H5Z_table_used_g = 0; @@ -74,19 +71,23 @@ static int H5Z__check_unregister_group_cb(void *obj_ptr, hid_t obj_id, void *key static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); /*------------------------------------------------------------------------- - * Function: H5Z__init_package + * Function: H5Z_init * - * Purpose: Initializes the data filter layer. + * Purpose: Initialize the interface from some other layer. * - * Return: Non-negative on success/Negative on failure + * Return: Success: non-negative + * Failure: negative *------------------------------------------------------------------------- */ herr_t -H5Z__init_package(void) +H5Z_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) + + if (H5_TERM_GLOBAL) + HGOTO_DONE(SUCCEED) /* Internal filters */ if (H5Z_register(H5Z_SHUFFLE) < 0) @@ -111,7 +112,7 @@ H5Z__init_package(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5Z__init_package() */ +} /*------------------------------------------------------------------------- * Function: H5Z_term_package @@ -128,76 +129,70 @@ H5Z_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { #ifdef H5Z_DEBUG - char comment[16], bandwidth[32]; - int dir, nprint = 0; - size_t i; - - if (H5DEBUG(Z)) { - for (i = 0; i < H5Z_table_used_g; i++) { - for (dir = 0; dir < 2; dir++) { - struct { - char *user; - char *system; - char *elapsed; - } timestrs = {H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.user), - H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.system), - H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.elapsed)}; - if (0 == H5Z_stat_table_g[i].stats[dir].total) - goto next; - - if (0 == nprint++) { - /* Print column headers */ - HDfprintf(H5DEBUG(Z), "H5Z: filter statistics " - "accumulated over life of library:\n"); - HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "Filter", "Total", - "Errors", "User", "System", "Elapsed", "Bandwidth"); - HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "------", "-----", - "------", "----", "------", "-------", "---------"); - } /* end if */ + char comment[16], bandwidth[32]; + int dir, nprint = 0; + size_t i; - /* Truncate the comment to fit in the field */ - HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment); - comment[sizeof(comment) - 1] = '\0'; - - /* - * Format bandwidth to have four significant digits and - * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or - * the word `Inf' if the elapsed time is zero. - */ - H5_bandwidth(bandwidth, (double)(H5Z_stat_table_g[i].stats[dir].total), - H5Z_stat_table_g[i].stats[dir].times.elapsed); - - /* Print the statistics */ - HDfprintf(H5DEBUG(Z), " %s%-15s %10" PRIdHSIZE " %10" PRIdHSIZE " %8s %8s %8s %10s\n", - (dir ? "<" : ">"), comment, H5Z_stat_table_g[i].stats[dir].total, - H5Z_stat_table_g[i].stats[dir].errors, timestrs.user, timestrs.system, - timestrs.elapsed, bandwidth); + if (H5DEBUG(Z)) { + for (i = 0; i < H5Z_table_used_g; i++) { + for (dir = 0; dir < 2; dir++) { + struct { + char *user; + char *system; + char *elapsed; + } timestrs = {H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.user), + H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.system), + H5_timer_get_time_string(H5Z_stat_table_g[i].stats[dir].times.elapsed)}; + if (0 == H5Z_stat_table_g[i].stats[dir].total) + goto next; + + if (0 == nprint++) { + /* Print column headers */ + HDfprintf(H5DEBUG(Z), "H5Z: filter statistics " + "accumulated over life of library:\n"); + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "Filter", "Total", + "Errors", "User", "System", "Elapsed", "Bandwidth"); + HDfprintf(H5DEBUG(Z), " %-16s %10s %10s %8s %8s %8s %10s\n", "------", "-----", + "------", "----", "------", "-------", "---------"); + } /* end if */ + + /* Truncate the comment to fit in the field */ + HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment); + comment[sizeof(comment) - 1] = '\0'; + + /* + * Format bandwidth to have four significant digits and + * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or + * the word `Inf' if the elapsed time is zero. + */ + H5_bandwidth(bandwidth, (double)(H5Z_stat_table_g[i].stats[dir].total), + H5Z_stat_table_g[i].stats[dir].times.elapsed); + + /* Print the statistics */ + HDfprintf(H5DEBUG(Z), " %s%-15s %10" PRIdHSIZE " %10" PRIdHSIZE " %8s %8s %8s %10s\n", + (dir ? "<" : ">"), comment, H5Z_stat_table_g[i].stats[dir].total, + H5Z_stat_table_g[i].stats[dir].errors, timestrs.user, timestrs.system, + timestrs.elapsed, bandwidth); next: - HDfree(timestrs.user); - HDfree(timestrs.system); - HDfree(timestrs.elapsed); - } /* end for */ - } /* end for */ - } /* end if */ -#endif /* H5Z_DEBUG */ - - /* Free the table of filters */ - if (H5Z_table_g) { - H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); + HDfree(timestrs.user); + HDfree(timestrs.system); + HDfree(timestrs.elapsed); + } /* end for */ + } /* end for */ + } /* end if */ +#endif /* H5Z_DEBUG */ + + /* Free the table of filters */ + if (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); + H5Z_stat_table_g = (H5Z_stats_t *)H5MM_xfree(H5Z_stat_table_g); #endif /* H5Z_DEBUG */ - H5Z_table_used_g = H5Z_table_alloc_g = 0; - - n++; - } /* end if */ + H5Z_table_used_g = H5Z_table_alloc_g = 0; - /* Mark interface as closed */ - if (0 == n) - H5_PKG_INIT_VAR = FALSE; + n++; } /* end if */ FUNC_LEAVE_NOAPI(n) @@ -1520,7 +1515,7 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) size_t idx; /* Index of filter in pipeline */ htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR HDassert(pline); HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX); @@ -1534,7 +1529,6 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) if (idx >= pline->nused) ret_value = FALSE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_in_pline() */ @@ -1554,7 +1548,7 @@ H5Z_all_filters_avail(const H5O_pline_t *pline) size_t i, j; /* Local index variable */ htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Check args */ HDassert(pline); diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index a8a63bf..48a29cd 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -364,12 +364,12 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ #define H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ { \ i = 0; \ - while (i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + while (i < d_nelmts && HDfabs((double)(buf[i] - filval)) < HDpow(10.0, -D_val)) \ i++; \ if (i < d_nelmts) \ min = max = buf[i]; \ for (; i < d_nelmts; i++) { \ - if (HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \ + if (HDfabs((double)(buf[i] - filval)) < HDpow(10.0, -D_val)) \ continue; /* ignore fill value */ \ if (buf[i] > max) \ max = buf[i]; \ @@ -425,22 +425,22 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ #define H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) \ { \ if (sizeof(type) == sizeof(int)) { \ - if (round_fun(max * pow_fun(10.0F, (type)D_val) - min * pow_fun(10.0F, (type)D_val)) > \ - pow_fun(2.0F, (type)(sizeof(int) * 8 - 1))) { \ + if (round_fun(max * pow_fun((type)10, (type)D_val) - min * pow_fun((type)10, (type)D_val)) > \ + pow_fun((type)2, (type)(sizeof(int) * 8 - 1))) { \ *minbits = sizeof(int) * 8; \ goto done; \ } \ } \ else if (sizeof(type) == sizeof(long)) { \ - if (round_fun(max * pow_fun(10.0F, (type)D_val) - min * pow_fun(10.0F, (type)D_val)) > \ - pow_fun(2.0F, (type)(sizeof(long) * 8 - 1))) { \ + if (round_fun(max * pow_fun((type)10, (type)D_val) - min * pow_fun((type)10, (type)D_val)) > \ + pow_fun((type)2, (type)(sizeof(long) * 8 - 1))) { \ *minbits = sizeof(long) * 8; \ goto done; \ } \ } \ else if (sizeof(type) == sizeof(long long)) { \ - if (round_fun(max * pow_fun(10.0F, (type)D_val) - min * pow_fun(10.0F, (type)D_val)) > \ - pow_fun(2.0F, (type)(sizeof(long long) * 8 - 1))) { \ + if (round_fun(max * pow_fun((type)10, (type)D_val) - min * pow_fun((type)10, (type)D_val)) > \ + pow_fun((type)2, (type)(sizeof(long long) * 8 - 1))) { \ *minbits = sizeof(long long) * 8; \ goto done; \ } \ @@ -530,27 +530,27 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ { \ if (sizeof(type) == sizeof(int)) \ for (i = 0; i < d_nelmts; i++) { \ - if (abs_fun(buf[i] - filval) < pow_fun(10.0F, (type)-D_val)) \ + if (abs_fun(buf[i] - filval) < pow_fun((type)10, (type)-D_val)) \ *(int *)((void *)&buf[i]) = (int)(((unsigned int)1 << *minbits) - 1); \ else \ - *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0F, (type)D_val) - \ - min * pow_fun(10.0F, (type)D_val)); \ + *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)); \ } \ else if (sizeof(type) == sizeof(long)) \ for (i = 0; i < d_nelmts; i++) { \ - if (abs_fun(buf[i] - filval) < pow_fun(10.0F, (type)-D_val)) \ + if (abs_fun(buf[i] - filval) < pow_fun((type)10, (type)-D_val)) \ *(long *)((void *)&buf[i]) = (long)(((unsigned long)1 << *minbits) - 1); \ else \ - *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun(10.0F, (type)D_val) - \ - min * pow_fun(10.0F, (type)D_val)); \ + *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)); \ } \ else if (sizeof(type) == sizeof(long long)) \ for (i = 0; i < d_nelmts; i++) { \ - if (abs_fun(buf[i] - filval) < pow_fun(10.0F, (type)-D_val)) \ + if (abs_fun(buf[i] - filval) < pow_fun((type)10, (type)-D_val)) \ *(long long *)((void *)&buf[i]) = (long long)(((unsigned long long)1 << *minbits) - 1); \ else \ - *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun(10.0F, (type)D_val) - \ - min * pow_fun(10.0F, (type)D_val)); \ + *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)); \ } \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ @@ -561,16 +561,16 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ { \ if (sizeof(type) == sizeof(int)) \ for (i = 0; i < d_nelmts; i++) \ - *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun(10.0F, (type)D_val) - \ - min * pow_fun(10.0F, (type)D_val)); \ + *(int *)((void *)&buf[i]) = (int)lround_fun(buf[i] * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)); \ else if (sizeof(type) == sizeof(long)) \ for (i = 0; i < d_nelmts; i++) \ - *(long *)((void *)&buf[i]) = \ - lround_fun(buf[i] * pow_fun(10.0F, (type)D_val) - min * pow_fun(10.0F, (type)D_val)); \ + *(long *)((void *)&buf[i]) = lround_fun(buf[i] * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)); \ else if (sizeof(type) == sizeof(long long)) \ for (i = 0; i < d_nelmts; i++) \ - *(long long *)((void *)&buf[i]) = \ - llround_fun(buf[i] * pow_fun(10.0F, (type)D_val) - min * pow_fun(10.0F, (type)D_val)); \ + *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)); \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } @@ -606,8 +606,8 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) span = \ - (unsigned long long)(llround_fun(max * pow_fun(10.0F, (type)D_val) - \ - min * pow_fun(10.0F, (type)D_val)) + \ + (unsigned long long)(llround_fun(max * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)) + \ 1); \ *minbits = H5Z__scaleoffset_log2(span + 1); \ if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ @@ -617,8 +617,8 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ else { /* fill value undefined */ \ H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) span = \ - (unsigned long long)(llround_fun(max * pow_fun(10.0F, (type)D_val) - \ - min * pow_fun(10.0F, (type)D_val)) + \ + (unsigned long long)(llround_fun(max * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)) + \ 1); \ *minbits = H5Z__scaleoffset_log2(span); \ if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ @@ -685,19 +685,19 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ buf[i] = \ (type)((*(int *)((void *)&buf[i]) == (int)(((unsigned int)1 << minbits) - 1)) \ ? filval \ - : (type)(*(int *)((void *)&buf[i])) / pow_fun(10.0F, (type)D_val) + min); \ + : (type)(*(int *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + min); \ else if (sizeof(type) == sizeof(long)) \ for (i = 0; i < d_nelmts; i++) \ buf[i] = \ (type)((*(long *)((void *)&buf[i]) == (long)(((unsigned long)1 << minbits) - 1)) \ ? filval \ - : (type)(*(long *)((void *)&buf[i])) / pow_fun(10.0F, (type)D_val) + min); \ + : (type)(*(long *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + min); \ else if (sizeof(type) == sizeof(long long)) \ for (i = 0; i < d_nelmts; i++) \ buf[i] = (type)( \ (*(long long *)((void *)&buf[i]) == (long long)(((unsigned long long)1 << minbits) - 1)) \ ? filval \ - : (type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0F, (type)D_val) + min); \ + : (type)(*(long long *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + min); \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } @@ -707,13 +707,13 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ { \ if (sizeof(type) == sizeof(int)) \ for (i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(int *)((void *)&buf[i])) / pow_fun(10.0F, (type)D_val) + min); \ + buf[i] = ((type)(*(int *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + min); \ else if (sizeof(type) == sizeof(long)) \ for (i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(long *)((void *)&buf[i])) / pow_fun(10.0F, (type)D_val) + min); \ + buf[i] = ((type)(*(long *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + min); \ else if (sizeof(type) == sizeof(long long)) \ for (i = 0; i < d_nelmts; i++) \ - buf[i] = ((type)(*(long long *)((void *)&buf[i])) / pow_fun(10.0F, (type)D_val) + min); \ + buf[i] = ((type)(*(long long *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + min); \ else \ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ } diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index ab7e9be..ea532cf 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -150,7 +150,6 @@ static void H5Z__xform_reduce_tree(H5Z_node *tree); HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unexpected type conversion operation") \ } -#if H5_SIZEOF_LONG_DOUBLE != 0 #if CHAR_MIN >= 0 #define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ { \ @@ -212,65 +211,6 @@ static void H5Z__xform_reduce_tree(H5Z_node *tree); H5Z_XFORM_DO_OP1((RESL), (RESR), long double, OP, (SIZE)) \ } #endif /* CHAR_MIN >= 0 */ -#else -#if CHAR_MIN >= 0 -#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ - { \ - if ((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_SCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), signed char, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ - } -#else /* CHAR_MIN >= 0 */ -#define H5Z_XFORM_TYPE_OP(RESL, RESR, TYPE, OP, SIZE) \ - { \ - if ((TYPE) == H5T_NATIVE_CHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), char, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_UCHAR) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned char, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_SHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), short, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_USHORT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned short, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_INT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), int, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_UINT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned int, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_LONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_ULONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_LLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), long long, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_ULLONG) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), unsigned long long, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_FLOAT) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), float, OP, (SIZE)) \ - else if ((TYPE) == H5T_NATIVE_DOUBLE) \ - H5Z_XFORM_DO_OP1((RESL), (RESR), double, OP, (SIZE)) \ - } -#endif /* CHAR_MIN >= 0 */ -#endif /*H5_SIZEOF_LONG_DOUBLE */ #define H5Z_XFORM_DO_OP3(OP) \ { \ @@ -1056,10 +996,8 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void *array, size_t array_size H5Z_XFORM_DO_OP5(float, array_size) else if (array_type == H5T_NATIVE_DOUBLE) H5Z_XFORM_DO_OP5(double, array_size) -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (array_type == H5T_NATIVE_LDOUBLE) H5Z_XFORM_DO_OP5(long double, array_size) -#endif } /* end if */ /* Otherwise, do the full data transform */ @@ -1267,11 +1205,9 @@ H5Z__xform_find_type(const H5T_t *type) /* Check for DOUBLE type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_DOUBLE) -#if H5_SIZEOF_LONG_DOUBLE != 0 /* Check for LONGDOUBLE type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) HGOTO_DONE(H5T_NATIVE_LDOUBLE) -#endif else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not find matching type") diff --git a/src/H5detect.c b/src/H5detect.c index e8cded7..022cb55 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -1412,7 +1412,7 @@ detect_C99_floats(void) */ DETECT_F(double, LDOUBLE, d_g[nd_g]); nd_g++; -#elif H5_SIZEOF_LONG_DOUBLE != 0 +#else DETECT_F(long double, LDOUBLE, d_g[nd_g]); nd_g++; #endif diff --git a/src/H5private.h b/src/H5private.h index d1275dc..1e0edd4 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -99,8 +99,14 @@ #include #endif -/* Define the default VFD for this platform. - * Since the removal of the Windows VFD, this is sec2 for all platforms. +/* Define the default VFD for this platform. Since the removal of the + * Windows VFD, this is sec2 for all platforms. + * + * Note well: if you change the default, then be sure to change + * H5_default_vfd_init() to call that default's initializer. Also, + * make sure that the initializer for each *non*-default VFD calls + * H5_init_library(); also, make sure that the initializer for default + * VFD does *not* call H5_init_library(). */ #define H5_DEFAULT_VFD H5FD_SEC2 @@ -252,10 +258,10 @@ #define H5_ATTR_NORETURN __attribute__((noreturn)) #define H5_ATTR_CONST __attribute__((const)) #define H5_ATTR_PURE __attribute__((pure)) -#if defined(__GNUC__) && __GNUC__ >= 7 && !defined(__INTEL_COMPILER) +#if defined(__clang__) || defined(__GNUC__) && __GNUC__ >= 7 && !defined(__INTEL_COMPILER) #define H5_ATTR_FALLTHROUGH __attribute__((fallthrough)); #else -#define H5_ATTR_FALLTHROUGH /*void*/ +#define H5_ATTR_FALLTHROUGH /* FALLTHROUGH */ #endif #else #define H5_ATTR_FORMAT(X, Y, Z) /*void*/ @@ -2021,33 +2027,6 @@ extern hbool_t H5_use_selection_io_g; extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ #endif -/* Macros for referencing package initialization symbols */ -#define H5_PACKAGE_INIT_VAR(x) H5_GLUE(x, _init_g) -#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __init_package) - -/* Macros for defining package initialization routines */ -#ifdef H5_MY_PKG -#define H5_PKG_INIT_VAR H5_PACKAGE_INIT_VAR(H5_MY_PKG) -#define H5_PKG_INIT_FUNC H5_PACKAGE_INIT_FUNC(H5_MY_PKG) -#define H5_PACKAGE_YES_INIT(err) \ - /* Initialize this interface or bust */ \ - if (!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) { \ - H5_PKG_INIT_VAR = TRUE; \ - if (H5_PKG_INIT_FUNC() < 0) { \ - H5_PKG_INIT_VAR = FALSE; \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "interface initialization failed") \ - } \ - } -#define H5_PACKAGE_NO_INIT(err) \ - /* Initialize this interface or bust */ \ - if (!H5_PKG_INIT_VAR && !H5_TERM_GLOBAL) \ - H5_PKG_INIT_VAR = TRUE; -#define H5_PACKAGE_INIT(pkg_init, err) H5_GLUE3(H5_PACKAGE_, pkg_init, _INIT)(err) -#else /* H5_MY_PKG */ -#define H5_PKG_INIT_VAR (TRUE) -#define H5_PACKAGE_INIT(pkg_init, err) -#endif /* H5_MY_PKG */ - /* Forward declaration of H5CXpush() / H5CXpop() */ /* (Including H5CXprivate.h creates bad circular dependencies - QAK, 3/18/2018) */ H5_DLL herr_t H5CX_push(void); @@ -2103,10 +2082,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); if (!H5_INIT_GLOBAL && !H5_TERM_GLOBAL) { \ if (H5_init_library() < 0) \ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, "library initialization failed") \ - } /* end if */ \ - \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) + } #define FUNC_ENTER_API_PUSH(err) \ /* Push the name of this function on the function stack */ \ @@ -2215,27 +2191,19 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON_NOERR(H5_IS_API(__func__)); \ { -/* Note: this macro only works when there's _no_ interface initialization routine for the module */ -#define FUNC_ENTER_NOAPI_INIT(err) \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ - \ - /* Push the name of this function on the function stack */ \ - H5_PUSH_FUNC - /* Use this macro for all "normal" non-API functions */ #define FUNC_ENTER_NOAPI(err) \ { \ FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ - FUNC_ENTER_NOAPI_INIT(err) \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + H5_PUSH_FUNC \ + { /* Use this macro for all non-API functions, which propagate errors, but don't issue them */ #define FUNC_ENTER_NOAPI_NOERR \ { \ FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \ - FUNC_ENTER_NOAPI_INIT(-) \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + H5_PUSH_FUNC \ + { /* * Use this macro for non-API functions which fall into these categories: @@ -2249,7 +2217,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); { \ FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions which fall into these categories: @@ -2264,7 +2232,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); { \ FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions which fall into these categories: @@ -2276,9 +2244,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); { \ FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ \ - /* Initialize the package, if appropriate */ \ - H5_PACKAGE_INIT(H5_MY_PKG_INIT, err) \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions which fall into these categories: @@ -2292,7 +2258,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); #define FUNC_ENTER_NOAPI_NOERR_NOFS \ { \ FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions that shouldn't perform _any_ initialization @@ -2314,8 +2280,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); \ FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ H5AC_tag(tag, &prev_tag); \ - FUNC_ENTER_NOAPI_INIT(err) \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + H5_PUSH_FUNC \ + { #define FUNC_ENTER_NOAPI_NOINIT_TAG(tag) \ { \ @@ -2324,21 +2290,21 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \ H5AC_tag(tag, &prev_tag); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for all "normal" package-level functions */ #define FUNC_ENTER_PACKAGE \ { \ FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for package-level functions which propgate errors, but don't issue them */ #define FUNC_ENTER_PACKAGE_NOERR \ { \ FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use the following macro as replacement for the FUNC_ENTER_PACKAGE * macro when the function needs to set up a metadata tag. */ @@ -2349,28 +2315,28 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \ H5AC_tag(tag, &prev_tag); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for all "normal" staticly-scoped functions */ #define FUNC_ENTER_STATIC \ { \ FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for staticly-scoped functions which propgate errors, but don't issue them */ #define FUNC_ENTER_STATIC_NOERR \ { \ FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(__func__)); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* Use this macro for staticly-scoped functions which propgate errors, but don't issue them */ /* And that shouldn't push their name on the function stack */ #define FUNC_ENTER_STATIC_NOERR_NOFS \ { \ FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(__func__)); \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /* * Use this macro for non-API functions that shouldn't perform _any_ initialization @@ -2392,7 +2358,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \ H5AC_tag(tag, &prev_tag); \ H5_PUSH_FUNC \ - if (H5_PKG_INIT_VAR || !H5_TERM_GLOBAL) { + { /*------------------------------------------------------------------------- * Purpose: Register function exit for code profiling. This should be @@ -2521,27 +2487,6 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); return (ret_value); \ } /*end scope from beginning of FUNC_ENTER*/ -/* Macros to declare package initialization function, if a package initialization routine is defined */ -#ifdef H5_PKG_SINGLE_SOURCE -#define H5_PKG_DECLARE_YES_FUNC(pkg) static herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#else -#define H5_PKG_DECLARE_YES_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void); -#endif -#define H5_PKG_DECLARE_NO_FUNC(pkg) - -/* Declare package initialization symbols (if in a package) */ -#ifdef H5_PKG_SINGLE_SOURCE -#define H5_PKG_DECLARE_VAR(pkg) static hbool_t H5_PACKAGE_INIT_VAR(pkg); -#else -#define H5_PKG_DECLARE_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(pkg); -#endif -#define H5_PKG_DECLARE_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_DECLARE_, pkg_init, _FUNC)(pkg) - -#ifdef H5_MY_PKG -H5_PKG_DECLARE_VAR(H5_MY_PKG) -H5_PKG_DECLARE_FUNC(H5_MY_PKG_INIT, H5_MY_PKG) -#endif - /* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient). * Make sure to use HGOTO_ERROR_TAG and HGOTO_DONE_TAG between these macros! */ #define H5_BEGIN_TAG(tag) \ diff --git a/src/H5trace.c b/src/H5trace.c index 0797f65..baf6a10 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -1622,10 +1622,8 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5T_NATIVE_FLOAT"); else if (obj == H5T_NATIVE_DOUBLE_g) H5RS_acat(rs, "H5T_NATIVE_DOUBLE"); -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (obj == H5T_NATIVE_LDOUBLE_g) H5RS_acat(rs, "H5T_NATIVE_LDOUBLE"); -#endif else if (obj == H5T_IEEE_F32BE_g) H5RS_acat(rs, "H5T_IEEE_F32BE"); else if (obj == H5T_IEEE_F32LE_g) diff --git a/src/Makefile.am b/src/Makefile.am index 04b0d40..5374eb0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAint.c H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c H5FDfamily.c H5FDint.c H5FDlog.c \ - H5FDmulti.c H5FDsec2.c H5FDspace.c \ + H5FDmulti.c H5FDperform.c H5FDsec2.c H5FDspace.c \ H5FDsplitter.c H5FDstdio.c H5FDtest.c \ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSint.c H5FSsection.c \ H5FSstat.c H5FStest.c \ diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 44c1540..7fe1a36 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -67,28 +67,29 @@ Languages: Features: --------- - Parallel HDF5: @PARALLEL@ -Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ - Large Parallel I/O: @LARGE_PARALLEL_IO@ - High-level library: @HDF5_HL@ - Build HDF5 Tests: @HDF5_TESTS@ - Build HDF5 Tools: @HDF5_TOOLS@ - Threadsafety: @THREADSAFE@ - Default API mapping: @DEFAULT_API_VERSION@ - With deprecated public symbols: @DEPRECATED_SYMBOLS@ - I/O filters (external): @EXTERNAL_FILTERS@ - MPE: @MPE@ - Map (H5M) API: @MAP_API@ - Direct VFD: @DIRECT_VFD@ - Mirror VFD: @MIRROR_VFD@ - (Read-Only) S3 VFD: @ROS3_VFD@ - (Read-Only) HDFS VFD: @HAVE_LIBHDFS@ - dmalloc: @HAVE_DMALLOC@ - Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@ - API tracing: @TRACE_API@ - Using memory checker: @USINGMEMCHECKER@ - Memory allocation sanity checks: @MEMORYALLOCSANITYCHECK@ - Function stack tracing: @CODESTACK@ - Use file locking: @DESIRED_FILE_LOCKING@ - Strict file format checks: @STRICT_FORMAT_CHECKS@ - Optimization instrumentation: @INSTRUMENT_LIBRARY@ + Parallel HDF5: @PARALLEL@ + Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ + Large Parallel I/O: @LARGE_PARALLEL_IO@ + High-level library: @HDF5_HL@ +Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@ + Build HDF5 Tests: @HDF5_TESTS@ + Build HDF5 Tools: @HDF5_TOOLS@ + Threadsafety: @THREADSAFE@ + Default API mapping: @DEFAULT_API_VERSION@ + With deprecated public symbols: @DEPRECATED_SYMBOLS@ + I/O filters (external): @EXTERNAL_FILTERS@ + MPE: @MPE@ + Map (H5M) API: @MAP_API@ + Direct VFD: @DIRECT_VFD@ + Mirror VFD: @MIRROR_VFD@ + (Read-Only) S3 VFD: @ROS3_VFD@ + (Read-Only) HDFS VFD: @HAVE_LIBHDFS@ + dmalloc: @HAVE_DMALLOC@ + Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@ + API tracing: @TRACE_API@ + Using memory checker: @USINGMEMCHECKER@ + Memory allocation sanity checks: @MEMORYALLOCSANITYCHECK@ + Function stack tracing: @CODESTACK@ + Use file locking: @DESIRED_FILE_LOCKING@ + Strict file format checks: @STRICT_FORMAT_CHECKS@ + Optimization instrumentation: @INSTRUMENT_LIBRARY@ diff --git a/src/uthash.h b/src/uthash.h index 8bdca55..ea99839 100644 --- a/src/uthash.h +++ b/src/uthash.h @@ -714,25 +714,35 @@ typedef unsigned char uint8_t; hashv += (unsigned)(keylen); \ switch (_hj_k) { \ case 11: \ - hashv += ((unsigned)_hj_key[10] << 24); /* FALLTHROUGH */ \ + hashv += ((unsigned)_hj_key[10] << 24); \ + H5_ATTR_FALLTHROUGH \ case 10: \ - hashv += ((unsigned)_hj_key[9] << 16); /* FALLTHROUGH */ \ + hashv += ((unsigned)_hj_key[9] << 16); \ + H5_ATTR_FALLTHROUGH \ case 9: \ - hashv += ((unsigned)_hj_key[8] << 8); /* FALLTHROUGH */ \ + hashv += ((unsigned)_hj_key[8] << 8); \ + H5_ATTR_FALLTHROUGH \ case 8: \ - _hj_j += ((unsigned)_hj_key[7] << 24); /* FALLTHROUGH */ \ + _hj_j += ((unsigned)_hj_key[7] << 24); \ + H5_ATTR_FALLTHROUGH \ case 7: \ - _hj_j += ((unsigned)_hj_key[6] << 16); /* FALLTHROUGH */ \ + _hj_j += ((unsigned)_hj_key[6] << 16); \ + H5_ATTR_FALLTHROUGH \ case 6: \ - _hj_j += ((unsigned)_hj_key[5] << 8); /* FALLTHROUGH */ \ + _hj_j += ((unsigned)_hj_key[5] << 8); \ + H5_ATTR_FALLTHROUGH \ case 5: \ - _hj_j += _hj_key[4]; /* FALLTHROUGH */ \ + _hj_j += _hj_key[4]; \ + H5_ATTR_FALLTHROUGH \ case 4: \ - _hj_i += ((unsigned)_hj_key[3] << 24); /* FALLTHROUGH */ \ + _hj_i += ((unsigned)_hj_key[3] << 24); \ + H5_ATTR_FALLTHROUGH \ case 3: \ - _hj_i += ((unsigned)_hj_key[2] << 16); /* FALLTHROUGH */ \ + _hj_i += ((unsigned)_hj_key[2] << 16); \ + H5_ATTR_FALLTHROUGH \ case 2: \ - _hj_i += ((unsigned)_hj_key[1] << 8); /* FALLTHROUGH */ \ + _hj_i += ((unsigned)_hj_key[1] << 8); \ + H5_ATTR_FALLTHROUGH \ case 1: \ _hj_i += _hj_key[0]; \ } \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1461101..4e543fd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -357,7 +357,7 @@ set (H5_TESTS ros3 s3comms hdfs - mirror_vfd + #mirror_vfd # multiple source ntypes dangle dtransform @@ -378,6 +378,9 @@ set (H5_TESTS cmpd_dtransform event_set ) +if (HDF5_BUILD_UTILS) + set (H5_TESTS ${H5_TESTS} mirror_vfd) +endif () macro (ADD_H5_EXE file) add_executable (${file} ${HDF5_TEST_SOURCE_DIR}/${file}.c) @@ -552,30 +555,25 @@ if (HDF5_ENABLE_FORMATTERS) clang_format (HDF5_TEST_thread_id_FORMAT thread_id) endif () -#-- Adding test for mirror_vfd -add_executable (mirror_vfd ${mirror_vfd_SOURCES}) -target_include_directories (mirror_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") -if (NOT BUILD_SHARED_LIBS) - TARGET_C_PROPERTIES (mirror_vfd STATIC) - target_link_libraries (mirror_vfd PRIVATE ${HDF5_TEST_LIB_TARGET}) -else () - TARGET_C_PROPERTIES (mirror_vfd SHARED) - target_link_libraries (mirror_vfd PRIVATE ${HDF5_TEST_LIBSH_TARGET}) -endif () -set_target_properties (mirror_vfd PROPERTIES FOLDER test) - -#----------------------------------------------------------------------------- -# Add Target to clang-format -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_FORMATTERS) - clang_format (HDF5_TEST_mirror_vfd_FORMAT mirror_vfd) -endif () +if (HDF5_BUILD_UTILS) # requires mirror server + #-- Adding test for mirror_vfd + add_executable (mirror_vfd ${mirror_vfd_SOURCES}) + target_include_directories (mirror_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (mirror_vfd STATIC) + target_link_libraries (mirror_vfd PRIVATE ${HDF5_TEST_LIB_TARGET}) + else () + TARGET_C_PROPERTIES (mirror_vfd SHARED) + target_link_libraries (mirror_vfd PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + endif () + set_target_properties (mirror_vfd PROPERTIES FOLDER test) -#----------------------------------------------------------------------------- -# Add Target to clang-format -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_FORMATTERS) - clang_format (HDF5_TEST_event_set_FORMAT event_set) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TEST_mirror_vfd_FORMAT mirror_vfd) + endif () endif () ############################################################################## @@ -617,7 +615,6 @@ endif () set (H5_SWMR_TESTS swmr_addrem_writer - swmr_check_compat_vfd swmr_generator swmr_reader swmr_remove_reader @@ -755,24 +752,26 @@ if (HDF5_ENABLE_FORMATTERS) clang_format (HDF5_TEST_use_append_chunk_FORMAT use_append_chunk) endif () -set (use_append_chunk_mirror_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_append_chunk_mirror.c ${HDF5_TEST_SOURCE_DIR}/use_common.c ${HDF5_TEST_SOURCE_DIR}/use.h) -add_executable (use_append_chunk_mirror ${use_append_chunk_mirror_SOURCES}) -target_compile_options(use_append_chunk_mirror PRIVATE "${HDF5_CMAKE_C_FLAGS}") -target_include_directories (use_append_chunk_mirror PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") -if (NOT BUILD_SHARED_LIBS) - TARGET_C_PROPERTIES (use_append_chunk_mirror STATIC) - target_link_libraries (use_append_chunk_mirror PRIVATE ${HDF5_TEST_LIB_TARGET}) -else () - TARGET_C_PROPERTIES (use_append_chunk_mirror SHARED) - target_link_libraries (use_append_chunk_mirror PRIVATE ${HDF5_TEST_LIBSH_TARGET}) -endif () -set_target_properties (use_append_chunk_mirror PROPERTIES FOLDER test) +if (HDF5_BUILD_UTILS) # requires mirror server + set (use_append_chunk_mirror_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_append_chunk_mirror.c ${HDF5_TEST_SOURCE_DIR}/use_common.c ${HDF5_TEST_SOURCE_DIR}/use.h) + add_executable (use_append_chunk_mirror ${use_append_chunk_mirror_SOURCES}) + target_compile_options(use_append_chunk_mirror PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_include_directories (use_append_chunk_mirror PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (use_append_chunk_mirror STATIC) + target_link_libraries (use_append_chunk_mirror PRIVATE ${HDF5_TEST_LIB_TARGET}) + else () + TARGET_C_PROPERTIES (use_append_chunk_mirror SHARED) + target_link_libraries (use_append_chunk_mirror PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + endif () + set_target_properties (use_append_chunk_mirror PROPERTIES FOLDER test) -#----------------------------------------------------------------------------- -# Add Target to clang-format -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_FORMATTERS) - clang_format (HDF5_TEST_use_append_chunk_mirror_FORMAT use_append_chunk_mirror) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TEST_use_append_chunk_mirror_FORMAT use_append_chunk_mirror) + endif () endif () set (use_append_mchunks_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_append_mchunks.c ${HDF5_TEST_SOURCE_DIR}/use_common.c ${HDF5_TEST_SOURCE_DIR}/use.h) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index c537f37..b2ed8e8 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -879,8 +879,6 @@ if (ENABLE_EXTENDED_TESTS) # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* -# add_test (NAME H5Test-swmr_check_compat_vfd COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - #-- Adding test for flushrefresh file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/flushrefresh_test") if (H5_PERL_FOUND) diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index 723595b..e08e4d2 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -16,41 +16,10 @@ ############################################################################## ############################################################################## # included from CMakeTests.cmake +H5_CREATE_VFD_DIR() -set (VFD_LIST - sec2 - stdio - core - core_paged - split - multi - family - splitter - #log - log VFD currently has file space allocation bugs -) - -if (H5_HAVE_DIRECT) - set (VFD_LIST ${VFD_LIST} direct) -endif () -if (H5_HAVE_PARALLEL) - # MPI I/O VFD is currently incompatible with too many tests in the VFD test set - # set (VFD_LIST ${VFD_LIST} mpio) -endif () -if (H5_HAVE_MIRROR_VFD) - set (VFD_LIST ${VFD_LIST} mirror) -endif () -if (H5_HAVE_ROS3_VFD) - set (VFD_LIST ${VFD_LIST} ros3) -endif () -if (H5_HAVE_LIBHDFS) - set (VFD_LIST ${VFD_LIST} hdfs) -endif () -if (H5_HAVE_WINDOWS) - set (VFD_LIST ${VFD_LIST} windows) -endif () - +# create more test folders for each VFD foreach (vfdtest ${VFD_LIST}) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}") file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}/testfiles") file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}/testfiles/plist_files") endforeach () diff --git a/test/Makefile.am b/test/Makefile.am index 09277b0..ff09003 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -36,8 +36,7 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # test_mirror.sh: mirror_vfd ../utils/mirror_vfd/* # test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh testexternal_env.sh \ - testswmr.sh testvds_env.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh \ - test_mirror.sh + testswmr.sh testvds_env.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ external_env$(EXEEXT) filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ flushrefresh$(EXEEXT) use_append_chunk$(EXEEXT) use_append_mchunks$(EXEEXT) use_disable_mdc_flushes$(EXEEXT) \ @@ -50,6 +49,10 @@ if HAVE_SHARED_CONDITIONAL SCRIPT_DEPEND += filter_plugin$(EXEEXT) vol_plugin$(EXEEXT) endif +if MIRROR_VFD_CONDITIONAL + TEST_SCRIPT += test_mirror.sh +endif + check_SCRIPTS = $(TEST_SCRIPT) # These are our main targets. They should be listed in the order to be @@ -91,12 +94,15 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ use_append_chunk use_append_chunk_mirror use_append_mchunks use_disable_mdc_flushes \ swmr_generator swmr_start_write swmr_reader swmr_writer swmr_remove_reader \ swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \ - swmr_check_compat_vfd vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer \ - mirror_vfd + vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer if HAVE_SHARED_CONDITIONAL check_PROGRAMS+= filter_plugin vfd_plugin vol_plugin endif +if MIRROR_VFD_CONDITIONAL + check_PROGRAMS+= mirror_vfd +endif + # These programs generate test files for the tests. They don't need to be # compiled every time we want to test the library. However, putting # them in a conditional causes automake to generate rules so that they diff --git a/test/ShellTests.cmake b/test/ShellTests.cmake index 9614152..732091b 100644 --- a/test/ShellTests.cmake +++ b/test/ShellTests.cmake @@ -21,6 +21,7 @@ if (UNIX) if (SH_PROGRAM) set (srcdir ${HDF5_TEST_SOURCE_DIR}) set (bindir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set (testdir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) ############################################################################## # configure scripts to test dir ############################################################################## @@ -37,7 +38,7 @@ if (UNIX) #shell script creates dir #file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/swmr_test") add_custom_command ( - TARGET swmr_check_compat_vfd + TARGET accum_swmr_reader POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${HDF5_SOURCE_DIR}/bin/output_filter.sh" "${HDF5_TEST_BINARY_DIR}/H5TEST/bin/output_filter.sh" @@ -46,9 +47,11 @@ if (UNIX) #shell script creates dir #file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/usecases_test") - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/swmr_test") + #shell script creates dir + #file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/swmr_test") - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/vds_swmr_test") + #shell script creates dir + #file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/vds_swmr_test") ############################################################################## ############################################################################## diff --git a/test/cork.c b/test/cork.c index 8001f5d..2031ac1 100644 --- a/test/cork.c +++ b/test/cork.c @@ -93,10 +93,11 @@ static unsigned verify_old_dset_cork(void) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */ - hid_t dcpl = -1, dcpl2 = -1, dcpl3 = -1; /* Dataset creation property lists */ - hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t did = H5I_INVALID_HID, did2 = H5I_INVALID_HID, did3 = H5I_INVALID_HID; /* Dataset IDs */ + hid_t dcpl = H5I_INVALID_HID, dcpl2 = H5I_INVALID_HID, + dcpl3 = H5I_INVALID_HID; /* Dataset creation property lists */ + hid_t sid = H5I_INVALID_HID, sid2 = H5I_INVALID_HID, sid3 = H5I_INVALID_HID; /* Dataspace IDs */ hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ @@ -299,19 +300,19 @@ static unsigned verify_obj_dset_cork(hbool_t swmr) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t aid = -1; /* Attribute ID */ - hid_t sid = -1, sid2 = -1; /* Dataspace IDs */ - hid_t did = -1, did2 = -1; /* Dataset IDs */ - hid_t oid = -1; /* Object ID */ - hid_t dcpl2; /* Dataset creation property list */ - int i = 0; /* Local index variable */ - hsize_t dim[1] = {100}; /* Dataset dimension size */ - hsize_t chunk_dim[1] = {7}; /* Dataset chunk dimension size */ - H5O_info2_t oinfo, oinfo2; /* Object metadata information */ - char attrname[500]; /* Name of attribute */ - unsigned flags; /* File access flags */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t sid = H5I_INVALID_HID, sid2 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t did = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* Dataset IDs */ + hid_t oid = H5I_INVALID_HID; /* Object ID */ + hid_t dcpl2 = H5I_INVALID_HID; /* Dataset creation property list */ + int i = 0; /* Local index variable */ + hsize_t dim[1] = {100}; /* Dataset dimension size */ + hsize_t chunk_dim[1] = {7}; /* Dataset chunk dimension size */ + H5O_info2_t oinfo, oinfo2; /* Object metadata information */ + char attrname[500]; /* Name of attribute */ + unsigned flags; /* File access flags */ if (swmr) { TESTING("cork status for dataset objects with attributes (SWMR)"); @@ -504,11 +505,11 @@ static unsigned verify_dset_cork(hbool_t swmr, hbool_t new_format) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t did = H5I_INVALID_HID, did2 = H5I_INVALID_HID, did3 = H5I_INVALID_HID; /* Dataset IDs */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hid_t sid = H5I_INVALID_HID, sid2 = H5I_INVALID_HID, sid3 = H5I_INVALID_HID; /* Dataspace IDs */ hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ @@ -762,15 +763,15 @@ static unsigned verify_group_cork(hbool_t swmr) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t gid = -1, gid2 = -1, gid3 = -1; /* Group IDs */ - H5O_info2_t oinfo, oinfo2, oinfo3; /* Object metadata information */ - hid_t aid; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - char attrname[500]; /* Name of attribute */ - unsigned flags; /* File access flags */ - int i = 0; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t gid = H5I_INVALID_HID, gid2 = H5I_INVALID_HID, gid3 = H5I_INVALID_HID; /* Group IDs */ + H5O_info2_t oinfo, oinfo2, oinfo3; /* Object metadata information */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + char attrname[500]; /* Name of attribute */ + unsigned flags; /* File access flags */ + int i = 0; /* Local index variable */ /* Testing Macro */ if (swmr) { @@ -931,17 +932,17 @@ static unsigned verify_named_cork(hbool_t swmr) { /* Variable Declarations */ - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t tid = -1, tid2 = -1, tid3 = -1; /* Datatype IDs */ - hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5O_info2_t oinfo, oinfo2, oinfo3, oinfo4; /* Object metadata information */ - hid_t aid = -1; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - hid_t did; /* Dataset ID */ - char attrname[500]; /* Name of attribute */ - unsigned flags; /* File access flags */ - int i = 0; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t tid = H5I_INVALID_HID, tid2 = H5I_INVALID_HID, tid3 = H5I_INVALID_HID; /* Datatype IDs */ + hid_t gid = H5I_INVALID_HID, gid2 = H5I_INVALID_HID; /* Group IDs */ + H5O_info2_t oinfo, oinfo2, oinfo3, oinfo4; /* Object metadata information */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + char attrname[500]; /* Name of attribute */ + unsigned flags; /* File access flags */ + int i = 0; /* Local index variable */ /* Testing Macro */ if (swmr) { @@ -1208,20 +1209,20 @@ static unsigned verify_multiple_cork(hbool_t swmr) { /* Variable Declarations */ - hid_t fid1 = -1, fid2 = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */ - hid_t gid1 = -1, gid2 = -1; /* Group IDs */ - hid_t did1 = -1, did2 = -1; /* Dataset ID */ - hid_t aidg1 = -1, aidg2 = -1; /* Attribute ID */ - hid_t aidd1 = -1, aidd2 = -1; /* Attribute ID */ - hid_t aidt1 = -1, aidt2 = -1; /* Attribute ID */ - hid_t sid = -1; /* Dataspace ID */ - H5O_info2_t oinfo1, oinfo2, oinfo3; /* Object metadata information */ - hsize_t dim[1] = {5}; /* Dimension sizes */ - unsigned flags; /* File access flags */ - hbool_t corked; /* Cork status */ - herr_t ret; /* Return value */ + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + hid_t tid1 = H5I_INVALID_HID, tid2 = H5I_INVALID_HID; /* Datatype IDs */ + hid_t gid1 = H5I_INVALID_HID, gid2 = H5I_INVALID_HID; /* Group IDs */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* Dataset ID */ + hid_t aidg1 = H5I_INVALID_HID, aidg2 = H5I_INVALID_HID; /* Attribute ID */ + hid_t aidd1 = H5I_INVALID_HID, aidd2 = H5I_INVALID_HID; /* Attribute ID */ + hid_t aidt1 = H5I_INVALID_HID, aidt2 = H5I_INVALID_HID; /* Attribute ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + H5O_info2_t oinfo1, oinfo2, oinfo3; /* Object metadata information */ + hsize_t dim[1] = {5}; /* Dimension sizes */ + unsigned flags; /* File access flags */ + hbool_t corked; /* Cork status */ + herr_t ret; /* Return value */ /* Testing Macro */ if (swmr) { @@ -1884,18 +1885,18 @@ error: static unsigned test_dset_cork(hbool_t swmr, hbool_t new_format) { - hid_t fid; /* File ID */ - hid_t fapl; /* File access property list */ - hid_t gid; /* Groupd ID */ - hid_t did1, did2; /* Dataset IDs */ - hid_t tid1, tid2; /* Datatype IDs */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataset creation property list */ - hsize_t dims[RANK]; /* Dataset dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dataset dimensions */ - hsize_t cdims[RANK] = {2, 2}; /* Chunk dimensions */ - int fillval = 0; /* Fill value */ - int i, j, k = 0; /* Local index variables */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl; /* File access property list */ + hid_t gid = H5I_INVALID_HID; /* Groupd ID */ + hid_t did1 = H5I_INVALID_HID, did2 = H5I_INVALID_HID; /* Dataset IDs */ + hid_t tid1 = H5I_INVALID_HID, tid2 = H5I_INVALID_HID; /* Datatype IDs */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hsize_t dims[RANK]; /* Dataset dimensions */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dataset dimensions */ + hsize_t cdims[RANK] = {2, 2}; /* Chunk dimensions */ + int fillval = 0; /* Fill value */ + int i, j, k = 0; /* Local index variables */ int ** wbuf = NULL; /* Data buffer for writes (pointers to fake 2D array) */ int * wbuf_data = NULL; /* Data buffer for writes (real data) */ int * rbuf_data = NULL; /* Data buffer for reads (real data) */ diff --git a/test/dt_arith.c b/test/dt_arith.c index 91e31d5..7e96d29 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -68,9 +68,7 @@ typedef enum dtype_t { INT_ULLONG, FLT_FLOAT, FLT_DOUBLE, -#if H5_SIZEOF_LONG_DOUBLE != 0 FLT_LDOUBLE, -#endif OTHER } dtype_t; @@ -457,10 +455,8 @@ reset_hdf5(void) SET_ALIGNMENT(ULLONG, H5_SIZEOF_LONG_LONG); SET_ALIGNMENT(FLOAT, H5_SIZEOF_FLOAT); SET_ALIGNMENT(DOUBLE, H5_SIZEOF_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE != 0 SET_ALIGNMENT(LDOUBLE, H5_SIZEOF_LONG_DOUBLE); #endif -#endif } /*------------------------------------------------------------------------- @@ -2704,10 +2700,10 @@ my_isnan(dtype_t type, void *val) double x = 0.0; HDmemcpy(&x, val, sizeof(double)); retval = (x != x); -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (FLT_LDOUBLE == type) { - long double x = 0.0; + long double x = 0.0L; HDmemcpy(&x, val, sizeof(long double)); retval = (x != x); #endif @@ -2732,10 +2728,10 @@ my_isnan(dtype_t type, void *val) HDmemcpy(&x, val, sizeof(double)); HDsnprintf(s, sizeof(s), "%g", x); -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (FLT_LDOUBLE == type) { - long double x = 0.0; + long double x = 0.0L; HDmemcpy(&x, val, sizeof(long double)); HDsnprintf(s, sizeof(s), "%Lg", x); @@ -2898,7 +2894,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) else if (H5Tequal(src, H5T_NATIVE_DOUBLE)) { src_type_name = "double"; src_type = FLT_DOUBLE; -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (H5Tequal(src, H5T_NATIVE_LDOUBLE)) { src_type_name = "long double"; @@ -2917,7 +2913,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) else if (H5Tequal(dst, H5T_NATIVE_DOUBLE)) { dst_type_name = "double"; dst_type = FLT_DOUBLE; -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (H5Tequal(dst, H5T_NATIVE_LDOUBLE)) { dst_type_name = "long double"; @@ -3000,7 +2996,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) else if (src_type == FLT_DOUBLE) { INIT_FP_NORM(double, DBL_MAX, DBL_MIN, DBL_MAX_10_EXP, DBL_MIN_10_EXP, src_size, dst_size, buf, saved, nelmts); -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (src_type == FLT_LDOUBLE) { INIT_FP_NORM(long double, LDBL_MAX, LDBL_MIN, LDBL_MAX_10_EXP, LDBL_MIN_10_EXP, src_size, @@ -3019,7 +3015,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) else if (src_type == FLT_DOUBLE) { INIT_FP_DENORM(double, DBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, nelmts); -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (src_type == FLT_LDOUBLE) { INIT_FP_DENORM(long double, LDBL_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, @@ -3037,7 +3033,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) } else if (src_type == FLT_DOUBLE) { INIT_FP_SPECIAL(src_size, src_nbits, sendian, DBL_MANT_DIG, dst_size, buf, saved, nelmts); -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (src_type == FLT_LDOUBLE) { INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts); @@ -3059,7 +3055,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) for (j = 0; j < nelmts; j++) { underflow = 0; hw_f = 911.0F; - hw_d = 911.0F; + hw_d = 911.0; #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE hw_ld = 911.0L; #endif @@ -3108,14 +3104,14 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) if (FLT_FLOAT == dst_type) { hw_f = (float)*((long double *)aligned); hw = (unsigned char *)&hw_f; - underflow = HDfabsl(*((long double *)aligned)) < FLT_MIN; - overflow = HDfabsl(*((long double *)aligned)) > FLT_MAX; + underflow = HDfabsl(*((long double *)aligned)) < (long double)FLT_MIN; + overflow = HDfabsl(*((long double *)aligned)) > (long double)FLT_MAX; } else if (FLT_DOUBLE == dst_type) { hw_d = (double)*((long double *)aligned); hw = (unsigned char *)&hw_d; - underflow = HDfabsl(*((long double *)aligned)) < DBL_MIN; - overflow = HDfabsl(*((long double *)aligned)) > DBL_MAX; + underflow = HDfabsl(*((long double *)aligned)) < (long double)DBL_MIN; + overflow = HDfabsl(*((long double *)aligned)) > (long double)DBL_MAX; } else { hw_ld = *((long double *)aligned); @@ -3133,7 +3129,6 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) * last few unused bytes may have garbage in them. Clean them out with * 0s before compare the values. */ -#if H5_SIZEOF_LONG_DOUBLE != 0 if (sendian == H5T_ORDER_LE && dst_type == FLT_LDOUBLE) { size_t q; @@ -3142,7 +3137,6 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) hw[q] = 0x00; } } -#endif /* Are the two results the same? */ for (k = (dst_size - (dst_nbits / 8)); k < dst_size; k++) @@ -3163,7 +3157,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) else if (FLT_DOUBLE == dst_type && my_isnan(dst_type, buf + j * sizeof(double)) && my_isnan(dst_type, hw)) { continue; -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (FLT_LDOUBLE == dst_type && my_isnan(dst_type, buf + j * sizeof(long double)) && my_isnan(dst_type, hw)) { @@ -3204,8 +3198,8 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) if (overflow && my_isinf(dendian, buf + j * sizeof(float), dst_size, dst_mpos, dst_msize, dst_epos, dst_esize)) continue; /* all overflowed, no error */ - check_mant[0] = HDfrexpf(x, check_expo + 0); - check_mant[1] = HDfrexpf(hw_f, check_expo + 1); + check_mant[0] = (double)HDfrexpf(x, check_expo + 0); + check_mant[1] = (double)HDfrexpf(hw_f, check_expo + 1); } else if (FLT_DOUBLE == dst_type) { double x = 0.0; @@ -3217,10 +3211,10 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) continue; /* all overflowed, no error */ check_mant[0] = HDfrexp(x, check_expo + 0); check_mant[1] = HDfrexp(hw_d, check_expo + 1); -#if H5_SIZEOF_LONG_DOUBLE != 0 && (H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE) +#if (H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE) } else { - long double x = 0.0; + long double x = 0.0L; HDmemcpy(&x, &buf[j * dst_size], sizeof(long double)); /* dst is largest float, no need to check underflow. */ check_mant[0] = (double)HDfrexpl(x, check_expo + 0); @@ -3278,7 +3272,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else { - long double x = 0.0; + long double x = 0.0L; HDmemcpy(&x, &saved[j * src_size], sizeof(long double)); HDfprintf(stdout, " %29.20Le\n", x); #endif @@ -3300,7 +3294,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else { - long double x = 0.0; + long double x = 0.0L; HDmemcpy(&x, &buf[j * dst_size], sizeof(long double)); HDfprintf(stdout, " %29.20Le\n", x); #endif @@ -3506,7 +3500,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) else if (H5Tequal(src, H5T_NATIVE_DOUBLE)) { src_type_name = "double"; src_type = FLT_DOUBLE; -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (H5Tequal(src, H5T_NATIVE_LDOUBLE)) { src_type_name = "long double"; @@ -3566,7 +3560,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) else if (H5Tequal(dst, H5T_NATIVE_DOUBLE)) { dst_type_name = "double"; dst_type = FLT_DOUBLE; -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (H5Tequal(dst, H5T_NATIVE_LDOUBLE)) { dst_type_name = "long double"; @@ -3590,11 +3584,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) if ((INT_SCHAR == src_type || INT_UCHAR == src_type || INT_SHORT == src_type || INT_USHORT == src_type || INT_INT == src_type || INT_UINT == src_type || INT_LONG == src_type || INT_ULONG == src_type || INT_LLONG == src_type || INT_ULLONG == src_type) && - (FLT_FLOAT != dst_type && FLT_DOUBLE != dst_type -#if H5_SIZEOF_LONG_DOUBLE != 0 - && FLT_LDOUBLE != dst_type -#endif - )) { + (FLT_FLOAT != dst_type && FLT_DOUBLE != dst_type && FLT_LDOUBLE != dst_type)) { HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); HDprintf("%-70s", str); H5_FAILED(); @@ -3602,11 +3592,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) goto error; } - if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type -#if H5_SIZEOF_LONG_DOUBLE != 0 - || FLT_LDOUBLE == src_type -#endif - ) && + if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type) && (INT_SCHAR != dst_type && INT_UCHAR != dst_type && INT_SHORT != dst_type && INT_USHORT != dst_type && INT_INT != dst_type && INT_UINT != dst_type && INT_LONG != dst_type && INT_ULONG != dst_type && INT_LLONG != dst_type && INT_ULLONG != dst_type)) { @@ -3738,7 +3724,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) else { INIT_FP_SPECIAL(src_size, src_nbits, sendian, DBL_MANT_DIG, dst_size, buf, saved, nelmts); } -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } else if (src_type == FLT_LDOUBLE) { if (run_test == TEST_NORMAL) { @@ -3763,11 +3749,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) /* Check the results from the library against hardware */ for (j = 0; j < nelmts; j++) { - if (FLT_FLOAT == src_type || FLT_DOUBLE == src_type -#if H5_SIZEOF_LONG_DOUBLE != 0 - || FLT_LDOUBLE == src_type -#endif - ) + if (FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type) if (my_isnan(src_type, saved + j * src_size)) continue; @@ -3874,7 +3856,6 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDassert(0 && "Unknown type"); break; } -#if H5_SIZEOF_LONG_DOUBLE != 0 } else if (FLT_LDOUBLE == dst_type) { hw = (unsigned char *)&hw_ldouble; @@ -3927,7 +3908,6 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDassert(0 && "Unknown type"); break; } -#endif } else if (INT_SCHAR == dst_type) { hw = (unsigned char *)&hw_schar; @@ -3940,12 +3920,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_schar = (signed char)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_schar = (signed char)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -3973,12 +3951,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_uchar = (unsigned char)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_uchar = (unsigned char)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4006,12 +3982,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_short = (short)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_short = (short)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4039,12 +4013,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_ushort = (unsigned short)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_ushort = (unsigned short)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4072,12 +4044,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_int = (int)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_int = (int)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4105,12 +4075,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_uint = (unsigned int)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_uint = (unsigned int)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4138,12 +4106,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_long = (long)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_long = (long)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4171,12 +4137,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_ulong = (unsigned long)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_ulong = (unsigned long)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4204,12 +4168,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_llong = (long long)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_llong = (long long)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4237,12 +4199,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); hw_ullong = (unsigned long long)(*((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_ullong = (unsigned long long)(*((long double *)aligned)); break; -#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4269,14 +4229,12 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * bytes may have garbage in them. Clean them out with 0s before compare * the values. */ -#if H5_SIZEOF_LONG_DOUBLE != 0 if (dendian == H5T_ORDER_LE && dst_type == FLT_LDOUBLE) { size_t q; for (q = dst_nbits / 8; q < dst_size; q++) buf[j * dst_size + q] = 0x00; } -#endif /* Are the two results the same? */ for (k = (dst_size - (dst_nbits / 8)); k < dst_size; k++) @@ -4315,11 +4273,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * Try to follow the except_func callback function to check if the * desired value was set. */ - if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type -#if H5_SIZEOF_LONG_DOUBLE != 0 - || FLT_LDOUBLE == src_type -#endif - ) && + if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type) && (INT_SCHAR == dst_type || INT_SHORT == dst_type || INT_INT == dst_type || INT_LONG == dst_type || INT_LLONG == dst_type)) { if (0 == H5T__bit_get_d(src_bits, src_nbits - 1, (size_t)1) && @@ -4359,11 +4313,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) } } - if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type -#if H5_SIZEOF_LONG_DOUBLE != 0 - || FLT_LDOUBLE == src_type -#endif - ) && + if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type) && (INT_UCHAR == dst_type || INT_USHORT == dst_type || INT_UINT == dst_type || INT_ULONG == dst_type || INT_ULLONG == dst_type)) { if (H5T__bit_get_d(src_bits, src_nbits - 1, (size_t)1)) { @@ -4462,12 +4412,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, saved + j * sizeof(double), sizeof(double)); HDprintf(" %29f\n", *((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); HDprintf(" %29Lf\n", *((long double *)aligned)); break; -#endif case OTHER: default: HDassert(0 && "Unknown type"); @@ -4527,12 +4475,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDmemcpy(aligned, buf + j * sizeof(double), sizeof(double)); HDprintf(" %29f\n", *((double *)aligned)); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDmemcpy(aligned, buf + j * sizeof(long double), sizeof(long double)); HDprintf(" %29Lf\n", *((long double *)aligned)); break; -#endif case OTHER: default: HDassert(0 && "Unknown type"); @@ -4580,11 +4526,9 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) case FLT_DOUBLE: HDprintf(" %29f\n", *((double *)((void *)hw))); break; -#if H5_SIZEOF_LONG_DOUBLE != 0 case FLT_LDOUBLE: HDprintf(" %29Lf\n", *((long double *)((void *)hw))); break; -#endif case OTHER: default: HDassert(0 && "Unknown type"); @@ -4923,16 +4867,14 @@ run_fp_tests(const char *name) if (!HDstrcmp(name, "noop")) { nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_FLOAT, H5T_NATIVE_FLOAT); nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_DOUBLE, H5T_NATIVE_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE != 0 nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LDOUBLE); -#endif goto done; } /*Test normalized values. TEST_NORMAL indicates normalized values.*/ nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT); -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_FLOAT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_LDOUBLE); nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_LDOUBLE, H5T_NATIVE_FLOAT); @@ -4942,7 +4884,7 @@ run_fp_tests(const char *name) /*Test denormalized values. TEST_DENORM indicates denormalized values.*/ nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT); -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_DOUBLE, H5T_NATIVE_LDOUBLE); #ifndef H5_DISABLE_SOME_LDOUBLE_CONV @@ -4955,11 +4897,7 @@ run_fp_tests(const char *name) "float"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); -#else - HDputs(" Test skipped due to disabled long double."); -#endif } #endif @@ -4969,7 +4907,7 @@ run_fp_tests(const char *name) /*Test special values, +/-0, +/-infinity, +/-QNaN, +/-SNaN.*/ nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT); -#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_LDOUBLE); #ifndef H5_DISABLE_SOME_LDOUBLE_CONV @@ -4983,11 +4921,7 @@ run_fp_tests(const char *name) "float or double"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); -#else - HDputs(" Test skipped due to disabled long double."); -#endif } #endif #endif @@ -5068,11 +5002,7 @@ run_int_fp_conv(const char *name) "long double"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the special algorithm of hardware conversion."); -#else - HDputs(" Test skipped due to disabled long double."); -#endif } #endif #endif /* H5_SIZEOF_LONG!=H5_SIZEOF_INT */ @@ -5193,14 +5123,10 @@ run_fp_int_conv(const char *name) "signed and unsigned char, short, int, long"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the conversion problem on IBM ppc64le cpu."); -#else - HDputs(" Test skipped due to disabled long double."); -#endif #endif } -#if H5_SIZEOF_LONG != H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG != H5_SIZEOF_INT #ifndef H5_LDOUBLE_TO_LONG_SPECIAL if (test_values != TEST_SPECIAL && test_values != TEST_NORMAL) { nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG); @@ -5220,35 +5146,27 @@ run_fp_int_conv(const char *name) "(unsigned) long"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to the special algorithm of hardware conversion."); -#else - HDputs(" Test skipped due to disabled long double."); -#endif } #endif -#endif /*H5_SIZEOF_LONG!=H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE!=0 */ +#endif /*H5_SIZEOF_LONG!=H5_SIZEOF_INT */ -#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG && H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG #ifdef H5_LDOUBLE_TO_LLONG_ACCURATE nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LLONG); -#else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ +#else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ { char str[256]; /*string */ HDsnprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, "long double", "long long"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to hardware conversion error."); -#else - HDputs(" Test skipped due to disabled long double."); -#endif } #endif /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ #if defined(H5_LDOUBLE_TO_LLONG_ACCURATE) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULLONG); -#else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ +#else /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ { char str[256]; /*string */ @@ -5256,11 +5174,7 @@ run_fp_int_conv(const char *name) "unsigned long long"); HDprintf("%-70s", str); SKIPPED(); -#if H5_SIZEOF_LONG_DOUBLE != 0 HDputs(" Test skipped due to hardware conversion error."); -#else - HDputs(" Test skipped due to disabled long double."); -#endif } #endif /*H5_LDOUBLE_TO_LLONG_ACCURATE*/ #endif diff --git a/test/dtransform.c b/test/dtransform.c index b721a59..5d1c04f 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -359,9 +359,7 @@ main(void) TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0); TEST_TYPE_CONTIG(dxpl_id_c_to_f, float, H5T_NATIVE_FLOAT, "float", windchillFfloat, 1); TEST_TYPE_CONTIG(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1); -#if H5_SIZEOF_LONG_DOUBLE != 0 TEST_TYPE_CONTIG(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1); -#endif TEST_TYPE_CHUNK(dxpl_id_utrans_inv, char, H5T_NATIVE_CHAR, "char", transformData, 0); TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned char, H5T_NATIVE_UCHAR, "uchar", transformData, 0); @@ -376,9 +374,7 @@ main(void) TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned long long, H5T_NATIVE_ULLONG, "ullong", transformData, 0); TEST_TYPE_CHUNK(dxpl_id_c_to_f, float, H5T_NATIVE_FLOAT, "float", windchillFfloat, 1); TEST_TYPE_CHUNK(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1); -#if H5_SIZEOF_LONG_DOUBLE != 0 TEST_TYPE_CHUNK(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1); -#endif if (test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy) < 0) TEST_ERROR; diff --git a/test/dtypes.c b/test/dtypes.c index 1c1a6ec..e9a2461 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -160,10 +160,8 @@ reset_hdf5(void) SET_ALIGNMENT(ULLONG, H5_SIZEOF_LONG_LONG); SET_ALIGNMENT(FLOAT, H5_SIZEOF_FLOAT); SET_ALIGNMENT(DOUBLE, H5_SIZEOF_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE != 0 SET_ALIGNMENT(LDOUBLE, H5_SIZEOF_LONG_DOUBLE); #endif -#endif } /*------------------------------------------------------------------------- diff --git a/test/null_vfd_plugin.c b/test/null_vfd_plugin.c index 8031484..f41da00 100644 --- a/test/null_vfd_plugin.c +++ b/test/null_vfd_plugin.c @@ -75,42 +75,73 @@ static const H5FD_class_t H5FD_null_g = { static H5FD_t * H5FD_null_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { + (void)name; + (void)flags; + (void)fapl_id; + (void)maxaddr; + return NULL; } static herr_t H5FD_null_close(H5FD_t *_file) { + (void)_file; + return 0; } static herr_t H5FD_null_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf) { + (void)_file; + (void)type; + (void)dxpl_id; + (void)addr; + (void)size; + (void)buf; + return 0; } static herr_t H5FD_null_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { + (void)_file; + (void)type; + (void)dxpl_id; + (void)addr; + (void)size; + (void)buf; + return 0; } static haddr_t H5FD_null_get_eoa(const H5FD_t *_file, H5FD_mem_t type) { + (void)_file; + (void)type; + return HADDR_UNDEF; } static herr_t H5FD_null_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { + (void)_file; + (void)type; + (void)addr; + return 0; } static haddr_t H5FD_null_get_eof(const H5FD_t *_file, H5FD_mem_t type) { + (void)_file; + (void)type; + return HADDR_UNDEF; } diff --git a/test/swmr.c b/test/swmr.c index e6fdb47..bf84fcd 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -5220,7 +5220,7 @@ test_file_lock_swmr_concur(hid_t H5_ATTR_UNUSED in_fapl) static int test_file_lock_swmr_concur(hid_t in_fapl) { - hid_t fid; /* File ID */ + hid_t fid = H5I_INVALID_HID; /* File ID */ hid_t fapl; /* File access property list */ char filename[NAME_BUF_SIZE]; /* file name */ pid_t childpid = 0; /* Child process ID */ @@ -6721,7 +6721,7 @@ test_refresh_concur(hid_t H5_ATTR_UNUSED in_fapl, hbool_t new_format) static int test_refresh_concur(hid_t in_fapl, hbool_t new_format) { - hid_t fid; /* File ID */ + hid_t fid = H5I_INVALID_HID; /* File ID */ hid_t fapl; /* File access property list */ pid_t childpid = 0; /* Child process ID */ pid_t tmppid; /* Child process ID returned by waitpid */ diff --git a/test/swmr_check_compat_vfd.c b/test/swmr_check_compat_vfd.c deleted file mode 100644 index 720c747..0000000 --- a/test/swmr_check_compat_vfd.c +++ /dev/null @@ -1,53 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* Purpose: This is a small program that checks if the HDF5_DRIVER - * environment variable is set to a value that supports SWMR. - * - * It is intended for use in shell scripts. - */ - -#include "h5test.h" - -/* This file needs to access the file driver testing code */ -#define H5FD_FRIEND /*suppress error about including H5FDpkg */ -#define H5FD_TESTING -#include "H5FDpkg.h" /* File drivers */ - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: Inspects the HDF5_DRIVER environment variable, which - * determines the VFD that the test harness will use with - * the majority of the tests. - * - * Return: VFD supports SWMR: EXIT_SUCCESS - * - * VFD does not support SWMR - * or failure: EXIT_FAILURE - * - *------------------------------------------------------------------------- - */ -int -main(void) -{ - char *driver = NULL; - - driver = HDgetenv(HDF5_DRIVER); - - if (H5FD__supports_swmr_test(driver)) - return EXIT_SUCCESS; - else - return EXIT_FAILURE; - -} /* end main() */ diff --git a/test/tconfig.c b/test/tconfig.c index 101de9a..8bd625f 100644 --- a/test/tconfig.c +++ b/test/tconfig.c @@ -114,30 +114,14 @@ test_config_ctypes(void) vrfy_cint_type(long, unsigned long, H5_SIZEOF_LONG); vrfy_ctype(float, H5_SIZEOF_FLOAT); vrfy_ctype(double, H5_SIZEOF_DOUBLE); -#if H5_SIZEOF_LONG_DOUBLE > 0 vrfy_ctype(long double, H5_SIZEOF_LONG_DOUBLE); -#endif /* standard C99 basic types */ -#if H5_SIZEOF_LONG_LONG > 0 vrfy_cint_type(long long, unsigned long long, H5_SIZEOF_LONG_LONG); -#endif - -#if H5_SIZEOF_INT8_T > 0 vrfy_cint_type(int8_t, uint8_t, H5_SIZEOF_INT8_T); -#endif - -#if H5_SIZEOF_INT16_T > 0 vrfy_cint_type(int16_t, uint16_t, H5_SIZEOF_INT16_T); -#endif - -#if H5_SIZEOF_INT32_T > 0 vrfy_cint_type(int32_t, uint32_t, H5_SIZEOF_INT32_T); -#endif - -#if H5_SIZEOF_INT64_T > 0 vrfy_cint_type(int64_t, uint64_t, H5_SIZEOF_INT64_T); -#endif /* Some vendors have different sizes for the signed and unsigned */ /* fast8_t. Need to check them individually. */ diff --git a/test/test_usecases.sh.in b/test/test_usecases.sh.in index eaa875e..3f7d5f1 100644 --- a/test/test_usecases.sh.in +++ b/test/test_usecases.sh.in @@ -21,14 +21,38 @@ # For now, it shows how to run the test cases programs. It only verifies the # exit codes are okay (0). +############################################################################### +## test variables +############################################################################### + +# Number of errors encountered during test run. +nerrors=0 + +# Define variables +verbose=yes + +############################################################################### +## Main +############################################################################### srcdir=@srcdir@ bindir=@bindir@ +testdir=@testdir@ + +# The build (current) directory might be different than the source directory. +if test -z "$srcdir"; then + srcdir=. +fi # If the bindir directory is not set just use current (.). if test -z "$bindir"; then bindir=. fi +# If the testdir directory is not set just use current (.). +if test -z "$testdir"; then + testdir=. +fi + # Check to see if the VFD specified by the HDF5_DRIVER environment variable # supports SWMR. $bindir/swmr_check_compat_vfd @@ -53,10 +77,6 @@ RESULT_SKIP="-SKIP-" USECASES_PROGRAMS="use_append_chunk use_append_mchunks" TESTNAME="Use Case" -# Define variables -nerrors=0 -verbose=yes - # Source in the output filter function definitions. . $srcdir/../bin/output_filter.sh @@ -91,7 +111,7 @@ TOOLTEST() { # Run test. TESTING $program $@ ( - $RUNSERIAL $bindir/$program "$@" + $RUNSERIAL $testdir/$program "$@" ) >$actual 2>$actual_err exit_code=$? @@ -123,7 +143,7 @@ TOOLTEST() { # the test. Running each of these tests in its own directory should eliminate # the problem. mkdir usecases_test -cp twriteorder usecases_test +cp $bindir/twriteorder usecases_test for FILE in use_*; do case "$FILE" in *.o) continue ;; ## don't copy the .o files diff --git a/test/testflushrefresh.sh.in b/test/testflushrefresh.sh.in index 83685e8..3c7f13d 100644 --- a/test/testflushrefresh.sh.in +++ b/test/testflushrefresh.sh.in @@ -58,14 +58,28 @@ fi ############################################################################### ## Main ############################################################################### +srcdir=@srcdir@ +bindir=@bindir@ +testdir=@testdir@ + # The build (current) directory might be different than the source directory. if test -z "$srcdir"; then srcdir=. fi +# If the bindir directory is not set just use current (.). +if test -z "$bindir"; then + bindir=. +fi + +# If the testdir directory is not set just use current (.). +if test -z "$testdir"; then + testdir=. +fi + # Check to see if the VFD specified by the HDF5_DRIVER environment variable # supports SWMR. -./swmr_check_compat_vfd +$bindir/swmr_check_compat_vfd rc=$? if [ $rc -ne 0 ] ; then echo @@ -83,7 +97,7 @@ fi # the test. Running each of these tests in its own directory should eliminate # the problem. mkdir -p flushrefresh_test -cp flushrefresh flushrefresh_test +cp $bindir/flushrefresh flushrefresh_test # With the --disable-shared option, flushrefresh is built in the test directory, # otherwise it is in test/.libs with a wrapper script named flushrefresh in @@ -118,7 +132,7 @@ fi # ======================== # Launch the Test Program. # ======================== -./flushrefresh & +$testdir/flushrefresh & pid_main=$! # ======================================= @@ -155,7 +169,7 @@ until [ $verification_done -eq 1 ]; do verification_done=1 echo "all flush verification complete" > $endsignal else - ./flushrefresh $param1 $param2 + $testdir/flushrefresh $param1 $param2 # Check for core dump if [ $? -gt 0 ]; then @@ -200,7 +214,7 @@ if [ $timedout -eq 0 ]; then verification_done=2 echo "all refresh verification complete" > $endsignal else - ./flushrefresh $param1 + $testdir/flushrefresh $param1 # Check for core dump if [ $? -gt 0 ]; then diff --git a/test/testmeta.c b/test/testmeta.c index c59c6cb..7cb3000 100644 --- a/test/testmeta.c +++ b/test/testmeta.c @@ -195,7 +195,7 @@ main(void) start[0] = 0; status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, start, stride, count, NULL); - start[0] = (hssize_t)j; + start[0] = (hsize_t)j; status = H5Sselect_hyperslab(dataspace_id, H5S_SELECT_SET, start, stride, count, NULL); status = H5Dwrite(dataset_id, type_id, memspace_id, dataspace_id, H5P_DEFAULT, &floatval); if (status < 0) { diff --git a/test/testswmr.sh.in b/test/testswmr.sh.in index 37e8f9c..cb60fce 100644 --- a/test/testswmr.sh.in +++ b/test/testswmr.sh.in @@ -18,6 +18,7 @@ srcdir=@srcdir@ bindir=@bindir@ +testdir=@testdir@ ############################################################################### ## test parameters @@ -103,6 +104,11 @@ if test -z "$bindir"; then bindir=. fi +# If the testdir directory is not set just use current (.). +if test -z "$testdir"; then + testdir=. +fi + # Check to see if the VFD specified by the HDF5_DRIVER environment variable # supports SWMR. $bindir/swmr_check_compat_vfd @@ -178,7 +184,7 @@ do echo "###############################################################################" # Launch the Generator without SWMR_WRITE echo launch the swmr_generator - $bindir/swmr_generator $compress $index_type + $testdir/swmr_generator $compress $index_type if test $? -ne 0; then echo generator had error nerrors=`expr $nerrors + 1` @@ -186,7 +192,7 @@ do # Launch the Generator with SWMR_WRITE echo launch the swmr_generator with SWMR_WRITE - $bindir/swmr_generator -s $compress $index_type + $testdir/swmr_generator -s $compress $index_type if test $? -ne 0; then echo generator had error nerrors=`expr $nerrors + 1` @@ -210,7 +216,7 @@ do # Launch the Writer echo launch the swmr_start_writer seed="" # Put -r command here - $bindir/swmr_start_write $compress $index_type $Nrecords $seed 2>&1 |tee swmr_writer.out & + $testdir/swmr_start_write $compress $index_type $Nrecords $seed 2>&1 |tee swmr_writer.out & pid_writer=$! $DPRINT pid_writer=$pid_writer @@ -226,7 +232,7 @@ do while [ $n -lt $Nreaders ]; do #seed="-r ${seeds[$n]}" seed="" - $bindir/swmr_reader $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & + $testdir/swmr_reader $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" n=`expr $n + 1` done @@ -271,7 +277,7 @@ do # Launch the Generator echo launch the swmr_generator - $bindir/swmr_generator -s $compress $index_type + $testdir/swmr_generator -s $compress $index_type if test $? -ne 0; then echo generator had error nerrors=`expr $nerrors + 1` @@ -283,7 +289,7 @@ do # Launch the Writer echo launch the swmr_writer seed="" # Put -r command here - $bindir/swmr_writer -o $Nrecords $seed 2>&1 |tee swmr_writer.out & + $testdir/swmr_writer -o $Nrecords $seed 2>&1 |tee swmr_writer.out & pid_writer=$! $DPRINT pid_writer=$pid_writer @@ -298,7 +304,7 @@ do while [ $n -lt $Nreaders ]; do #seed="-r ${seeds[$n]}" seed="" - $bindir/swmr_reader $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & + $testdir/swmr_reader $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" n=`expr $n + 1` done @@ -346,7 +352,7 @@ do # Launch the Remove Writer echo launch the swmr_remove_writer seed="" # Put -r command here - $bindir/swmr_remove_writer -o $Nrecs_rem $seed 2>&1 |tee swmr_writer.out & + $testdir/swmr_remove_writer -o $Nrecs_rem $seed 2>&1 |tee swmr_writer.out & pid_writer=$! $DPRINT pid_writer=$pid_writer @@ -361,7 +367,7 @@ do while [ $n -lt $Nreaders ]; do #seed="-r ${seeds[$n]}" seed="" - $bindir/swmr_remove_reader $Nsecs_rem $seed 2>&1 |tee swmr_reader.out.$n & + $testdir/swmr_remove_reader $Nsecs_rem $seed 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" n=`expr $n + 1` done @@ -406,7 +412,7 @@ do # Launch the Generator echo launch the swmr_generator - $bindir/swmr_generator $compress $index_type + $testdir/swmr_generator $compress $index_type if test $? -ne 0; then echo generator had error nerrors=`expr $nerrors + 1` @@ -415,7 +421,7 @@ do # Launch the Writer (not in parallel - just to rebuild the datasets) echo launch the swmr_writer seed="" # Put -r command here - $bindir/swmr_writer $Nrecords $seed + $testdir/swmr_writer $Nrecords $seed if test $? -ne 0; then echo writer had error nerrors=`expr $nerrors + 1` @@ -427,7 +433,7 @@ do # Launch the Add/Remove Writer echo launch the swmr_addrem_writer seed="" # Put -r command here - $bindir/swmr_addrem_writer $Nrecords $seed 2>&1 |tee swmr_writer.out & + $testdir/swmr_addrem_writer $Nrecords $seed 2>&1 |tee swmr_writer.out & pid_writer=$! $DPRINT pid_writer=$pid_writer @@ -442,7 +448,7 @@ do while [ $n -lt $Nreaders ]; do #seed="-r ${seeds[$n]}" seed="" - $bindir/swmr_remove_reader $Nsecs_addrem $seed 2>&1 |tee swmr_reader.out.$n & + $testdir/swmr_remove_reader $Nsecs_addrem $seed 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" n=`expr $n + 1` done @@ -490,7 +496,7 @@ do # created by the generator. echo launch the swmr_generator seed="" # Put -r command here - $bindir/swmr_generator $compress $index_type $seed + $testdir/swmr_generator $compress $index_type $seed if test $? -ne 0; then echo generator had error nerrors=`expr $nerrors + 1` @@ -500,7 +506,7 @@ do rm -f $WRITER_MESSAGE # Launch the Sparse writer echo launch the swmr_sparse_writer - nice -n 20 $bindir/swmr_sparse_writer $Nrecs_spa 2>&1 |tee swmr_writer.out & + nice -n 20 $testdir/swmr_sparse_writer $Nrecs_spa 2>&1 |tee swmr_writer.out & pid_writer=$! $DPRINT pid_writer=$pid_writer @@ -513,7 +519,7 @@ do echo launch $Nrdrs_spa swmr_sparse_readers while [ $n -lt $Nrdrs_spa ]; do # The sparse reader spits out a LOT of data so it's set to 'quiet' - $bindir/swmr_sparse_reader -q $Nrecs_spa 2>&1 |tee swmr_reader.out.$n & + $testdir/swmr_sparse_reader -q $Nrecs_spa 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" n=`expr $n + 1` done diff --git a/test/testvdsswmr.sh.in b/test/testvdsswmr.sh.in index 5399903..c57cc08 100644 --- a/test/testvdsswmr.sh.in +++ b/test/testvdsswmr.sh.in @@ -18,6 +18,7 @@ srcdir=@srcdir@ bindir=@bindir@ +testdir=@testdir@ ############################################################################### ## test parameters @@ -89,6 +90,11 @@ if test -z "$bindir"; then bindir=. fi +# If the testdir directory is not set just use current (.). +if test -z "$testdir"; then + testdir=. +fi + # Check to see if the VFD specified by the HDF5_DRIVER environment variable # supports SWMR. $bindir/swmr_check_compat_vfd @@ -154,7 +160,7 @@ echo "########################################################################## # Launch the file generator echo launch the generator -$bindir/vds_swmr_gen +$testdir/vds_swmr_gen if test $? -ne 0; then echo generator had error nerrors=`expr $nerrors + 1` @@ -172,7 +178,7 @@ echo "launch the $Nwriters SWMR VDS writers (1 per source)" pid_writers="" n=0 while [ $n -lt $Nwriters ]; do - $bindir/vds_swmr_writer $n & + $testdir/vds_swmr_writer $n & pid_writers="$pid_writers $!" n=`expr $n + 1` done @@ -187,7 +193,7 @@ echo launch $Nreaders SWMR readers pid_readers="" n=0 while [ $n -lt $Nreaders ]; do - $bindir/vds_swmr_reader & + $testdir/vds_swmr_reader & pid_readers="$pid_readers $!" n=`expr $n + 1` done diff --git a/test/tskiplist.c b/test/tskiplist.c index 4bf9b11..31b5cff 100644 --- a/test/tskiplist.c +++ b/test/tskiplist.c @@ -1165,213 +1165,6 @@ test_skiplist_free(void) /**************************************************************** ** -** test_skiplist_try_free_safe(): Test H5SL (skip list) code. -** Tests 'try_free_safe' operation in skip lists. -** -****************************************************************/ -/* Macro definitions */ -#define TEST_TFS_MAX_NOBJS 100 -#define TEST_TFS_MIN_NOBJS 5 -#define TEST_TFS_NITER 50 - -/* Structure to hold the list of objects */ -typedef struct { - H5SL_t * slist; /* Skiplist holding the objects */ - struct test_tfs_obj_t *list; /* Linear list of objects */ - int nobjs; /* Number of objects in list */ - int nobjs_rem; /* Number of objects in list that have not been freed */ -} test_tfs_list_t; - -/* Structure for an object */ -typedef struct test_tfs_obj_t { - int idx; /* Index (key) for this object */ - int nfrees; /* Number of times this object has been freed */ -} test_tfs_obj_t; - -/* op_data struct for H5SL_iterate() */ -typedef struct test_tfs_it_ud_t { - test_tfs_list_t *obj_list; /* List of objects */ - int last_idx; /* Index of last object visited in iteration */ - int ncalls; /* Number of times this callback was called */ -} test_tfs_it_ud_t; - -/* iterate callback */ -static herr_t -test_tfs_iter(void *_obj, void *key, void *_udata) -{ - test_tfs_obj_t * obj = (test_tfs_obj_t *)_obj; - test_tfs_it_ud_t *udata = (test_tfs_it_ud_t *)_udata; - - /* Check consistency */ - CHECK_PTR_EQ((void *)&obj->idx, key, "obj->idx"); - CHECK_PTR_EQ(obj, &udata->obj_list->list[obj->idx], "obj_list->list[obj->idx]"); - - /* Increment number of calls */ - udata->ncalls++; - - /* Verify we were given the correct object */ - do { - udata->last_idx++; - } while (udata->obj_list->list[udata->last_idx].nfrees != 0); - VERIFY(udata->last_idx, obj->idx, "H5SL_iterate"); - - return 0; -} /* end test_tfs_iter() */ - -/* try_free_safe callback */ -static htri_t -test_tfs_free(void *_obj, void *key, void *_obj_list) -{ - test_tfs_obj_t * obj = (test_tfs_obj_t *)_obj; - test_tfs_list_t *obj_list = (test_tfs_list_t *)_obj_list; - test_tfs_it_ud_t iter_ud; - int nrems, rem_idx, i, j; - test_tfs_obj_t * obj_ret; - herr_t ret; /* return value */ - htri_t ret_value; - - /* Check consistency */ - CHECK_PTR_EQ((void *)&obj->idx, key, "obj->idx"); - CHECK_PTR_EQ(obj, &obj_list->list[obj->idx], "obj_list->list[obj->idx]"); - - /* Mark this object as freed (to make sure it isn't recursively freed, that - * is not something we support, we will undo this if we decide later not to - * free the object) */ - obj->nfrees++; - obj_list->nobjs_rem--; - - /* Decide how many objects to remove */ - nrems = (int)(HDrandom() % (long)3); - - /* Remove objects */ - for (i = 0; i < nrems; i++) - /* Check nobjs_rem */ - if (obj_list->nobjs_rem > 0) { - /* Remove a random object from the list */ - rem_idx = (int)(HDrandom() % (long)obj_list->nobjs_rem); - - /* Scan the list, finding the rem_idx'th object that has not been - * freed */ - for (j = 0; j < obj_list->nobjs; j++) - if (obj_list->list[j].nfrees == 0) { - if (rem_idx == 0) - break; - else - rem_idx--; - } /* end if */ - if (j == obj_list->nobjs) - ERROR("invalid obj_list"); - else { - /* Remove the object */ - obj_ret = (test_tfs_obj_t *)H5SL_remove(obj_list->slist, &j); - CHECK_PTR(obj_ret, "H5SL_remove"); - obj_ret->nfrees++; - obj_list->nobjs_rem--; - } /* end else */ - } /* end if */ - - /* Mark this object as not freed so we know to expect it in the iterate call - */ - obj->nfrees--; - obj_list->nobjs_rem++; - - /* Iterate over skip list (maybe) */ - if (HDrandom() % (long)5) { - iter_ud.obj_list = obj_list; - iter_ud.last_idx = -1; - iter_ud.ncalls = 0; - ret = H5SL_iterate(obj_list->slist, test_tfs_iter, &iter_ud); - CHECK(ret, FAIL, "H5SL_iterate"); - VERIFY(iter_ud.ncalls, obj_list->nobjs_rem, "H5SL_iterate"); - } /* end if */ - - /* Verify nobjs_rem is non-negative */ - if (obj_list->nobjs_rem < 0) - ERROR("invalid nobjs_rem"); - - /* Decide whether this object should be freed */ - if (HDrandom() % (long)2) { - /* Free the object */ - ret_value = TRUE; - obj->nfrees++; - obj_list->nobjs_rem--; - } /* end if */ - else - /* Do not free the object */ - ret_value = FALSE; - - return ret_value; -} /* end test_tfs_free() */ - -/* Test function */ -static void -test_skiplist_try_free_safe(void) -{ - test_tfs_list_t obj_list; - test_tfs_obj_t list[TEST_TFS_MAX_NOBJS]; - int i, j; - int nobjs_found; - hsize_t count; - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Skip List 'Try Free Safe' Operation\n")); - - /* Create a skip list */ - obj_list.slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK_PTR(obj_list.slist, "H5SL_create"); - - /* Init obj_list.list */ - obj_list.list = list; - for (j = 0; j < TEST_TFS_MAX_NOBJS; j++) - list[j].idx = j; - - for (i = 0; i < TEST_TFS_NITER; i++) { - /* Build object list */ - obj_list.nobjs = obj_list.nobjs_rem = - (int)(TEST_TFS_MIN_NOBJS + (HDrandom() % (long)(TEST_TFS_MAX_NOBJS - TEST_TFS_MIN_NOBJS + 1))); - for (j = 0; j < obj_list.nobjs; j++) { - list[j].nfrees = 0; - ret = H5SL_insert(obj_list.slist, &list[j], &list[j].idx); - CHECK(ret, FAIL, "H5SL_insert"); - } /* end for */ - - /* Call H5S_try_free_safe() - free most of the items in the skip list in - * a safe manner */ - ret = H5SL_try_free_safe(obj_list.slist, test_tfs_free, &obj_list); - CHECK(ret, FAIL, "H5SL_try_free_safe"); - - /* Verify list */ - nobjs_found = 0; - for (j = 0; j < obj_list.nobjs; j++) - if (list[j].nfrees == 0) - nobjs_found++; - else - VERIFY(list[j].nfrees, (long)1, "list[j].nfrees"); - - /* Verify number of objects */ - VERIFY(obj_list.nobjs_rem, nobjs_found, "obj_list.nobjs_rem"); - count = H5SL_count(obj_list.slist); - VERIFY(count, (size_t)nobjs_found, "H5SL_count"); - - /* Release the skip list, forcibly freeing all nodes (will not make - * callbacks) */ - ret = H5SL_release(obj_list.slist); - CHECK(ret, FAIL, "H5SL_release"); - - /* Verify number of objects is 0 */ - count = H5SL_count(obj_list.slist); - VERIFY(count, (size_t)0, "H5SL_count"); - } /* end for */ - - /* Close the skip list */ - ret = H5SL_close(obj_list.slist); - CHECK(ret, FAIL, "H5SL_close"); - -} /* end test_skiplist_try_free_safe() */ - -/**************************************************************** -** ** test_skiplist_less(): Test H5SL (skip list) code. ** Tests 'less' operation in skip lists. ** @@ -1796,7 +1589,6 @@ test_skiplist(void) test_skiplist_add(); /* Test 'add' operation */ test_skiplist_destroy(); /* Test 'destroy' operation */ test_skiplist_free(); /* Test 'free' operation */ - test_skiplist_try_free_safe(); /* Test 'try_free_safe' operation */ test_skiplist_less(); /* Test 'less' operation */ test_skiplist_greater(); /* Test 'greater' operation */ test_skiplist_below(); /* Test 'below' operation */ diff --git a/test/tvlstr.c b/test/tvlstr.c index 7e47c7b..68f6124 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -293,7 +293,7 @@ test_vlstrings_special(void) /* Check data read in */ for (i = 0; i < SPACE1_DIM1; i++) if (rdata[i] != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)i, rdata[i]); + TestErrPrintf("VL doesn't match!, rdata[%d]=%s\n", (int)i, rdata[i]); /* Write dataset to disk */ ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); @@ -352,7 +352,7 @@ test_vlstrings_special(void) /* Check data read in */ for (i = 0; i < SPACE1_DIM1; i++) if (rdata[i] != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)i, rdata[i]); + TestErrPrintf("VL doesn't match!, rdata[%d]=%s\n", (int)i, rdata[i]); /* Try to write nil strings to disk. */ ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata2); @@ -365,7 +365,7 @@ test_vlstrings_special(void) /* Check data read in */ for (i = 0; i < SPACE1_DIM1; i++) if (rdata[i] != NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)i, rdata[i]); + TestErrPrintf("VL doesn't match!, rdata[%d]=%s\n", (int)i, rdata[i]); /* Close Dataset */ ret = H5Dclose(dataset); diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index 785c08d..d6a4025 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -15,46 +15,13 @@ ### T E S T I N G ### ############################################################################## ############################################################################## -set (VFD_LIST - sec2 - stdio - core - core_paged - split - multi - family - splitter - #log - log VFD currently has file space allocation bugs -) +H5_CREATE_VFD_DIR() set (H5P_VFD_TESTS t_pflush1 t_pflush2 ) -if (H5_HAVE_DIRECT) - set (VFD_LIST ${VFD_LIST} direct) -endif () -if (H5_HAVE_PARALLEL) - set (VFD_LIST ${VFD_LIST} mpio) -endif () -if (H5_HAVE_MIRROR_VFD) - set (VFD_LIST ${VFD_LIST} mirror) -endif () -if (H5_HAVE_ROS3_VFD) - set (VFD_LIST ${VFD_LIST} ros3) -endif () -if (H5_HAVE_LIBHDFS) - set (VFD_LIST ${VFD_LIST} hdfs) -endif () -if (H5_HAVE_WINDOWS) - set (VFD_LIST ${VFD_LIST} windows) -endif () - -foreach (vfdtest ${VFD_LIST}) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}") -endforeach () - macro (ADD_VFD_TEST vfdname resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) foreach (h5_test ${H5P_VFD_TESTS}) diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index e16a045..1b0d36f 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -24,12 +24,8 @@ *------------------------------------------------------------------------- */ -#define F_FORMAT "%-15g %-15g %-15g\n" - -#if H5_SIZEOF_LONG_DOUBLE != 0 -#define LD_FORMAT "%-15Lg %-15Lg %-15Lg\n" -#endif - +#define F_FORMAT "%-15g %-15g %-15g\n" +#define LD_FORMAT "%-15Lg %-15Lg %-15Lg\n" #define I_FORMAT "%-15d %-15d %-15d\n" #define S_FORMAT "%-16s %-17s\n" #define UI_FORMAT "%-15u %-15u %-15u\n" @@ -39,12 +35,8 @@ #define ULLI_FORMAT "%-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u %-15" H5_PRINTF_LL_WIDTH "u\n" /* with -p option */ -#define F_FORMAT_P "%-15.10g %-15.10g %-15.10g %-14.10g\n" - -#if H5_SIZEOF_LONG_DOUBLE != 0 -#define LD_FORMAT_P "%-15.10Lg %-15.10Lg %-15.10Lg %-14.10Lg\n" -#endif - +#define F_FORMAT_P "%-15.10g %-15.10g %-15.10g %-14.10g\n" +#define LD_FORMAT_P "%-15.10Lg %-15.10Lg %-15.10Lg %-14.10Lg\n" #define I_FORMAT_P "%-15d %-15d %-15d %-14f\n" #define UI_FORMAT_P "%-15u %-15u %-15u %-14f\n" #define LI_FORMAT_P "%-15ld %-15ld %-15ld %-14f\n" @@ -56,12 +48,8 @@ #define SPACES " " /* not comparable */ -#define F_FORMAT_P_NOTCOMP "%-15.10g %-15.10g %-15.10g not comparable\n" - -#if H5_SIZEOF_LONG_DOUBLE != 0 -#define LD_FORMAT_P_NOTCOMP "%-15.10Lg %-15.10Lg %-15.10Lg not comparable\n" -#endif - +#define F_FORMAT_P_NOTCOMP "%-15.10g %-15.10g %-15.10g not comparable\n" +#define LD_FORMAT_P_NOTCOMP "%-15.10Lg %-15.10Lg %-15.10Lg not comparable\n" #define I_FORMAT_P_NOTCOMP "%-15d %-15d %-15d not comparable\n" #define UI_FORMAT_P_NOTCOMP "%-15u %-15u %-15u not comparable\n" #define LI_FORMAT_P_NOTCOMP "%-15ld %-15ld %-15ld not comparable\n" @@ -145,9 +133,7 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, h diff_opt_t *opts); static hbool_t equal_float(float value, float expected, diff_opt_t *opts); static hbool_t equal_double(double value, double expected, diff_opt_t *opts); -#if H5_SIZEOF_LONG_DOUBLE != 0 static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts); -#endif static int print_data(diff_opt_t *opts); static void print_pos(diff_opt_t *opts, hsize_t elemtno, size_t u); @@ -162,10 +148,8 @@ static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsiz diff_opt_t *opts); static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -#if H5_SIZEOF_LONG_DOUBLE != 0 static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); -#endif static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, @@ -191,12 +175,7 @@ static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsi *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE != 0 typedef enum dtype_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE } dtype_t; -#else - -typedef enum dtype_t { FLT_FLOAT, FLT_DOUBLE } dtype_t; -#endif /*------------------------------------------------------------------------- * XCAO, 11/10/2010 @@ -278,7 +257,6 @@ diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_ return nfound; } /* nelmts */ } -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (H5Tequal(opts->m_tid, H5T_NATIVE_LDOUBLE)) { for (i = 0; i < opts->hs_nelmts; i++) { nfound += diff_ldouble_element(mem1, mem2, i, opts); @@ -289,7 +267,6 @@ diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_ return nfound; } /* nelmts */ } -#endif break; case H5T_INTEGER: @@ -1620,6 +1597,9 @@ character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, hbool_t both_zero = FALSE; double per; + /* both_zero is set in the PER_UNSIGN macro but not used in this function */ + (void)both_zero; + HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); H5TOOLS_START_DEBUG(" %d=%d", temp1_uchar, temp2_uchar); @@ -2034,7 +2014,6 @@ diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, * Return: number of differences found *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE != 0 static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) @@ -2200,7 +2179,6 @@ diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, return nfound; } -#endif /* H5_SIZEOF_LONG_DOUBLE */ /*------------------------------------------------------------------------- * Function: diff_schar_element @@ -3203,7 +3181,6 @@ equal_double(double value, double expected, diff_opt_t *opts) *------------------------------------------------------------------------- */ -#if H5_SIZEOF_LONG_DOUBLE != 0 static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts) { @@ -3244,8 +3221,6 @@ equal_ldouble(long double value, long double expected, diff_opt_t *opts) return FALSE; } -#endif /* #if H5_SIZEOF_LONG_DOUBLE !=0 */ - /*------------------------------------------------------------------------- * Function: equal_float * diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index e487a12..c40de9d 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -133,10 +133,8 @@ print_type(hid_t type) parallel_print("H5T_NATIVE_FLOAT"); else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) parallel_print("H5T_NATIVE_DOUBLE"); -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) parallel_print("H5T_NATIVE_LDOUBLE"); -#endif else parallel_print("undefined float"); break; diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index abc0058..3cd12bb 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -705,7 +705,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai HDmemcpy(&tempdouble, vp, sizeof(double)); h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); -#if H5_SIZEOF_LONG_DOUBLE != 0 } else if (sizeof(long double) == nsize) { /* if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) */ @@ -713,7 +712,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai HDmemcpy(&templdouble, vp, sizeof(long double)); h5tools_str_append(str, "%Lg", templdouble); -#endif } else { size_t i; diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index 6517e43..7272dff 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -467,14 +467,12 @@ readIntegerData(FILE *strm, struct Input *in) H5DT_INT16 temp16; H5DT_INT32 *in32; H5DT_INT32 temp32; -#ifdef H5_SIZEOF_LONG_LONG H5DT_INT64 *in64; H5DT_INT64 temp64; char buffer[256]; -#endif - hsize_t len = 1; - hsize_t i; - int j; + hsize_t len = 1; + hsize_t i; + int j; const char *err1 = "Unable to get integer value from file.\n"; const char *err2 = "Unrecognized input class type.\n"; @@ -589,7 +587,6 @@ readIntegerData(FILE *strm, struct Input *in) } break; -#ifdef H5_SIZEOF_LONG_LONG case 64: in64 = (H5DT_INT64 *)in->data; switch (in->inputClass) { @@ -626,7 +623,6 @@ readIntegerData(FILE *strm, struct Input *in) return (-1); } break; -#endif /* ifdef H5_SIZEOF_LONG_LONG */ default: (void)HDfprintf(stderr, "%s", err3); @@ -643,17 +639,15 @@ readUIntegerData(FILE *strm, struct Input *in) H5DT_UINT16 temp16; H5DT_UINT32 *in32; H5DT_UINT32 temp32; -#ifdef H5_SIZEOF_LONG_LONG H5DT_UINT64 *in64; H5DT_UINT64 temp64; char buffer[256]; -#endif - hsize_t len = 1; - hsize_t i; - int j; - const char *err1 = "Unable to get unsigned integer value from file.\n"; - const char *err2 = "Unrecognized input class type.\n"; - const char *err3 = "Invalid input size.\n"; + hsize_t len = 1; + hsize_t i; + int j; + const char * err1 = "Unable to get unsigned integer value from file.\n"; + const char * err2 = "Unrecognized input class type.\n"; + const char * err3 = "Invalid input size.\n"; for (j = 0; j < in->rank; j++) len *= in->sizeOfDimension[j]; @@ -760,7 +754,6 @@ readUIntegerData(FILE *strm, struct Input *in) } break; -#ifdef H5_SIZEOF_LONG_LONG case 64: in64 = (H5DT_UINT64 *)in->data; switch (in->inputClass) { @@ -797,7 +790,6 @@ readUIntegerData(FILE *strm, struct Input *in) return (-1); } break; -#endif /* ifdef H5_SIZEOF_LONG_LONG */ default: (void)HDfprintf(stderr, "%s", err3); @@ -2457,9 +2449,6 @@ validateConfigurationParameters(struct Input *in) const char *err4a = "OUTPUT-ARCHITECTURE cannot be STD if OUTPUT-CLASS is floating point (FP).\n"; const char *err4b = "OUTPUT-ARCHITECTURE cannot be IEEE if OUTPUT-CLASS is integer (IN).\n"; const char *err5 = "For OUTPUT-CLASS FP, valid values for OUTPUT-SIZE are (32, 64) .\n"; -#ifndef H5_SIZEOF_LONG_LONG - const char *err6 = "No support for reading 64-bit integer (INPUT-CLASS: IN, TEXTIN, UIN, TEXTUIN files\n"; -#endif /* for class STR other parameters are ignored */ if (in->inputClass == 5) /* STR */ @@ -2505,13 +2494,6 @@ validateConfigurationParameters(struct Input *in) return (-1); } -#ifndef H5_SIZEOF_LONG_LONG - if (in->inputSize == 64 && - (in->inputClass == 0 || in->inputClass == 4 || in->inputClass == 6 || in->inputClass == 7)) { - (void)HDfprintf(stderr, "%s", err6); - return -1; - } -#endif return (0); } @@ -3250,7 +3232,6 @@ getInputClassType(struct Input *in, char *buffer) kindex = 3; } -#if H5_SIZEOF_LONG_DOUBLE != 0 else if (!HDstrcmp(buffer, "H5T_NATIVE_LDOUBLE")) { in->inputSize = H5_SIZEOF_LONG_DOUBLE; in->configOptionVector[INPUT_SIZE] = 1; @@ -3263,7 +3244,6 @@ getInputClassType(struct Input *in, char *buffer) kindex = 3; } -#endif else if (!HDstrcmp(buffer, "H5T_TIME: not yet implemented")) { kindex = -1; } diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index d75b1cf..d0aad79 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -221,6 +221,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options) * to free the stack. *------------------------------------------------------------------------- */ + 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) @@ -354,24 +355,28 @@ done: 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) { - hid_t attr_id = H5I_INVALID_HID; /* attr ID */ - hid_t attr_out = H5I_INVALID_HID; /* attr ID */ - hid_t space_id = H5I_INVALID_HID; /* space ID */ - hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ - hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ - size_t msize; /* size of type */ - 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_info2_t oinfo; /* object info */ - int j; - unsigned u; - hbool_t is_ref = 0; - H5T_class_t type_class = -1; - int ret_value = 0; + hid_t attr_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr_out = H5I_INVALID_HID; /* attr ID */ + hid_t space_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ + hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ + size_t msize; /* size of type */ + 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 */ + H5_timer_t timer; /* Timer for read/write operations */ + H5_timevals_t times; /* Elapsed time for each operation */ + static double read_time = 0; + static double write_time = 0; + char name[255]; + H5O_info2_t oinfo; /* object info */ + int j; + unsigned u; + hbool_t is_ref = 0; + H5T_class_t type_class = -1; + int ret_value = 0; if (H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed"); @@ -468,6 +473,9 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ } /* end for each member */ } /* end if type_class is H5T_COMPOUND */ + read_time = 0; + write_time = 0; + if (!is_ref) { /*----------------------------------------------------------------- * read to memory @@ -478,8 +486,17 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ if (buf == NULL) { H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Aread(attr_id, wtype_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + read_time += times.elapsed; + } /*----------------------------------------------------------------- * copy @@ -488,8 +505,18 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ if ((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed on ,%s>", name); + + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Awrite(attr_out, wtype_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + write_time += times.elapsed; + } /*close*/ if (H5Aclose(attr_out) < 0) @@ -499,11 +526,14 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ * be reclaimed */ if (TRUE == h5tools_detect_vlen(wtype_id)) H5Treclaim(wtype_id, space_id, H5P_DEFAULT, buf); + HDfree(buf); buf = NULL; } /*H5T_REFERENCE*/ - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_ATTR_TIME, "attr", read_time, write_time, name); + else HDprintf(FORMAT_OBJ_ATTR, "attr", name); /*--------------------------------------------------------------------- @@ -569,7 +599,7 @@ check_options(pack_opt_t *options) * Objects to layout *------------------------------------------------------------------------- */ - if (options->verbose && have_request(options)) { + if (options->verbose > 0 && have_request(options)) { if (options->all_layout == 1) { HDprintf("All objects to modify layout are...\n"); switch (options->layout_g) { @@ -610,7 +640,7 @@ check_options(pack_opt_t *options) char *name = options->op_tbl->objs[i].path; if (options->op_tbl->objs[i].chunk.rank > 0) { - if (options->verbose) { + if (options->verbose > 0) { HDprintf(" <%s> with chunk size ", name); for (k = 0; k < options->op_tbl->objs[i].chunk.rank; k++) HDprintf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]); @@ -619,7 +649,7 @@ check_options(pack_opt_t *options) has_ck = 1; } else if (options->op_tbl->objs[i].chunk.rank == -2) { /* TODO: replace 'magic number' */ - if (options->verbose) + if (options->verbose > 0) HDprintf(" <%s> %s\n", name, "NONE (contiguous)"); has_ck = 1; } @@ -633,7 +663,7 @@ check_options(pack_opt_t *options) *------------------------------------------------------------------------- */ - if (options->verbose && have_request(options)) { + if (options->verbose > 0 && have_request(options)) { if (options->all_filter == 1) { HDprintf("All objects to apply filter are...\n"); for (k = 0; k < options->n_filter_g; k++) { @@ -670,7 +700,7 @@ check_options(pack_opt_t *options) char * name = pack.path; for (j = 0; j < pack.nfilters; j++) { - if (options->verbose) { + if (options->verbose > 0) { if (pack.filter[j].filtn >= 0) { if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) { HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), @@ -708,7 +738,7 @@ check_options(pack_opt_t *options) *------------------------------------------------------------------------ */ if (options->ublock_filename != NULL && options->ublock_size == 0) { - if (options->verbose) { + if (options->verbose > 0) { HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename); options->ublock_size = 1024; @@ -781,21 +811,21 @@ check_objects(const char *fname, pack_opt_t *options) *------------------------------------------------------------------------- */ - if (options->verbose) + if (options->verbose > 0) HDprintf("Opening file. Searching %zu objects to modify ...\n", travt->nobjs); for (i = 0; i < options->op_tbl->nelems; i++) { pack_info_t obj = options->op_tbl->objs[i]; char * name = obj.path; - if (options->verbose) + if (options->verbose > 0) HDprintf(" <%s>", name); /* the input object names are present in the file and are valid */ if (h5trav_getindext(name, travt) < 0) H5TOOLS_GOTO_ERROR((-1), "%s Could not find <%s> in file <%s>. Exiting...\n", - (options->verbose ? "\n" : ""), name, fname); - if (options->verbose) + (options->verbose > 0 ? "\n" : ""), name, fname); + if (options->verbose > 0) HDprintf("...Found\n"); for (ifil = 0; ifil < obj.nfilters; ifil++) { diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h index 74525f4..b242a71 100644 --- a/tools/src/h5repack/h5repack.h +++ b/tools/src/h5repack/h5repack.h @@ -27,6 +27,12 @@ #define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ #define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */ +/* timing formats */ +#define FORMAT_OBJ_TIME " %-27s %e/%e %s\n" /* obj type, name */ +#define FORMAT_OBJ_ATTR_TIME " %-27s %e/%e %s\n" /* obj type, name */ +#define FORMAT_OBJ_NOTIME " %-27s %s\n" /* obj type, name */ +#define FORMAT_OBJ_ATTR_NOTIME " %-27s %s\n" /* obj type, name */ + /* File space default information */ #define FS_PAGESIZE_DEF 4096 #define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 3806a4e..0497867 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -39,7 +39,8 @@ */ static int get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t size_datum, hsize_t dims_hslab[], hsize_t *hslab_nbytes_p); -static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr); +static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr, pack_opt_t *options, + double read_time, double write_time); static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options); static int copy_user_block(const char *infile, const char *outfile, hsize_t size); #if defined(H5REPACK_DEBUG_USER_BLOCK) @@ -298,7 +299,7 @@ copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options) * create the output file *------------------------------------------------------------------------- */ - if (options->verbose) + if (options->verbose > 0) HDprintf("Making new file ...\n"); if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, options->fout_fapl)) < 0) @@ -643,6 +644,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti int req_filter; /* there was a request for a filter */ int req_obj_layout = 0; /* request layout to current object */ unsigned crt_order_flags; /* group creation order flag */ + H5_timer_t timer; /* Timer for read/write operations */ + H5_timevals_t times; /* Elapsed time for each operation */ + static double read_time = 0; + static double write_time = 0; h5tool_link_info_t linkinfo; unsigned i; unsigned u; @@ -661,7 +666,12 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti *------------------------------------------------------------------------- */ - if (options->verbose) { + if (options->verbose == 2) { + HDprintf("-----------------------------------------------------------------\n"); + HDprintf(" Type Filter (Compression) Timing read/write Name\n"); + HDprintf("-----------------------------------------------------------------\n"); + } + else { HDprintf("-----------------------------------------\n"); HDprintf(" Type Filter (Compression) Name\n"); HDprintf("-----------------------------------------\n"); @@ -682,7 +692,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti *------------------------------------------------------------------------- */ case H5TRAV_TYPE_GROUP: - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_NOTIME, "group", travt->objs[i].name); + else HDprintf(FORMAT_OBJ, "group", travt->objs[i].name); /* open input group */ @@ -749,6 +761,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti case H5TRAV_TYPE_DATASET: { hbool_t use_h5ocopy; + read_time = 0.0; + write_time = 0.0; + has_filter = 0; req_filter = 0; @@ -972,7 +987,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti H5P_DEFAULT, dcpl_out, H5P_DEFAULT); if (dset_out == H5I_INVALID_HID) { H5TOOLS_INFO("H5Dcreate2 failed"); - if (options->verbose) + if (options->verbose > 0) HDprintf(" warning: could not create dataset <%s>. Applying original " "settings\n", travt->objs[i].name); @@ -1013,11 +1028,27 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti } if (buf != NULL) { + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + read_time += times.elapsed; + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, dxpl_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + write_time += times.elapsed; + } /* Check if we have VL data in the dataset's * datatype that must be reclaimed */ @@ -1115,12 +1146,28 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti hs_select_nelmts = 1; } /* end (else) rank == 0 */ + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + read_time += times.elapsed; + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, dxpl_id, hslab_buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + write_time += times.elapsed; + } /* reclaim any VL memory, if necessary */ if (vl_data) @@ -1149,7 +1196,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti * print amount of compression used *------------------------------------------------------------------------- */ - if (options->verbose) { + if (options->verbose > 0) { double ratio = 0; /* only print the compression ration if there was a filter request */ @@ -1160,10 +1207,12 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti /* compression ratio = uncompressed size / compressed size */ if (dsize_out != 0) ratio = (double)dsize_in / (double)dsize_out; - print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1); + print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1, options, + read_time, write_time); } else - print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0); + print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0, options, + read_time, write_time); /* print a message that the filter was not applied * (in case there was a filter) @@ -1220,6 +1269,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti if (H5Pset_copy_object(ocpl_id, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed"); + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } 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 */ @@ -1227,6 +1280,11 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti ocpl_id, /* Properties which apply to the copy */ H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + write_time += times.elapsed; + } if (H5Pclose(ocpl_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); @@ -1247,7 +1305,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti if (H5Dclose(dset_out) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_TIME, "dset", 0.0, write_time, travt->objs[i].name); + else HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); } /* end whether we have request for filter/chunking */ @@ -1260,7 +1320,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti *------------------------------------------------------------------------- */ case H5TRAV_TYPE_NAMED_DATATYPE: - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_NOTIME, "type", travt->objs[i].name); + else HDprintf(FORMAT_OBJ, "type", travt->objs[i].name); if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) @@ -1300,7 +1362,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti */ case H5TRAV_TYPE_LINK: case H5TRAV_TYPE_UDLINK: - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_NOTIME, "link", travt->objs[i].name); + else HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); /* Check -X option. */ @@ -1425,7 +1489,8 @@ done: *------------------------------------------------------------------------- */ static void -print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) +print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr, pack_opt_t *options, double read_time, + double write_time) { char strfilter[255]; #if defined(PRINT_DEBUG) @@ -1514,7 +1579,10 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) } /* end for each filter */ if (!pr) - HDprintf(FORMAT_OBJ, "dset", objname); + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_TIME, "dset", read_time, write_time, objname); + else + HDprintf(FORMAT_OBJ, "dset", objname); else { char str[512], temp[512]; @@ -1522,7 +1590,10 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) HDstrcat(str, strfilter); HDsprintf(temp, " (%.3f:1)", ratio); HDstrcat(str, temp); - HDprintf(FORMAT_OBJ, str, objname); + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_TIME, str, read_time, write_time, objname); + else + HDprintf(FORMAT_OBJ, str, objname); } } /* end print_dataset_info() */ diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 08568cd..7c3d229 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -31,7 +31,7 @@ const char *outfile = NULL; * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:EG:LM:P:S:T:VXWY:Z:1:2:3:4:5:6:7:8:9:0:"; +static const char *s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:v*z:EG:LM:P:S:T:VXWY:Z:1:2:3:4:5:6:7:8:9:0:"; static struct h5_long_options l_opts[] = {{"alignment", require_arg, 'a'}, {"block", require_arg, 'b'}, {"compact", require_arg, 'c'}, @@ -50,7 +50,7 @@ static struct h5_long_options l_opts[] = {{"alignment", require_arg, 'a'}, {"ssize", require_arg, 's'}, {"threshold", require_arg, 't'}, {"ublock", require_arg, 'u'}, - {"verbose", no_arg, 'v'}, + {"verbose", optional_arg, 'v'}, {"sort_order", require_arg, 'z'}, {"enable-error-stack", no_arg, 'E'}, {"fs_pagesize", require_arg, 'G'}, @@ -94,7 +94,8 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " file2 Output HDF5 File\n"); PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n"); - PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n"); + PRINTVALSTREAM(rawoutstream, " -v N, --verbose=N Verbose mode, print object information.\n"); + PRINTVALSTREAM(rawoutstream, " N - is an integer greater than 1, 2 displays read/write timing\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); PRINTVALSTREAM(rawoutstream, @@ -555,7 +556,12 @@ parse_command_line(int argc, const char **argv, pack_opt_t *options) goto done; case 'v': - options->verbose = 1; + if (H5_optarg != NULL) { + if (2 == HDatoi(H5_optarg)) + options->verbose = 2; + } + else + options->verbose = 1; break; case 'f': diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c index 6191624..6d62e52 100644 --- a/tools/src/h5repack/h5repack_refs.c +++ b/tools/src/h5repack/h5repack_refs.c @@ -182,8 +182,11 @@ do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti /* create the reference, -1 parameter for objects */ if (H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); - if (options->verbose) { - HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); + if (options->verbose > 0) { + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_NOTIME, "dset", travt->objs[i].name); + else + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); HDprintf("object <%s> object reference created to <%s>\n", travt->objs[i].name, refname); } @@ -276,7 +279,7 @@ do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); if (H5Sclose(region_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); - if (options->verbose) { + if (options->verbose > 0) { HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); HDprintf("object <%s> region reference created to <%s>\n", travt->objs[i].name, refname); diff --git a/tools/test/h5diff/h5diffgentest.c b/tools/test/h5diff/h5diffgentest.c index 8b23e27..5a0f7bf 100644 --- a/tools/test/h5diff/h5diffgentest.c +++ b/tools/test/h5diff/h5diffgentest.c @@ -442,7 +442,6 @@ test_basic(const char *fname1, const char *fname2, const char *fname3) write_dset(gid1, 2, dims2, "d2", H5T_NATIVE_DOUBLE, data14); } -#if H5_SIZEOF_LONG_DOUBLE != 0 { /*------------------------------------------------------------------------- @@ -454,7 +453,6 @@ test_basic(const char *fname1, const char *fname2, const char *fname3) write_dset(gid1, 2, dims2, "ld", H5T_NATIVE_LDOUBLE, data15); } -#endif /*------------------------------------------------------------------------- * NaNs in H5T_NATIVE_FLOAT diff --git a/tools/test/h5dump/CMakeVFDTests.cmake b/tools/test/h5dump/CMakeVFDTests.cmake index 01834b3..7ab8c1f 100644 --- a/tools/test/h5dump/CMakeVFDTests.cmake +++ b/tools/test/h5dump/CMakeVFDTests.cmake @@ -15,20 +15,7 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - -set (VFD_H5DUMP_LIST - sec2 - stdio - core - core_paged - split - multi - family -) - -if (H5_HAVE_DIRECT) - set (VFD_H5DUMP_LIST ${VFD_H5DUMP_LIST} direct) -endif () +H5_CREATE_VFD_DIR() # -------------------------------------------------------------------- # Copy all the HDF5 files from the source directory into the test directory @@ -37,8 +24,7 @@ set (HDF5_VFD_H5DUMP_FILES packedbits ) -foreach (vfdtest ${VFD_H5DUMP_LIST}) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") +foreach (vfdtest ${VFD_LIST}) foreach (h5_tfile ${HDF5_VFD_H5DUMP_FILES}) HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}.h5" "${PROJECT_BINARY_DIR}/${vfdtest}/${h5_tfile}.h5" "HDF5_VFD_H5DUMP_files") HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}.ddl" "${PROJECT_BINARY_DIR}/${vfdtest}/${h5_tfile}.ddl" "HDF5_VFD_H5DUMP_files") @@ -79,7 +65,7 @@ endmacro () ############################################################################## # Run test with different Virtual File Driver -foreach (vfd ${VFD_H5DUMP_LIST}) +foreach (vfd ${VFD_LIST}) # test for signed/unsigned datasets ADD_VFD_H5DUMP_TEST (${vfd} packedbits 0 --enable-error-stack packedbits.h5) endforeach () diff --git a/tools/test/h5import/h5importtest.c b/tools/test/h5import/h5importtest.c index e49125b..7dbf762 100644 --- a/tools/test/h5import/h5importtest.c +++ b/tools/test/h5import/h5importtest.c @@ -46,11 +46,9 @@ main(void) int rowo4i = 11, colo4i = 21, plno4i = 51; int rowi4i = 1, coli4i = 2, plni4i = 5; -#ifdef H5_SIZEOF_LONG_LONG long long row4i64[3], col4i64[4], pln4i64[5]; long long rowo4i64 = (long long)11, colo4i64 = (long long)21, plno4i64 = (long long)51; long long rowi4i64 = (long long)1, coli4i64 = (long long)2, plni4i64 = (long long)5; -#endif short b16i3[5][3][4]; short row4i16[3], col4i16[4], pln4i16[5]; @@ -101,11 +99,9 @@ main(void) col4i[0] = colo4i; pln4i[0] = plno4i; -#ifdef H5_SIZEOF_LONG_LONG row4i64[0] = rowo4i64; col4i64[0] = colo4i64; pln4i64[0] = plno4i64; -#endif row4i16[0] = rowo4i16; col4i16[0] = colo4i16; @@ -116,33 +112,27 @@ main(void) pln4i8[0] = plno4i8; for (i = 1; i < nrow; i++) { - row4[i] = row4[i - 1] + rowi4; - row8[i] = row8[i - 1] + rowi8; - row4i[i] = row4i[i - 1] + rowi4i; -#ifdef H5_SIZEOF_LONG_LONG + row4[i] = row4[i - 1] + rowi4; + row8[i] = row8[i - 1] + rowi8; + row4i[i] = row4i[i - 1] + rowi4i; row4i64[i] = row4i64[i - 1] + rowi4i64; -#endif row4i16[i] = (short)(row4i16[i - 1] + rowi4i16); row4i8[i] = (char)(row4i8[i - 1] + rowi4i8); } for (j = 1; j < ncol; j++) { - col4[j] = col4[j - 1] + coli4; - col8[j] = col8[j - 1] + coli8; - col4i[j] = col4i[j - 1] + coli4i; -#ifdef H5_SIZEOF_LONG_LONG + col4[j] = col4[j - 1] + coli4; + col8[j] = col8[j - 1] + coli8; + col4i[j] = col4i[j - 1] + coli4i; col4i64[j] = col4i64[j - 1] + coli4i64; -#endif col4i16[j] = (short)(col4i16[j - 1] + coli4i16); col4i8[j] = (char)(col4i8[j - 1] + coli4i8); } for (k = 1; k < npln; k++) { - pln4[k] = pln4[k - 1] + plni4; - pln8[k] = pln8[k - 1] + plni8; - pln4i[k] = pln4i[k - 1] + plni4i; -#ifdef H5_SIZEOF_LONG_LONG + pln4[k] = pln4[k - 1] + plni4; + pln8[k] = pln8[k - 1] + plni8; + pln4i[k] = pln4i[k - 1] + plni4i; pln4i64[k] = pln4i64[k - 1] + plni4i64; -#endif pln4i16[k] = (short)(pln4i16[k - 1] + plni4i16); pln4i8[k] = (char)(pln4i8[k - 1] + plni4i8); } diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index 037287d..397c3ac 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -1544,7 +1544,7 @@ # the references in attribute of compund or vlen datatype ADD_H5_TEST (HDFFV-5932 "TEST" ${FILE_ATTR_REF}) -# Add test for memory leak in attirbute. This test is verified by CTEST. +# Add test for memory leak in attribute. This test is verified by CTEST. # 1. leak from vlen string # 2. leak from compound type without reference member # (HDFFV-7840, ) @@ -1552,12 +1552,12 @@ ADD_H5_TEST (HDFFV-7840 "TEST" h5diff_attr1.h5) # test CVE-2018-17432 fix - set (arg h5repack_CVE-2018-17432.h5 h5repack__CVE-2018-17432_out.h5 --low=1 --high=2 -f GZIP=8 -l dset1:CHUNK=5x6) + set (arg h5repack_CVE-2018-17432.h5 --low=1 --high=2 -f GZIP=8 -l dset1:CHUNK=5x6) set (TESTTYPE "TEST") ADD_H5_FILTER_TEST (HDFFV-10590 "" ${TESTTYPE} 1 ${arg}) # test CVE-2018-14460 fix - set (arg h5repack_CVE-2018-14460.h5 h5repack_CVE-2018-14460_out.h5) + set (arg h5repack_CVE-2018-14460.h5) set (TESTTYPE "TEST") ADD_H5_FILTER_TEST (HDFFV-11223 "" ${TESTTYPE} 1 ${arg}) diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake index 4f6e51d..f8ac10b 100644 --- a/tools/test/h5repack/CMakeVFDTests.cmake +++ b/tools/test/h5repack/CMakeVFDTests.cmake @@ -15,37 +15,7 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - -set (VFD_LIST - sec2 - stdio - core - core_paged - split - multi - family - splitter - #log - log VFD currently has file space allocation bugs -) - -if (H5_HAVE_DIRECT) - set (VFD_LIST ${VFD_LIST} direct) -endif () -if (H5_HAVE_PARALLEL) - set (VFD_LIST ${VFD_LIST} mpio) -endif () -if (H5_HAVE_MIRROR_VFD) - set (VFD_LIST ${VFD_LIST} mirror) -endif () -if (H5_HAVE_ROS3_VFD) - set (VFD_LIST ${VFD_LIST} ros3) -endif () -if (H5_HAVE_LIBHDFS) - set (VFD_LIST ${VFD_LIST} hdfs) -endif () -if (H5_HAVE_WINDOWS) - set (VFD_LIST ${VFD_LIST} windows) -endif () +H5_CREATE_VFD_DIR() ############################################################################## ############################################################################## @@ -55,7 +25,6 @@ endif () macro (ADD_VFD_TEST vfdname resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") add_test ( NAME H5REPACK-${vfdname}-h5repacktest-clear-objects COMMAND ${CMAKE_COMMAND} -E remove diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index 3756a95..1e54670 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -885,13 +885,24 @@ TOOLTEST_FAIL() ( cd $TESTDIR $ENVCMD $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile - ) >$actual + ) >&$actual RET=$? - if [ $RET == 0 ] ; then + + # Normally h5repack of files tested with this function are expected + # to return not 0, but if the command results in "Segmentation fault" + # or "core dumped" it is a failure regardless of the return value. + failure=`grep -e 'Segmentation fault' -e 'core dumped' $actual` + if [ "$failure" != "" ]; then nerrors="`expr $nerrors + 1`" echo " FAILED" + echo " $failure" else - echo " PASSED" + if [ $RET == 0 ] ; then + nerrors="`expr $nerrors + 1`" + echo " FAILED" + else + echo " PASSED" + fi fi rm -f $outfile } diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index 894f88c..c1caf52 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -3,7 +3,8 @@ usage: h5repack [OPTIONS] file1 file2 file2 Output HDF5 File OPTIONS -h, --help Print a usage message and exit - -v, --verbose Verbose mode, print object information + -v N, --verbose=N Verbose mode, print object information. + N - is an integer greater than 1, 2 displays read/write timing -V, --version Print version number and exit -n, --native Use a native HDF5 type when repacking --enable-error-stack Prints messages from the HDF5 error stack as they diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 2d5626e..7c263d1 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,4 +1,11 @@ cmake_minimum_required (VERSION 3.10) project (HDF5_UTILS C) -add_subdirectory (mirror_vfd) +if (BUILD_TESTING) + add_subdirectory (test) +endif () + +option (HDF5_BUILD_UTILS "Build HDF5 Utils" ON) +if (HDF5_BUILD_UTILS) + add_subdirectory (mirror_vfd) +endif () diff --git a/utils/Makefile.am b/utils/Makefile.am index 288da37..876dfb1 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -20,7 +20,19 @@ include $(top_srcdir)/config/commence.am CONFIG=ordered +if BUILD_TESTS_CONDITIONAL + TESTUTIL_DIR =test +else + TESTUTIL_DIR= +endif + +if MIRROR_VFD_CONDITIONAL + MIRROR_VFD_DIR = mirror_vfd +else + MIRROR_VFD_DIR= +endif + # All subdirectories -SUBDIRS=mirror_vfd +SUBDIRS=$(MIRROR_VFD_DIR) $(TESTUTIL_DIR) include $(top_srcdir)/config/conclude.am diff --git a/utils/test/CMakeLists.txt b/utils/test/CMakeLists.txt new file mode 100644 index 0000000..921fbd0 --- /dev/null +++ b/utils/test/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required (VERSION 3.12) +project (HDF5_TEST C) + +################################################################################# +# Test program sources +################################################################################# + +macro (ADD_H5_EXE file) + add_executable (${file} ${HDF5_TEST_SOURCE_DIR}/${file}.c) + target_include_directories (${file} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(${file} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (${file} STATIC) + target_link_libraries (${file} PRIVATE ${HDF5_TEST_LIB_TARGET}) + else () + TARGET_C_PROPERTIES (${file} SHARED) + target_link_libraries (${file} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + endif () + set_target_properties (${file} PROPERTIES FOLDER test) +endmacro () + +############################################################################## +### S W I M M E R T E S T U T I L S ### +############################################################################## +set (H5_UTIL_TESTS) + +if (HDF5_TEST_SWMR) + set (H5_UTIL_TESTS ${H5_UTIL_TESTS} swmr_check_compat_vfd) +endif () + +if (H5_UTIL_TESTS) + foreach (h5_test ${H5_UTIL_TESTS}) + ADD_H5_EXE(${h5_test}) + endforeach () +endif () diff --git a/utils/test/Makefile.am b/utils/test/Makefile.am new file mode 100644 index 0000000..164562f --- /dev/null +++ b/utils/test/Makefile.am @@ -0,0 +1,34 @@ +# +# 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 COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +## +## Makefile.am +## Run automake to generate a Makefile.in from this file. +# +# HDF5 Library Makefile(.in) +# + +include $(top_srcdir)/config/commence.am + +# Include src and tools/lib directories +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib -I$(top_srcdir)/utils/test + +# These are our main targets, the tools + +noinst_PROGRAMS=swmr_check_compat_vfd + +# Programs all depend on the hdf5 library, the tools library, and the HL +# library. +LDADD=$(LIBH5TEST) $(LIBHDF5) + +CHECK_CLEANFILES+=*.h5 + +include $(top_srcdir)/config/conclude.am diff --git a/utils/test/swmr_check_compat_vfd.c b/utils/test/swmr_check_compat_vfd.c new file mode 100644 index 0000000..720c747 --- /dev/null +++ b/utils/test/swmr_check_compat_vfd.c @@ -0,0 +1,53 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Purpose: This is a small program that checks if the HDF5_DRIVER + * environment variable is set to a value that supports SWMR. + * + * It is intended for use in shell scripts. + */ + +#include "h5test.h" + +/* This file needs to access the file driver testing code */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_TESTING +#include "H5FDpkg.h" /* File drivers */ + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Inspects the HDF5_DRIVER environment variable, which + * determines the VFD that the test harness will use with + * the majority of the tests. + * + * Return: VFD supports SWMR: EXIT_SUCCESS + * + * VFD does not support SWMR + * or failure: EXIT_FAILURE + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + char *driver = NULL; + + driver = HDgetenv(HDF5_DRIVER); + + if (H5FD__supports_swmr_test(driver)) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; + +} /* end main() */ -- cgit v0.12